Example usage for javax.swing SwingConstants RIGHT

List of usage examples for javax.swing SwingConstants RIGHT

Introduction

In this page you can find the example usage for javax.swing SwingConstants RIGHT.

Prototype

int RIGHT

To view the source code for javax.swing SwingConstants RIGHT.

Click Source Link

Document

Box-orientation constant used to specify the right side of a box.

Usage

From source file:org.openconcerto.erp.core.finance.accounting.ui.ResultatPanel.java

public ResultatPanel() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    this.add(new JLabel("Vous allez gnrer le fichier result_2033B.pdf contenant le rsultat."), c);
    c.gridy++;/* w w w  .ja v a2s.c o m*/
    try {
        this.add(new JLabel("Il se trouvera dans le dossier "
                + new File(TemplateNXProps.getInstance().getStringProperty("Location2033BPDF"))
                        .getCanonicalPath()),
                c);
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    final JButton buttonFermer = new JButton("Fermer");
    buttonFermer.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            ((JFrame) SwingUtilities.getRoot(ResultatPanel.this)).dispose();
        }
    });

    final JButton buttonOuvrir = new JButton("Ouvrir dossier");
    buttonOuvrir.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            final String file = TemplateNXProps.getInstance().getStringProperty("Location2033BPDF");
            File f = new File(file);
            FileUtils.browseFile(f);
        }
    });

    // FIXME impossible de gnrer si le fichier est ouvert
    final JButton buttonGenerer = new JButton("Gnrer");
    buttonGenerer.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            final Map2033B map = new Map2033B(new JProgressBar());
            map.generateMap();
        }
    });

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(buttonOuvrir, c);

    c.gridy++;
    c.anchor = GridBagConstraints.EAST;
    c.weightx = 1;
    buttonGenerer.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(buttonGenerer, c);
    c.weightx = 0;
    this.add(buttonFermer, c);
}

From source file:org.openconcerto.erp.core.sales.credit.component.AvoirClientSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();
    textNumero = new JUniqueTextField(16);
    // Champ Module
    c.gridx = 0;//from w  w  w. ja v a2  s. c  o m
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    this.textNom = new JTextField();
    this.date = new JDate(true);

    this.date.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            fireValidChange();

        }
    });

    // Ligne 1: Numero
    this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    c.gridx++;

    DefaultGridBagConstraints.lockMinimumSize(textNumero);
    this.add(this.textNumero, c);

    // Date
    c.gridx++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel("Date", SwingConstants.RIGHT), c);
    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.add(this.date, c);

    // Ligne 2: Libell
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);
    c.gridx++;
    // c.weightx = 1;
    this.add(this.textNom, c);

    // Commercial
    c.gridx++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    this.comboCommercial = new ElementComboBox();
    this.comboCommercial.setMinimumSize(this.comboCommercial.getPreferredSize());
    this.add(new JLabel(getLabelFor("ID_COMMERCIAL"), SwingConstants.RIGHT), c);
    c.gridx++;
    // c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.add(this.comboCommercial, c);

    this.addSQLObject(this.comboCommercial, "ID_COMMERCIAL");

    // Ligne 3: Motif
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    this.add(new JLabel(getLabelFor("MOTIF"), SwingConstants.RIGHT), c);
    c.gridx++;
    c.gridwidth = 3;
    // c.weightx = 1;

    JTextField textMotif = new JTextField();
    this.add(textMotif, c);

    // Client
    c.gridx = 0;
    c.gridy++;
    // c.weightx = 0;
    c.gridwidth = 1;
    this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);
    c.gridx++;
    c.gridwidth = 3;
    // c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.add(this.comboClient, c);
    // Adresse spe
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    // c.weightx = 0;
    c.gridwidth = 1;
    this.add(new JLabel(getLabelFor("ID_ADRESSE"), SwingConstants.RIGHT), c);

    c.gridx++;
    c.gridwidth = 3;
    // c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.add(this.comboAdresse, c);
    final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration
            .getInstance());

    // Contact
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    // c.weightx = 0;
    final JLabel labelContact = new JLabel(getLabelFor("ID_CONTACT"), SwingConstants.RIGHT);
    this.add(labelContact, c);

    c.gridx++;
    c.gridwidth = 3;
    // c.weightx = 1;
    c.fill = GridBagConstraints.NONE;

    this.add(selectContact, c);
    final SQLElement contactElement = getElement().getForeignElement("ID_CONTACT");
    selectContact.init(contactElement, contactElement.getComboRequest(true));
    this.addView(selectContact, "ID_CONTACT");
    this.defaultContactRowValues = new SQLRowValues(selectContact.getRequest().getPrimaryTable());
    selectContact.getAddComp().setDefaults(this.defaultContactRowValues);

    // Compte Service
    this.checkCompteServiceAuto = new JCheckBox(getLabelFor("COMPTE_SERVICE_AUTO"));
    this.addSQLObject(this.checkCompteServiceAuto, "COMPTE_SERVICE_AUTO");
    this.compteSelService = new ISQLCompteSelector();

    this.labelCompteServ = new JLabel("Compte Service");
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 1;
    // c.weightx = 0;
    this.labelCompteServ.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(this.labelCompteServ, c);

    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    // c.weightx = 1;
    this.add(this.compteSelService, c);

    this.addRequiredSQLObject(this.compteSelService, "ID_COMPTE_PCE_SERVICE");

    String valServ = DefaultNXProps.getInstance().getStringProperty("ArticleService");
    Boolean bServ = Boolean.valueOf(valServ);
    if (!bServ) {
        this.labelCompteServ.setVisible(false);
        this.compteSelService.setVisible(false);
    }

    this.checkCompteServiceAuto.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setCompteServiceVisible(!AvoirClientSQLComponent.this.checkCompteServiceAuto.isSelected());
        }
    });

    // setCompteServiceVisible(!(bServ != null && !bServ.booleanValue()));

    // Tarif
    if (this.getTable().getFieldsName().contains("ID_TARIF")) {
        // TARIF
        c.gridy++;
        c.gridx = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        this.add(new JLabel("Tarif  appliquer", SwingConstants.RIGHT), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;

        c.weightx = 1;
        this.add(boxTarif, c);
        this.addView(boxTarif, "ID_TARIF");
        boxTarif.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                table.setTarif(boxTarif.getSelectedRow(), false);
            }
        });
    }

    // Table
    this.table = new AvoirItemTable();
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.gridheight = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weighty = 1;
    // c.weightx = 0;
    this.add(this.table, c);
    this.addView(this.table.getRowValuesTable(), "");

    // Panel du bas
    final JPanel panelBottom = getBottomPanel();
    c.gridy++;
    c.weighty = 0;
    this.add(panelBottom, c);

    // Infos

    c.gridheight = 1;
    c.gridx = 0;
    c.gridy++;
    this.add(new JLabel(getLabelFor("INFOS")), c);

    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.weighty = 0;
    c.gridwidth = 4;
    ITextArea infos = new ITextArea(4, 4);
    infos.setBorder(null);
    JScrollPane scrollPane = new JScrollPane(infos);
    DefaultGridBagConstraints.lockMinimumSize(scrollPane);
    this.add(scrollPane, c);

    //
    // Impression
    this.panelGestDoc = new PanelOOSQLComponent(this);
    c.fill = GridBagConstraints.NONE;
    c.gridy++;
    c.anchor = GridBagConstraints.EAST;
    this.add(panelGestDoc, c);

    this.addSQLObject(this.textNom, "NOM");
    if (getTable().contains("INFOS")) {
        this.addSQLObject(infos, "INFOS");
    }
    this.addSQLObject(this.boxAdeduire, "A_DEDUIRE");
    this.addSQLObject(textMotif, "MOTIF");
    this.addSQLObject(this.comboAdresse, "ID_ADRESSE");

    this.addRequiredSQLObject(this.textNumero, "NUMERO");
    this.addRequiredSQLObject(this.date, "DATE");
    this.addRequiredSQLObject(this.comboClient, "ID_CLIENT");

    this.boxAdeduire.addActionListener(this);

    this.comboClient.addModelListener("wantedID", this.listenerModeReglDefaut);
    this.comboClient.addModelListener("wantedID", this.changeClientListener);
    DefaultGridBagConstraints.lockMinimumSize(comboClient);
    DefaultGridBagConstraints.lockMinimumSize(this.comboAdresse);
    DefaultGridBagConstraints.lockMinimumSize(this.comboBanque);
    DefaultGridBagConstraints.lockMinimumSize(comboCommercial);

}

From source file:org.openconcerto.erp.core.sales.credit.component.AvoirClientSQLComponent.java

private JPanel getBottomPanel() {

    // UI/*from ww  w .j a v a 2  s. c  o m*/

    final JPanel panel = new JPanel(new GridBagLayout());
    panel.setOpaque(false);
    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.anchor = GridBagConstraints.NORTHWEST;
    c.weightx = 1;
    // Colonne 1
    this.boxAdeduire.setOpaque(false);
    this.boxAdeduire.setMinimumSize(new Dimension(430, this.boxAdeduire.getPreferredSize().height));
    this.boxAdeduire.setPreferredSize(new Dimension(430, this.boxAdeduire.getPreferredSize().height));
    panel.add(this.boxAdeduire, c);
    this.addView("ID_MODE_REGLEMENT", DEC + ";" + SEP);
    this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");

    c.gridy++;
    c.fill = GridBagConstraints.NONE;
    c.weighty = 1;
    this.eltModeRegl.setOpaque(false);
    panel.add(this.eltModeRegl, c);

    // Colonne 2 : port et remise

    final JPanel panelPortEtRemise = new JPanel();
    panelPortEtRemise.setOpaque(false);
    panelPortEtRemise.setLayout(new GridBagLayout());

    final GridBagConstraints cFrais = new DefaultGridBagConstraints();

    DeviseField textPortHT = new DeviseField(5);
    DeviseField textRemiseHT = new DeviseField(5);

    // Frais de port
    cFrais.gridheight = 1;
    cFrais.fill = GridBagConstraints.VERTICAL;
    cFrais.weighty = 1;
    cFrais.gridx = 1;

    // FIXME implmenter la remise et les port pour les avoirs
    JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT"));
    labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT);
    cFrais.gridy++;
    // panelPortEtRemise.add(labelPortHT, cFrais);
    cFrais.gridx++;
    DefaultGridBagConstraints.lockMinimumSize(textPortHT);
    // panelPortEtRemise.add(textPortHT, cFrais);

    // Remise
    JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT"));
    labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT);
    cFrais.gridy++;
    cFrais.gridx = 1;
    // panelPortEtRemise.add(labelRemiseHT, cFrais);
    cFrais.gridx++;
    DefaultGridBagConstraints.lockMinimumSize(textRemiseHT);
    // panelPortEtRemise.add(textRemiseHT, cFrais);
    cFrais.gridy++;

    c.gridx++;
    c.gridy = 0;
    c.gridheight = 2;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    panel.add(panelPortEtRemise, c);

    // Colonne 3 : totaux
    final DeviseField fieldHT = new DeviseField();
    final DeviseField fieldTVA = new DeviseField();
    final DeviseField fieldService = new DeviseField();
    final DeviseField fieldTTC = new DeviseField();
    // SQL
    addSQLObject(textPortHT, "PORT_HT");
    final DeviseField fieldDevise = new DeviseField();
    if (getTable().getFieldsName().contains("T_DEVISE"))
        addSQLObject(fieldDevise, "T_DEVISE");
    addSQLObject(textRemiseHT, "REMISE_HT");
    addRequiredSQLObject(fieldHT, "MONTANT_HT");
    addRequiredSQLObject(fieldTVA, "MONTANT_TVA");
    addRequiredSQLObject(fieldTTC, "MONTANT_TTC");
    addRequiredSQLObject(fieldService, "MONTANT_SERVICE");
    //
    JTextField poids = new JTextField();
    if (getTable().getFieldsName().contains("T_POIDS"))
        addSQLObject(poids, "T_POIDS");
    final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT,
            textRemiseHT, fieldService, null, fieldDevise, poids, null);
    totalTTC.setOpaque(false);
    c.gridx++;
    c.gridy = 0;
    c.gridheight = 2;
    c.fill = GridBagConstraints.BOTH;
    panel.add(totalTTC, c);

    // Listeners
    textPortHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });

    textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });
    return panel;
}

From source file:org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    this.checkPrevisionnelle = new JCheckBox();
    this.checkComplement = new JCheckBox();
    this.fieldTTC = new DeviseField();

    final ComptaPropsConfiguration comptaPropsConfiguration = ((ComptaPropsConfiguration) Configuration
            .getInstance());//from   w  ww  .  j a  v a 2s . co m

    this.textAvoirTTC = new DeviseField();

    // Champ Module
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    if (getTable().contains("ID_POLE_PRODUIT")) {
        JLabel labelPole = new JLabel(getLabelFor("ID_POLE_PRODUIT"));
        labelPole.setHorizontalAlignment(SwingConstants.RIGHT);
        this.add(labelPole, c);
        c.gridx++;
        ElementComboBox pole = new ElementComboBox();

        this.add(pole, c);
        this.addSQLObject(pole, "ID_POLE_PRODUIT");
        c.gridy++;
        c.gridwidth = 1;
        c.gridx = 0;
    }

    /*******************************************************************************************
     * * RENSEIGNEMENTS
     ******************************************************************************************/
    // Ligne 1 : Numero de facture
    JLabel labelNum = new JLabel(getLabelFor("NUMERO"));
    labelNum.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    this.add(labelNum, c);

    this.textNumeroUnique = new JUniqueTextField(16);
    c.gridx++;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique);
    this.add(textNumeroUnique, c);

    // Date
    c.gridx++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c);

    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    final JDate dateSaisie = new JDate(true);

    // listener permettant la mise  jour du numro de facture en fonction de la date
    // slectionne
    dateSaisie.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!isFilling() && dateSaisie.getValue() != null) {

                final String nextNumero = NumerotationAutoSQLElement
                        .getNextNumero(SaisieVenteFactureSQLElement.class, dateSaisie.getValue());

                if (textNumeroUnique.getText().trim().length() > 0
                        && !nextNumero.equalsIgnoreCase(textNumeroUnique.getText())) {

                    int answer = JOptionPane.showConfirmDialog(SaisieVenteFactureSQLComponent.this,
                            "Voulez vous actualiser le numro de la facture?",
                            "Changement du numro de facture", JOptionPane.YES_NO_OPTION);
                    if (answer == JOptionPane.NO_OPTION) {
                        return;
                    }
                }

                textNumeroUnique.setText(nextNumero);

            }

        }
    });
    this.add(dateSaisie, c);

    // Ligne 2 : reference
    c.gridx = 0;
    c.gridwidth = 1;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    JLabel labelLibelle = new JLabel(getLabelFor("NOM"));
    labelLibelle.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelLibelle, c);

    SQLTextCombo textLibelle = new SQLTextCombo();
    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    this.add(textLibelle, c);

    this.addSQLObject(textLibelle, "NOM");
    c.fill = GridBagConstraints.HORIZONTAL;
    this.comboCommercial = new ElementComboBox(false);
    // Commercial
    String field;
    field = "ID_COMMERCIAL";
    c.gridx++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c);

    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;

    this.add(this.comboCommercial, c);
    this.addRequiredSQLObject(this.comboCommercial, field);
    // Client
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);

    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.comboClient = new ElementComboBox();

    this.add(this.comboClient, c);

    if (getTable().contains("ID_ECHEANCIER_CCI")) {
        // Echeancier
        c.gridx++;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        this.add(new JLabel(getLabelFor("ID_ECHEANCIER_CCI"), SwingConstants.RIGHT), c);

        c.gridx++;
        c.weightx = 1;
        c.fill = GridBagConstraints.NONE;
        final ElementComboBox echeancier = new ElementComboBox();
        final SQLElement contactElement = Configuration.getInstance().getDirectory()
                .getElement("ECHEANCIER_CCI");
        echeancier.init(contactElement, contactElement.getComboRequest(true));
        DefaultGridBagConstraints.lockMinimumSize(echeancier);
        this.addView(echeancier, "ID_ECHEANCIER_CCI");

        selAffaire.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent arg0) {
                // TODO Raccord de mthode auto-gnr
                if (selAffaire.getSelectedRow() != null) {
                    echeancier.getRequest().setWhere(new Where(contactElement.getTable().getField("ID_AFFAIRE"),
                            "=", selAffaire.getSelectedRow().getID()));

                    if (!isFilling()) {
                        SQLRow rowPole = selAffaire.getSelectedRow().getForeignRow("ID_POLE_PRODUIT");
                        comboCommercial.setValue(rowPole);
                    }
                } else {
                    echeancier.getRequest().setWhere(null);
                }
            }
        });
        this.add(echeancier, c);

    }

    this.comboClient.addValueListener(this.changeClientListener);

    this.comboAdresse = new ElementComboBox();
    this.comboAdresse.setAddIconVisible(false);
    this.comboAdresse.setListIconVisible(false);
    JLabel labelAdresse = new JLabel(getLabelFor("ID_ADRESSE"), SwingConstants.RIGHT);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    labelAdresse.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelAdresse, c);

    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    this.add(this.comboAdresse, c);

    // Acompte
    this.checkAcompte = new JCheckBox(getLabelFor("ACOMPTE"));
    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    // this.add(this.checkAcompte, c);
    c.gridwidth = 1;
    this.addView(this.checkAcompte, "ACOMPTE");

    // Compte Service
    this.checkCompteServiceAuto = new JCheckBox(getLabelFor("COMPTE_SERVICE_AUTO"));
    this.addSQLObject(this.checkCompteServiceAuto, "COMPTE_SERVICE_AUTO");
    this.compteSelService = new ISQLCompteSelector();

    this.labelCompteServ = new JLabel("Compte Service");
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 1;
    c.weightx = 0;
    this.labelCompteServ.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(this.labelCompteServ, c);

    c.gridx++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    this.add(this.compteSelService, c);

    String valServ = DefaultNXProps.getInstance().getStringProperty("ArticleService");
    Boolean bServ = Boolean.valueOf(valServ);

    this.checkCompteServiceAuto.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            setCompteServiceVisible(!SaisieVenteFactureSQLComponent.this.checkCompteServiceAuto.isSelected());
        }
    });

    // FIXME A checker si utile pour Preventec ou KD
    setCompteServiceVisible(false);
    // setCompteServiceVisible(!(bServ != null && !bServ.booleanValue()));

    final JPanel pAcompte = new JPanel();
    final DeviseField textAcompteHT = new DeviseField();
    pAcompte.add(new JLabel("Acompte HT"));
    pAcompte.add(textAcompteHT);

    pAcompte.add(new JLabel("soit"));
    final JTextField textAcompte = new JTextField(5);
    pAcompte.add(textAcompte);
    pAcompte.add(new JLabel("%"));
    c.gridx = 0;
    c.gridy++;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    this.add(pAcompte, c);
    c.anchor = GridBagConstraints.WEST;
    this.addView(textAcompte, "POURCENT_ACOMPTE");

    pAcompte.setVisible(false);

    /*******************************************************************************************
     * * DETAILS
     ******************************************************************************************/
    this.tableFacture = new SaisieVenteFactureItemTable();

    final ElementComboBox boxTarif = new ElementComboBox();
    if (this.getTable().getFieldsName().contains("ID_TARIF")) {
        // TARIF
        c.gridy++;
        c.gridx = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        c.fill = GridBagConstraints.HORIZONTAL;
        this.add(new JLabel("Tarif  appliquer", SwingConstants.RIGHT), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;
        c.fill = GridBagConstraints.NONE;
        c.weightx = 1;
        DefaultGridBagConstraints.lockMinimumSize(boxTarif);
        this.add(boxTarif, c);
        this.addView(boxTarif, "ID_TARIF");
        boxTarif.addModelListener("wantedID", new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
                tableFacture.setTarif(selectedRow, false);
            }
        });
    }
    c.gridy++;
    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;

    ITextArea infos = new ITextArea(4, 4);
    this.add(this.tableFacture, c);

    // FIXME
    this.addView(this.tableFacture.getRowValuesTable(), "");

    /*******************************************************************************************
     * * MODE DE REGLEMENT
     ******************************************************************************************/
    JPanel panelBottom = new JPanel(new GridBagLayout());
    GridBagConstraints cBottom = new DefaultGridBagConstraints();
    cBottom.weightx = 1;
    cBottom.anchor = GridBagConstraints.NORTHWEST;
    // Mode de rglement
    this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
    this.eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
    panelBottom.add(this.eltModeRegl, cBottom);

    /*******************************************************************************************
     * * FRAIS DE PORT ET REMISE
     ******************************************************************************************/
    JPanel panelFrais = new JPanel();
    panelFrais.setLayout(new GridBagLayout());

    final GridBagConstraints cFrais = new DefaultGridBagConstraints();

    this.textPortHT = new DeviseField(5);
    DefaultGridBagConstraints.lockMinimumSize(textPortHT);
    addSQLObject(this.textPortHT, "PORT_HT");
    this.textRemiseHT = new DeviseField(5);
    DefaultGridBagConstraints.lockMinimumSize(textRemiseHT);
    addSQLObject(this.textRemiseHT, "REMISE_HT");

    // Frais de port
    cFrais.gridheight = 1;
    cFrais.gridx = 1;
    SQLRequestComboBox boxTaxePort = new SQLRequestComboBox(false, 8);
    if (getTable().contains("ID_TAXE_PORT")) {

        JLabel labelPortHT = new JLabel(getLabelFor("PORT_HT"));
        labelPortHT.setHorizontalAlignment(SwingConstants.RIGHT);
        cFrais.gridy++;
        panelFrais.add(labelPortHT, cFrais);
        cFrais.gridx++;
        panelFrais.add(this.textPortHT, cFrais);

        JLabel labelTaxeHT = new JLabel(getLabelFor("ID_TAXE_PORT"));
        labelTaxeHT.setHorizontalAlignment(SwingConstants.RIGHT);
        cFrais.gridx = 1;
        cFrais.gridy++;
        panelFrais.add(labelTaxeHT, cFrais);
        cFrais.gridx++;
        panelFrais.add(boxTaxePort, cFrais);
        this.addView(boxTaxePort, "ID_TAXE_PORT", REQ);

        boxTaxePort.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                // TODO Raccord de mthode auto-gnr
                totalTTC.updateTotal();
            }
        });
    }

    // Remise
    JLabel labelRemiseHT = new JLabel(getLabelFor("REMISE_HT"));
    labelRemiseHT.setHorizontalAlignment(SwingConstants.RIGHT);
    cFrais.gridy++;
    cFrais.gridx = 1;
    panelFrais.add(labelRemiseHT, cFrais);
    cFrais.gridx++;
    panelFrais.add(this.textRemiseHT, cFrais);
    cFrais.gridy++;

    cBottom.gridx++;
    cBottom.weightx = 1;
    cBottom.anchor = GridBagConstraints.NORTHEAST;
    cBottom.fill = GridBagConstraints.NONE;
    panelBottom.add(panelFrais, cBottom);

    /*******************************************************************************************
     * * CALCUL DES TOTAUX
     ******************************************************************************************/
    DeviseField fieldHT = new DeviseField();
    final DeviseField fieldTVA = new DeviseField();
    DeviseField fieldService = new DeviseField();
    DeviseField fieldTHA = new DeviseField();

    DeviseField fieldDevise = null;
    if (getTable().getFieldsName().contains("T_DEVISE")) {
        fieldDevise = new DeviseField();
        addSQLObject(fieldDevise, "T_DEVISE");
    }
    // FIXME was required but not displayed for KD
    addSQLObject(fieldTHA, "T_HA");
    addRequiredSQLObject(fieldHT, "T_HT");
    addRequiredSQLObject(fieldTVA, "T_TVA");
    addRequiredSQLObject(this.fieldTTC, "T_TTC");
    addRequiredSQLObject(fieldService, "T_SERVICE");
    JTextField poids = new JTextField();
    addSQLObject(poids, "T_POIDS");

    totalTTC = new TotalPanel(this.tableFacture, fieldHT, fieldTVA, this.fieldTTC, this.textPortHT,
            this.textRemiseHT, fieldService, fieldTHA, fieldDevise, poids, null,
            (getTable().contains("ID_TAXE_PORT") ? boxTaxePort : null));
    DefaultGridBagConstraints.lockMinimumSize(totalTTC);
    cBottom.gridx++;
    cBottom.weightx = 1;
    cBottom.anchor = GridBagConstraints.EAST;
    cBottom.fill = GridBagConstraints.HORIZONTAL;
    panelBottom.add(totalTTC, cBottom);

    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy++;
    c.weighty = 0;
    this.add(panelBottom, c);

    // Ligne : Avoir
    c.gridy++;
    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(createPanelAvoir(), c);

    // Infos
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 4;
    c.fill = GridBagConstraints.BOTH;
    this.add(new TitledSeparator(getLabelFor("INFOS")), c);

    c.gridy++;

    final JScrollPane comp = new JScrollPane(infos);
    infos.setBorder(null);
    DefaultGridBagConstraints.lockMinimumSize(comp);
    this.add(comp, c);

    this.panelOO = new PanelOOSQLComponent(this);
    c.gridy++;
    c.gridx = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.NORTHEAST;
    this.add(this.panelOO, c);

    this.addSQLObject(this.textAvoirTTC, "T_AVOIR_TTC");

    this.addRequiredSQLObject(dateSaisie, "DATE");
    this.addRequiredSQLObject(this.comboClient, "ID_CLIENT");
    this.addSQLObject(this.comboAdresse, "ID_ADRESSE");
    this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO");
    this.addSQLObject(infos, "INFOS");
    this.addSQLObject(this.checkPrevisionnelle, "PREVISIONNELLE");
    this.addSQLObject(this.checkComplement, "COMPLEMENT");
    this.addSQLObject(this.selAvoir, "ID_AVOIR_CLIENT");
    this.addSQLObject(this.compteSelService, "ID_COMPTE_PCE_SERVICE");
    ModeDeReglementSQLComponent modeReglComp;

    modeReglComp = (ModeDeReglementSQLComponent) this.eltModeRegl.getSQLChild();
    this.selAvoir.getRequest().setWhere(new Where(this.tableAvoir.getField("SOLDE"), "=", Boolean.FALSE));
    this.selAvoir.fillCombo();

    // Selection du compte de service
    int idCompteVenteService = rowPrefsCompte.getInt("ID_COMPTE_PCE_VENTE_SERVICE");
    if (idCompteVenteService <= 1) {
        try {
            idCompteVenteService = ComptePCESQLElement.getIdComptePceDefault("VentesServices");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    this.compteSelService.setValue(idCompteVenteService);

    // Lock

    DefaultGridBagConstraints.lockMinimumSize(this.comboClient);
    DefaultGridBagConstraints.lockMinimumSize(this.comboCommercial);
    DefaultGridBagConstraints.lockMinimumSize(this.comboAdresse);

    // Listeners

    this.comboClient.addValueListener(this.listenerModeReglDefaut);
    this.fieldTTC.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent e) {
            refreshText();
        }

    });

    this.selAvoir.addValueListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            refreshText();
        }

    });

    this.checkAcompte.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {

            pAcompte.setVisible(SaisieVenteFactureSQLComponent.this.checkAcompte.isSelected());
        }
    });

    this.changeClientListener = new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {

            if (SaisieVenteFactureSQLComponent.this.comboClient.getValue() != null) {
                final SQLRow row = SaisieVenteFactureSQLComponent.this.comboClient.getSelectedRow();
                final int id = row == null ? SQLRow.NONEXISTANT_ID : row.getID();

                SaisieVenteFactureSQLComponent.this.defaultContactRowValues.putForeignID("ID_CLIENT", row);
                if (row != null) {
                    if (SaisieVenteFactureSQLComponent.this.contact != null) {
                        Where w = new Where(
                                SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"),
                                "=", SQLRow.NONEXISTANT_ID);
                        w = w.or(new Where(
                                SaisieVenteFactureSQLComponent.this.eltContact.getTable().getField("ID_CLIENT"),
                                "=", id));
                        SaisieVenteFactureSQLComponent.this.contact.getRequest().setWhere(w);
                    }
                    if (SaisieVenteFactureSQLComponent.this.comboAdresse != null) {

                        Where w = new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=",
                                row.getInt("ID_ADRESSE"));

                        w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=",
                                row.getInt("ID_ADRESSE_L")));
                        w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getKey(), "=",
                                row.getInt("ID_ADRESSE_F")));

                        SQLRow rowCli = row;

                        w = w.or(new Where(SaisieVenteFactureSQLComponent.TABLE_ADRESSE.getField("ID_CLIENT"),
                                "=", rowCli.getID()));

                        SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(w);
                    }
                } else {
                    if (SaisieVenteFactureSQLComponent.this.comboAdresse != null) {
                        SaisieVenteFactureSQLComponent.this.comboAdresse.getRequest().setWhere(null);
                    }
                }
                SaisieVenteFactureSQLComponent.this.previousClient = id;
            }

        }
    };

    this.changeCompteListener = new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            SQLSelect sel = new SQLSelect(getTable().getBase());
            sel.addSelect(SaisieVenteFactureSQLComponent.this.client.getTable().getKey());
            Where where = new Where(
                    SaisieVenteFactureSQLComponent.this.client.getTable().getField("ID_COMPTE_PCE"), "=",
                    SaisieVenteFactureSQLComponent.this.compteSel.getValue());
            sel.setWhere(where);

            String req = sel.asString();
            List l = getTable().getBase().getDataSource().execute(req);
            if (l != null) {
                if (l.size() == 1) {
                    Map<String, Object> m = (Map<String, Object>) l.get(0);
                    Object o = m.get(SaisieVenteFactureSQLComponent.this.client.getTable().getKey().getName());
                    System.err.println("Only one value match :: " + o);
                    if (o != null) {
                        SaisieVenteFactureSQLComponent.this.comboClient
                                .setValue(Integer.valueOf(((Number) o).intValue()));
                    }
                }
            }
        }
    };

    this.textPortHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });

    this.textRemiseHT.getDocument().addDocumentListener(new SimpleDocumentListener() {
        @Override
        public void update(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });
    this.comboClient.addValueListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (SaisieVenteFactureSQLComponent.this.isFilling())
                return;
            final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow();
            if (row != null) {
                SaisieVenteFactureSQLComponent.this.defaultContactRowValues.putForeignID("ID_CLIENT", row);
                if (SaisieVenteFactureSQLComponent.this.client.getTable().contains("ID_TARIF")) {
                    SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                    if (foreignRow != null && !foreignRow.isUndefined()
                            && (boxTarif.getSelectedRow() == null
                                    || boxTarif.getSelectedId() != foreignRow.getID())
                            && JOptionPane.showConfirmDialog(null,
                                    "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) {
                        boxTarif.setValue(foreignRow.getID());
                        // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
                        // true);
                    } else {
                        boxTarif.setValue(foreignRow);
                    }

                }

                int idCpt = row.getInt("ID_COMPTE_PCE");

                if (idCpt <= 1) {
                    // Select Compte client par defaut
                    idCpt = rowPrefsCompte.getInt("ID_COMPTE_PCE_CLIENT");
                    if (idCpt <= 1) {
                        try {
                            idCpt = ComptePCESQLElement.getIdComptePceDefault("Clients");
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                if (SaisieVenteFactureSQLComponent.this.compteSel != null) {
                    Integer i = SaisieVenteFactureSQLComponent.this.compteSel.getValue();
                    if (i == null || i.intValue() != idCpt) {
                        SaisieVenteFactureSQLComponent.this.compteSel.setValue(idCpt);
                    }
                }
            }

        }
    });

}

From source file:org.openconcerto.erp.core.sales.invoice.component.SaisieVenteFactureSQLComponent.java

private JPanel createPanelAvoir() {
    JPanel panelAvoir = new JPanel(new GridBagLayout());
    panelAvoir.setOpaque(false);//from w ww  .  j  a v a 2 s  .co m
    GridBagConstraints cA = new DefaultGridBagConstraints();
    JLabel labelAvoir = new JLabel(getLabelFor("ID_AVOIR_CLIENT"));
    labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT);
    cA.weightx = 1;
    labelAvoir.setHorizontalAlignment(SwingConstants.RIGHT);
    panelAvoir.add(labelAvoir, cA);
    cA.weightx = 0;
    cA.gridx++;
    this.selAvoir = new ElementComboBox();
    this.selAvoir.setAddIconVisible(false);
    panelAvoir.add(this.selAvoir, cA);
    final JLabel labelTotalAvoir = new JLabel("Total  rgler");
    this.textTotalAvoir = new DeviseField();
    this.textTotalAvoir.setEditable(false);
    cA.gridx++;
    cA.weightx = 0;
    panelAvoir.add(labelTotalAvoir, cA);
    cA.gridx++;
    cA.weightx = 0;
    panelAvoir.add(this.textTotalAvoir, cA);
    this.textTotalAvoir.setHorizontalAlignment(SwingConstants.RIGHT);

    return panelAvoir;
}

From source file:org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Numero du commande
    c.gridx = 0;//from   w  w w . jav a  2s  . c  om
    this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);

    this.numeroUniqueCommande = new JUniqueTextField(16);
    c.fill = GridBagConstraints.NONE;
    c.gridx++;
    c.weightx = 1;
    this.add(this.numeroUniqueCommande, c);

    // Date
    JLabel labelDate = new JLabel(getLabelFor("DATE"));
    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    this.add(labelDate, c);

    JDate dateCommande = new JDate(true);
    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    this.add(dateCommande, c);

    // Champ Module
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();

    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    this.comboDevis = new ElementComboBox();

    // Reference
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel labelObjet = new JLabel(getLabelFor("NOM"));
    labelObjet.setHorizontalAlignment(SwingConstants.RIGHT);
    c.weightx = 0;
    this.add(labelObjet, c);

    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.textObjet, c);

    String field;
    field = "ID_COMMERCIAL";
    c.fill = GridBagConstraints.HORIZONTAL;
    // Commercial
    JLabel labelCommercial = new JLabel(getLabelFor(field));
    labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT);

    c.gridx++;
    c.weightx = 0;
    this.add(labelCommercial, c);

    this.comboCommercial = new ElementComboBox(false, 25);
    this.comboCommercial.setListIconVisible(false);
    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 1;
    this.add(this.comboCommercial, c);
    addRequiredSQLObject(this.comboCommercial, field);

    // Ligne 3: Client
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);

    this.comboClient = new ElementComboBox();
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 3;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.comboClient, c);
    final ElementComboBox boxTarif = new ElementComboBox();
    this.comboClient.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!isFilling() && comboClient.getValue() != null) {
                Integer id = comboClient.getValue();

                if (id > 1) {

                    SQLRow row = comboClient.getElement().getTable().getRow(id);
                    if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {

                        SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                        if (!foreignRow.isUndefined()
                                && (boxTarif.getSelectedRow() == null
                                        || boxTarif.getSelectedId() != foreignRow.getID())
                                && JOptionPane.showConfirmDialog(null,
                                        "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) {
                            boxTarif.setValue(foreignRow.getID());
                            // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
                            // true);
                        } else {
                            boxTarif.setValue(foreignRow.getID());
                        }
                        // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                        // if (foreignRow.isUndefined() &&
                        // !row.getForeignRow("ID_DEVISE").isUndefined()) {
                        // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
                        // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
                        // foreignRow = rowValsD;
                        //
                        // }
                        // table.setTarif(foreignRow, true);
                    }
                }
            }

        }
    });
    // tarif
    if (this.getTable().getFieldsName().contains("ID_TARIF")) {
        // TARIF
        c.gridy++;
        c.gridx = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        this.add(new JLabel("Tarif  appliquer"), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;

        c.weightx = 1;
        this.add(boxTarif, c);
        this.addView(boxTarif, "ID_TARIF");
        boxTarif.addModelListener("wantedID", new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
                table.setTarif(selectedRow, false);
            }
        });
    }

    // Table d'lment
    this.table = new CommandeClientItemTable();
    c.fill = GridBagConstraints.BOTH;
    c.gridy++;
    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(this.table, c);

    DeviseField textPortHT = new DeviseField();
    DeviseField textRemiseHT = new DeviseField();

    // INfos
    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.weighty = 0;
    c.weightx = 1;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 2;
    this.add(new TitledSeparator(getLabelFor("INFOS")), c);

    c.gridy++;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    final JScrollPane scrollPane = new JScrollPane(this.infos);
    scrollPane.setBorder(null);
    this.add(scrollPane, c);

    // Poids
    c.gridwidth = 1;

    DefaultProps props = DefaultNXProps.getInstance();
    Boolean b = props.getBooleanValue("ArticleShowPoids");
    final JTextField textPoidsTotal = new JTextField(8);
    if (b) {
        JPanel panel = new JPanel();

        panel.add(new JLabel(getLabelFor("T_POIDS")), c);

        textPoidsTotal.setEnabled(false);
        textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
        textPoidsTotal.setDisabledTextColor(Color.BLACK);
        panel.add(textPoidsTotal, c);

        panel.setOpaque(false);
        DefaultGridBagConstraints.lockMinimumSize(panel);

        c.gridx = 2;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        c.fill = GridBagConstraints.NONE;
        c.anchor = GridBagConstraints.NORTHEAST;
        this.add(panel, c);
    }

    // Total
    DeviseField fieldHT = new DeviseField();
    DeviseField fieldTVA = new DeviseField();
    DeviseField fieldTTC = new DeviseField();
    DeviseField fieldDevise = new DeviseField();
    DeviseField fieldService = new DeviseField();
    DeviseField fieldHA = new DeviseField();
    fieldHT.setOpaque(false);
    fieldHA.setOpaque(false);
    fieldTVA.setOpaque(false);
    fieldTTC.setOpaque(false);
    fieldService.setOpaque(false);
    addSQLObject(fieldDevise, "T_DEVISE");
    addRequiredSQLObject(fieldHT, "T_HT");
    addRequiredSQLObject(fieldTVA, "T_TVA");
    addRequiredSQLObject(fieldTTC, "T_TTC");
    addRequiredSQLObject(fieldService, "T_SERVICE");
    if (getTable().contains("PREBILAN")) {
        addSQLObject(fieldHA, "PREBILAN");
    } else if (getTable().contains("T_HA")) {
        addSQLObject(fieldHA, "T_HA");
    }

    JTextField poids = new JTextField();
    // addSQLObject(poids, "T_POIDS");
    final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT,
            textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null);

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridy--;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.fill = GridBagConstraints.NONE;
    c.weighty = 0;

    this.add(totalTTC, c);

    this.panelOO = new PanelOOSQLComponent(this);
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    c.gridx = 0;
    c.gridy += 3;
    c.weightx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(this.panelOO, c);

    textPortHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });

    textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });

    addRequiredSQLObject(this.comboClient, "ID_CLIENT");
    addSQLObject(this.textObjet, "NOM");
    addSQLObject(textPoidsTotal, "T_POIDS");
    addRequiredSQLObject(dateCommande, "DATE");
    // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
    addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
    addSQLObject(this.infos, "INFOS");
    addSQLObject(this.comboDevis, "ID_DEVIS");

    this.numeroUniqueCommande
            .setText(NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()));

    this.table.getModel().addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal()));
        }
    });
    DefaultGridBagConstraints.lockMinimumSize(comboClient);
    DefaultGridBagConstraints.lockMinimumSize(comboCommercial);
    DefaultGridBagConstraints.lockMinimumSize(comboDevis);
    DefaultGridBagConstraints.lockMinimumSize(totalTTC);
    DefaultGridBagConstraints.lockMaximumSize(totalTTC);
    DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande);

}

From source file:org.openconcerto.erp.core.sales.pos.element.SaisieVenteComptoirSQLElement.java

public SQLComponent createComponent() {
    return new BaseSQLComponent(this) {
        private final JCheckBox checkService = new JCheckBox("dont ");
        private SQLSearchableTextCombo textNom;
        private DeviseField textMontantTTC;
        private DeviseField textMontantService;
        private ElementComboBox comboFournisseur;
        private JTextField textEcheance;

        private ElementComboBox comboTaxe;
        private DeviseField textMontantHT;
        private JCheckBox checkCommande;
        private JDate dateSaisie;

        private ElementComboBox nomArticle;
        private Date dateEch;
        private JLabel labelEcheancejours = new JLabel("jours");
        private ElementComboBox comboAvoir;
        private ElementComboBox comboClient;

        private final JLabel labelWarning = new JLabelWarning(
                "le montant du service ne peut pas dpasser le total HT!");
        private ValidState validState = ValidState.getTrueInstance();
        // FIXME: use w
        private Where w;
        private DocumentListener docTTCListen;
        private PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent evt) {

                if ((nomArticle.getValidState().isValid()) && (!nomArticle.isEmpty()) && !isFilling()) {
                    int idArticle = nomArticle.getValue().intValue();

                    SQLTable tableArticle = ((ComptaPropsConfiguration) Configuration.getInstance())
                            .getRootSociete().getTable("ARTICLE");
                    SQLRow rowArticle = tableArticle.getRow(idArticle);
                    if (rowArticle != null) {
                        comboTaxe.setValue(rowArticle.getInt("ID_TAXE"));

                        textMontantTTC.setText(((BigDecimal) rowArticle.getObject("PV_TTC")).toString());
                    }/* w ww.  j a  va 2  s.co  m*/
                    System.out.println("value article Changed");

                }
            }
        };

        public void addViews() {
            this.setLayout(new GridBagLayout());
            final GridBagConstraints c = new DefaultGridBagConstraints();

            this.docTTCListen = new DocumentListener() {
                public void changedUpdate(DocumentEvent e) {
                    calculMontant();
                }

                public void removeUpdate(DocumentEvent e) {
                    calculMontant();
                }

                public void insertUpdate(DocumentEvent e) {
                    calculMontant();
                }
            };

            /***********************************************************************************
             * * RENSEIGNEMENTS
             **********************************************************************************/
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.gridheight = 1;
            TitledSeparator sep = new TitledSeparator("Renseignements");
            this.add(sep, c);
            c.insets = new Insets(2, 2, 1, 2);

            c.gridwidth = 1;

            // Libell vente
            JLabel labelNom = new JLabel(getLabelFor("NOM"));
            labelNom.setHorizontalAlignment(SwingConstants.RIGHT);
            c.gridy++;
            c.gridx = 0;
            c.weightx = 0;
            this.add(labelNom, c);

            this.textNom = new SQLSearchableTextCombo();
            c.gridx++;
            c.weightx = 1;
            c.gridwidth = 2;
            this.add(this.textNom, c);

            // Date
            JLabel labelDate = new JLabel(getLabelFor("DATE"));

            this.dateSaisie = new JDate(true);
            c.gridwidth = 1;
            // c.gridx += 2;
            c.gridx = 0;
            c.gridy++;
            c.weightx = 0;
            labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
            this.add(labelDate, c);
            c.gridx++;
            c.weightx = 1;
            this.add(this.dateSaisie, c);

            // article
            c.gridy++;
            c.gridx = 0;

            this.nomArticle = new ElementComboBox();

            JLabel labelNomArticle = new JLabel(getLabelFor("ID_ARTICLE"));
            c.weightx = 0;
            labelNomArticle.setHorizontalAlignment(SwingConstants.RIGHT);
            // this.add(labelNomArticle, c);

            c.gridx++;
            c.weightx = 0;
            c.gridwidth = GridBagConstraints.REMAINDER;
            // this.add(this.nomArticle, c);

            this.nomArticle.addValueListener(this.propertyChangeListener);

            // client
            this.comboClient = new ElementComboBox();
            this.comboClient.addValueListener(new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {

                    if (comboClient.isEmpty()) {
                        w = new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=",
                                -1);
                    } else {
                        w = new Where(getTable().getBase().getTable("AVOIR_CLIENT").getField("ID_CLIENT"), "=",
                                comboClient.getSelectedId());
                    }
                }
            });

            JLabel labelNomClient = new JLabel(getLabelFor("ID_CLIENT"));
            c.gridy++;
            c.gridx = 0;
            c.gridwidth = 1;
            c.weightx = 0;
            labelNomClient.setHorizontalAlignment(SwingConstants.RIGHT);
            this.add(labelNomClient, c);

            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 0;
            this.add(this.comboClient, c);

            // Selection d'un avoir si le client en possede

            this.comboAvoir = new ElementComboBox();

            JLabel labelAvoirClient = new JLabel(getLabelFor("ID_AVOIR_CLIENT"));
            c.gridy++;
            c.gridx = 0;
            c.gridwidth = 1;
            c.weightx = 0;
            labelAvoirClient.setHorizontalAlignment(SwingConstants.RIGHT);
            // this.add(labelAvoirClient, c);

            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 0;
            // this.add(this.comboAvoir, c);

            /***********************************************************************************
             * * MONTANT
             **********************************************************************************/
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.gridx = 0;
            c.gridy++;
            c.weightx = 1;
            sep = new TitledSeparator("Montant en Euros");
            c.insets = new Insets(10, 2, 1, 2);
            this.add(sep, c);
            c.insets = new Insets(2, 2, 1, 2);

            c.gridwidth = 1;

            final JLabel labelMontantHT = new JLabel(getLabelFor("MONTANT_HT"));
            labelMontantHT.setHorizontalAlignment(SwingConstants.RIGHT);
            this.textMontantHT = new DeviseField();
            this.textMontantHT.setEditable(false);
            this.textMontantHT.setEnabled(false);
            this.textMontantHT.setFocusable(false);

            final JLabel labelMontantTTC = new JLabel(getLabelFor("MONTANT_TTC"));
            labelMontantTTC.setHorizontalAlignment(SwingConstants.RIGHT);
            this.textMontantTTC = new DeviseField();
            this.textMontantTTC.getDocument().addDocumentListener(this.docTTCListen);

            // Montant HT
            c.fill = GridBagConstraints.HORIZONTAL;

            c.weightx = 0;
            c.gridy++;
            c.gridx = 0;
            c.gridwidth = 1;
            this.add(labelMontantHT, c);

            c.gridx++;
            c.weightx = 1;
            this.add(this.textMontantHT, c);

            // Montant Service

            c.gridx++;

            c.weightx = 0;
            this.add(checkService, c);

            checkService.addActionListener(new ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent e) {
                    if (isFilling())
                        return;
                    boolean b = checkService.isSelected();
                    textMontantService.setEditable(b);
                    textMontantService.setEnabled(b);
                    textMontantService.setFocusable(b);

                    if (!b) {
                        textMontantService.setText("");
                        // montantServiceValide = true;
                    } else {
                        textMontantService.setText(textMontantHT.getText());
                    }
                };
            });

            this.textMontantService = new DeviseField();
            c.gridx++;
            c.weightx = 1;
            this.add(this.textMontantService, c);

            JLabel labelMontantService = new JLabel("de service HT");
            c.weightx = 0;
            c.gridx++;
            this.add(labelMontantService, c);

            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            this.add(this.labelWarning, c);
            this.labelWarning.setVisible(false);

            // Choix TVA
            c.gridy++;
            c.gridx = 0;
            c.weightx = 0;
            c.gridwidth = 1;

            final JLabel labelTaxe = new JLabel(getLabelFor("ID_TAXE"));
            labelTaxe.setHorizontalAlignment(SwingUtilities.RIGHT);
            this.add(labelTaxe, c);

            c.gridx++;
            this.comboTaxe = new ElementComboBox(false);

            c.fill = GridBagConstraints.NONE;

            this.add(this.comboTaxe, c);

            c.fill = GridBagConstraints.HORIZONTAL;

            // Montant TTC
            c.gridy++;
            c.gridx = 0;
            c.weightx = 0;
            this.add(labelMontantTTC, c);

            c.gridx++;
            c.weightx = 0;
            this.add(this.textMontantTTC, c);

            /***********************************************************************************
             * * MODE DE REGLEMENT
             **********************************************************************************/
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.gridx = 0;
            c.gridy++;
            sep = new TitledSeparator("Mode de rglement");
            c.insets = new Insets(10, 2, 1, 2);
            this.add(sep, c);
            c.insets = new Insets(2, 2, 1, 2);

            c.gridx = 0;
            c.gridy++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            this.addView("ID_MODE_REGLEMENT", REQ + ";" + DEC + ";" + SEP);
            ElementSQLObject eltModeRegl = (ElementSQLObject) this.getView("ID_MODE_REGLEMENT");
            this.add(eltModeRegl, c);

            /***********************************************************************************
             * * COMMANDE
             **********************************************************************************/
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.gridx = 0;
            c.gridy++;
            sep = new TitledSeparator("Commande");
            c.insets = new Insets(10, 2, 1, 2);
            this.add(sep, c);
            c.insets = new Insets(2, 2, 1, 2);

            this.checkCommande = new JCheckBox("Produit  commander");

            c.gridx = 0;
            c.gridy++;
            c.weightx = 0;
            c.gridwidth = 2;
            // this.add(this.checkCommande, c);

            this.checkCommande.addActionListener(new ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent e) {
                    boolean b = checkCommande.isSelected();
                    comboFournisseur.setEnabled(b);
                    comboFournisseur.setEditable(b);

                    textEcheance.setEditable(b);
                    textEcheance.setEnabled(b);

                    updateValidState();
                };
            });

            // Fournisseurs
            JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR"));
            c.gridx = 0;
            c.gridy++;
            c.weightx = 0;
            c.gridwidth = 1;
            labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT);
            // this.add(labelFournisseur, c);

            this.comboFournisseur = new ElementComboBox();

            c.gridx++;
            c.weightx = 1;
            c.gridwidth = 4;
            // this.add(this.comboFournisseur, c);

            // Echeance
            JLabel labelEcheance = new JLabel("Echeance");
            c.gridx = 0;
            c.gridy++;
            c.weightx = 0;
            c.gridwidth = 1;
            labelEcheance.setHorizontalAlignment(SwingConstants.RIGHT);
            // this.add(labelEcheance, c);

            c.gridx++;
            c.weightx = 1;
            this.textEcheance = new JTextField();
            // this.add(this.textEcheance, c);
            this.textEcheance.addKeyListener(new KeyAdapter() {

                public void keyReleased(KeyEvent e) {
                    calculDate();
                }
            });

            c.gridx++;
            c.weightx = 0;
            // this.add(this.labelEcheancejours, c);

            /***********************************************************************************
             * * INFORMATIONS COMPLEMENTAIRES
             **********************************************************************************/
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.gridx = 0;
            c.gridy++;
            sep = new TitledSeparator("Informations complmentaires");
            c.insets = new Insets(10, 2, 1, 2);
            // this.add(sep, c);
            c.insets = new Insets(2, 2, 1, 2);

            ITextArea textInfos = new ITextArea();

            c.gridx = 0;
            c.gridy++;
            c.gridheight = GridBagConstraints.REMAINDER;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 1;
            c.weighty = 1;
            c.fill = GridBagConstraints.BOTH;
            // this.add(textInfos, c);

            this.addSQLObject(this.textNom, "NOM");
            this.addRequiredSQLObject(this.comboClient, "ID_CLIENT");
            this.addSQLObject(this.nomArticle, "ID_ARTICLE");
            this.addRequiredSQLObject(this.textMontantTTC, "MONTANT_TTC");
            this.addRequiredSQLObject(this.textMontantHT, "MONTANT_HT");
            this.addSQLObject(this.textMontantService, "MONTANT_SERVICE");
            this.addRequiredSQLObject(this.dateSaisie, "DATE");
            this.addSQLObject(textInfos, "INFOS");
            this.addSQLObject(this.comboFournisseur, "ID_FOURNISSEUR");
            this.addSQLObject(this.textEcheance, "ECHEANCE");
            this.addRequiredSQLObject(this.comboTaxe, "ID_TAXE");
            this.addSQLObject(this.comboAvoir, "ID_AVOIR_CLIENT");
            this.comboTaxe.setButtonsVisible(false);
            this.comboTaxe.setValue(2);

            checkService.setSelected(false);
            this.textMontantService.setEditable(false);
            this.textMontantService.setEnabled(false);

            this.checkCommande.setSelected(false);
            this.comboFournisseur.setEditable(false);
            this.comboFournisseur.setEnabled(false);
            this.textEcheance.setEditable(false);
            this.textEcheance.setEnabled(false);

            this.comboTaxe.addValueListener(new PropertyChangeListener() {

                public void propertyChange(PropertyChangeEvent evt) {
                    calculMontant();
                }
            });

            final SimpleDocumentListener docL = new SimpleDocumentListener() {
                @Override
                public void update(DocumentEvent e) {
                    updateValidState();
                }
            };
            this.textMontantService.getDocument().addDocumentListener(docL);
            this.textMontantHT.getDocument().addDocumentListener(docL);
            this.comboFournisseur.addEmptyListener(new EmptyListener() {
                @Override
                public void emptyChange(EmptyObj src, boolean newValue) {
                    updateValidState();
                }
            });

            /*
             * this.nomClient.addValueListener(new PropertyChangeListener() {
             * 
             * public void propertyChange(PropertyChangeEvent evt) { if (nomClient.isValid()) {
             * System.err.println("Changed Combo Avoir"); comboAvoir = new ElementComboBox(new
             * AvoirClientSQLElement(new Where(new
             * AvoirClientSQLElement().getTable().getField("ID_CLIENT"), "=",
             * nomClient.getValue()))); if (comboAvoir != null) { comboAvoir.setEnabled(true); }
             * } else { comboAvoir.setEnabled(false); } } });
             */

        }

        @Override
        public Set<String> getPartialResetNames() {
            Set<String> s = new HashSet<String>();
            s.addAll(super.getPartialResetNames());
            s.add("MONTANT_TTC");
            s.add("MONTANT_SERVICE");
            s.add("MONTANT_HT");
            s.add("NOM");
            s.add("ID_AVOIR_CLIENT");
            s.add("ID_ARTICLE");
            s.add("INFOS");
            return s;
        }

        private void calculMontant() {

            if (!isFilling()) {

                float taux;
                // PrixHT pHT;
                PrixTTC pTTC;
                // taux de la TVA selectionnee
                int idTaxe = this.comboTaxe.getSelectedId();
                if (idTaxe > 1) {
                    SQLRow ligneTaxe = getTable().getBase().getTable("TAXE").getRow(idTaxe);
                    if (ligneTaxe != null) {
                        taux = (ligneTaxe.getFloat("TAUX")) / 100.0F;

                        // calcul des montants HT ou TTC
                        if (this.textMontantTTC.getText().trim().length() > 0) {

                            if (this.textMontantTTC.getText().trim().equals("-")) {
                                pTTC = new PrixTTC(0);
                            } else {
                                pTTC = new PrixTTC(
                                        GestionDevise.parseLongCurrency(this.textMontantTTC.getText()));
                            }

                            // affichage
                            updateTextHT(GestionDevise.currencyToString(pTTC.calculLongHT(taux)));
                        } else {
                            updateTextHT("");
                        }
                    }
                }
            }
        }

        private boolean isMontantServiceValid() {
            String montant = this.textMontantService.getText().trim();
            String montantHT = this.textMontantHT.getText().trim();

            boolean b;
            if (montant.length() == 0) {
                b = true;
            } else {
                if (montantHT.length() == 0) {
                    b = false;
                } else {
                    b = (GestionDevise.parseLongCurrency(montantHT) >= GestionDevise
                            .parseLongCurrency(montant));
                }
            }

            this.labelWarning.setVisible(!b);
            System.err.println("Montant service is valid ? " + b + " --> HT val " + montantHT
                    + " --> service val " + montant);

            return b;
        }

        /*
         * private void calculMontantHT() {
         * 
         * float taux; PrixHT pHT;
         * 
         * if (!this.comboTaxe.isEmpty()) { // taux de la TVA selectionnee SQLRow ligneTaxe =
         * Configuration.getInstance().getBase().getTable("TAXE").getRow(((Integer)
         * this.comboTaxe.getValue()).intValue()); taux = (ligneTaxe.getFloat("TAUX")) / 100; //
         * calcul des montants HT ou TTC if (this.textMontantHT.getText().trim().length() > 0) {
         * 
         * if (this.textMontantHT.getText().trim().equals("-")) { pHT = new PrixHT(0); } else {
         * pHT = new PrixHT(Float.parseFloat(this.textMontantHT.getText())); } // affichage
         * updateTextTTC(String.valueOf(pHT.CalculTTC(taux))); } else updateTextTTC(""); } }
         */

        private void updateTextHT(final String prixHT) {
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {

                    textMontantHT.setText(prixHT);
                }
            });
        }

        @Override
        protected SQLRowValues createDefaults() {
            SQLRowValues vals = new SQLRowValues(this.getTable());
            SQLRowAccessor r;

            try {
                r = ModeReglementDefautPrefPanel.getDefaultRow(true);
                SQLElement eltModeReglement = Configuration.getInstance().getDirectory()
                        .getElement("MODE_REGLEMENT");
                if (r.getID() > 1) {
                    SQLRowValues rowVals = eltModeReglement.createCopy(r.getID());
                    System.err.println(rowVals.getInt("ID_TYPE_REGLEMENT"));
                    vals.put("ID_MODE_REGLEMENT", rowVals);
                }
            } catch (SQLException e) {
                System.err.println("Impossible de slectionner le mode de rglement par dfaut du client.");
                e.printStackTrace();
            }
            return vals;
        }

        // private void updateTextTTC(final String prixTTC) {
        // SwingUtilities.invokeLater(new Runnable() {
        //
        // public void run() {
        //
        // if (docTTCListen != null) {
        //
        // textMontantTTC.getDocument().removeDocumentListener(docTTCListen);
        // }
        //
        // textMontantTTC.setText(prixTTC);
        //
        // // textTaxe.setText(prixTVA);
        // textMontantTTC.getDocument().addDocumentListener(docTTCListen);
        // }
        // });
        // }

        private void calculDate() {

            int aJ = 0;

            // on rcupre les valeurs saisies
            if (this.textEcheance.getText().trim().length() != 0) {

                try {
                    aJ = Integer.parseInt(this.textEcheance.getText());
                } catch (Exception e) {
                    System.out.println("Erreur de format sur TextField Ajour " + this.textEcheance.getText());
                }
            }

            Calendar cal = Calendar.getInstance();

            // on fixe le temps sur ToDay + Ajour
            cal.setTime(new Date());
            long tempsMil = aJ * 86400000;
            cal.setTimeInMillis(cal.getTimeInMillis() + tempsMil);

            DateFormat dateFormat = new SimpleDateFormat("dd/MM/yy");
            this.dateEch = cal.getTime();
            this.labelEcheancejours.setText("jours, soit le " + dateFormat.format(this.dateEch));
        }

        private void updateValidState() {
            this.setValidState(this.computeValidState());
        }

        private ValidState computeValidState() {
            ValidState res = ValidState.getTrueInstance();
            if (!this.isMontantServiceValid())
                res = res.and(ValidState.createCached(false, this.labelWarning.getText()));
            if (this.checkCommande.isSelected())
                res = res.and(ValidState.createCached(!this.comboFournisseur.isEmpty(),
                        "Fournisseur non renseign"));
            return res;
        }

        private final void setValidState(ValidState validState) {
            if (!validState.equals(this.validState)) {
                this.validState = validState;
                this.fireValidChange();
            }
        }

        @Override
        public synchronized ValidState getValidState() {
            return super.getValidState().and(this.validState);
        }

        public int insert(SQLRow order) {

            // On teste si l'article n'existe pas, on le cre
            if (this.nomArticle.isEmpty()) {
                createArticle();
            }

            if (this.textNom.getValue() == null || this.textNom.getValue().trim().length() <= 0) {
                this.textNom.setValue(this.nomArticle.getTextComp().getText());
            }
            final int id = super.insert(order);
            // on verifie si le produit est  commander
            if (this.checkCommande.isSelected()) {
                createCommande(id);
            }

            SQLRow rowArt = getTable().getRow(id).getForeignRow("ID_ARTICLE");
            if (rowArt != null && !rowArt.isUndefined() && rowArt.getBoolean("GESTION_STOCK")) {
                Configuration.getInstance().getNonInteractiveSQLExecutor().execute(new Runnable() {

                    @Override
                    public void run() {

                        final SQLRow rowVC = getTable().getRow(id);
                        // Mise  jour des stocks
                        final SQLElement eltMvtStock = Configuration.getInstance().getDirectory()
                                .getElement("MOUVEMENT_STOCK");
                        final SQLRowValues rowVals = new SQLRowValues(eltMvtStock.getTable());
                        rowVals.put("QTE", -1);
                        rowVals.put("NOM", "Saisie vente comptoir");
                        rowVals.put("IDSOURCE", id);
                        rowVals.put("SOURCE", getTable().getName());
                        rowVals.put("ID_ARTICLE", rowVC.getInt("ID_ARTICLE"));
                        rowVals.put("DATE", rowVC.getObject("DATE"));

                        try {
                            final SQLRow row = rowVals.insert();
                            final ListMap<SQLRow, SQLRowValues> map = ((MouvementStockSQLElement) Configuration
                                    .getInstance().getDirectory().getElement("MOUVEMENT_STOCK"))
                                            .updateStock(Arrays.asList(row), false);
                            MouvementStockSQLElement.createCommandeF(map, null);

                        } catch (SQLException e) {
                            ExceptionHandler.handle("Erreur lors de la cration des mouvements de stock", e);
                        }
                    }
                });

            }
            new GenerationMvtSaisieVenteComptoir(id);
            return id;
        }

        private void createCommande(final int id) {

            System.out.println("Ajout d'une commande");
            SQLRow rowSaisie = SaisieVenteComptoirSQLElement.this.getTable().getRow(id);
            Map<String, Object> m = new HashMap<String, Object>();
            // NOM, DATE, ECHEANCE, IDSOURCE, SOURCE, ID_CLI, ID_FOURN, ID_ARTICLE
            m.put("NOM", rowSaisie.getObject("NOM"));
            m.put("DATE", rowSaisie.getObject("DATE"));
            m.put("DATE_ECHEANCE", new java.sql.Date(this.dateEch.getTime()));

            m.put("IDSOURCE", new Integer(id));
            m.put("SOURCE", "SAISIE_VENTE_COMPTOIR");

            m.put("ID_CLIENT", rowSaisie.getObject("ID_CLIENT"));
            m.put("ID_FOURNISSEUR", rowSaisie.getObject("ID_FOURNISSEUR"));
            m.put("ID_ARTICLE", rowSaisie.getObject("ID_ARTICLE"));

            SQLTable tableCmd = getTable().getBase().getTable("COMMANDE_CLIENT");

            SQLRowValues valCmd = new SQLRowValues(tableCmd, m);

            try {
                if (valCmd.getInvalid() == null) {
                    // ajout de l'ecriture
                    valCmd.insert();
                }
            } catch (Exception e) {
                System.err.println("Erreur  l'insertion dans la table " + valCmd.getTable().getName());
                e.printStackTrace();
            }
        }

        private void createArticle() {
            System.out.println("Cration de l'article");

            String tNomArticle = this.nomArticle.getTextComp().getText();
            String codeArticle = "";// this.nomArticle.getTextOpt();

            if (tNomArticle.trim().length() == 0 && codeArticle.trim().length() == 0) {
                return;
            }

            SQLTable articleTable = getTable().getBase().getTable("ARTICLE");

            int idTaxe = this.comboTaxe.getSelectedId();
            final BigDecimal prix = StringUtils.getBigDecimalFromUserText(this.textMontantHT.getText());
            final BigDecimal prixTTC = StringUtils.getBigDecimalFromUserText(this.textMontantTTC.getText());

            if (tNomArticle.trim().length() == 0) {
                tNomArticle = "Nom Indefini";
            }
            if (codeArticle.trim().length() == 0) {
                codeArticle = "Indefini";
            }

            SQLRowValues vals = new SQLRowValues(articleTable);
            vals.put("NOM", tNomArticle);
            vals.put("CODE", codeArticle);
            vals.put("PA_HT", prix);
            vals.put("PV_HT", prix);
            vals.put("PRIX_METRIQUE_VT_1", prix);
            vals.put("PRIX_METRIQUE_HA_1", prix);
            vals.put("PV_TTC", prixTTC);
            vals.put("ID_UNITE_VENTE", UniteVenteArticleSQLElement.A_LA_PIECE);
            vals.put("ID_TAXE", new Integer(idTaxe));
            vals.put("CREATION_AUTO", Boolean.TRUE);
            vals.put("GESTION_STOCK", Boolean.FALSE);

            try {
                SQLRow row = vals.insert();
                this.nomArticle.setValue(row);
            } catch (SQLException e) {

                e.printStackTrace();
            }
        }

        public void update() {

            if (JOptionPane.showConfirmDialog(this,
                    "Attention en modifiant cette vente comptoir, vous supprimerez les chques et les chances associs. Continuer?",
                    "Modification de vente comptoir", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {

                // on efface les mouvements de stocks associs
                SQLRow row = getTable().getRow(this.getSelectedID());
                SQLElement eltMvtStock = Configuration.getInstance().getDirectory()
                        .getElement("MOUVEMENT_STOCK");
                SQLSelect sel = new SQLSelect();
                sel.addSelect(eltMvtStock.getTable().getField("ID"));
                Where w = new Where(eltMvtStock.getTable().getField("IDSOURCE"), "=", row.getID());
                Where w2 = new Where(eltMvtStock.getTable().getField("SOURCE"), "=", getTable().getName());
                sel.setWhere(w.and(w2));

                List l = (List) eltMvtStock.getTable().getBase().getDataSource().execute(sel.asString(),
                        new ArrayListHandler());
                if (l != null) {
                    for (int i = 0; i < l.size(); i++) {
                        Object[] tmp = (Object[]) l.get(i);
                        try {
                            eltMvtStock.archive(((Number) tmp[0]).intValue());
                        } catch (SQLException e) {
                            e.printStackTrace();
                        }
                    }
                }

                if (this.textNom.getValue() != null && this.textNom.getValue().trim().length() <= 0) {
                    this.textNom.setValue(this.nomArticle.getTextComp().getText());
                }

                // On teste si l'article n'existe pas, on le cre
                if (this.nomArticle.getValue() == null
                        || Integer.parseInt(this.nomArticle.getValue().toString()) == -1) {
                    createArticle();
                }

                // TODO check echeance, ---> creation article, commande??
                super.update();

                row = getTable().getRow(this.getSelectedID());
                int idMvt = row.getInt("ID_MOUVEMENT");
                System.out.println(row.getID() + "__________***************** UPDATE " + idMvt);

                // on supprime tout ce qui est li  la facture
                EcritureSQLElement eltEcr = (EcritureSQLElement) Configuration.getInstance().getDirectory()
                        .getElement("ECRITURE");
                eltEcr.archiveMouvementProfondeur(idMvt, false);

                SQLRow rowArt = row.getForeignRow("ID_ARTICLE");
                if (rowArt != null && !rowArt.isUndefined() && rowArt.getBoolean("GESTION_STOCK")) {
                    // Mise  jour des stocks
                    SQLRowValues rowVals = new SQLRowValues(eltMvtStock.getTable());
                    rowVals.put("QTE", -1);
                    rowVals.put("NOM", "Saisie vente comptoir");
                    rowVals.put("IDSOURCE", getSelectedID());
                    rowVals.put("SOURCE", getTable().getName());
                    rowVals.put("ID_ARTICLE", row.getInt("ID_ARTICLE"));
                    rowVals.put("DATE", row.getObject("DATE"));
                    try {
                        SQLRow rowNew = rowVals.insert();
                        final ListMap<SQLRow, SQLRowValues> map = ((MouvementStockSQLElement) Configuration
                                .getInstance().getDirectory().getElement("MOUVEMENT_STOCK"))
                                        .updateStock(Arrays.asList(rowNew), false);
                        ComptaPropsConfiguration.getInstanceCompta().getNonInteractiveSQLExecutor()
                                .execute(new Runnable() {

                                    @Override
                                    public void run() {
                                        MouvementStockSQLElement.createCommandeF(map, null);
                                    }
                                });
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                }
                if (idMvt > 1) {
                    new GenerationMvtSaisieVenteComptoir(this.getSelectedID(), idMvt);
                } else {
                    new GenerationMvtSaisieVenteComptoir(this.getSelectedID());
                }
            }
        }

        @Override
        public void select(SQLRowAccessor r) {
            this.textMontantTTC.getDocument().removeDocumentListener(this.docTTCListen);
            this.nomArticle.rmValueListener(this.propertyChangeListener);

            super.select(r);

            checkService.setSelected(
                    r != null && r.getObject("MONTANT_SERVICE") != null && r.getLong("MONTANT_SERVICE") > 0);

            this.textMontantTTC.getDocument().addDocumentListener(this.docTTCListen);
            this.nomArticle.addValueListener(this.propertyChangeListener);
        }

        @Override
        public void select(SQLRowAccessor r, Set<String> views) {
            super.select(r, views);
            checkService.setSelected(
                    r != null && r.getObject("MONTANT_SERVICE") != null && r.getLong("MONTANT_SERVICE") > 0);
        }

    };
}

From source file:org.openconcerto.erp.core.sales.shipment.component.BonDeLivraisonSQLComponent.java

public void addViews() {
    this.textTotalHT.setOpaque(false);
    this.textTotalTVA.setOpaque(false);
    this.textTotalTTC.setOpaque(false);

    this.selectCommande = new ElementComboBox();

    this.setLayout(new GridBagLayout());

    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Champ Module
    c.gridx = 0;/*w ww  .  jav a2 s.  co m*/
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    // Numero
    JLabel labelNum = new JLabel(getLabelFor("NUMERO"));
    labelNum.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNum, c);

    this.textNumeroUnique = new JUniqueTextField(16);
    c.gridx++;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    DefaultGridBagConstraints.lockMinimumSize(textNumeroUnique);
    this.add(this.textNumeroUnique, c);

    // Date
    c.gridx++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    this.add(new JLabel(getLabelFor("DATE"), SwingConstants.RIGHT), c);

    JDate date = new JDate(true);
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(date, c);

    // Reference
    c.gridy++;
    c.gridx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);
    c.gridx++;
    c.weightx = 1;
    this.add(this.textNom, c);
    if (getTable().contains("DATE_LIVRAISON")) {
        // Date livraison
        c.gridx++;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 0;
        this.add(new JLabel(getLabelFor("DATE_LIVRAISON"), SwingConstants.RIGHT), c);

        JDate dateLivraison = new JDate(true);
        c.gridx++;
        c.weightx = 0;
        c.weighty = 0;
        c.fill = GridBagConstraints.NONE;
        this.add(dateLivraison, c);
        this.addView(dateLivraison, "DATE_LIVRAISON");
    }
    // Client
    JLabel labelClient = new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT);
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0;
    this.add(labelClient, c);

    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.comboClient = new ElementComboBox();
    this.add(this.comboClient, c);
    if (getTable().contains("SPEC_LIVRAISON")) {
        // Date livraison
        c.gridx++;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 0;
        this.add(new JLabel(getLabelFor("SPEC_LIVRAISON"), SwingConstants.RIGHT), c);

        JTextField specLivraison = new JTextField();
        c.gridx++;
        c.weightx = 0;
        c.weighty = 0;
        this.add(specLivraison, c);
        this.addView(specLivraison, "SPEC_LIVRAISON");
    }

    final ElementComboBox boxTarif = new ElementComboBox();
    this.comboClient.addValueListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (comboClient.getElement().getTable().contains("ID_TARIF")) {
                if (BonDeLivraisonSQLComponent.this.isFilling())
                    return;
                final SQLRow row = ((SQLRequestComboBox) evt.getSource()).getSelectedRow();
                if (row != null) {
                    // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                    // if (foreignRow.isUndefined() &&
                    // !row.getForeignRow("ID_DEVISE").isUndefined()) {
                    // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
                    // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
                    // foreignRow = rowValsD;
                    //
                    // }
                    // tableBonItem.setTarif(foreignRow, true);
                    SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                    if (!foreignRow.isUndefined()
                            && (boxTarif.getSelectedRow() == null
                                    || boxTarif.getSelectedId() != foreignRow.getID())
                            && JOptionPane.showConfirmDialog(null,
                                    "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) {
                        boxTarif.setValue(foreignRow.getID());
                        // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
                        // true);
                    } else {
                        boxTarif.setValue(foreignRow.getID());
                    }
                }
            }
        }
    });

    // Bouton tout livrer
    JButton boutonAll = new JButton("Tout livrer");

    boutonAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            RowValuesTableModel m = BonDeLivraisonSQLComponent.this.tableBonItem.getModel();

            // on livre tout les lments
            for (int i = 0; i < m.getRowCount(); i++) {
                SQLRowValues rowVals = m.getRowValuesAt(i);
                Object o = rowVals.getObject("QTE");
                int qte = o == null ? 0 : ((Number) o).intValue();
                m.putValue(qte, i, "QTE_LIVREE");
            }
        }
    });

    // Tarif
    if (this.getTable().getFieldsName().contains("ID_TARIF")) {
        // TARIF
        c.gridy++;
        c.gridx = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        this.add(new JLabel("Tarif  appliquer"), c);
        c.gridx++;
        c.gridwidth = 1;

        c.weightx = 1;
        this.add(boxTarif, c);
        this.addView(boxTarif, "ID_TARIF");
        boxTarif.addModelListener("wantedID", new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
                tableBonItem.setTarif(selectedRow, !isFilling());
            }
        });
    }

    if (getTable().contains("A_ATTENTION")) {
        // Date livraison
        c.gridx++;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 0;
        this.add(new JLabel(getLabelFor("A_ATTENTION"), SwingConstants.RIGHT), c);

        JTextField specLivraison = new JTextField();
        c.gridx++;
        c.weightx = 0;
        c.weighty = 0;
        this.add(specLivraison, c);
        this.addView(specLivraison, "A_ATTENTION");
    }

    // Element du bon
    List<JButton> l = new ArrayList<JButton>();
    l.add(boutonAll);
    this.tableBonItem = new BonDeLivraisonItemTable(l);

    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.tableBonItem, c);
    c.anchor = GridBagConstraints.EAST;
    // Totaux
    reconfigure(this.textTotalHT);
    reconfigure(this.textTotalTVA);
    reconfigure(this.textTotalTTC);

    // Poids Total
    c.gridy++;
    c.gridx = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS");
    this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT");
    this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA");
    this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC");
    TotalPanel panelTotal = new TotalPanel(tableBonItem, textTotalHT, textTotalTVA, textTotalTTC,
            new DeviseField(), new DeviseField(), new DeviseField(), new DeviseField(), new DeviseField(),
            textPoidsTotal, null);
    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(panelTotal, c);

    c.anchor = GridBagConstraints.WEST;

    /*******************************************************************************************
     * * INFORMATIONS COMPLEMENTAIRES
     ******************************************************************************************/
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy++;
    TitledSeparator sep = new TitledSeparator("Informations complmentaires");
    c.insets = new Insets(10, 2, 1, 2);
    this.add(sep, c);
    c.insets = new Insets(2, 2, 1, 2);

    ITextArea textInfos = new ITextArea(4, 4);

    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;

    final JScrollPane scrollPane = new JScrollPane(textInfos);
    this.add(scrollPane, c);
    textInfos.setBorder(null);
    DefaultGridBagConstraints.lockMinimumSize(scrollPane);

    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.gridwidth = 4;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;

    this.panelOO = new PanelOOSQLComponent(this);
    this.add(this.panelOO, c);

    this.addRequiredSQLObject(date, "DATE");
    this.addSQLObject(textInfos, "INFOS");
    this.addSQLObject(this.textNom, "NOM");
    this.addSQLObject(this.selectCommande, "ID_COMMANDE_CLIENT");
    this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO");

    this.addRequiredSQLObject(this.comboClient, "ID_CLIENT");

    // Doit etre lock a la fin
    DefaultGridBagConstraints.lockMinimumSize(comboClient);

}

From source file:org.openconcerto.erp.core.supplychain.order.component.CommandeSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Numero du commande
    c.gridx = 0;//from  w w  w .  java 2 s . co  m
    c.weightx = 0;
    this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);

    this.numeroUniqueCommande = new JUniqueTextField(16);
    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande);
    this.add(this.numeroUniqueCommande, c);

    // Date
    JLabel labelDate = new JLabel(getLabelFor("DATE"));
    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 2;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(labelDate, c);

    JDate dateCommande = new JDate(true);
    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    this.add(dateCommande, c);

    // Fournisseur
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_FOURNISSEUR"), SwingConstants.RIGHT), c);

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.fourn, c);

    if (!getTable().getFieldsName().contains("LIVRER")) {
        // Commande en cours
        JCheckBox boxEnCours = new JCheckBox(getLabelFor("EN_COURS"));
        c.gridx = 2;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = GridBagConstraints.REMAINDER;
        this.add(boxEnCours, c);
        c.gridwidth = 1;
        this.addRequiredSQLObject(boxEnCours, "EN_COURS");
    }

    // Fournisseur
    if (getTable().contains("ID_CONTACT_FOURNISSEUR")) {
        c.gridx = 0;
        c.gridy++;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        this.add(new JLabel(getLabelFor("ID_CONTACT_FOURNISSEUR"), SwingConstants.RIGHT), c);

        c.gridx = GridBagConstraints.RELATIVE;
        c.gridwidth = 1;
        c.weightx = 1;
        c.weighty = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        final ElementComboBox boxContactFournisseur = new ElementComboBox();
        final SQLElement contactElement = Configuration.getInstance().getDirectory()
                .getElement("CONTACT_FOURNISSEUR");
        boxContactFournisseur.init(contactElement, contactElement.getComboRequest(true));
        this.add(boxContactFournisseur, c);
        this.addView(boxContactFournisseur, "ID_CONTACT_FOURNISSEUR", REQ);

        fourn.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent arg0) {
                // TODO Raccord de mthode auto-gnr
                if (fourn.getSelectedRow() != null) {
                    boxContactFournisseur.getRequest()
                            .setWhere(new Where(contactElement.getTable().getField("ID_FOURNISSEUR"), "=",
                                    fourn.getSelectedRow().getID()));
                } else {
                    boxContactFournisseur.getRequest().setWhere(null);
                }
            }
        });
    }
    // Adresse de livraison
    if (getTable().getFieldsName().contains("ID_ADRESSE")) {
        if (getTable().getFieldsName().contains("LIVRAISON_F")) {
            c.gridx = 0;
            c.gridy++;
            c.weightx = 0;
            c.fill = GridBagConstraints.HORIZONTAL;
            this.add(new JLabel(getLabelFor("ID_ADRESSE")), c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            // c.gridy++;
            this.addView("ID_ADRESSE");
            final DefaultElementSQLObject comp = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp();

            if (getTable().getFieldsName().contains("LIVRAISON_F")) {
                final JCheckBox boxLivr = new JCheckBox("Livr par le fournisseur");
                this.add(boxLivr, c);
                this.addSQLObject(boxLivr, "LIVRAISON_F");
                boxLivr.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        if (boxLivr.isSelected() && !comp.isCreated()) {
                            comp.setCreated(true);
                            if (CommandeSQLComponent.this.getTable().contains("ID_AFFAIRE")) {

                                SQLRowValues rowVals = getLivraisonAdr(
                                        ((ElementComboBox) CommandeSQLComponent.this.getView("ID_AFFAIRE")
                                                .getComp()).getSelectedRow());

                                comp.setValue(rowVals);
                            }

                        } else {
                            if (!boxLivr.isSelected()) {
                                comp.setCreated(false);
                            }
                        }
                    }
                });
            }

            c.gridy++;
            this.add(comp, c);
            this.add(this.getView("ID_ADRESSE").getComp(), c);
        } else {

            c.gridy++;
            c.gridx = 0;
            this.add(new JLabel("Livraison"), c);
            c.gridx++;
            c.gridwidth = GridBagConstraints.REMAINDER;
            this.add(boxLivrClient, c);
            c.gridwidth = 1;

            final GridBagConstraints cAdr = new DefaultGridBagConstraints();

            panelAdrSpec.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), cAdr);
            final ElementComboBox boxClient = new ElementComboBox(true);
            cAdr.weightx = 1;
            cAdr.gridx++;
            panelAdrSpec.add(boxClient, cAdr);
            this.addView(boxClient, "ID_CLIENT");

            cAdr.gridy++;
            cAdr.weightx = 0;
            cAdr.gridx = 0;
            panelAdrSpec.add(new JLabel("Adresse", SwingConstants.RIGHT), cAdr);
            final SQLRequestComboBox boxAdr = new SQLRequestComboBox(true);
            boxAdr.uiInit(Configuration.getInstance().getDirectory().getElement(getTable().getTable("ADRESSE"))
                    .getComboRequest(true));
            boxClient.addModelListener("wantedID", new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    if (boxClient.getSelectedRow() != null && !boxClient.getSelectedRow().isUndefined()) {
                        Where w = new Where(boxAdr.getRequest().getPrimaryTable().getField("ID_CLIENT"), "=",
                                boxClient.getSelectedRow().getID());
                        w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
                                boxClient.getSelectedRow().getInt("ID_ADRESSE")));
                        w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
                                boxClient.getSelectedRow().getInt("ID_ADRESSE_F")));
                        w = w.or(new Where(boxAdr.getRequest().getPrimaryTable().getKey(), "=",
                                boxClient.getSelectedRow().getInt("ID_ADRESSE_L")));
                        boxAdr.getRequest().setWhere(w);
                    } else {
                        boxAdr.getRequest().setWhere(null);
                    }
                }
            });
            cAdr.weightx = 1;
            cAdr.gridx++;
            panelAdrSpec.add(boxAdr, cAdr);

            cAdr.gridx = 0;
            cAdr.gridy++;
            cAdr.weightx = 0;
            if (getMode() == Mode.MODIFICATION) {
                panelAdrSpec.add(new JLabel(getLabelFor("ID_ADRESSE")), cAdr);
            }
            cAdr.gridx++;
            cAdr.gridwidth = GridBagConstraints.REMAINDER;
            this.addView("ID_ADRESSE");
            compAdr = (DefaultElementSQLObject) this.getView("ID_ADRESSE").getComp();

            cAdr.gridy++;
            if (getMode() == Mode.MODIFICATION) {
                panelAdrSpec.add(compAdr, cAdr);
            }
            boxAdr.addValueListener(new PropertyChangeListener() {

                @Override
                public void propertyChange(PropertyChangeEvent evt) {
                    SQLRow row = boxAdr.getSelectedRow();
                    if (row != null && !row.isUndefined()) {
                        compAdr.setCreated(true);
                        SQLRowValues asRowValues = new SQLRowValues(row.asRowValues());
                        compAdr.setValue(asRowValues);
                    }
                }
            });

            c.gridy++;
            c.gridx = 0;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 1;
            this.add(panelAdrSpec, c);
            c.gridwidth = 1;
            c.weightx = 0;

            boxLivrClient.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    panelAdrSpec.setVisible(boxLivrClient.isSelected());

                    if (!boxLivrClient.isSelected()) {
                        boxClient.setValue((Integer) null);
                        boxAdr.setValue((Integer) null);
                        compAdr.setCreated(false);
                    }
                }
            });
            panelAdrSpec.setVisible(false);
        }
    }
    c.gridwidth = 1;

    // Champ Module
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    final ElementComboBox boxDevise = new ElementComboBox();
    if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE,
            false)) {
        // Devise
        c.gridx = 0;
        c.gridy++;
        c.weightx = 0;
        c.fill = GridBagConstraints.HORIZONTAL;
        this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);

        c.gridx = GridBagConstraints.RELATIVE;
        c.gridwidth = 1;
        c.weightx = 1;
        c.weighty = 0;
        c.fill = GridBagConstraints.NONE;
        this.add(boxDevise, c);
        this.addView(boxDevise, "ID_DEVISE");
    }

    // Reference
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.EAST;
    this.add(new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT), c);

    final JTextField textNom = new JTextField();
    c.gridx++;
    c.weightx = 1;
    this.add(textNom, c);

    String field;
    field = "ID_COMMERCIAL";
    // Commercial
    c.weightx = 0;
    c.gridx++;
    this.add(new JLabel(getLabelFor(field), SwingConstants.RIGHT), c);

    ElementComboBox commSel = new ElementComboBox(false, 25);
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    this.add(commSel, c);
    addRequiredSQLObject(commSel, field);

    // Table d'lment
    c.fill = GridBagConstraints.BOTH;
    c.gridy++;
    c.gridx = 0;
    c.weightx = 0;
    c.weighty = 1;
    c.gridwidth = 4;
    this.add(this.table, c);
    if (DefaultNXProps.getInstance().getBooleanValue(AbstractVenteArticleItemTable.ARTICLE_SHOW_DEVISE,
            false)) {

        boxDevise.addValueListener(new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                table.setDevise(boxDevise.getSelectedRow());

            }
        });
    }

    this.fourn.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            table.setFournisseur(fourn.getSelectedRow());
        }
    });
    // Bottom
    c.gridy++;
    c.weighty = 0;
    this.add(getBottomPanel(), c);

    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;

    JPanel panelOO = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    panelOO.add(this.checkImpression, c);
    panelOO.add(this.checkVisu, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(panelOO, c);

    addRequiredSQLObject(this.fourn, "ID_FOURNISSEUR");
    addSQLObject(textNom, "NOM");
    addRequiredSQLObject(dateCommande, "DATE");
    // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
    addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
    addSQLObject(this.infos, "INFOS");

    this.numeroUniqueCommande.setText(NumerotationAutoSQLElement.getNextNumero(CommandeSQLElement.class));

    // radioEtat.setValue(EtatDevisSQLElement.EN_ATTENTE);
    // this.numeroUniqueDevis.addLabelWarningMouseListener(new MouseAdapter() {
    // public void mousePressed(MouseEvent e) {
    //
    // if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
    // numeroUniqueDevis.setText(NumerotationAutoSQLElement.getNextNumeroDevis());
    // }
    // }
    // });

    DefaultGridBagConstraints.lockMinimumSize(this.fourn);
    DefaultGridBagConstraints.lockMinimumSize(commSel);
}

From source file:org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Champ Module
    c.gridx = 0;//from ww w  .  j  a  v a 2s .  c  o m
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    this.textTotalHT.setOpaque(false);
    this.textTotalTVA.setOpaque(false);
    this.textTotalTTC.setOpaque(false);

    this.selectCommande = new ElementComboBox();
    // Numero
    JLabel labelNum = new JLabel(getLabelFor("NUMERO"));
    labelNum.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNum, c);

    this.textNumeroUnique = new JUniqueTextField(16);
    c.gridx++;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique);
    this.add(this.textNumeroUnique, c);

    // Date
    JLabel labelDate = new JLabel(getLabelFor("DATE"));
    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx++;
    c.weightx = 0;
    this.add(labelDate, c);

    JDate date = new JDate(true);
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    this.add(date, c);
    // Reference
    c.gridy++;
    c.gridx = 0;
    final JLabel labelNom = new JLabel(getLabelFor("NOM"));
    labelNom.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNom, c);
    c.gridx++;
    c.fill = GridBagConstraints.HORIZONTAL;
    DefaultGridBagConstraints.lockMinimumSize(this.textReference);
    this.add(this.textReference, c);
    // Fournisseur
    JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR"));
    labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.weighty = 0;
    this.add(labelFournisseur, c);

    this.fournisseur = new ElementComboBox();
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.fournisseur, c);

    // Devise
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);

    final ElementComboBox boxDevise = new ElementComboBox();
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(boxDevise, c);
    this.addView(boxDevise, "ID_DEVISE");

    // Element du bon
    this.tableBonItem = new BonReceptionItemTable();
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.tableBonItem, c);
    this.fournisseur.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            tableBonItem.setFournisseur(fournisseur.getSelectedRow());
        }
    });

    c.anchor = GridBagConstraints.EAST;
    // Totaux
    reconfigure(this.textTotalHT);
    reconfigure(this.textTotalTVA);
    reconfigure(this.textTotalTTC);

    // Poids Total
    c.gridy++;
    c.gridx = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;

    DefaultProps props = DefaultNXProps.getInstance();
    Boolean b = props.getBooleanValue("ArticleShowPoids");
    if (b) {
        JPanel panelPoids = new JPanel(new GridBagLayout());
        GridBagConstraints c2 = new DefaultGridBagConstraints();
        c2.fill = GridBagConstraints.NONE;

        panelPoids.add(new JLabel(getLabelFor("TOTAL_POIDS")), c2);
        // Necessaire pour ne pas avoir de saut de layout
        DefaultGridBagConstraints.lockMinimumSize(this.textPoidsTotal);
        this.textPoidsTotal.setEnabled(false);
        this.textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
        this.textPoidsTotal.setDisabledTextColor(Color.BLACK);
        c2.gridx++;
        c2.weightx = 1;
        c2.fill = GridBagConstraints.HORIZONTAL;
        panelPoids.add(this.textPoidsTotal, c2);
        this.add(panelPoids, c);

    }

    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    final GridBagConstraints cTotalPan = new DefaultGridBagConstraints();

    JPanel panelTotalHT = new JPanel();
    panelTotalHT.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.weightx = 0;
    cTotalPan.fill = GridBagConstraints.HORIZONTAL;
    cTotalPan.anchor = GridBagConstraints.WEST;
    final JLabelBold labelTotalHT = new JLabelBold(getLabelFor("TOTAL_HT"));
    panelTotalHT.add(labelTotalHT, cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    cTotalPan.weightx = 1;
    this.textTotalHT.setFont(labelTotalHT.getFont());
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalHT);
    panelTotalHT.add(this.textTotalHT, cTotalPan);
    this.add(panelTotalHT, c);

    JPanel panelTotalTVA = new JPanel();
    panelTotalTVA.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.weightx = 0;
    cTotalPan.anchor = GridBagConstraints.WEST;
    cTotalPan.fill = GridBagConstraints.HORIZONTAL;
    panelTotalTVA.add(new JLabelBold(getLabelFor("TOTAL_TVA")), cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    cTotalPan.weightx = 1;
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalTVA);
    panelTotalTVA.add(this.textTotalTVA, cTotalPan);
    c.gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(panelTotalTVA, c);

    JPanel panelTotalTTC = new JPanel();
    panelTotalTTC.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.anchor = GridBagConstraints.WEST;
    cTotalPan.gridwidth = GridBagConstraints.REMAINDER;
    cTotalPan.fill = GridBagConstraints.BOTH;
    cTotalPan.weightx = 1;
    panelTotalTTC.add(new JSeparator(), cTotalPan);
    cTotalPan.gridwidth = 1;
    cTotalPan.fill = GridBagConstraints.NONE;
    cTotalPan.weightx = 0;
    cTotalPan.gridy++;
    panelTotalTTC.add(new JLabelBold(getLabelFor("TOTAL_TTC")), cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    this.textTotalTTC.setFont(labelTotalHT.getFont());
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalTTC);
    panelTotalTTC.add(this.textTotalTTC, cTotalPan);
    c.gridy++;
    // probleme de tremblement vertical
    this.add(panelTotalTTC, c);
    c.anchor = GridBagConstraints.WEST;

    /*******************************************************************************************
     * * INFORMATIONS COMPLEMENTAIRES
     ******************************************************************************************/
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy++;
    TitledSeparator sep = new TitledSeparator("Informations complmentaires");
    c.insets = new Insets(10, 2, 1, 2);
    this.add(sep, c);
    c.insets = new Insets(2, 2, 1, 2);

    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    final ITextArea textInfos = new ITextArea(4, 4);
    JScrollPane scrollPane = new JScrollPane(textInfos);
    DefaultGridBagConstraints.lockMinimumSize(scrollPane);

    this.add(textInfos, c);

    this.addRequiredSQLObject(date, "DATE");
    this.addSQLObject(textInfos, "INFOS");
    this.addSQLObject(this.textReference, "NOM");
    this.addSQLObject(this.selectCommande, "ID_COMMANDE");
    this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO");
    this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS");
    this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT");
    this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA");
    this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC");
    this.addRequiredSQLObject(this.fournisseur, "ID_FOURNISSEUR");

    this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(BonReceptionSQLElement.class));

    // Listeners
    this.tableBonItem.getModel().addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {

            int columnIndexHT = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement(
                    BonReceptionSQLComponent.this.tableBonItem.getPrixTotalHTElement());
            int columnIndexTTC = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement(
                    BonReceptionSQLComponent.this.tableBonItem.getPrixTotalTTCElement());
            int columnIndexPoids = BonReceptionSQLComponent.this.tableBonItem.getModel()
                    .getColumnIndexForElement(
                            BonReceptionSQLComponent.this.tableBonItem.getPoidsTotalElement());

            if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexHT
                    || e.getColumn() == columnIndexTTC) {
                updateTotal();
            }
            if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexPoids) {
                BonReceptionSQLComponent.this.textPoidsTotal.setText(String
                        .valueOf(Math.round(BonReceptionSQLComponent.this.tableBonItem.getPoidsTotal() * 1000)
                                / 1000.0));
            }
        }
    });

    // Lock UI
    DefaultGridBagConstraints.lockMinimumSize(this.fournisseur);

}