OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 149 Rev 180
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 /*
14
 /*
15
 * Créé le 20 janv. 2012
15
 * Créé le 20 janv. 2012
16
 */
16
 */
17
package org.openconcerto.erp.core.supplychain.supplier.component;
17
package org.openconcerto.erp.core.supplychain.supplier.component;
18
 
18
 
19
import org.openconcerto.erp.config.ComptaPropsConfiguration;
19
import org.openconcerto.erp.config.ComptaPropsConfiguration;
20
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
20
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
21
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactItemTable;
21
import org.openconcerto.erp.core.customerrelationship.customer.element.ContactItemTable;
22
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
22
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
23
import org.openconcerto.erp.model.ISQLCompteSelector;
23
import org.openconcerto.erp.model.ISQLCompteSelector;
24
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
24
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
25
import org.openconcerto.sql.Configuration;
25
import org.openconcerto.sql.Configuration;
26
import org.openconcerto.sql.element.BaseSQLComponent;
26
import org.openconcerto.sql.element.BaseSQLComponent;
27
import org.openconcerto.sql.element.ElementSQLObject;
27
import org.openconcerto.sql.element.ElementSQLObject;
28
import org.openconcerto.sql.element.SQLElement;
28
import org.openconcerto.sql.element.SQLElement;
29
import org.openconcerto.sql.model.SQLBackgroundTableCache;
29
import org.openconcerto.sql.model.SQLBackgroundTableCache;
30
import org.openconcerto.sql.model.SQLBase;
30
import org.openconcerto.sql.model.SQLBase;
31
import org.openconcerto.sql.model.SQLRow;
31
import org.openconcerto.sql.model.SQLRow;
32
import org.openconcerto.sql.model.SQLRowAccessor;
32
import org.openconcerto.sql.model.SQLRowAccessor;
33
import org.openconcerto.sql.model.SQLRowValues;
33
import org.openconcerto.sql.model.SQLRowValues;
34
import org.openconcerto.sql.model.SQLTable;
34
import org.openconcerto.sql.model.SQLTable;
35
import org.openconcerto.sql.model.UndefinedRowValuesCache;
35
import org.openconcerto.sql.model.UndefinedRowValuesCache;
36
import org.openconcerto.sql.sqlobject.ElementComboBox;
36
import org.openconcerto.sql.sqlobject.ElementComboBox;
37
import org.openconcerto.sql.sqlobject.SQLTextCombo;
37
import org.openconcerto.sql.sqlobject.SQLTextCombo;
38
import org.openconcerto.ui.DefaultGridBagConstraints;
38
import org.openconcerto.ui.DefaultGridBagConstraints;
39
import org.openconcerto.ui.FormLayouter;
39
import org.openconcerto.ui.FormLayouter;
40
import org.openconcerto.ui.TitledSeparator;
40
import org.openconcerto.ui.TitledSeparator;
41
import org.openconcerto.ui.component.ITextArea;
41
import org.openconcerto.ui.component.ITextArea;
42
import org.openconcerto.ui.component.InteractionMode;
42
import org.openconcerto.ui.component.InteractionMode;
43
 
43
 
44
import java.awt.Dimension;
44
import java.awt.Dimension;
45
import java.awt.GridBagConstraints;
45
import java.awt.GridBagConstraints;
46
import java.awt.GridBagLayout;
46
import java.awt.GridBagLayout;
47
import java.awt.event.ActionListener;
47
import java.awt.event.ActionListener;
48
import java.sql.SQLException;
48
import java.sql.SQLException;
49
 
49
 
50
import javax.swing.JCheckBox;
50
import javax.swing.JCheckBox;
51
import javax.swing.JLabel;
51
import javax.swing.JLabel;
52
import javax.swing.JPanel;
52
import javax.swing.JPanel;
53
import javax.swing.JScrollPane;
53
import javax.swing.JScrollPane;
54
import javax.swing.JTabbedPane;
54
import javax.swing.JTabbedPane;
55
import javax.swing.JTextField;
55
import javax.swing.JTextField;
56
import javax.swing.SwingConstants;
56
import javax.swing.SwingConstants;
57
 
57
 
58
public class FournisseurSQLComponent extends BaseSQLComponent {
58
public class FournisseurSQLComponent extends BaseSQLComponent {
59
 
59
 
60
    public FournisseurSQLComponent(SQLElement elt) {
60
    public FournisseurSQLComponent(SQLElement elt) {
61
        super(elt);
61
        super(elt);
62
    }
62
    }
63
 
63
 
64
    JCheckBox checkEnlevement;
64
    JCheckBox checkEnlevement;
65
    ElementSQLObject comp2;
65
    ElementSQLObject comp2;
66
    TitledSeparator sep2;
66
    TitledSeparator sep2;
67
    private ContactItemTable table;
67
    private ContactItemTable table;
68
    private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT_FOURNISSEUR").getTable();
68
    private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT_FOURNISSEUR").getTable();
69
    private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
69
    private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
70
 
70
 
71
    public void addViews() {
71
    public void addViews() {
72
        this.setLayout(new GridBagLayout());
72
        this.setLayout(new GridBagLayout());
73
        final GridBagConstraints c = new DefaultGridBagConstraints();
73
        final GridBagConstraints c = new DefaultGridBagConstraints();
74
 
74
 
75
        // Code
75
        // Code
76
        JLabel labelCode = new JLabel("Code", SwingConstants.RIGHT);
76
        JLabel labelCode = new JLabel("Code", SwingConstants.RIGHT);
77
        JTextField textCode = new JTextField();
77
        JTextField textCode = new JTextField();
78
        c.gridx = 0;
78
        c.gridx = 0;
79
        c.gridy++;
79
        c.gridy++;
80
        c.weightx = 0;
80
        c.weightx = 0;
81
        c.weighty = 0;
81
        c.weighty = 0;
82
        this.add(labelCode, c);
82
        this.add(labelCode, c);
83
        c.gridx++;
83
        c.gridx++;
84
        c.weightx = 0.5;
84
        c.weightx = 0.5;
85
        this.add(textCode, c);
85
        this.add(textCode, c);
86
 
86
 
87
        c.gridy++;
87
        c.gridy++;
88
        c.gridx = 0;
88
        c.gridx = 0;
89
        c.weightx = 0;
89
        c.weightx = 0;
90
        // Raison sociale
90
        // Raison sociale
91
        JLabel labelRS = new JLabel("Forme juridique", SwingConstants.RIGHT);
91
        JLabel labelRS = new JLabel("Forme juridique", SwingConstants.RIGHT);
92
        SQLTextCombo textType = new SQLTextCombo();
92
        SQLTextCombo textType = new SQLTextCombo();
93
        JTextField textNom = new JTextField();
93
        JTextField textNom = new JTextField();
94
 
94
 
95
        this.add(labelRS, c);
95
        this.add(labelRS, c);
96
        c.gridx++;
96
        c.gridx++;
97
        c.weightx = 0.5;
97
        c.weightx = 0.5;
98
        this.add(textType, c);
98
        this.add(textType, c);
99
 
99
 
100
        // Tel
100
        // Tel
101
        JLabel labelTel = new JLabel(getLabelFor("TEL"), SwingConstants.RIGHT);
101
        JLabel labelTel = new JLabel(getLabelFor("TEL"), SwingConstants.RIGHT);
102
        JTextField textTel = new JTextField(15);
102
        JTextField textTel = new JTextField(15);
103
        c.gridx++;
103
        c.gridx++;
104
        c.weightx = 0;
104
        c.weightx = 0;
105
        c.weighty = 0;
105
        c.weighty = 0;
106
 
106
 
107
        this.add(labelTel, c);
107
        this.add(labelTel, c);
108
        c.gridx++;
108
        c.gridx++;
109
 
109
 
110
        c.weightx = 0.5;
110
        c.weightx = 0.5;
111
        this.add(textTel, c);
111
        this.add(textTel, c);
112
 
112
 
113
        // Nom
113
        // Nom
114
        c.gridy++;
114
        c.gridy++;
115
        c.gridx = 0;
115
        c.gridx = 0;
116
        c.weightx = 0;
116
        c.weightx = 0;
117
        String fieldNom = "NOM";
117
        String fieldNom = "NOM";
118
        if (getTable().contains("NOM_SOCIETE")) {
118
        if (getTable().contains("NOM_SOCIETE")) {
119
            fieldNom = "NOM_SOCIETE";
119
            fieldNom = "NOM_SOCIETE";
120
        }
120
        }
121
        this.add(new JLabel(getLabelFor(fieldNom), SwingConstants.RIGHT), c);
121
        this.add(new JLabel(getLabelFor(fieldNom), SwingConstants.RIGHT), c);
122
        c.gridx++;
122
        c.gridx++;
123
 
123
 
124
        c.weightx = 0.5;
124
        c.weightx = 0.5;
125
        this.add(textNom, c);
125
        this.add(textNom, c);
126
        this.addRequiredSQLObject(textNom, fieldNom);
126
        this.addRequiredSQLObject(textNom, fieldNom);
127
 
127
 
128
        // Fax
128
        // Fax
129
        c.gridx++;
129
        c.gridx++;
130
        c.weightx = 0;
130
        c.weightx = 0;
131
        this.add(new JLabel(getLabelFor("FAX"), SwingConstants.RIGHT), c);
131
        this.add(new JLabel(getLabelFor("FAX"), SwingConstants.RIGHT), c);
132
        c.gridx++;
132
        c.gridx++;
133
 
133
 
134
        c.weightx = 0.5;
134
        c.weightx = 0.5;
135
        JTextField textFax = new JTextField();
135
        JTextField textFax = new JTextField();
136
        this.add(textFax, c);
136
        this.add(textFax, c);
137
 
137
 
138
        // Mail
138
        // Mail
139
        c.gridy++;
139
        c.gridy++;
140
        c.gridx = 0;
140
        c.gridx = 0;
141
        c.weightx = 0;
141
        c.weightx = 0;
142
        c.gridwidth = 1;
142
        c.gridwidth = 1;
143
        this.add(new JLabel(getLabelFor("MAIL"), SwingConstants.RIGHT), c);
143
        this.add(new JLabel(getLabelFor("MAIL"), SwingConstants.RIGHT), c);
144
        c.gridx++;
144
        c.gridx++;
145
 
145
 
146
        c.weightx = 0.5;
146
        c.weightx = 0.5;
147
        JTextField textMail = new JTextField();
147
        JTextField textMail = new JTextField();
148
        this.add(textMail, c);
148
        this.add(textMail, c);
149
        this.addView(textMail, "MAIL");
149
        this.addView(textMail, "MAIL");
150
 
150
 
151
        // Tel P
151
        // Tel P
152
        c.gridx++;
152
        c.gridx++;
153
        c.weightx = 0;
153
        c.weightx = 0;
154
 
154
 
155
        this.add(new JLabel(getLabelFor("TEL_P"), SwingConstants.RIGHT), c);
155
        this.add(new JLabel(getLabelFor("TEL_P"), SwingConstants.RIGHT), c);
156
        c.gridx++;
156
        c.gridx++;
157
        c.weightx = 0.5;
157
        c.weightx = 0.5;
158
        JTextField textTelP = new JTextField();
158
        JTextField textTelP = new JTextField();
159
        this.add(textTelP, c);
159
        this.add(textTelP, c);
160
        this.addView(textTelP, "TEL_P");
160
        this.addView(textTelP, "TEL_P");
161
        // Langue
161
        // Langue
162
        c.gridy++;
162
        c.gridy++;
163
        c.gridx = 0;
163
        c.gridx = 0;
164
        c.weightx = 0;
164
        c.weightx = 0;
165
        this.add(new JLabel(getLabelFor("ID_LANGUE"), SwingConstants.RIGHT), c);
165
        this.add(new JLabel(getLabelFor("ID_LANGUE"), SwingConstants.RIGHT), c);
166
        c.gridx++;
166
        c.gridx++;
167
        c.weightx = 0.5;
167
        c.weightx = 0.5;
168
        ElementComboBox langue = new ElementComboBox(true, 35);
168
        ElementComboBox langue = new ElementComboBox(true, 35);
169
        this.add(langue, c);
169
        this.add(langue, c);
170
        this.addView(langue, "ID_LANGUE");
170
        this.addView(langue, "ID_LANGUE");
171
 
171
 
172
        // Resp
172
        // Resp
173
        c.gridx++;
173
        c.gridx++;
174
        c.weightx = 0;
174
        c.weightx = 0;
175
        this.add(new JLabel(getLabelFor("RESPONSABLE"), SwingConstants.RIGHT), c);
175
        this.add(new JLabel(getLabelFor("RESPONSABLE"), SwingConstants.RIGHT), c);
176
        c.gridx++;
176
        c.gridx++;
177
        c.weightx = 0.5;
177
        c.weightx = 0.5;
178
        JTextField textResp = new JTextField();
178
        JTextField textResp = new JTextField();
179
        this.add(textResp, c);
179
        this.add(textResp, c);
180
        this.addView(textResp, "RESPONSABLE");
180
        this.addView(textResp, "RESPONSABLE");
181
 
181
 
182
        // Siret
182
        // Siret
183
        c.gridy++;
183
        c.gridy++;
184
        c.gridx = 0;
184
        c.gridx = 0;
185
        c.weightx = 0;
185
        c.weightx = 0;
186
        this.add(new JLabel(getLabelFor("SIRET"), SwingConstants.RIGHT), c);
186
        this.add(new JLabel(getLabelFor("SIRET"), SwingConstants.RIGHT), c);
187
        c.gridx++;
187
        c.gridx++;
188
        c.weightx = 0.5;
188
        c.weightx = 0.5;
189
        JTextField textSiret = new JTextField();
189
        JTextField textSiret = new JTextField();
190
        ;
190
        ;
191
        this.add(textSiret, c);
191
        this.add(textSiret, c);
192
        this.addView(textSiret, "SIRET");
192
        this.addView(textSiret, "SIRET");
193
 
193
 
194
        // tva
194
        // tva
195
        c.gridx++;
195
        c.gridx++;
196
        c.weightx = 0;
196
        c.weightx = 0;
197
        this.add(new JLabel(getLabelFor("NUMERO_TVA"), SwingConstants.RIGHT), c);
197
        this.add(new JLabel(getLabelFor("NUMERO_TVA"), SwingConstants.RIGHT), c);
198
        c.gridx++;
198
        c.gridx++;
199
        c.weightx = 0.5;
199
        c.weightx = 0.5;
200
        JTextField textNumeroTVA = new JTextField();
200
        JTextField textNumeroTVA = new JTextField();
201
        this.add(textNumeroTVA, c);
201
        this.add(textNumeroTVA, c);
202
        this.addView(textNumeroTVA, "NUMERO_TVA");
202
        this.addView(textNumeroTVA, "NUMERO_TVA");
203
 
203
 
204
        c.gridx = 1;
204
        c.gridx = 1;
205
        c.gridy++;
205
        c.gridy++;
206
        JCheckBox boxUE = new JCheckBox(getLabelFor("UE"));
206
        JCheckBox boxUE = new JCheckBox(getLabelFor("UE"));
207
        this.add(boxUE, c);
207
        this.add(boxUE, c);
208
 
208
 
209
        if (getTable().contains("ID_DEVISE")) {
209
        if (getTable().contains("ID_DEVISE")) {
210
            c.gridx++;
210
            c.gridx++;
211
            c.weightx = 0;
211
            c.weightx = 0;
212
            this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);
212
            this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);
213
            c.gridx++;
213
            c.gridx++;
214
            c.weightx = 0.5;
214
            c.weightx = 0.5;
215
            ElementComboBox devise = new ElementComboBox(true, 35);
215
            ElementComboBox devise = new ElementComboBox(true, 35);
216
            this.add(devise, c);
216
            this.add(devise, c);
217
            this.addView(devise, "ID_DEVISE");
217
            this.addView(devise, "ID_DEVISE");
218
        }
218
        }
219
 
219
 
220
        if (getTable().contains("ALG_REGISTRE")) {
220
        if (getTable().contains("ALG_REGISTRE")) {
221
            c.gridy++;
221
            c.gridy++;
222
            c.gridx = 0;
222
            c.gridx = 0;
223
            c.weightx = 0;
223
            c.weightx = 0;
224
            this.add(new JLabel(getLabelFor("ALG_REGISTRE"), SwingConstants.RIGHT), c);
224
            this.add(new JLabel(getLabelFor("ALG_REGISTRE"), SwingConstants.RIGHT), c);
225
            c.gridx++;
225
            c.gridx++;
226
            c.weightx = 1;
226
            c.weightx = 1;
227
            JTextField fieldRegistre = new JTextField(20);
227
            JTextField fieldRegistre = new JTextField(20);
228
            this.add(fieldRegistre, c);
228
            this.add(fieldRegistre, c);
229
            this.addView(fieldRegistre, "ALG_REGISTRE");
229
            this.addView(fieldRegistre, "ALG_REGISTRE");
230
 
230
 
231
            c.gridx++;
231
            c.gridx++;
232
            c.weightx = 0;
232
            c.weightx = 0;
233
            this.add(new JLabel(getLabelFor("ALG_MATRICULE"), SwingConstants.RIGHT), c);
233
            this.add(new JLabel(getLabelFor("ALG_MATRICULE"), SwingConstants.RIGHT), c);
234
            c.gridx++;
234
            c.gridx++;
235
            c.weightx = 1;
235
            c.weightx = 1;
236
            JTextField fieldMatricule = new JTextField(20);
236
            JTextField fieldMatricule = new JTextField(20);
237
            this.add(fieldMatricule, c);
237
            this.add(fieldMatricule, c);
238
            this.addView(fieldMatricule, "ALG_MATRICULE");
238
            this.addView(fieldMatricule, "ALG_MATRICULE");
239
 
239
 
240
            c.gridy++;
240
            c.gridy++;
241
            c.gridx = 0;
241
            c.gridx = 0;
242
            c.weightx = 0;
242
            c.weightx = 0;
243
            this.add(new JLabel(getLabelFor("ALG_ARTICLE"), SwingConstants.RIGHT), c);
243
            this.add(new JLabel(getLabelFor("ALG_ARTICLE"), SwingConstants.RIGHT), c);
244
            c.gridx++;
244
            c.gridx++;
245
            c.weightx = 1;
245
            c.weightx = 1;
246
            JTextField fieldArticle = new JTextField(20);
246
            JTextField fieldArticle = new JTextField(20);
247
            this.add(fieldArticle, c);
247
            this.add(fieldArticle, c);
248
            this.addView(fieldArticle, "ALG_ARTICLE");
248
            this.addView(fieldArticle, "ALG_ARTICLE");
249
        }
249
        }
250
 
250
 
251
        // Champ Module
251
        // Champ Module
252
        c.gridx = 0;
252
        c.gridx = 0;
253
        c.gridy++;
253
        c.gridy++;
254
        c.gridwidth = GridBagConstraints.REMAINDER;
254
        c.gridwidth = GridBagConstraints.REMAINDER;
255
        final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
255
        final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
256
        this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
256
        this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
257
        this.add(addP, c);
257
        this.add(addP, c);
258
 
258
 
259
        // Tabbed
259
        // Tabbed
260
        JTabbedPane tabbedPane = new JTabbedPane();
260
        JTabbedPane tabbedPane = new JTabbedPane();
261
 
261
 
262
        JPanel panelAdresse = new JPanel(new GridBagLayout());
262
        JPanel panelAdresse = new JPanel(new GridBagLayout());
263
        panelAdresse.setOpaque(false);
263
        panelAdresse.setOpaque(false);
264
        GridBagConstraints cAdr = new DefaultGridBagConstraints();
264
        GridBagConstraints cAdr = new DefaultGridBagConstraints();
265
        // Adresse
265
        // Adresse
266
        TitledSeparator sep = new TitledSeparator("Adresse");
266
        TitledSeparator sep = new TitledSeparator("Adresse");
267
        sep.setOpaque(false);
267
        sep.setOpaque(false);
268
        panelAdresse.add(sep, cAdr);
268
        panelAdresse.add(sep, cAdr);
269
 
269
 
270
        this.sep2 = new TitledSeparator("Adresse d'enlévement");
270
        this.sep2 = new TitledSeparator("Adresse d'enlévement");
271
        this.sep2.setOpaque(false);
271
        this.sep2.setOpaque(false);
272
        cAdr.gridx = GridBagConstraints.RELATIVE;
272
        cAdr.gridx = GridBagConstraints.RELATIVE;
273
        panelAdresse.add(this.sep2, cAdr);
273
        panelAdresse.add(this.sep2, cAdr);
274
 
274
 
275
        //
275
        //
276
 
276
 
277
        this.addView("ID_ADRESSE", REQ + ";" + DEC + ";" + SEP);
277
        this.addView("ID_ADRESSE", REQ + ";" + DEC + ";" + SEP);
278
 
278
 
279
        cAdr.gridy++;
279
        cAdr.gridy++;
280
        cAdr.fill = GridBagConstraints.HORIZONTAL;
280
        cAdr.fill = GridBagConstraints.HORIZONTAL;
281
        cAdr.weightx = 1;
281
        cAdr.weightx = 1;
282
        final ElementSQLObject view = (ElementSQLObject) this.getView("ID_ADRESSE");
282
        final ElementSQLObject view = (ElementSQLObject) this.getView("ID_ADRESSE");
283
        view.setOpaque(false);
283
        view.setOpaque(false);
284
        panelAdresse.add(view, cAdr);
284
        panelAdresse.add(view, cAdr);
285
 
285
 
286
        // Selection de 2eme adresse
286
        // Selection de 2eme adresse
287
        this.addView("ID_ADRESSE_E", DEC);
287
        this.addView("ID_ADRESSE_E", DEC);
288
        cAdr.gridx = GridBagConstraints.RELATIVE;
288
        cAdr.gridx = GridBagConstraints.RELATIVE;
289
        this.comp2 = (ElementSQLObject) this.getView("ID_ADRESSE_E");
289
        this.comp2 = (ElementSQLObject) this.getView("ID_ADRESSE_E");
290
        this.comp2.setCreated(true);
290
        this.comp2.setCreated(true);
291
        this.comp2.setOpaque(false);
291
        this.comp2.setOpaque(false);
292
        panelAdresse.add(this.comp2, cAdr);
292
        panelAdresse.add(this.comp2, cAdr);
293
 
293
 
294
        this.checkEnlevement = new JCheckBox("Adresse d'enlèvement identique");
294
        this.checkEnlevement = new JCheckBox("Adresse d'enlèvement identique");
295
        this.checkEnlevement.setOpaque(false);
295
        this.checkEnlevement.setOpaque(false);
296
        cAdr.gridx = 0;
296
        cAdr.gridx = 0;
297
        cAdr.gridy++;
297
        cAdr.gridy++;
298
        cAdr.gridwidth = GridBagConstraints.REMAINDER;
298
        cAdr.gridwidth = GridBagConstraints.REMAINDER;
299
        panelAdresse.add(this.checkEnlevement, cAdr);
299
        panelAdresse.add(this.checkEnlevement, cAdr);
300
        tabbedPane.add("Adresses", panelAdresse);
300
        tabbedPane.add("Adresses", panelAdresse);
301
 
301
 
302
        this.checkEnlevement.setSelected(true);
302
        this.checkEnlevement.setSelected(true);
303
        this.sep2.setVisible(false);
303
        this.sep2.setVisible(false);
304
        this.checkEnlevement.addActionListener(new ActionListener() {
304
        this.checkEnlevement.addActionListener(new ActionListener() {
305
 
305
 
306
            public void actionPerformed(java.awt.event.ActionEvent e) {
306
            public void actionPerformed(java.awt.event.ActionEvent e) {
307
                System.out.println("Click");
307
                System.out.println("Click");
308
                if (checkEnlevement.isSelected()) {
308
                if (checkEnlevement.isSelected()) {
309
                    System.out.println("Mode 1");
309
                    System.out.println("Mode 1");
310
                    comp2.setEditable(InteractionMode.DISABLED);
310
                    comp2.setEditable(InteractionMode.DISABLED);
311
                    comp2.setCreated(false);
311
                    comp2.setCreated(false);
312
                    sep2.setVisible(false);
312
                    sep2.setVisible(false);
313
                } else {
313
                } else {
314
                    System.out.println("Mode 2");
314
                    System.out.println("Mode 2");
315
                    comp2.setEditable(InteractionMode.READ_WRITE);
315
                    comp2.setEditable(InteractionMode.READ_WRITE);
316
                    comp2.setCreated(true);
316
                    comp2.setCreated(true);
317
                    sep2.setVisible(true);
317
                    sep2.setVisible(true);
318
                }
318
                }
319
            };
319
            };
320
        });
320
        });
321
 
321
 
322
        // Contact
322
        // Contact
323
        JPanel panelContact = new JPanel(new GridBagLayout());
323
        JPanel panelContact = new JPanel(new GridBagLayout());
324
        panelContact.setOpaque(false);
324
        panelContact.setOpaque(false);
325
        this.table = new ContactItemTable(this.defaultContactRowVals);
325
        this.table = new ContactItemTable(this.defaultContactRowVals);
326
        this.table.setOpaque(false);
326
        this.table.setOpaque(false);
327
        this.table.setPreferredSize(new Dimension(this.table.getSize().width, 150));
327
        this.table.setPreferredSize(new Dimension(this.table.getSize().width, 150));
328
        GridBagConstraints cContact = new DefaultGridBagConstraints();
328
        GridBagConstraints cContact = new DefaultGridBagConstraints();
329
        cContact.fill = GridBagConstraints.BOTH;
329
        cContact.fill = GridBagConstraints.BOTH;
330
        cContact.weightx = 1;
330
        cContact.weightx = 1;
331
        cContact.weighty = 1;
331
        cContact.weighty = 1;
332
        panelContact.add(this.table, cContact);
332
        panelContact.add(this.table, cContact);
333
        tabbedPane.add("Contacts", panelContact);
333
        tabbedPane.add("Contacts", panelContact);
334
        c.gridx = 0;
334
        c.gridx = 0;
335
        c.gridy++;
335
        c.gridy++;
336
        c.anchor = GridBagConstraints.NORTHWEST;
336
        c.anchor = GridBagConstraints.NORTHWEST;
337
        c.fill = GridBagConstraints.BOTH;
337
        c.fill = GridBagConstraints.BOTH;
338
        c.gridwidth = GridBagConstraints.REMAINDER;
338
        c.gridwidth = GridBagConstraints.REMAINDER;
339
        this.add(tabbedPane, c);
339
        this.add(tabbedPane, c);
340
 
340
 
341
        // Mode de réglement
341
        // Mode de réglement
342
        TitledSeparator reglSep = new TitledSeparator(getLabelFor("ID_MODE_REGLEMENT"));
342
        TitledSeparator reglSep = new TitledSeparator(getLabelFor("ID_MODE_REGLEMENT"));
343
        c.gridwidth = 2;
343
        c.gridwidth = 2;
344
        c.gridy++;
344
        c.gridy++;
345
        c.gridx = 0;
345
        c.gridx = 0;
346
        this.add(reglSep, c);
346
        this.add(reglSep, c);
347
 
347
 
348
        c.gridy++;
348
        c.gridy++;
349
        c.gridx = 0;
349
        c.gridx = 0;
350
        c.fill = GridBagConstraints.NONE;
350
        c.fill = GridBagConstraints.NONE;
351
        this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
351
        this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
352
        ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
352
        ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
353
        this.add(eltModeRegl, c);
353
        this.add(eltModeRegl, c);
354
 
354
 
355
        //
355
        //
356
        {
356
        {
357
            c.gridx = 2;
357
            c.gridx = 2;
358
            c.gridy--;
358
            c.gridy--;
359
            c.gridwidth = 2;
359
            c.gridwidth = 2;
360
            c.fill = GridBagConstraints.BOTH;
360
            c.fill = GridBagConstraints.BOTH;
361
            TitledSeparator ribSep = new TitledSeparator("Coordonnées bancaires");
361
            TitledSeparator ribSep = new TitledSeparator("Coordonnées bancaires");
362
 
362
 
363
            this.add(ribSep, c);
363
            this.add(ribSep, c);
364
 
364
 
365
            final JPanel pCoordonneesBancaires = new JPanel();
365
            final JPanel pCoordonneesBancaires = new JPanel();
366
            pCoordonneesBancaires.setLayout(new GridBagLayout());
366
            pCoordonneesBancaires.setLayout(new GridBagLayout());
367
            GridBagConstraints c2 = new DefaultGridBagConstraints();
367
            GridBagConstraints c2 = new DefaultGridBagConstraints();
368
 
368
 
369
            c2.gridy++;
369
            c2.gridy++;
370
            // IBAN
370
            // IBAN
371
            JLabel labelIBAN = new JLabel("IBAN", SwingConstants.RIGHT);
371
            JLabel labelIBAN = new JLabel("IBAN", SwingConstants.RIGHT);
372
            JTextField textIBAN = new JTextField(40);
372
            JTextField textIBAN = new JTextField(40);
373
            c2.weightx = 0;
373
            c2.weightx = 0;
374
            pCoordonneesBancaires.add(labelIBAN, c2);
374
            pCoordonneesBancaires.add(labelIBAN, c2);
375
            c2.gridx++;
375
            c2.gridx++;
376
            c2.weightx = 1;
376
            c2.weightx = 1;
377
            pCoordonneesBancaires.add(textIBAN, c2);
377
            pCoordonneesBancaires.add(textIBAN, c2);
378
 
378
 
379
            // BIC
379
            // BIC
380
            JLabel labelBIC = new JLabel("BIC", SwingConstants.RIGHT);
380
            JLabel labelBIC = new JLabel("BIC", SwingConstants.RIGHT);
381
            JTextField textBIC = new JTextField(12);
381
            JTextField textBIC = new JTextField(20);
382
            c2.gridx = 0;
382
            c2.gridx = 0;
383
            c2.gridy++;
383
            c2.gridy++;
384
            c2.weightx = 0;
384
            c2.weightx = 0;
385
            pCoordonneesBancaires.add(labelBIC, c2);
385
            pCoordonneesBancaires.add(labelBIC, c2);
386
            c2.gridx++;
386
            c2.gridx++;
387
            c2.weightx = 1;
387
            c2.weightx = 1;
388
            c2.fill = GridBagConstraints.NONE;
388
            c2.fill = GridBagConstraints.NONE;
389
            pCoordonneesBancaires.add(textBIC, c2);
389
            pCoordonneesBancaires.add(textBIC, c2);
390
            c.gridy++;
390
            c.gridy++;
391
            c.fill = GridBagConstraints.HORIZONTAL;
391
            c.fill = GridBagConstraints.HORIZONTAL;
392
            this.add(pCoordonneesBancaires, c);
392
            this.add(pCoordonneesBancaires, c);
393
 
393
 
394
            this.addView(textIBAN, "IBAN");
394
            this.addView(textIBAN, "IBAN");
395
            this.addView(textBIC, "BIC");
395
            this.addView(textBIC, "BIC");
396
        }
396
        }
397
        // Compte associé
397
        // Compte associé
398
 
398
 
399
        c.gridx = 0;
399
        c.gridx = 0;
400
        c.gridy++;
400
        c.gridy++;
401
        c.weightx = 1;
401
        c.weightx = 1;
402
        c.weighty = 0;
402
        c.weighty = 0;
403
        c.fill = GridBagConstraints.HORIZONTAL;
403
        c.fill = GridBagConstraints.HORIZONTAL;
404
        c.gridwidth = GridBagConstraints.REMAINDER;
404
        c.gridwidth = GridBagConstraints.REMAINDER;
405
        TitledSeparator sepCompteCharge = new TitledSeparator("Comptes associés");
405
        TitledSeparator sepCompteCharge = new TitledSeparator("Comptes associés");
406
        this.add(sepCompteCharge, c);
406
        this.add(sepCompteCharge, c);
407
 
407
 
408
        final JPanel panel = new JPanel(new GridBagLayout());
408
        final JPanel panel = new JPanel(new GridBagLayout());
409
        final GridBagConstraints c2 = new DefaultGridBagConstraints();
409
        final GridBagConstraints c2 = new DefaultGridBagConstraints();
410
        panel.add(new JLabel("Compte fournisseur associé", SwingConstants.RIGHT), c2);
410
        panel.add(new JLabel("Compte fournisseur associé", SwingConstants.RIGHT), c2);
411
        ISQLCompteSelector compteSel = new ISQLCompteSelector(true);
411
        ISQLCompteSelector compteSel = new ISQLCompteSelector(true);
412
        c2.gridx++;
412
        c2.gridx++;
413
        c2.weightx = 1;
413
        c2.weightx = 1;
414
        panel.add(compteSel, c2);
414
        panel.add(compteSel, c2);
415
        c2.gridx = 0;
415
        c2.gridx = 0;
416
        c2.gridy++;
416
        c2.gridy++;
417
        c2.weightx = 0;
417
        c2.weightx = 0;
418
        panel.add(new JLabel(getLabelFor("ID_COMPTE_PCE_CHARGE"), SwingConstants.RIGHT), c2);
418
        panel.add(new JLabel(getLabelFor("ID_COMPTE_PCE_CHARGE"), SwingConstants.RIGHT), c2);
419
        ISQLCompteSelector compteSelCharge = new ISQLCompteSelector(true);
419
        ISQLCompteSelector compteSelCharge = new ISQLCompteSelector(true);
420
        c2.gridx++;
420
        c2.gridx++;
421
        c2.weightx = 1;
421
        c2.weightx = 1;
422
        panel.add(compteSelCharge, c2);
422
        panel.add(compteSelCharge, c2);
423
        addView(compteSelCharge, "ID_COMPTE_PCE_CHARGE");
423
        addView(compteSelCharge, "ID_COMPTE_PCE_CHARGE");
424
 
424
 
425
        c.gridwidth = GridBagConstraints.REMAINDER;
425
        c.gridwidth = GridBagConstraints.REMAINDER;
426
        c.gridy++;
426
        c.gridy++;
427
        c.gridx = 0;
427
        c.gridx = 0;
428
        c.weightx = 1;
428
        c.weightx = 1;
429
        c.anchor = GridBagConstraints.NORTHWEST;
429
        c.anchor = GridBagConstraints.NORTHWEST;
430
        this.add(panel, c);
430
        this.add(panel, c);
431
 
431
 
432
        c.gridwidth = 1;
432
        c.gridwidth = 1;
433
        c.gridy++;
433
        c.gridy++;
434
        c.gridx = 0;
434
        c.gridx = 0;
435
        c.weightx = 1;
435
        c.weightx = 1;
436
        c.anchor = GridBagConstraints.NORTHWEST;
436
        c.anchor = GridBagConstraints.NORTHWEST;
437
 
437
 
438
        // INfos
438
        // INfos
439
        c.gridx = 0;
439
        c.gridx = 0;
440
        c.gridy++;
440
        c.gridy++;
441
        c.gridheight = 1;
441
        c.gridheight = 1;
442
        c.weightx = 1;
442
        c.weightx = 1;
443
        c.anchor = GridBagConstraints.WEST;
443
        c.anchor = GridBagConstraints.WEST;
444
        c.gridwidth = GridBagConstraints.REMAINDER;
444
        c.gridwidth = GridBagConstraints.REMAINDER;
445
        this.add(new TitledSeparator(getLabelFor("INFOS")), c);
445
        this.add(new TitledSeparator(getLabelFor("INFOS")), c);
446
 
446
 
447
        c.gridy++;
447
        c.gridy++;
448
        c.weightx = 1;
448
        c.weightx = 1;
449
        c.weighty = 1;
449
        c.weighty = 1;
450
        c.fill = GridBagConstraints.BOTH;
450
        c.fill = GridBagConstraints.BOTH;
451
        ITextArea infos = new ITextArea();
451
        ITextArea infos = new ITextArea();
452
        final JScrollPane scrollPane = new JScrollPane(infos);
452
        final JScrollPane scrollPane = new JScrollPane(infos);
453
        scrollPane.setBorder(null);
453
        scrollPane.setBorder(null);
454
        this.add(scrollPane, c);
454
        this.add(scrollPane, c);
455
        this.addView(infos, "INFOS");
455
        this.addView(infos, "INFOS");
456
 
456
 
457
        this.addSQLObject(textType, "TYPE");
457
        this.addSQLObject(textType, "TYPE");
458
 
458
 
459
        this.addSQLObject(textCode, "CODE");
459
        this.addSQLObject(textCode, "CODE");
460
        this.addSQLObject(textTel, "TEL");
460
        this.addSQLObject(textTel, "TEL");
461
        this.addSQLObject(textFax, "FAX");
461
        this.addSQLObject(textFax, "FAX");
462
        this.addSQLObject(boxUE, "UE");
462
        this.addSQLObject(boxUE, "UE");
463
        this.addRequiredSQLObject(compteSel, "ID_COMPTE_PCE");
463
        this.addRequiredSQLObject(compteSel, "ID_COMPTE_PCE");
464
        // this.addRequiredPrivateForeignField(adresse,"ID_ADRESSE");
464
        // this.addRequiredPrivateForeignField(adresse,"ID_ADRESSE");
465
 
465
 
466
        // this.addSQLObject(adresse, "VILLE");
466
        // this.addSQLObject(adresse, "VILLE");
467
        /***********************************************************************************
467
        /***********************************************************************************
468
         * this.addSQLObject(new JTextField(), "NUMERO_CANTON"); this.addSQLObject(new JTextField(),
468
         * this.addSQLObject(new JTextField(), "NUMERO_CANTON"); this.addSQLObject(new JTextField(),
469
         * "NUMERO_COMMUNE");
469
         * "NUMERO_COMMUNE");
470
         */
470
         */
471
 
471
 
472
        // Select Compte fournisseur par defaut
472
        // Select Compte fournisseur par defaut
473
        final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
473
        final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
474
        final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
474
        final SQLTable tablePrefCompte = base.getTable("PREFS_COMPTE");
475
        final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
475
        final SQLRow rowPrefsCompte = tablePrefCompte.getRow(2);
476
        int idCompteFourn = rowPrefsCompte.getInt("ID_COMPTE_PCE_FOURNISSEUR");
476
        int idCompteFourn = rowPrefsCompte.getInt("ID_COMPTE_PCE_FOURNISSEUR");
477
        if (idCompteFourn <= 1) {
477
        if (idCompteFourn <= 1) {
478
            try {
478
            try {
479
                idCompteFourn = ComptePCESQLElement.getIdComptePceDefault("Fournisseurs");
479
                idCompteFourn = ComptePCESQLElement.getIdComptePceDefault("Fournisseurs");
480
            } catch (Exception e) {
480
            } catch (Exception e) {
481
                e.printStackTrace();
481
                e.printStackTrace();
482
            }
482
            }
483
        }
483
        }
484
 
484
 
485
        compteSel.setValue(idCompteFourn);
485
        compteSel.setValue(idCompteFourn);
486
    }
486
    }
487
 
487
 
488
    @Override
488
    @Override
489
    public void select(SQLRowAccessor r) {
489
    public void select(SQLRowAccessor r) {
490
        if (r != null && r.isForeignEmpty("ID_ADRESSE_E")) {
490
        if (r != null && r.isForeignEmpty("ID_ADRESSE_E")) {
491
            this.checkEnlevement.setSelected(true);
491
            this.checkEnlevement.setSelected(true);
492
            this.comp2.setEditable(InteractionMode.DISABLED);
492
            this.comp2.setEditable(InteractionMode.DISABLED);
493
            this.comp2.setCreated(false);
493
            this.comp2.setCreated(false);
494
            this.sep2.setVisible(false);
494
            this.sep2.setVisible(false);
495
        } else {
495
        } else {
496
            this.checkEnlevement.setSelected(false);
496
            this.checkEnlevement.setSelected(false);
497
            this.comp2.setEditable(InteractionMode.READ_WRITE);
497
            this.comp2.setEditable(InteractionMode.READ_WRITE);
498
            this.comp2.setCreated(true);
498
            this.comp2.setCreated(true);
499
            this.sep2.setVisible(true);
499
            this.sep2.setVisible(true);
500
        }
500
        }
501
 
501
 
502
        if (r != null) {
502
        if (r != null) {
503
            this.table.insertFrom("ID_" + this.getTable().getName(), r.asRowValues());
503
            this.table.insertFrom("ID_" + this.getTable().getName(), r.asRowValues());
504
            this.defaultContactRowVals.put("TEL_DIRECT", r.getString("TEL"));
504
            this.defaultContactRowVals.put("TEL_DIRECT", r.getString("TEL"));
505
            this.defaultContactRowVals.put("FAX", r.getString("FAX"));
505
            this.defaultContactRowVals.put("FAX", r.getString("FAX"));
506
        }
506
        }
507
 
507
 
508
        super.select(r);
508
        super.select(r);
509
    }
509
    }
510
 
510
 
511
    @Override
511
    @Override
512
    public void update() {
512
    public void update() {
513
        // TODO Raccord de méthode auto-généré
513
        // TODO Raccord de méthode auto-généré
514
        super.update();
514
        super.update();
515
        this.table.updateField("ID_" + this.getTable().getName(), getSelectedID());
515
        this.table.updateField("ID_" + this.getTable().getName(), getSelectedID());
516
    }
516
    }
517
 
517
 
518
    @Override
518
    @Override
519
    public int insert(SQLRow order) {
519
    public int insert(SQLRow order) {
520
        // TODO Raccord de méthode auto-généré
520
        // TODO Raccord de méthode auto-généré
521
        int id = super.insert(order);
521
        int id = super.insert(order);
522
        this.table.updateField("ID_" + this.getTable().getName(), id);
522
        this.table.updateField("ID_" + this.getTable().getName(), id);
523
        return id;
523
        return id;
524
    }
524
    }
525
 
525
 
526
    @Override
526
    @Override
527
    protected SQLRowValues createDefaults() {
527
    protected SQLRowValues createDefaults() {
528
        SQLRowValues vals = new SQLRowValues(this.getTable());
528
        SQLRowValues vals = new SQLRowValues(this.getTable());
529
        SQLRowAccessor r;
529
        SQLRowAccessor r;
530
        this.checkEnlevement.setSelected(true);
530
        this.checkEnlevement.setSelected(true);
531
        this.sep2.setVisible(false);
531
        this.sep2.setVisible(false);
532
        try {
532
        try {
533
            r = ModeReglementDefautPrefPanel.getDefaultRow(false);
533
            r = ModeReglementDefautPrefPanel.getDefaultRow(false);
534
            SQLElement eltModeReglement = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
534
            SQLElement eltModeReglement = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
535
            if (r.getID() > 1) {
535
            if (r.getID() > 1) {
536
                SQLRowValues rowVals = eltModeReglement.createCopy(r.getID());
536
                SQLRowValues rowVals = eltModeReglement.createCopy(r.getID());
537
                System.err.println(rowVals.getInt("ID_TYPE_REGLEMENT"));
537
                System.err.println(rowVals.getInt("ID_TYPE_REGLEMENT"));
538
                vals.put("ID_MODE_REGLEMENT", rowVals);
538
                vals.put("ID_MODE_REGLEMENT", rowVals);
539
            }
539
            }
540
        } catch (SQLException e) {
540
        } catch (SQLException e) {
541
            System.err.println("Impossible de sélectionner le mode de règlement par défaut du client.");
541
            System.err.println("Impossible de sélectionner le mode de règlement par défaut du client.");
542
            e.printStackTrace();
542
            e.printStackTrace();
543
        }
543
        }
544
 
544
 
545
        // Select Compte charge par defaut
545
        // Select Compte charge par defaut
546
        final SQLTable tablePrefCompte = getTable().getTable("PREFS_COMPTE");
546
        final SQLTable tablePrefCompte = getTable().getTable("PREFS_COMPTE");
547
        final SQLRow rowPrefsCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(tablePrefCompte).getRowFromId(2);
547
        final SQLRow rowPrefsCompte = SQLBackgroundTableCache.getInstance().getCacheForTable(tablePrefCompte).getRowFromId(2);
548
        // compte Achat
548
        // compte Achat
549
        int idCompteAchat = rowPrefsCompte.getInt("ID_COMPTE_PCE_ACHAT");
549
        int idCompteAchat = rowPrefsCompte.getInt("ID_COMPTE_PCE_ACHAT");
550
        if (idCompteAchat <= 1) {
550
        if (idCompteAchat <= 1) {
551
            try {
551
            try {
552
                idCompteAchat = ComptePCESQLElement.getIdComptePceDefault("Achats");
552
                idCompteAchat = ComptePCESQLElement.getIdComptePceDefault("Achats");
553
            } catch (Exception e) {
553
            } catch (Exception e) {
554
                e.printStackTrace();
554
                e.printStackTrace();
555
            }
555
            }
556
        }
556
        }
557
        vals.put("ID_COMPTE_PCE_CHARGE", idCompteAchat);
557
        vals.put("ID_COMPTE_PCE_CHARGE", idCompteAchat);
558
        return vals;
558
        return vals;
559
    }
559
    }
560
 
560
 
561
}
561
}