OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 177 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
93 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
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
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.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.customerrelationship.customer.element;
15
 
16
import org.openconcerto.erp.core.common.component.AdresseSQLComponent;
17
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
18
import org.openconcerto.erp.core.customerrelationship.customer.ui.AdresseClientItemTable;
177 ilm 19
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
144 ilm 20
import org.openconcerto.erp.core.sales.product.element.ClientCodeArticleTable;
180 ilm 21
import org.openconcerto.erp.core.sales.product.ui.CustomerProductFamilyQtyPriceListTable;
174 ilm 22
import org.openconcerto.erp.core.sales.product.ui.CustomerProductQtyPriceListTable;
177 ilm 23
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
132 ilm 24
import org.openconcerto.erp.preferences.ModeReglementDefautPrefPanel;
94 ilm 25
import org.openconcerto.erp.utils.TM;
93 ilm 26
import org.openconcerto.sql.Configuration;
27
import org.openconcerto.sql.element.ElementSQLObject;
28
import org.openconcerto.sql.element.GroupSQLComponent;
29
import org.openconcerto.sql.element.SQLElement;
30
import org.openconcerto.sql.model.SQLRow;
31
import org.openconcerto.sql.model.SQLRowAccessor;
32
import org.openconcerto.sql.model.SQLRowValues;
177 ilm 33
import org.openconcerto.sql.model.SQLSelect;
93 ilm 34
import org.openconcerto.sql.model.SQLTable;
35
import org.openconcerto.sql.model.UndefinedRowValuesCache;
177 ilm 36
import org.openconcerto.sql.model.Where;
37
import org.openconcerto.sql.preferences.SQLPreferences;
93 ilm 38
import org.openconcerto.sql.sqlobject.JUniqueTextField;
39
import org.openconcerto.sql.sqlobject.SQLSearchableTextCombo;
40
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenu;
41
import org.openconcerto.sql.ui.textmenu.TextFieldWithMenuItemsTableFetcher;
42
import org.openconcerto.sql.ui.textmenu.TextFieldWithWebBrowsing;
43
import org.openconcerto.sql.view.EditFrame;
44
import org.openconcerto.sql.view.EditPanel.EditMode;
45
import org.openconcerto.sql.view.IListFrame;
180 ilm 46
import org.openconcerto.sql.view.IListPanel;
93 ilm 47
import org.openconcerto.sql.view.ListeAddPanel;
180 ilm 48
import org.openconcerto.sql.view.list.IListe;
49
import org.openconcerto.sql.view.list.SQLTableModelSource;
93 ilm 50
import org.openconcerto.ui.DefaultGridBagConstraints;
51
import org.openconcerto.ui.FrameUtil;
52
import org.openconcerto.ui.JDate;
53
import org.openconcerto.ui.JLabelBold;
54
import org.openconcerto.ui.component.ComboLockedMode;
55
import org.openconcerto.ui.component.ITextArea;
56
import org.openconcerto.ui.component.InteractionMode;
142 ilm 57
import org.openconcerto.utils.ExceptionHandler;
93 ilm 58
 
94 ilm 59
import java.awt.Component;
60
import java.awt.Dimension;
177 ilm 61
import java.awt.Font;
94 ilm 62
import java.awt.GridBagConstraints;
63
import java.awt.GridBagLayout;
64
import java.awt.event.ActionEvent;
65
import java.awt.event.ActionListener;
66
import java.sql.SQLException;
67
import java.util.HashSet;
68
import java.util.Set;
69
 
70
import javax.swing.AbstractAction;
71
import javax.swing.Icon;
180 ilm 72
import javax.swing.JButton;
94 ilm 73
import javax.swing.JCheckBox;
74
import javax.swing.JComponent;
75
import javax.swing.JLabel;
142 ilm 76
import javax.swing.JOptionPane;
94 ilm 77
import javax.swing.JPanel;
78
import javax.swing.JTabbedPane;
79
import javax.swing.JTextField;
142 ilm 80
import javax.swing.SwingUtilities;
94 ilm 81
import javax.swing.event.DocumentEvent;
82
import javax.swing.event.DocumentListener;
83
 
93 ilm 84
public class CustomerSQLComponent extends GroupSQLComponent {
85
    private ContactItemTable table;
144 ilm 86
    private ClientCodeArticleTable tableCustomProduct;
93 ilm 87
    private AdresseClientItemTable adresseTable = new AdresseClientItemTable();
174 ilm 88
 
93 ilm 89
    private SQLTable contactTable = Configuration.getInstance().getDirectory().getElement("CONTACT").getTable();
90
    private final SQLTable tableNum = getTable().getBase().getTable("NUMEROTATION_AUTO");
142 ilm 91
    private final JUniqueTextField code = new JUniqueTextField(20) {
92
        @Override
93
        public String getAutoRefreshNumber() {
94
            if (getMode() == Mode.INSERTION) {
95
                return NumerotationAutoSQLElement.getNextNumero(getElement().getClass());
96
            } else {
97
                return null;
98
            }
99
        }
100
    };
93 ilm 101
 
174 ilm 102
    private CustomerProductQtyPriceListTable clienTarifTable = new CustomerProductQtyPriceListTable();
180 ilm 103
    private CustomerProductFamilyQtyPriceListTable clienFamilleTarifTable = new CustomerProductFamilyQtyPriceListTable();
93 ilm 104
    private SQLRowValues defaultContactRowVals = new SQLRowValues(UndefinedRowValuesCache.getInstance().getDefaultRowValues(this.contactTable));
105
    private JCheckBox checkAdrLivraison, checkAdrFacturation;
180 ilm 106
    private IListPanel agencePanel;
93 ilm 107
 
108
    public CustomerSQLComponent(SQLElement element) {
109
        super(element);
110
        this.table = new ContactItemTable(this.defaultContactRowVals);
144 ilm 111
        this.tableCustomProduct = new ClientCodeArticleTable();
93 ilm 112
        this.table.setPreferredSize(new Dimension(this.table.getSize().width, 150));
113
    }
114
 
115
    @Override
116
    protected Set<String> createRequiredNames() {
117
        final Set<String> s = new HashSet<String>();
118
        s.add("NOM");
119
        s.add("ID_ADRESSE");
120
        s.add("ID_MODE_REGLEMENT");
121
        return s;
122
    }
123
 
124
    @Override
125
    protected SQLRowValues createDefaults() {
126
 
127
        SQLRowValues rowVals = new SQLRowValues(getTable());
128
        rowVals.put("CODE", NumerotationAutoSQLElement.getNextNumero(getElement().getClass()));
132 ilm 129
        // Mode de règlement par defaut
130
        try {
131
            SQLRow r = ModeReglementDefautPrefPanel.getDefaultRow(true);
132
            SQLElement eltModeReglement = Configuration.getInstance().getDirectory().getElement("MODE_REGLEMENT");
133
            if (r.getID() > 1) {
134
                SQLRowValues rowValsMR = eltModeReglement.createCopy(r, null);
135
                rowVals.put("ID_MODE_REGLEMENT", rowValsMR);
136
            }
137
        } catch (SQLException e) {
138
            System.err.println("Impossible de sélectionner le mode de règlement par défaut du client.");
139
            e.printStackTrace();
140
        }
93 ilm 141
        return rowVals;
142
    }
143
 
144
    @Override
145
    public JComponent createEditor(String id) {
146
        if (id.equals("CATEGORIES")) {
147
            TextFieldWithMenuItemsTableFetcher itemsFetcher = new TextFieldWithMenuItemsTableFetcher(getTable().getTable("CATEGORIE_CLIENT").getField("NOM"));
148
            TextFieldWithMenu t = new TextFieldWithMenu(itemsFetcher, false);
149
            t.addAction(new AbstractAction(TM.tr("add")) {
150
 
151
                @Override
152
                public void actionPerformed(ActionEvent e) {
153
                    EditFrame frame = new EditFrame(getElement().getDirectory().getElement("CATEGORIE_CLIENT"), EditMode.CREATION);
154
                    FrameUtil.showPacked(frame);
155
 
156
                }
157
            });
151 ilm 158
            t.addAction(new AbstractAction(TM.tr("modify.or.delete")) {
93 ilm 159
 
160
                @Override
161
                public void actionPerformed(ActionEvent e) {
162
                    final SQLElement element = getElement().getDirectory().getElement("CATEGORIE_CLIENT");
163
 
164
                    ListeAddPanel p = new ListeAddPanel(element);
165
                    // EditFrame frame = new EditFrame(element, EditMode.CREATION);
166
                    IListFrame frame = new IListFrame(p);
167
                    FrameUtil.showPacked(frame);
168
 
169
                }
170
            });
171
            return t;
94 ilm 172
        } else if (id.equals("GROUPE") || id.equals("FORME_JURIDIQUE") || id.equals("CENTRE_GESTION") || id.equals("METHODE_RELANCE")) {
93 ilm 173
            return new SQLSearchableTextCombo(ComboLockedMode.UNLOCKED, 1, 20, false);
174
        } else if (id.equals("SITE_INTERNET")) {
175
            return new TextFieldWithWebBrowsing();
156 ilm 176
        } else if (id.equals("SIRET")) {
177
            return new JTextField(20);
93 ilm 178
        } else if (id.equals("DATE")) {
179
            return new JDate(true);
180
        } else if (id.equals("customerrelationship.customer.contacts")) {
181
            return this.table;
180 ilm 182
        } else if (id.equals("customerrelationship.customer.agencies")) {
183
            SQLElement elementAgence = getElement().getDirectory().getElement("AGENCE");
184
            SQLTableModelSource source = elementAgence.createTableSource(Where.FALSE);
185
            this.agencePanel = new ListeAddPanel(elementAgence, new IListe(source)) {
186
                @Override
187
                protected void handleAction(JButton source, ActionEvent evt) {
188
                    if (source == this.buttonAjouter) {
189
                        if (getMode() == Mode.MODIFICATION && getSelectedID() != SQLRow.NONEXISTANT_ID) {
190
                            SQLRowValues rowValsAgency = new SQLRowValues(elementAgence.getTable());
191
                            rowValsAgency.put("ID_CLIENT", getSelectedID());
192
                            this.getCreateFrame().getSQLComponent().select(rowValsAgency);
193
                        }
194
                        FrameUtil.show(this.getCreateFrame());
195
                    } else {
196
                        super.handleAction(source, evt);
197
                    }
198
                }
199
            };
200
            if (getMode() == Mode.INSERTION || getMode() == Mode.READ_ONLY) {
201
                this.agencePanel.getButtonAdd().setEnabled(false);
202
            }
203
            return this.agencePanel;
144 ilm 204
        } else if (id.equals("customerrelationship.customer.customproduct")) {
205
            return this.tableCustomProduct;
174 ilm 206
        } else if (id.equals("customerrelationship.customer.customtarif")) {
207
            return this.clienTarifTable;
180 ilm 208
        } else if (id.equals("customerrelationship.customer.customfamilytarif")) {
209
            return this.clienFamilleTarifTable;
93 ilm 210
        } else if (id.equals("customerrelationship.customer.addresses")) {
211
            return createAdressesComponent();
212
        } else if (id.equals("NOM")) {
132 ilm 213
            return super.createEditor(id);
93 ilm 214
        }
215
        if (id.equals("CODE")) {
216
 
217
            return this.code;
218
        } else if (id.equals("INFOS")) {
219
            return new ITextArea(4, 40);
220
        } else if (id.equals("COMMENTAIRES")) {
221
            return new ITextArea(10, 40);
222
        } else if (id.equals("TEL")) {
223
            final JTextField textTel = new JTextField(25);
224
            textTel.getDocument().addDocumentListener(new DocumentListener() {
225
 
226
                public void changedUpdate(DocumentEvent e) {
227
                    defaultContactRowVals.put("TEL_DIRECT", textTel.getText());
228
                }
229
 
230
                public void insertUpdate(DocumentEvent e) {
231
                    defaultContactRowVals.put("TEL_DIRECT", textTel.getText());
232
                }
233
 
234
                public void removeUpdate(DocumentEvent e) {
235
                    defaultContactRowVals.put("TEL_DIRECT", textTel.getText());
236
                }
237
 
238
            });
239
            return textTel;
240
        } else if (id.equals("FAX")) {
241
            final JTextField textFax = new JTextField(25);
242
            textFax.getDocument().addDocumentListener(new DocumentListener() {
243
 
244
                public void changedUpdate(DocumentEvent e) {
245
                    defaultContactRowVals.put("FAX", textFax.getText());
246
                }
247
 
248
                public void insertUpdate(DocumentEvent e) {
249
                    defaultContactRowVals.put("FAX", textFax.getText());
250
                }
251
 
252
                public void removeUpdate(DocumentEvent e) {
253
                    defaultContactRowVals.put("FAX", textFax.getText());
254
                }
255
 
256
            });
257
            return textFax;
258
        }
94 ilm 259
        JComponent c = super.createEditor(id);
260
        return c;
93 ilm 261
    }
262
 
263
    @Override
264
    public JComponent getLabel(String id) {
265
        if (id.equals("ID_MODE_REGLEMENT") || id.equals("INFOS") || id.startsWith("ID_ADRESSE")) {
266
            JLabel l = (JLabel) super.getLabel(id);
267
            l.setFont(l.getFont().deriveFont(Font.BOLD));
268
            return l;
269
        }
270
        if (id.equals("customerrelationship.customer.contact")) {
271
            return new JLabelBold("Contacts");
272
        } else if (id.equals("customerrelationship.customer.payment")) {
273
            return new JLabelBold("Mode de règlement");
274
        } else if (id.equals("customerrelationship.customer.address")) {
275
            return new JLabelBold("Adresses du client");
276
        }
94 ilm 277
        JComponent c = super.getLabel(id);
278
        return c;
93 ilm 279
    }
280
 
281
    @Override
282
    public void update() {
283
        super.update();
284
        final int selectedID = getSelectedID();
285
        this.table.updateField("ID_CLIENT", selectedID);
174 ilm 286
        this.clienTarifTable.updateField("ID_CLIENT", selectedID);
180 ilm 287
        this.clienFamilleTarifTable.updateField("ID_CLIENT", selectedID);
144 ilm 288
        this.tableCustomProduct.updateField("ID_CLIENT", selectedID);
93 ilm 289
        this.adresseTable.updateField("ID_CLIENT", selectedID);
290
    }
291
 
292
    @Override
293
    public void select(SQLRowAccessor r) {
294
        super.select(r);
295
        this.checkAdrLivraison.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_L") || r.isForeignEmpty("ID_ADRESSE_L"));
296
        this.checkAdrFacturation.setSelected(r == null || !r.getFields().contains("ID_ADRESSE_F") || r.isForeignEmpty("ID_ADRESSE_F"));
297
        if (r != null) {
298
            this.table.insertFrom("ID_CLIENT", r.asRowValues());
174 ilm 299
            this.clienTarifTable.insertFrom("ID_CLIENT", r.asRowValues());
180 ilm 300
            this.clienFamilleTarifTable.insertFrom("ID_CLIENT", r.asRowValues());
144 ilm 301
            this.tableCustomProduct.insertFrom("ID_CLIENT", r.asRowValues());
93 ilm 302
            this.adresseTable.insertFrom("ID_CLIENT", r.asRowValues());
303
        }
180 ilm 304
        if (r != null && r.hasID()) {
305
            this.agencePanel.getListe().getRequest().setWhere(new Where(this.agencePanel.getListe().getRequest().getPrimaryTable().getField("ID_CLIENT"), "=", r.getID()));
306
        } else {
307
            this.agencePanel.getListe().getRequest().setWhere(Where.FALSE);
308
        }
93 ilm 309
    }
310
 
311
    @Override
312
    public int insert(SQLRow order) {
142 ilm 313
        int id;
93 ilm 314
 
142 ilm 315
        int attempt = 0;
316
        // on verifie qu'un client du meme numero n'a pas été inséré entre temps
156 ilm 317
        if (this.code.getText().trim().length() > 0 && !this.code.checkValidation(false)) {
142 ilm 318
            while (attempt < JUniqueTextField.RETRY_COUNT) {
319
                String num = NumerotationAutoSQLElement.getNextNumero(getElement().getClass());
320
                this.code.setText(num);
321
                attempt++;
322
                if (this.code.checkValidation(false)) {
323
                    System.err.println("ATEMPT " + attempt + " SUCCESS WITH NUMERO " + num);
324
                    break;
325
                }
93 ilm 326
                try {
142 ilm 327
                    Thread.sleep(JUniqueTextField.SLEEP_WAIT_MS);
328
                } catch (InterruptedException e) {
93 ilm 329
                    e.printStackTrace();
330
                }
331
            }
332
        }
142 ilm 333
        final String num = this.code.getText();
334
        if (attempt == JUniqueTextField.RETRY_COUNT) {
335
            id = getSelectedID();
336
            ExceptionHandler.handle("Impossible d'ajouter, numéro de client existant.");
337
            final Object root = SwingUtilities.getRoot(this);
338
            if (root instanceof EditFrame) {
339
                final EditFrame frame = (EditFrame) root;
340
                frame.getPanel().setAlwaysVisible(true);
341
            }
342
        } else {
343
            id = super.insert(order);
344
            this.table.updateField("ID_CLIENT", id);
180 ilm 345
            this.clienTarifTable.updateField("ID_CLIENT", id);
346
            this.clienFamilleTarifTable.updateField("ID_CLIENT", id);
144 ilm 347
            this.tableCustomProduct.updateField("ID_CLIENT", id);
174 ilm 348
            this.clienTarifTable.updateField("ID_CLIENT", id);
142 ilm 349
            this.adresseTable.updateField("ID_CLIENT", id);
350
            if (NumerotationAutoSQLElement.getNextNumero(getElement().getClass()).equalsIgnoreCase(this.code.getText().trim())) {
351
                SQLRowValues rowVals = new SQLRowValues(this.tableNum);
352
                final SQLRow rowNumAuto = this.tableNum.getRow(2);
353
                if (rowNumAuto.getObject("CLIENT_START") != null) {
354
                    int val = rowNumAuto.getInt("CLIENT_START");
355
                    val++;
356
                    rowVals.put("CLIENT_START", new Integer(val));
93 ilm 357
 
142 ilm 358
                    try {
359
                        rowVals.update(2);
360
                    } catch (SQLException e) {
361
                        e.printStackTrace();
362
                    }
363
                }
364
            }
365
            if (attempt > 0) {
366
                SwingUtilities.invokeLater(new Runnable() {
367
                    public void run() {
368
                        JOptionPane.showMessageDialog(null, "Le numéro a été actualisé en " + num);
369
                    }
370
                });
371
            }
372
        }
177 ilm 373
        SQLPreferences prefs = new SQLPreferences(getTable().getDBRoot());
374
        if (prefs.getBoolean(GestionCommercialeGlobalPreferencePanel.COMPTE_CLIENT_AUTO, Boolean.FALSE)) {
375
            createCompteClientFromCodeAuto(id);
376
        }
93 ilm 377
        return id;
378
    }
379
 
177 ilm 380
    private void createCompteClientFromCodeAuto(int idClient) {
381
        final SQLRow rowClient = getTable().getRow(idClient);
382
        if (rowClient.isForeignEmpty("ID_COMPTE_PCE")) {
383
 
384
            SQLRowValues rowVals = rowClient.createEmptyUpdateRow();
385
            final String text = rowClient.getString("CODE");
386
 
387
            String compte = "411" + text;
388
 
389
            SQLTable table = getTable().getForeignTable("ID_COMPTE_PCE");
390
            SQLSelect selCompte = new SQLSelect();
391
            selCompte.addSelectFunctionStar("COUNT");
392
            selCompte.setArchivedPolicy(SQLSelect.BOTH);
393
            selCompte.setWhere(new Where(table.getField("NUMERO"), "LIKE", compte + "%"));
394
            System.err.println(selCompte.asString());
395
            Object o = getTable().getDBRoot().getDBSystemRoot().getDataSource().executeScalar(selCompte.asString());
396
 
397
            int nb = 0;
398
            if (o != null) {
399
                Long i = (Long) o;
400
                nb = i.intValue();
401
            }
402
            if (nb > 0) {
403
                compte = compte + nb;
404
            }
405
            int idCpt = ComptePCESQLElement.getId(compte, rowClient.getString("NOM"));
406
            rowVals.put("ID_COMPTE_PCE", idCpt);
407
            try {
408
                rowVals.update();
409
            } catch (SQLException e) {
410
                e.printStackTrace();
411
            }
412
        }
413
    }
414
 
93 ilm 415
    private JComponent createAdressesComponent() {
416
        final JTabbedPane tabbedAdresse = new JTabbedPane() {
417
            public void insertTab(String title, Icon icon, Component component, String tip, int index) {
418
                if (component instanceof JComponent) {
419
                    ((JComponent) component).setOpaque(false);
420
                }
421
                super.insertTab(title, icon, component, tip, index);
422
            }
423
 
424
        };
425
 
426
        // Adr principale
427
 
428
        final JPanel panelAdressePrincipale = new JPanel(new GridBagLayout());
429
        GridBagConstraints cPanel = new DefaultGridBagConstraints();
430
        cPanel.weightx = 1;
431
        cPanel.weighty = 1;
432
        cPanel.anchor = GridBagConstraints.NORTH;
433
        this.addView("ID_ADRESSE", REQ + ";" + DEC + ";" + SEP);
434
 
435
        final ElementSQLObject componentPrincipale = (ElementSQLObject) this.getView("ID_ADRESSE");
436
        ((AdresseSQLComponent) componentPrincipale.getSQLChild()).setDestinataireVisible(true);
437
        componentPrincipale.setOpaque(false);
438
        panelAdressePrincipale.add(componentPrincipale, cPanel);
439
        tabbedAdresse.add(getLabelFor("ID_ADRESSE"), panelAdressePrincipale);
440
        tabbedAdresse.setOpaque(false);
441
 
442
        // Adresse de facturation
443
 
444
        tabbedAdresse.add(getLabelFor("ID_ADRESSE_F"), createFacturationPanel());
445
 
446
        // Adresse de livraison
447
 
448
        tabbedAdresse.add(getLabelFor("ID_ADRESSE_L"), createLivraisonPanel());
449
 
450
        // Adresses supplémentaires
451
        String labelAdrSuppl = TM.tr("additional.address");
452
        tabbedAdresse.add(labelAdrSuppl, this.adresseTable);
453
 
454
        return tabbedAdresse;
455
    }
456
 
457
    private Component createLivraisonPanel() {
458
        final JPanel panel = new JPanel(new GridBagLayout());
459
        final GridBagConstraints c = new DefaultGridBagConstraints();
460
        final String field = "ID_ADRESSE_L";
461
 
462
        this.addView(field, DEC + ";" + SEP);
463
        final ElementSQLObject component = (ElementSQLObject) this.getView(field);
464
        final AdresseSQLComponent adresseSQLComponent = (AdresseSQLComponent) component.getSQLChild();
465
        adresseSQLComponent.setDestinataireVisible(true);
466
        System.err.println("CustomerSQLComponent.createLivraisonPanel()" + component + " " + System.identityHashCode(component));
467
        System.err.println("CustomerSQLComponent.createLivraisonPanel()" + adresseSQLComponent + " " + System.identityHashCode(adresseSQLComponent));
468
        component.setOpaque(false);
469
        c.weightx = 1;
470
        this.checkAdrLivraison = new JCheckBox(TM.tr("delivery.address.same.main.address"));
471
        this.checkAdrLivraison.setOpaque(false);
472
        panel.add(component, c);
473
 
474
        c.gridy++;
475
        c.weighty = 1;
476
        c.anchor = GridBagConstraints.NORTH;
477
        panel.add(this.checkAdrLivraison, c);
478
        // Listener
479
        this.checkAdrLivraison.addActionListener(new ActionListener() {
480
 
481
            public void actionPerformed(java.awt.event.ActionEvent e) {
482
                boolean b = checkAdrLivraison.isSelected();
483
                System.err.println("CustomerSQLComponent.createAdressesComponent().new ActionListener() {...}.actionPerformed() checkAdrLivraison " + b);
484
                component.setEditable((!b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
485
                component.setCreated(!b);
486
            };
487
        });
488
        panel.setOpaque(false);
489
        return panel;
490
    }
491
 
492
    private Component createFacturationPanel() {
493
        final JPanel panel = new JPanel(new GridBagLayout());
494
        final GridBagConstraints c = new DefaultGridBagConstraints();
495
        final String field = "ID_ADRESSE_F";
496
 
497
        this.addView(field, DEC + ";" + SEP);
498
        final ElementSQLObject component = (ElementSQLObject) this.getView(field);
499
        final AdresseSQLComponent adresseSQLComponent = (AdresseSQLComponent) component.getSQLChild();
500
        System.err.println("CustomerSQLComponent.createFacturationPanel()" + component + " " + System.identityHashCode(component));
501
        System.err.println("CustomerSQLComponent.createFacturationPanel()" + adresseSQLComponent + " " + System.identityHashCode(adresseSQLComponent));
502
        adresseSQLComponent.setDestinataireVisible(true);
503
        component.setOpaque(false);
504
        c.weightx = 1;
505
        this.checkAdrFacturation = new JCheckBox(TM.tr("invoice.address.same.main.address"));
506
        this.checkAdrFacturation.setOpaque(false);
507
        c.anchor = GridBagConstraints.NORTH;
508
        panel.add(component, c);
509
 
510
        c.gridy++;
511
        c.weighty = 1;
512
        c.anchor = GridBagConstraints.NORTH;
513
        panel.add(this.checkAdrFacturation, c);
514
        // Listener
515
        this.checkAdrFacturation.addActionListener(new ActionListener() {
516
 
517
            public void actionPerformed(java.awt.event.ActionEvent e) {
518
                boolean b = checkAdrFacturation.isSelected();
519
                System.err.println("CustomerSQLComponent.createAdressesComponent().new ActionListener() {...}.actionPerformed() checkAdrFacturation " + b);
520
                component.setEditable((!b) ? InteractionMode.READ_WRITE : InteractionMode.DISABLED);
521
                component.setCreated(!b);
522
            };
523
        });
524
        panel.setOpaque(false);
525
        return panel;
526
    }
527
 
528
}