OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 140 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 140 Rev 154
1
package org.openconcerto.modules.customerrelationship.lead;
1
package org.openconcerto.modules.customerrelationship.lead;
2
 
2
 
3
import java.awt.Component;
3
import java.awt.Component;
4
import java.awt.FileDialog;
4
import java.awt.FileDialog;
5
import java.awt.Frame;
5
import java.awt.Frame;
6
import java.awt.event.ActionEvent;
6
import java.awt.event.ActionEvent;
7
import java.io.File;
7
import java.io.File;
8
import java.io.FilenameFilter;
8
import java.io.FilenameFilter;
9
import java.io.IOException;
9
import java.io.IOException;
10
import java.sql.SQLException;
10
import java.sql.SQLException;
11
 
11
 
12
import javax.swing.AbstractAction;
12
import javax.swing.AbstractAction;
13
import javax.swing.JFrame;
13
import javax.swing.JFrame;
14
 
14
 
15
import org.openconcerto.erp.action.CreateFrameAbstractAction;
15
import org.openconcerto.erp.action.CreateFrameAbstractAction;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
17
import org.openconcerto.erp.config.Gestion;
17
import org.openconcerto.erp.config.Gestion;
18
import org.openconcerto.erp.config.MainFrame;
18
import org.openconcerto.erp.config.MainFrame;
19
import org.openconcerto.erp.modules.AbstractModule;
19
import org.openconcerto.erp.modules.AbstractModule;
20
import org.openconcerto.erp.modules.ComponentsContext;
20
import org.openconcerto.erp.modules.ComponentsContext;
21
import org.openconcerto.erp.modules.DBContext;
21
import org.openconcerto.erp.modules.DBContext;
22
import org.openconcerto.erp.modules.MenuContext;
22
import org.openconcerto.erp.modules.MenuContext;
23
import org.openconcerto.erp.modules.ModuleFactory;
23
import org.openconcerto.erp.modules.ModuleFactory;
24
import org.openconcerto.erp.modules.ModuleManager;
24
import org.openconcerto.erp.modules.ModuleManager;
25
import org.openconcerto.erp.modules.ModulePackager;
25
import org.openconcerto.erp.modules.ModulePackager;
26
import org.openconcerto.erp.modules.RuntimeModuleFactory;
26
import org.openconcerto.erp.modules.RuntimeModuleFactory;
27
import org.openconcerto.modules.customerrelationship.lead.call.CustomerCallSQLElement;
27
import org.openconcerto.modules.customerrelationship.lead.call.CustomerCallSQLElement;
28
import org.openconcerto.modules.customerrelationship.lead.call.CustomerCallServiceSQLElement;
28
import org.openconcerto.modules.customerrelationship.lead.call.CustomerCallServiceSQLElement;
29
import org.openconcerto.modules.customerrelationship.lead.call.LeadCallSQLElement;
29
import org.openconcerto.modules.customerrelationship.lead.call.LeadCallSQLElement;
30
import org.openconcerto.modules.customerrelationship.lead.call.LeadCallServiceSQLElement;
30
import org.openconcerto.modules.customerrelationship.lead.call.LeadCallServiceSQLElement;
31
import org.openconcerto.modules.customerrelationship.lead.importer.LeadImporter;
31
import org.openconcerto.modules.customerrelationship.lead.importer.LeadImporter;
32
import org.openconcerto.modules.customerrelationship.lead.visit.CustomerVisitSQLElement;
32
import org.openconcerto.modules.customerrelationship.lead.visit.CustomerVisitSQLElement;
33
import org.openconcerto.modules.customerrelationship.lead.visit.CustomerVisitServiceSQLElement;
33
import org.openconcerto.modules.customerrelationship.lead.visit.CustomerVisitServiceSQLElement;
34
import org.openconcerto.modules.customerrelationship.lead.visit.LeadVisitSQLElement;
34
import org.openconcerto.modules.customerrelationship.lead.visit.LeadVisitSQLElement;
35
import org.openconcerto.modules.customerrelationship.lead.visit.LeadVisitServiceSQLElement;
35
import org.openconcerto.modules.customerrelationship.lead.visit.LeadVisitServiceSQLElement;
36
import org.openconcerto.openoffice.ContentTypeVersioned;
36
import org.openconcerto.openoffice.ContentTypeVersioned;
37
import org.openconcerto.sql.element.GlobalMapper;
37
import org.openconcerto.sql.element.GlobalMapper;
38
import org.openconcerto.sql.element.SQLElement;
38
import org.openconcerto.sql.element.SQLElement;
39
import org.openconcerto.sql.element.SQLElementDirectory;
39
import org.openconcerto.sql.element.SQLElementDirectory;
40
import org.openconcerto.sql.model.ConnectionHandlerNoSetup;
40
import org.openconcerto.sql.model.ConnectionHandlerNoSetup;
41
import org.openconcerto.sql.model.DBRoot;
41
import org.openconcerto.sql.model.DBRoot;
42
import org.openconcerto.sql.model.SQLDataSource;
42
import org.openconcerto.sql.model.SQLDataSource;
43
import org.openconcerto.sql.model.SQLRequestLog;
43
import org.openconcerto.sql.model.SQLRequestLog;
44
import org.openconcerto.sql.model.SQLRow;
44
import org.openconcerto.sql.model.SQLRow;
45
import org.openconcerto.sql.model.SQLRowValues;
45
import org.openconcerto.sql.model.SQLRowValues;
46
import org.openconcerto.sql.model.SQLTable;
46
import org.openconcerto.sql.model.SQLTable;
47
import org.openconcerto.sql.ui.ConnexionPanel;
47
import org.openconcerto.sql.ui.ConnexionPanel;
48
import org.openconcerto.sql.utils.SQLCreateTable;
48
import org.openconcerto.sql.utils.SQLCreateTable;
49
import org.openconcerto.sql.utils.SQLUtils;
49
import org.openconcerto.sql.utils.SQLUtils;
50
import org.openconcerto.sql.view.EditFrame;
50
import org.openconcerto.sql.view.EditFrame;
51
import org.openconcerto.sql.view.ListeAddPanel;
51
import org.openconcerto.sql.view.ListeAddPanel;
52
import org.openconcerto.sql.view.list.IListe;
52
import org.openconcerto.sql.view.list.IListe;
53
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
53
import org.openconcerto.sql.view.list.IListeAction.IListeEvent;
54
import org.openconcerto.sql.view.list.RowAction;
54
import org.openconcerto.sql.view.list.RowAction;
55
import org.openconcerto.ui.FrameUtil;
55
import org.openconcerto.ui.FrameUtil;
56
import org.openconcerto.ui.SwingThreadUtils;
56
import org.openconcerto.ui.SwingThreadUtils;
57
import org.openconcerto.utils.ExceptionHandler;
57
import org.openconcerto.utils.ExceptionHandler;
58
 
58
 
59
public final class Module extends AbstractModule {
59
public final class Module extends AbstractModule {
60
 
60
 
61
    public static final String TABLE_LEAD = "LEAD";
61
    public static final String TABLE_LEAD = "LEAD";
62
    public static final String TABLE_LEAD_CALL = "LEAD_CALL";
62
    public static final String TABLE_LEAD_CALL = "LEAD_CALL";
63
    public static final String TABLE_CUSTOMER_CALL = "CUSTOMER_CALL";
63
    public static final String TABLE_CUSTOMER_CALL = "CUSTOMER_CALL";
64
    public static final String TABLE_LEAD_VISIT = "LEAD_VISIT";
64
    public static final String TABLE_LEAD_VISIT = "LEAD_VISIT";
65
    public static final String TABLE_CUSTOMER_VISIT = "CUSTOMER_VISIT";
65
    public static final String TABLE_CUSTOMER_VISIT = "CUSTOMER_VISIT";
66
    public static final String TABLE_SERVICE = "SERVICE";
66
    public static final String TABLE_SERVICE = "SERVICE";
67
    //
67
    //
68
    public static final String TABLE_LEAD_CALL_SERVICE = "LEAD_CALL_SERVICE";
68
    public static final String TABLE_LEAD_CALL_SERVICE = "LEAD_CALL_SERVICE";
69
    public static final String TABLE_CUSTOMER_CALL_SERVICE = "CUSTOMER_CALL_SERVICE";
69
    public static final String TABLE_CUSTOMER_CALL_SERVICE = "CUSTOMER_CALL_SERVICE";
70
    public static final String TABLE_LEAD_VISIT_SERVICE = "LEAD_VISIT_SERVICE";
70
    public static final String TABLE_LEAD_VISIT_SERVICE = "LEAD_VISIT_SERVICE";
71
    public static final String TABLE_CUSTOMER_VISIT_SERVICE = "CUSTOMER_VISIT_SERVICE";
71
    public static final String TABLE_CUSTOMER_VISIT_SERVICE = "CUSTOMER_VISIT_SERVICE";
72
 
72
 
73
    public Module(ModuleFactory f) throws IOException {
73
    public Module(ModuleFactory f) throws IOException {
74
        super(f);
74
        super(f);
75
    }
75
    }
76
 
76
 
77
    @Override
77
    @Override
78
    protected void install(DBContext ctxt) {
78
    protected void install(DBContext ctxt) throws SQLException, IOException {
79
        super.install(ctxt);
79
        super.install(ctxt);
80
        // TODO use version to upgrade
80
        // TODO use version to upgrade
81
        if (ctxt.getRoot().getTable(TABLE_LEAD) == null) {
81
        if (ctxt.getRoot().getTable(TABLE_LEAD) == null) {
82
            final SQLCreateTable createTable = ctxt.getCreateTable(TABLE_LEAD);
82
            final SQLCreateTable createTable = ctxt.getCreateTable(TABLE_LEAD);
83
 
83
 
84
            createTable.addVarCharColumn("NUMBER", 20);
84
            createTable.addVarCharColumn("NUMBER", 20);
85
            createTable.addDateAndTimeColumn("DATE");
85
            createTable.addDateAndTimeColumn("DATE");
86
            createTable.addVarCharColumn("FIRSTNAME", 64);
86
            createTable.addVarCharColumn("FIRSTNAME", 64);
87
            createTable.addVarCharColumn("NAME", 64);
87
            createTable.addVarCharColumn("NAME", 64);
88
            createTable.addVarCharColumn("COMPANY", 64);
88
            createTable.addVarCharColumn("COMPANY", 64);
89
            //
89
            //
90
            createTable.addVarCharColumn("PHONE", 16);
90
            createTable.addVarCharColumn("PHONE", 16);
91
            createTable.addVarCharColumn("MOBILE", 16);
91
            createTable.addVarCharColumn("MOBILE", 16);
92
            createTable.addVarCharColumn("FAX", 16);
92
            createTable.addVarCharColumn("FAX", 16);
93
            createTable.addVarCharColumn("EMAIL", 32);
93
            createTable.addVarCharColumn("EMAIL", 32);
94
            createTable.addVarCharColumn("WEBSITE", 64);
94
            createTable.addVarCharColumn("WEBSITE", 64);
95
            //
95
            //
96
            createTable.addVarCharColumn("SOURCE", 200);
96
            createTable.addVarCharColumn("SOURCE", 200);
97
            createTable.addVarCharColumn("STATUS", 50);
97
            createTable.addVarCharColumn("STATUS", 50);
98
            //
98
            //
99
            createTable.addForeignColumn("ADRESSE");
99
            createTable.addForeignColumn("ADRESSE");
100
            createTable.addForeignColumn("COMMERCIAL");
100
            createTable.addForeignColumn("COMMERCIAL");
101
            //
101
            //
102
            createTable.addVarCharColumn("INFORMATION", 512);
102
            createTable.addVarCharColumn("INFORMATION", 512);
103
            //
103
            //
104
            createTable.addVarCharColumn("INDUSTRY", 200);
104
            createTable.addVarCharColumn("INDUSTRY", 200);
105
            createTable.addVarCharColumn("RATING", 200);
105
            createTable.addVarCharColumn("RATING", 200);
106
 
106
 
107
            createTable.addIntegerColumn("REVENUE", 0);
107
            createTable.addIntegerColumn("REVENUE", 0);
108
            createTable.addIntegerColumn("EMPLOYEES", 0);
108
            createTable.addIntegerColumn("EMPLOYEES", 0);
109
 
109
 
110
            createTable.addVarCharColumn("ROLE", 128);
110
            createTable.addVarCharColumn("ROLE", 128);
111
            createTable.addForeignColumn("CLIENT");
111
            createTable.addForeignColumn("CLIENT");
112
            createTable.addVarCharColumn("LOCALISATION", 256);
112
            createTable.addVarCharColumn("LOCALISATION", 256);
113
            createTable.addVarCharColumn("INFOS", 128);
113
            createTable.addVarCharColumn("INFOS", 128);
114
            createTable.addForeignColumn("TITRE_PERSONNEL");
114
            createTable.addForeignColumn("TITRE_PERSONNEL");
115
            createTable.addDateAndTimeColumn("REMIND_DATE");
115
            createTable.addDateAndTimeColumn("REMIND_DATE");
116
            createTable.addVarCharColumn("APE", 128);
116
            createTable.addVarCharColumn("APE", 128);
117
            createTable.addVarCharColumn("SIRET", 256);
117
            createTable.addVarCharColumn("SIRET", 256);
118
            createTable.addVarCharColumn("DISPO", 256);
118
            createTable.addVarCharColumn("DISPO", 256);
119
            createTable.addBooleanColumn("MAILING", Boolean.FALSE, false);
119
            createTable.addBooleanColumn("MAILING", Boolean.FALSE, false);
120
 
120
 
121
            // V2
121
            // V2
122
 
122
 
123
            // Appel à un prospect
123
            // Appel à un prospect
124
            final SQLCreateTable createLCall = ctxt.getCreateTable(TABLE_LEAD_CALL);
124
            final SQLCreateTable createLCall = ctxt.getCreateTable(TABLE_LEAD_CALL);
125
            createLCall.addDateAndTimeColumn("DATE");
125
            createLCall.addDateAndTimeColumn("DATE");
126
            createLCall.addForeignColumn(createTable);
126
            createLCall.addForeignColumn(createTable);
127
            createLCall.addVarCharColumn("INFORMATION", 10240);
127
            createLCall.addVarCharColumn("INFORMATION", 10240);
128
            createLCall.addDateAndTimeColumn("NEXTCONTACT_DATE");
128
            createLCall.addDateAndTimeColumn("NEXTCONTACT_DATE");
129
            createLCall.addVarCharColumn("NEXTCONTACT_INFO", 1024);
129
            createLCall.addVarCharColumn("NEXTCONTACT_INFO", 1024);
130
 
130
 
131
            // Appel à un client
131
            // Appel à un client
132
            final SQLCreateTable createCCall = ctxt.getCreateTable(TABLE_CUSTOMER_CALL);
132
            final SQLCreateTable createCCall = ctxt.getCreateTable(TABLE_CUSTOMER_CALL);
133
            createCCall.addDateAndTimeColumn("DATE");
133
            createCCall.addDateAndTimeColumn("DATE");
134
            createCCall.addForeignColumn("CLIENT");
134
            createCCall.addForeignColumn("CLIENT");
135
            createCCall.addVarCharColumn("INFORMATION", 10240);
135
            createCCall.addVarCharColumn("INFORMATION", 10240);
136
            createCCall.addDateAndTimeColumn("NEXTCONTACT_DATE");
136
            createCCall.addDateAndTimeColumn("NEXTCONTACT_DATE");
137
            createCCall.addVarCharColumn("NEXTCONTACT_INFO", 1024);
137
            createCCall.addVarCharColumn("NEXTCONTACT_INFO", 1024);
138
 
138
 
139
            // Visites chez un prospect
139
            // Visites chez un prospect
140
            final SQLCreateTable createLV = ctxt.getCreateTable(TABLE_LEAD_VISIT);
140
            final SQLCreateTable createLV = ctxt.getCreateTable(TABLE_LEAD_VISIT);
141
            createLV.addDateAndTimeColumn("DATE");
141
            createLV.addDateAndTimeColumn("DATE");
142
            createLV.addForeignColumn(createTable);
142
            createLV.addForeignColumn(createTable);
143
            createLV.addVarCharColumn("INFORMATION", 10240);
143
            createLV.addVarCharColumn("INFORMATION", 10240);
144
            createLV.addDateAndTimeColumn("NEXTCONTACT_DATE");
144
            createLV.addDateAndTimeColumn("NEXTCONTACT_DATE");
145
            createLV.addVarCharColumn("NEXTCONTACT_INFO", 1024);
145
            createLV.addVarCharColumn("NEXTCONTACT_INFO", 1024);
146
            // Visites chez un client
146
            // Visites chez un client
147
            final SQLCreateTable createCV = ctxt.getCreateTable(TABLE_CUSTOMER_VISIT);
147
            final SQLCreateTable createCV = ctxt.getCreateTable(TABLE_CUSTOMER_VISIT);
148
            createCV.addDateAndTimeColumn("DATE");
148
            createCV.addDateAndTimeColumn("DATE");
149
            createCV.addForeignColumn("CLIENT");
149
            createCV.addForeignColumn("CLIENT");
150
            createCV.addVarCharColumn("INFORMATION", 10240);
150
            createCV.addVarCharColumn("INFORMATION", 10240);
151
            createCV.addDateAndTimeColumn("NEXTCONTACT_DATE");
151
            createCV.addDateAndTimeColumn("NEXTCONTACT_DATE");
152
            createCV.addVarCharColumn("NEXTCONTACT_INFO", 1024);
152
            createCV.addVarCharColumn("NEXTCONTACT_INFO", 1024);
153
 
153
 
154
            // Services
154
            // Services
155
            final SQLCreateTable createService = ctxt.getCreateTable(TABLE_SERVICE);
155
            final SQLCreateTable createService = ctxt.getCreateTable(TABLE_SERVICE);
156
            createService.addVarCharColumn("NAME", 256);
156
            createService.addVarCharColumn("NAME", 256);
157
 
157
 
158
            //
158
            //
159
            if (ctxt.getRoot().getTable(TABLE_LEAD_CALL_SERVICE) == null) {
159
            if (ctxt.getRoot().getTable(TABLE_LEAD_CALL_SERVICE) == null) {
160
                final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_LEAD_CALL_SERVICE);
160
                final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_LEAD_CALL_SERVICE);
161
                createTable1.addForeignColumn(createLCall);
161
                createTable1.addForeignColumn(createLCall);
162
                createTable1.addForeignColumn(createService);
162
                createTable1.addForeignColumn(createService);
163
            }
163
            }
164
            if (ctxt.getRoot().getTable(TABLE_CUSTOMER_CALL_SERVICE) == null) {
164
            if (ctxt.getRoot().getTable(TABLE_CUSTOMER_CALL_SERVICE) == null) {
165
                final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_CUSTOMER_CALL_SERVICE);
165
                final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_CUSTOMER_CALL_SERVICE);
166
                createTable1.addForeignColumn(createCCall);
166
                createTable1.addForeignColumn(createCCall);
167
                createTable1.addForeignColumn(createService);
167
                createTable1.addForeignColumn(createService);
168
            }
168
            }
169
            if (ctxt.getRoot().getTable(TABLE_LEAD_VISIT_SERVICE) == null) {
169
            if (ctxt.getRoot().getTable(TABLE_LEAD_VISIT_SERVICE) == null) {
170
                final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_LEAD_VISIT_SERVICE);
170
                final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_LEAD_VISIT_SERVICE);
171
                createTable1.addForeignColumn(createLV);
171
                createTable1.addForeignColumn(createLV);
172
                createTable1.addForeignColumn(createService);
172
                createTable1.addForeignColumn(createService);
173
            }
173
            }
174
            if (ctxt.getRoot().getTable(TABLE_CUSTOMER_VISIT_SERVICE) == null) {
174
            if (ctxt.getRoot().getTable(TABLE_CUSTOMER_VISIT_SERVICE) == null) {
175
                final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_CUSTOMER_VISIT_SERVICE);
175
                final SQLCreateTable createTable1 = ctxt.getCreateTable(TABLE_CUSTOMER_VISIT_SERVICE);
176
                createTable1.addForeignColumn(createCV);
176
                createTable1.addForeignColumn(createCV);
177
                createTable1.addForeignColumn(createService);
177
                createTable1.addForeignColumn(createService);
178
            }
178
            }
179
        }
179
        }
180
    }
180
    }
181
 
181
 
182
    @Override
182
    @Override
183
    protected void setupElements(final SQLElementDirectory dir) {
183
    protected void setupElements(final SQLElementDirectory dir) {
184
        super.setupElements(dir);
184
        super.setupElements(dir);
185
 
185
 
186
        final LeadSQLElement element = new LeadSQLElement(this);
186
        final LeadSQLElement element = new LeadSQLElement(this);
187
        GlobalMapper.getInstance().map(element.getCode() + ".default", new LeadGroup());
187
        GlobalMapper.getInstance().map(element.getCode() + ".default", new LeadGroup());
188
        dir.addSQLElement(element);
188
        dir.addSQLElement(element);
189
 
189
 
190
        dir.addSQLElement(new LeadCallSQLElement(this));
190
        dir.addSQLElement(new LeadCallSQLElement(this));
191
        dir.addSQLElement(new CustomerCallSQLElement(this));
191
        dir.addSQLElement(new CustomerCallSQLElement(this));
192
        dir.addSQLElement(new LeadVisitSQLElement(this));
192
        dir.addSQLElement(new LeadVisitSQLElement(this));
193
        dir.addSQLElement(new CustomerVisitSQLElement(this));
193
        dir.addSQLElement(new CustomerVisitSQLElement(this));
194
        dir.addSQLElement(new ServiceSQLElement(this));
194
        dir.addSQLElement(new ServiceSQLElement(this));
195
        // Services
195
        // Services
196
        dir.addSQLElement(new LeadCallServiceSQLElement(this));
196
        dir.addSQLElement(new LeadCallServiceSQLElement(this));
197
        dir.addSQLElement(new CustomerCallServiceSQLElement(this));
197
        dir.addSQLElement(new CustomerCallServiceSQLElement(this));
198
        dir.addSQLElement(new LeadVisitServiceSQLElement(this));
198
        dir.addSQLElement(new LeadVisitServiceSQLElement(this));
199
        dir.addSQLElement(new CustomerVisitServiceSQLElement(this));
199
        dir.addSQLElement(new CustomerVisitServiceSQLElement(this));
200
 
200
 
201
        // Call
201
        // Call
202
        final RowAction.PredicateRowAction addCallAction = new RowAction.PredicateRowAction(new AbstractAction("Appeler") {
202
        final RowAction.PredicateRowAction addCallAction = new RowAction.PredicateRowAction(new AbstractAction("Appeler") {
203
 
203
 
204
            @Override
204
            @Override
205
            public void actionPerformed(ActionEvent e) {
205
            public void actionPerformed(ActionEvent e) {
206
                SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
206
                SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
207
                final SQLElement eCall = dir.getElement(Module.TABLE_CUSTOMER_CALL);
207
                final SQLElement eCall = dir.getElement(Module.TABLE_CUSTOMER_CALL);
208
                final SQLTable table = eCall.getTable();
208
                final SQLTable table = eCall.getTable();
209
                EditFrame editFrame = new EditFrame(eCall);
209
                EditFrame editFrame = new EditFrame(eCall);
210
                final SQLRowValues sqlRowValues = new SQLRowValues(table);
210
                final SQLRowValues sqlRowValues = new SQLRowValues(table);
211
                sqlRowValues.put("ID_CLIENT", sRow.getIDNumber());
211
                sqlRowValues.put("ID_CLIENT", sRow.getIDNumber());
212
                editFrame.getSQLComponent().select(sqlRowValues);
212
                editFrame.getSQLComponent().select(sqlRowValues);
213
                FrameUtil.show(editFrame);
213
                FrameUtil.show(editFrame);
214
            }
214
            }
215
        }, true) {
215
        }, true) {
216
        };
216
        };
217
        addCallAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
217
        addCallAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
218
        dir.getElement("CLIENT").getRowActions().add(addCallAction);
218
        dir.getElement("CLIENT").getRowActions().add(addCallAction);
219
        // Visit
219
        // Visit
220
        final RowAction.PredicateRowAction addVisitAction = new RowAction.PredicateRowAction(new AbstractAction("Enregister une visite") {
220
        final RowAction.PredicateRowAction addVisitAction = new RowAction.PredicateRowAction(new AbstractAction("Enregister une visite") {
221
 
221
 
222
            @Override
222
            @Override
223
            public void actionPerformed(ActionEvent e) {
223
            public void actionPerformed(ActionEvent e) {
224
                SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
224
                SQLRow sRow = IListe.get(e).getSelectedRow().asRow();
225
                final SQLElement eCall = dir.getElement(Module.TABLE_CUSTOMER_VISIT);
225
                final SQLElement eCall = dir.getElement(Module.TABLE_CUSTOMER_VISIT);
226
                final SQLTable table = eCall.getTable();
226
                final SQLTable table = eCall.getTable();
227
                EditFrame editFrame = new EditFrame(eCall);
227
                EditFrame editFrame = new EditFrame(eCall);
228
                final SQLRowValues sqlRowValues = new SQLRowValues(table);
228
                final SQLRowValues sqlRowValues = new SQLRowValues(table);
229
                sqlRowValues.put("ID_CLIENT", sRow.getIDNumber());
229
                sqlRowValues.put("ID_CLIENT", sRow.getIDNumber());
230
                editFrame.getSQLComponent().select(sqlRowValues);
230
                editFrame.getSQLComponent().select(sqlRowValues);
231
                FrameUtil.show(editFrame);
231
                FrameUtil.show(editFrame);
232
            }
232
            }
233
        }, true) {
233
        }, true) {
234
        };
234
        };
235
        addVisitAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
235
        addVisitAction.setPredicate(IListeEvent.getSingleSelectionPredicate());
236
        dir.getElement("CLIENT").getRowActions().add(addVisitAction);
236
        dir.getElement("CLIENT").getRowActions().add(addVisitAction);
237
 
237
 
238
    }
238
    }
239
 
239
 
240
    @Override
240
    @Override
241
    protected void setupComponents(ComponentsContext ctxt) {
241
    protected void setupComponents(ComponentsContext ctxt) {
242
 
242
 
243
    }
243
    }
244
 
244
 
245
    @Override
245
    @Override
246
    protected void setupMenu(final MenuContext ctxt) {
246
    protected void setupMenu(final MenuContext ctxt) {
247
        ctxt.addMenuItem(new LeadListAction(), MainFrame.LIST_MENU);
247
        ctxt.addMenuItem(new LeadListAction(), MainFrame.LIST_MENU);
248
 
248
 
249
        ctxt.addMenuItem(new CreateFrameAbstractAction("Liste des services") {
249
        ctxt.addMenuItem(new CreateFrameAbstractAction("Liste des services") {
250
            @Override
250
            @Override
251
            public JFrame createFrame() {
251
            public JFrame createFrame() {
252
                final JFrame frame = new JFrame("Services proposés");
252
                final JFrame frame = new JFrame("Services proposés");
253
                frame.setContentPane(new ListeAddPanel(ctxt.getElement(TABLE_SERVICE)));
253
                frame.setContentPane(new ListeAddPanel(ctxt.getElement(TABLE_SERVICE)));
254
                return frame;
254
                return frame;
255
            }
255
            }
256
        }, MainFrame.STRUCTURE_MENU);
256
        }, MainFrame.STRUCTURE_MENU);
257
        ctxt.addMenuItem(new SuiviClientProspectListAction(), MainFrame.LIST_MENU);
257
        ctxt.addMenuItem(new SuiviClientProspectListAction(), MainFrame.LIST_MENU);
258
        // ctxt.addMenuItem(ctxt.createListAction(TABLE_CUSTOMER_CALL), MainFrame.LIST_MENU);
258
        // ctxt.addMenuItem(ctxt.createListAction(TABLE_CUSTOMER_CALL), MainFrame.LIST_MENU);
259
        // ctxt.addMenuItem(ctxt.createListAction(TABLE_CUSTOMER_VISIT), MainFrame.LIST_MENU);
259
        // ctxt.addMenuItem(ctxt.createListAction(TABLE_CUSTOMER_VISIT), MainFrame.LIST_MENU);
260
        // ctxt.addMenuItem(ctxt.createListAction(TABLE_LEAD_CALL), MainFrame.LIST_MENU);
260
        // ctxt.addMenuItem(ctxt.createListAction(TABLE_LEAD_CALL), MainFrame.LIST_MENU);
261
        // ctxt.addMenuItem(ctxt.createListAction(TABLE_LEAD_VISIT), MainFrame.LIST_MENU);
261
        // ctxt.addMenuItem(ctxt.createListAction(TABLE_LEAD_VISIT), MainFrame.LIST_MENU);
262
 
262
 
263
        ctxt.addMenuItem(new AbstractAction("Import de prospects") {
263
        ctxt.addMenuItem(new AbstractAction("Import de prospects") {
264
            @Override
264
            @Override
265
            public void actionPerformed(ActionEvent e) {
265
            public void actionPerformed(ActionEvent e) {
266
                final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
266
                final Frame frame = SwingThreadUtils.getAncestorOrSelf(Frame.class, (Component) e.getSource());
267
                final FileDialog fd = new FileDialog(frame, "Import de prospects", FileDialog.LOAD);
267
                final FileDialog fd = new FileDialog(frame, "Import de prospects", FileDialog.LOAD);
268
                fd.setFilenameFilter(new FilenameFilter() {
268
                fd.setFilenameFilter(new FilenameFilter() {
269
                    @Override
269
                    @Override
270
                    public boolean accept(File dir, String name) {
270
                    public boolean accept(File dir, String name) {
271
                        return name.endsWith("." + ContentTypeVersioned.SPREADSHEET.getExtension());
271
                        return name.endsWith("." + ContentTypeVersioned.SPREADSHEET.getExtension());
272
                    }
272
                    }
273
                });
273
                });
274
                fd.setVisible(true);
274
                fd.setVisible(true);
275
                if (fd.getFile() != null) {
275
                if (fd.getFile() != null) {
276
                    final DBRoot rootSociete = ((ComptaPropsConfiguration) ComptaPropsConfiguration.getInstance()).getRootSociete();
276
                    final DBRoot rootSociete = ((ComptaPropsConfiguration) ComptaPropsConfiguration.getInstance()).getRootSociete();
277
                    try {
277
                    try {
278
                        SQLUtils.executeAtomic(rootSociete.getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() {
278
                        SQLUtils.executeAtomic(rootSociete.getDBSystemRoot().getDataSource(), new ConnectionHandlerNoSetup<Object, IOException>() {
279
                            @Override
279
                            @Override
280
                            public Object handle(final SQLDataSource ds) throws SQLException, IOException {
280
                            public Object handle(final SQLDataSource ds) throws SQLException, IOException {
281
                                File f = new File(fd.getDirectory());
281
                                File f = new File(fd.getDirectory());
282
 
282
 
283
                                LeadImporter imp = new LeadImporter();
283
                                LeadImporter imp = new LeadImporter();
284
                                try {
284
                                try {
285
                                    imp.exportLead(rootSociete, f, new File(fd.getDirectory(), fd.getFile()));
285
                                    imp.exportLead(rootSociete, f, new File(fd.getDirectory(), fd.getFile()));
286
                                    imp.importFromFile(f, rootSociete);
286
                                    imp.importFromFile(f, rootSociete);
287
                                } catch (Exception exn) {
287
                                } catch (Exception exn) {
288
                                    // TODO Bloc catch auto-généré
288
                                    // TODO Bloc catch auto-généré
289
                                    exn.printStackTrace();
289
                                    exn.printStackTrace();
290
                                }
290
                                }
291
                                return null;
291
                                return null;
292
                            }
292
                            }
293
                        });
293
                        });
294
                    } catch (IOException exn) {
294
                    } catch (IOException exn) {
295
                        ExceptionHandler.handle(frame, "Erreur lors de la lecture du fichier", exn);
295
                        ExceptionHandler.handle(frame, "Erreur lors de la lecture du fichier", exn);
296
                    } catch (SQLException exn) {
296
                    } catch (SQLException exn) {
297
                        ExceptionHandler.handle(frame, "Erreur lors de l'insertion dans la base", exn);
297
                        ExceptionHandler.handle(frame, "Erreur lors de l'insertion dans la base", exn);
298
                    }
298
                    }
299
                }
299
                }
300
            }
300
            }
301
        }, MainFrame.FILE_MENU);
301
        }, MainFrame.FILE_MENU);
302
    }
302
    }
303
 
303
 
304
    @Override
304
    @Override
305
    protected void start() {
305
    protected void start() {
306
        new LeadCustomerSQLInjector();
306
        new LeadCustomerSQLInjector();
307
        new LeadContactSQLInjector();
307
        new LeadContactSQLInjector();
308
    }
308
    }
309
 
309
 
310
    @Override
310
    @Override
311
    protected void stop() {
311
    protected void stop() {
312
    }
312
    }
313
 
313
 
314
    public static void main(String[] args) throws IOException {
314
    public static void main(String[] args) throws IOException {
315
        System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
315
        System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
316
        final File propsFile = new File("module.properties");
316
        final File propsFile = new File("module.properties");
317
        System.out.println(propsFile.getAbsolutePath());
317
        System.out.println(propsFile.getAbsolutePath());
318
        final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
318
        final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
319
        SQLRequestLog.setEnabled(true);
319
        SQLRequestLog.setEnabled(true);
320
        SQLRequestLog.showFrame();
320
        SQLRequestLog.showFrame();
321
        // uncomment to create and use the jar
321
        // uncomment to create and use the jar
322
        final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/"));
322
        final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/"));
323
        modulePackager.writeToDir(new File("../OpenConcerto/Modules"));
323
        modulePackager.writeToDir(new File("../OpenConcerto/Modules"));
324
        // final ModuleFactory factory = new JarModuleFactory(jar);
324
        // final ModuleFactory factory = new JarModuleFactory(jar);
325
        ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules"));
325
        ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules"));
326
        ModuleManager.getInstance().addFactoryAndStart(factory, false);
326
        ModuleManager.getInstance().addFactoryAndStart(factory, false);
327
        Gestion.main(args);
327
        Gestion.main(args);
328
    }
328
    }
329
 
329
 
330
}
330
}