Example usage for java.awt GridBagConstraints HORIZONTAL

List of usage examples for java.awt GridBagConstraints HORIZONTAL

Introduction

In this page you can find the example usage for java.awt GridBagConstraints HORIZONTAL.

Prototype

int HORIZONTAL

To view the source code for java.awt GridBagConstraints HORIZONTAL.

Click Source Link

Document

Resize the component horizontally but not vertically.

Usage

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  w w .jav a2  s .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:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java

private void addSparkClustersLineItem() {
    JLabel sparkClusterLabel = new JLabel("Spark clusters(Linux only)");
    sparkClusterLabel.setToolTipText(/*from  w w w . j  a v  a 2s.  c o  m*/
            "The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
    GridBagConstraints c11 = new GridBagConstraints();
    c11.gridx = 0;
    c11.gridy = 0;
    c11.insets = new Insets(margin, margin, 0, margin);
    add(sparkClusterLabel, new GridBagConstraints(0, displayLayoutCurrentRow, 1, 1, 0, 0,
            GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0));

    clustersListComboBox = new ComboboxWithBrowseButton();
    clustersListComboBox.setButtonIcon(StreamUtil.getImageResourceFile(REFRESH_BUTTON_PATH));
    clustersListComboBox.getButton().setToolTipText("Refresh");
    clustersListComboBox.getButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Cursor cursor = getCursor();
            setCursor(new Cursor(Cursor.WAIT_CURSOR));
            List<IClusterDetail> clusterDetails = ClusterManagerEx.getInstance()
                    .getClusterDetails(submitModel.getProject());
            setCursor(cursor);
            submitModel.setClusterComboBoxModel(clusterDetails);
        }
    });
    clustersListComboBox.getComboBox().setToolTipText(
            "The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported.");
    clustersListComboBox.getComboBox().addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName() == "model" && evt.getNewValue() instanceof DefaultComboBoxModel) {
                int size = ((DefaultComboBoxModel) evt.getNewValue()).getSize();
                setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.ClusterName.ordinal(), size <= 0);
            }
        }
    });

    add(clustersListComboBox,
            new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0));

    errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()] = new JLabel(
            "Cluster Name Should not be null");
    errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()]
            .setForeground(DarkThemeManager.getInstance().getErrorMessageColor());

    clustersListComboBox.getComboBox().addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            setVisibleForFixedErrorMessageLabel(0, clustersListComboBox.getComboBox().getItemCount() == 0);
        }
    });

    add(errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()],
            new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST,
                    GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0));
}

From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java

/**
 * Creates a new RegistryBrowser object.
 *//*from   ww w  .  j av  a  2 s  .  co  m*/
@SuppressWarnings("unchecked")
private RegistryBrowser() {
    instance = this;

    classLoader = getClass().getClassLoader(); // new
    // JAXRBrowserClassLoader(getClass().getClassLoader());
    Thread.currentThread().setContextClassLoader(classLoader);

    /*
     * try { classLoader.loadClass("javax.xml.soap.SOAPMessage"); } catch
     * (ClassNotFoundException e) {
     * log.error("Could not find class javax.xml.soap.SOAPMessage", e); }
     */

    UIManager.addPropertyChangeListener(new UISwitchListener(getRootPane()));

    // add listener for 'locale' bound property
    addPropertyChangeListener(PROPERTY_LOCALE, this);

    menuBar = new JMenuBar();
    fileMenu = new JMenu();
    editMenu = new JMenu();
    viewMenu = new JMenu();
    helpMenu = new JMenu();

    JSeparator JSeparator1 = new JSeparator();
    newItem = new JMenuItem();
    importItem = new JMenuItem();
    saveItem = new JMenuItem();
    saveAsItem = new JMenuItem();
    exitItem = new JMenuItem();
    cutItem = new JMenuItem();
    copyItem = new JMenuItem();
    pasteItem = new JMenuItem();
    aboutItem = new JMenuItem();
    setJMenuBar(menuBar);
    setTitle(resourceBundle.getString("title.registryBrowser.java"));
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout(0, 0));

    // Scale window to be centered using 70% of screen
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

    setBounds((int) (dim.getWidth() * .15), (int) (dim.getHeight() * .1), (int) (dim.getWidth() * .7),
            (int) (dim.getHeight() * .75));
    setVisible(false);
    saveFileDialog.setMode(FileDialog.SAVE);
    saveFileDialog.setTitle(resourceBundle.getString("dialog.save.title"));

    GridBagLayout gb = new GridBagLayout();

    topPanel.setLayout(gb);
    getContentPane().add("North", topPanel);

    GridBagConstraints c = new GridBagConstraints();
    toolbarPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 0, 0));
    toolbarPanel.setBounds(0, 0, 488, 29);

    discoveryToolBar = createDiscoveryToolBar();
    toolbarPanel.add(discoveryToolBar);

    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(toolbarPanel, c);
    topPanel.add(toolbarPanel);

    // Panel containing context info like registry location and user context
    JPanel contextPanel = new JPanel();
    GridBagLayout gb1 = new GridBagLayout();
    contextPanel.setLayout(gb1);

    locationLabel = new JLabel(resourceBundle.getString("label.registryLocation"));

    // locationLabel.setPreferredSize(new Dimension(80, 23));
    // c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 0, 0);
    gb1.setConstraints(locationLabel, c);

    // contextPanel.setBackground(Color.green);
    contextPanel.add(locationLabel);

    selectAnItemText = new ItemText(selectAnItem);
    registryCombo.addItem(selectAnItemText.toString());

    ConfigurationType uiConfigurationType = UIUtility.getInstance().getConfigurationType();
    RegistryURIListType urlList = uiConfigurationType.getRegistryURIList();

    List<String> urls = urlList.getRegistryURI();
    Iterator<String> urlsIter = urls.iterator();
    while (urlsIter.hasNext()) {
        ItemText url = new ItemText(urlsIter.next());
        registryCombo.addItem(url.toString());
    }

    registryCombo.setEditable(true);
    registryCombo.setEnabled(true);
    registryCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            final String url = (String) registryCombo.getSelectedItem();
            if ((url == null) || (url.equals(selectAnItem))) {
                return;
            }

            // Clean tabbedPaneParent. Will create new content
            tabbedPaneParent.removeAll();
            conceptsTreeDialog = null;
            ConceptsTreeDialog.clearCache();

            // design:
            // 1. connect and construct tabbedPane in a now swing thread
            // 2. add tabbedPane in swing thread
            // 3. call reloadModel that should use WingWorkers
            final SwingWorker worker1 = new SwingWorker(RegistryBrowser.this) {
                public Object doNonUILogic() {
                    try {
                        // Try to connect
                        if (connectToRegistry(url)) {
                            return new JBTabbedPane();
                        }
                    } catch (JAXRException e1) {
                        displayError(e1);
                    }
                    return null;
                }

                public void doUIUpdateLogic() {
                    tabbedPane = (JBTabbedPane) get();
                    if (tabbedPane != null) {
                        tabbedPaneParent.add(tabbedPane, BorderLayout.CENTER);
                        tabbedPane.reloadModel();
                        try {
                            // DBH 1/30/04 - Add the submissions panel if
                            // the user is authenticated.
                            ConnectionImpl connection = RegistryBrowser.client.connection;
                            boolean newValue = connection.isAuthenticated();
                            firePropertyChange(PROPERTY_AUTHENTICATED, false, newValue);
                            getRootPane().updateUI();
                        } catch (JAXRException e1) {
                            displayError(e1);
                        }
                    }
                }
            };
            worker1.start();
        }
    });
    // c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 5, 0);
    gb1.setConstraints(registryCombo, c);
    contextPanel.add(registryCombo);

    JLabel currentUserLabel = new JLabel(resourceBundle.getString("label.currentUser"),
            SwingConstants.TRAILING);
    c.gridx = 2;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    gb1.setConstraints(currentUserLabel, c);

    // contextPanel.add(currentUserLabel);
    currentUserText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            @SuppressWarnings("unused")
            String text = currentUserText.getText();
        }
    });

    currentUserText.setEditable(false);
    c.gridx = 3;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 5, 5);
    gb1.setConstraints(currentUserText, c);

    // contextPanel.add(currentUserText);
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.9;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(0, 0, 0, 0);
    gb.setConstraints(contextPanel, c);
    topPanel.add(contextPanel, c);

    tabbedPaneParent.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    tabbedPaneParent.setLayout(new BorderLayout());
    tabbedPaneParent.setToolTipText(resourceBundle.getString("tabbedPane.tip"));

    getContentPane().add("Center", tabbedPaneParent);

    fileMenu.setText(resourceBundle.getString("menu.file"));
    fileMenu.setActionCommand("File");
    fileMenu.setMnemonic((int) 'F');
    menuBar.add(fileMenu);

    saveItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    saveItem.setText(resourceBundle.getString("menu.save"));
    saveItem.setActionCommand("Save");
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
    saveItem.setMnemonic((int) 'S');

    // fileMenu.add(saveItem);
    fileMenu.add(JSeparator1);
    importItem.setText(resourceBundle.getString("menu.import"));
    importItem.setActionCommand("Import");
    importItem.setMnemonic((int) 'I');
    importItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();
            importFromFile();
            RegistryBrowser.setDefaultCursor();
        }
    });
    fileMenu.add(importItem);

    exitItem.setText(resourceBundle.getString("menu.exit"));
    exitItem.setActionCommand("Exit");
    exitItem.setMnemonic((int) 'X');
    fileMenu.add(exitItem);

    editMenu.setText(resourceBundle.getString("menu.edit"));
    editMenu.setActionCommand("Edit");
    editMenu.setMnemonic((int) 'E');

    // menuBar.add(editMenu);
    cutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    cutItem.setText(resourceBundle.getString("menu.cut"));
    cutItem.setActionCommand("Cut");
    cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
    cutItem.setMnemonic((int) 'T');
    editMenu.add(cutItem);

    copyItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    copyItem.setText(resourceBundle.getString("menu.copy"));
    copyItem.setActionCommand("Copy");
    copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
    copyItem.setMnemonic((int) 'C');
    editMenu.add(copyItem);

    pasteItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    pasteItem.setText(resourceBundle.getString("menu.paste"));
    pasteItem.setActionCommand("Paste");
    pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
    pasteItem.setMnemonic((int) 'P');
    editMenu.add(pasteItem);

    viewMenu.setText(resourceBundle.getString("menu.view"));
    viewMenu.setActionCommand("view");
    viewMenu.setMnemonic((int) 'V');

    themeMenu = new MetalThemeMenu(resourceBundle.getString("menu.theme"), themes);
    viewMenu.add(themeMenu);
    menuBar.add(viewMenu);

    helpMenu.setText(resourceBundle.getString("menu.help"));
    helpMenu.setActionCommand("Help");
    helpMenu.setMnemonic((int) 'H');
    menuBar.add(helpMenu);
    aboutItem.setHorizontalTextPosition(SwingConstants.TRAILING);
    aboutItem.setText(resourceBundle.getString("menu.about"));
    aboutItem.setActionCommand("About...");
    aboutItem.setMnemonic((int) 'A');

    aboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Object[] aboutArgs = { BROWSER_VERSION };
            MessageFormat form = new MessageFormat(resourceBundle.getString("dialog.about.text"));
            JOptionPane.showMessageDialog(RegistryBrowser.this, form.format(aboutArgs),
                    resourceBundle.getString("dialog.about.title"), JOptionPane.INFORMATION_MESSAGE);
        }
    });

    helpMenu.add(aboutItem);

    // REGISTER_LISTENERS
    SymWindow aSymWindow = new SymWindow();

    this.addWindowListener(aSymWindow);

    SymAction lSymAction = new SymAction();

    saveItem.addActionListener(lSymAction);
    exitItem.addActionListener(lSymAction);

    SwingUtilities.updateComponentTreeUI(getContentPane());
    SwingUtilities.updateComponentTreeUI(menuBar);
    SwingUtilities.updateComponentTreeUI(fileChooser);

    // Auto select the registry that is configured to connect to by default
    String selectedIndexStr = ProviderProperties.getInstance()
            .getProperty("jaxr-ebxml.registryBrowser.registryLocationCombo.initialSelectionIndex", "0");

    int index = Integer.parseInt(selectedIndexStr);

    try {
        registryCombo.setSelectedIndex(index);
    } catch (IllegalArgumentException e) {
        Object[] invalidIndexArguments = { new Integer(index) };
        MessageFormat form = new MessageFormat(resourceBundle.getString("message.error.invalidIndex"));
        displayError(form.format(invalidIndexArguments), e);
    }
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.ChannelAcquisitionComponent.java

/** Builds and lays out the UI. */
private void buildGUI() {
    setBackground(UIUtilities.BACKGROUND_COLOR);
    parent.layoutFields(generalPane, unsetGeneral, fieldsGeneral, unsetGeneralShown);

    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.BOTH;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.insets = new Insets(0, 2, 2, 0);
    constraints.weightx = 1.0;/*from w  w w . jav  a 2s  . c om*/
    constraints.gridy = 0;
    if (generalPane.isVisible()) {
        add(generalPane, constraints);
        ++constraints.gridy;
    }
    if (detectorPane.isVisible()) {
        add(detectorPane, constraints);
        ++constraints.gridy;
    }
    if (lightPane.isVisible()) {
        add(lightPane, constraints);
        ++constraints.gridy;
    }
    if (lightPathPane != null) {
        add(lightPathPane, constraints);
        ++constraints.gridy;
    }
    if (filterSetPane != null) {
        add(filterSetPane, constraints);
        ++constraints.gridy;
    }
    constraints.fill = GridBagConstraints.HORIZONTAL;
    add(exposureTask, constraints);
    parent.attachListener(fieldsGeneral);
}

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());
                    }//from w w w . j  a va  2  s  . c  o  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:TalkServerThread.java

public void init() {
        //Get the address of the host we came from.
        host = getCodeBase().getHost();//from  w  w w  .  j a v a2  s .c om

        //Set up the UI.
        GridBagLayout gridBag = new GridBagLayout();
        GridBagConstraints c = new GridBagConstraints();
        setLayout(gridBag);

        message = new TextField("");
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = GridBagConstraints.REMAINDER;
        gridBag.setConstraints(message, c);
        message.addActionListener(this);
        add(message);

        display = new TextArea(10, 40);
        display.setEditable(false);
        c.weightx = 1.0;
        c.weighty = 1.0;
        c.fill = GridBagConstraints.BOTH;
        gridBag.setConstraints(display, c);
        add(display);

        Label l = new Label("Enter the port (on host " + host + ") to send the request to:", Label.RIGHT);
        c.fill = GridBagConstraints.HORIZONTAL;
        c.gridwidth = 1;
        c.weightx = 0.0;
        c.weighty = 0.0;
        gridBag.setConstraints(l, c);
        add(l);

        portField = new TextField(6);
        c.fill = GridBagConstraints.NONE;
        gridBag.setConstraints(portField, c);
        portField.addActionListener(this);
        add(portField);

        button = new Button("Connect");
        gridBag.setConstraints(button, c);
        button.addActionListener(this);
        add(button);

        newline = System.getProperty("line.separator");
    }

From source file:org.docx4all.swing.ExternalHyperlinkDialog.java

private void fillRow3(JPanel host, GridBagConstraints c) {
    c.gridx = 0;//w ww  .j ava  2  s.  co  m
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.NONE;
    this.documentNameLabel = new JLabel("Document Name");
    host.add(this.documentNameLabel, c);

    c.gridx = 1;
    c.gridy = 2;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.insets = gridCellInsets;
    c.ipadx = 0;
    c.ipady = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.documentNameField = new JTextField(70);
    //this.documentNameField.setMinimumSize(new Dimension(100, 70));
    //this.documentNameField.setPreferredSize(new Dimension(100, 70));
    host.add(this.documentNameField, c);
}

From source file:com.dbschools.quickquiz.client.giver.MainWindow.java

/** This method is called from within the constructor to
 * initialize the form./*from  ww w .j  a  va  2  s .  co  m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    pnlPlayers = new javax.swing.JPanel();
    pnlChat = new javax.swing.JPanel();
    jLabel4 = new javax.swing.JLabel();
    txtChatLine = new javax.swing.JTextField();
    btnSendChatLine = new javax.swing.JButton();
    chkChatEnabled = new javax.swing.JCheckBox();
    pnlMessages = new javax.swing.JPanel();
    scpMessages = new javax.swing.JScrollPane();
    lstMessages = new javax.swing.JList();
    pnlQA = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    countdownMeter = new com.dbschools.gui.CountdownMeter();
    pnlButtons = new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    jLabel3 = new javax.swing.JLabel();
    txtTimeLimit = new javax.swing.JFormattedTextField();
    btnSendQuestion = new javax.swing.JButton();
    pnlAward = new javax.swing.JPanel();
    btnAwardPoints = new javax.swing.JButton();
    sprPoints = new javax.swing.JSpinner();
    cbxQuestions = new javax.swing.JComboBox();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    mnuReset = new javax.swing.JMenuItem();
    jMenuItem1 = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    mnuLoad = new javax.swing.JMenuItem();

    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            exitForm(evt);
        }
    });
    getContentPane().setLayout(new java.awt.GridBagLayout());

    java.util.ResourceBundle bundle = java.util.ResourceBundle
            .getBundle("com/dbschools/quickquiz/client/giver/Bundle"); // NOI18N
    pnlPlayers.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("takers"))); // NOI18N
    pnlPlayers.setPreferredSize(new java.awt.Dimension(600, 250));
    pnlPlayers.setRequestFocusEnabled(false);
    pnlPlayers.setLayout(new javax.swing.BoxLayout(pnlPlayers, javax.swing.BoxLayout.LINE_AXIS));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 0.6;
    gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
    getContentPane().add(pnlPlayers, gridBagConstraints);

    pnlChat.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("chat"))); // NOI18N
    pnlChat.setLayout(new java.awt.GridBagLayout());

    jLabel4.setDisplayedMnemonic('m');
    jLabel4.setLabelFor(txtChatLine);
    jLabel4.setText(bundle.getString("chatMessage")); // NOI18N
    pnlChat.add(jLabel4, new java.awt.GridBagConstraints());

    txtChatLine.setColumns(40);
    java.util.ResourceBundle bundle1 = java.util.ResourceBundle.getBundle("quickquiz"); // NOI18N
    txtChatLine.setToolTipText(bundle1.getString("tttChatMessage")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2);
    pnlChat.add(txtChatLine, gridBagConstraints);

    btnSendChatLine.setText(bundle.getString("sendChatLine")); // NOI18N
    btnSendChatLine.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSendChatLineActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2);
    pnlChat.add(btnSendChatLine, gridBagConstraints);

    chkChatEnabled.setSelected(true);
    chkChatEnabled.setText("Enabled");
    chkChatEnabled.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            chatEnable(evt);
        }
    });
    pnlChat.add(chkChatEnabled, new java.awt.GridBagConstraints());

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 5;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
    getContentPane().add(pnlChat, gridBagConstraints);

    pnlMessages.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("messages"))); // NOI18N
    pnlMessages.setLayout(new javax.swing.BoxLayout(pnlMessages, javax.swing.BoxLayout.LINE_AXIS));

    lstMessages.setFont(new java.awt.Font("SansSerif", 0, 10));
    lstMessages.setModel(new MessagesListModel());
    lstMessages.setFocusable(false);
    lstMessages.setRequestFocusEnabled(false);
    scpMessages.setViewportView(lstMessages);

    pnlMessages.add(scpMessages);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 6;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weighty = 0.4;
    gridBagConstraints.insets = new java.awt.Insets(5, 2, 0, 2);
    getContentPane().add(pnlMessages, gridBagConstraints);

    pnlQA.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("qa"))); // NOI18N
    pnlQA.setLayout(new java.awt.GridBagLayout());

    jLabel2.setDisplayedMnemonic('q');
    jLabel2.setLabelFor(cbxQuestions);
    jLabel2.setText(bundle.getString("question")); // NOI18N
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    pnlQA.add(jLabel2, gridBagConstraints);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    pnlQA.add(countdownMeter, gridBagConstraints);

    pnlButtons.setLayout(new javax.swing.BoxLayout(pnlButtons, javax.swing.BoxLayout.LINE_AXIS));

    jLabel3.setDisplayedMnemonic('l');
    jLabel3.setLabelFor(txtTimeLimit);
    jLabel3.setText(bundle.getString("timeLimit")); // NOI18N
    jPanel2.add(jLabel3);

    txtTimeLimit.setColumns(3);
    txtTimeLimit.setToolTipText(bundle1.getString("tttTimeLimit")); // NOI18N
    txtTimeLimit.setValue(new Integer(20));
    jPanel2.add(txtTimeLimit);

    btnSendQuestion.setMnemonic('s');
    btnSendQuestion.setText(bundle.getString("sendQuestion")); // NOI18N
    btnSendQuestion.setToolTipText(bundle1.getString("tttSendQuestion")); // NOI18N
    btnSendQuestion.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnSendQuestionActionPerformed(evt);
        }
    });
    jPanel2.add(btnSendQuestion);

    pnlButtons.add(jPanel2);

    btnAwardPoints.setMnemonic('a');
    btnAwardPoints.setText(bundle.getString("winnerButton")); // NOI18N
    btnAwardPoints.setToolTipText(bundle.getString("tttAssignWinner")); // NOI18N
    btnAwardPoints.setEnabled(false);
    btnAwardPoints.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnAwardPointsActionPerformed(evt);
        }
    });
    pnlAward.add(btnAwardPoints);

    sprPoints.setToolTipText(bundle.getString("tttWinnerPoints")); // NOI18N
    sprPoints.setPreferredSize(new java.awt.Dimension(50, 24));
    pnlAward.add(sprPoints);

    pnlButtons.add(pnlAward);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 4;
    gridBagConstraints.gridwidth = 3;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    pnlQA.add(pnlButtons, gridBagConstraints);

    cbxQuestions.setEditable(true);
    cbxQuestions.setMaximumRowCount(100);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
    gridBagConstraints.weightx = 2.0;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    pnlQA.add(cbxQuestions, gridBagConstraints);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
    getContentPane().add(pnlQA, gridBagConstraints);

    jMenu1.setText(bundle.getString("quiz")); // NOI18N

    mnuReset.setText(bundle.getString("resetButton")); // NOI18N
    mnuReset.setToolTipText(bundle.getString("tttResetButton")); // NOI18N
    mnuReset.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            mnuResetActionPerformed(evt);
        }
    });
    jMenu1.add(mnuReset);

    jMenuItem1.setText("Add Simulated Takers");
    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            addSimulatedTakers(evt);
        }
    });
    jMenu1.add(jMenuItem1);

    jMenuBar1.add(jMenu1);

    jMenu2.setText(bundle.getString("questions")); // NOI18N

    mnuLoad.setText(bundle.getString("load")); // NOI18N
    mnuLoad.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            mnuLoadActionPerformed(evt);
        }
    });
    jMenu2.add(mnuLoad);

    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    pack();
}

From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java

/**
 * This method initializes jPanel2   //from w  w  w . j a va2 s.c o  m
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelForOkReset() {
    if (jPanelForOkReset == null) {
        GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
        gridBagConstraints15.insets = new Insets(5, 0, 7, 0);
        gridBagConstraints15.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints15.gridx = 0;
        gridBagConstraints15.gridy = 0;
        GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
        gridBagConstraints12.insets = new Insets(0, 0, 0, 0);
        gridBagConstraints12.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints12.gridx = 0;
        gridBagConstraints12.gridy = 1;
        GridBagConstraints gridBagConstraintsAdvanced = new GridBagConstraints();
        gridBagConstraintsAdvanced.insets = new Insets(20, 0, 0, 0);
        gridBagConstraintsAdvanced.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsAdvanced.gridx = 0;
        gridBagConstraintsAdvanced.gridy = 3;
        jPanelForOkReset = new JPanel();
        jPanelForOkReset.setLayout(new GridBagLayout());
        jPanelForOkReset.add(getJButtonOK(), gridBagConstraints15);
        jPanelForOkReset.add(getJButtonCancel(), gridBagConstraints12);
        jPanelForOkReset.add(getJButtonAdvanced(), gridBagConstraintsAdvanced);
    }
    return jPanelForOkReset;
}

From source file:org.multibit.viewsystem.swing.view.panels.ShowPreferencesPanel.java

private void initUI() {
    setMinimumSize(new Dimension(550, 160));
    setLayout(new BorderLayout());
    setOpaque(true);/*from ww  w. j av  a  2s.  com*/
    setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);

    JPanel mainPanel = new JPanel();
    mainPanel.setOpaque(false);

    String[] keys = new String[] { "fontChooser.fontName", "fontChooser.fontStyle", "fontChooser.fontSize",
            "showPreferencesPanel.ticker.exchange", "showPreferencesPanel.ticker.currency",
            "showPreferencesPanel.lookAndFeel", "showPreferencesPanel.oerLabel.text" };
    int stentWidth = MultiBitTitledPanel.calculateStentWidthForKeys(controller.getLocaliser(), keys, this)
            + STENT_DELTA;

    GridBagConstraints constraints = new GridBagConstraints();
    mainPanel.setLayout(new GridBagLayout());

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.gridwidth = 2;
    constraints.weightx = 1;
    constraints.weighty = 1.6;
    constraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
    // Disable language selection, uncomment to enable
    //        mainPanel.add(createLanguagePanel(stentWidth), constraints);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 2;
    constraints.gridwidth = 2;
    constraints.weightx = 1;
    constraints.weighty = 1.6;
    constraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
    mainPanel.add(createAppearancePanel(stentWidth), constraints);

    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.gridwidth = 2;
    constraints.weightx = 1;
    constraints.weighty = 1.6;
    constraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
    mainPanel.add(createMessagingServerPanel(stentWidth), constraints);

    /*
         constraints.fill = GridBagConstraints.HORIZONTAL;
         constraints.gridx = 0;
         constraints.gridy = 3;
         constraints.gridwidth = 2;
         constraints.weightx = 1;
         constraints.weighty = 1.6;
         constraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
         mainPanel.add(createTickerPanel(stentWidth), constraints);
    */
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 4;
    constraints.gridwidth = 2;
    constraints.weightx = 1;
    constraints.weighty = 1.6;
    constraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
    mainPanel.add(createBrowserIntegrationPanel(stentWidth), constraints);

    JLabel filler1 = new JLabel();
    filler1.setOpaque(false);
    constraints.fill = GridBagConstraints.BOTH;
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.gridwidth = 2;
    constraints.weightx = 1;
    constraints.weighty = 100;
    constraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
    mainPanel.add(filler1, constraints);

    JScrollPane mainScrollPane = new JScrollPane(mainPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    mainScrollPane.setBorder(BorderFactory.createEmptyBorder());
    mainScrollPane.getViewport().setBackground(ColorAndFontConstants.VERY_LIGHT_BACKGROUND_COLOR);
    mainScrollPane.getViewport().setOpaque(true);
    mainScrollPane.getHorizontalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT);
    mainScrollPane.getVerticalScrollBar().setUnitIncrement(CoreModel.SCROLL_INCREMENT);

    add(mainScrollPane, BorderLayout.CENTER);

    JPanel buttonPanel = createButtonPanel();
    buttonPanel.setMinimumSize(new Dimension(60, 60));
    add(buttonPanel, BorderLayout.SOUTH);
}