public BalanceAgeePanel() {
    super(new GridBagLayout());

    JLabel label = new JLabel("Balance âgée client pour la période du ");

    SQLRow rowExercice =
        ((ComptaPropsConfiguration) Configuration.getInstance())
            .getRowSociete()
            .getForeignRow("ID_EXERCICE_COMMON");
    Calendar dDebut = rowExercice.getDate("DATE_DEB");
    final JDate dateDeb = new JDate();
    dateDeb.setDate(dDebut.getTime());
    final JDate dateFin = new JDate(true);

    DefaultGridBagConstraints c = new DefaultGridBagConstraints();
    c.gridx = GridBagConstraints.RELATIVE;
    this.add(label, c);
    this.add(dateDeb, c);
    this.add(new JLabel("au"), c);
    this.add(dateFin, c);

    c.gridy++;
    c.gridx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JCheckBox boxExcludeEcr = new JCheckBox("Exclure les écritures de clotures");
    boxExcludeEcr.setSelected(true);
    this.add(boxExcludeEcr, c);

    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    JButton gen = new JButton("Créer");

    this.add(gen, c);

    gen.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            BalanceAgeeListeSheetXML l =
                new BalanceAgeeListeSheetXML(
                    dateDeb.getDate(), dateFin.getDate(), boxExcludeEcr.isSelected());

            try {
              l.createDocument();
              l.openDocument(false);
            } catch (Exception originalExn) {
              ExceptionHandler.handle("Impossible de créer la balance âgée", originalExn);
            }
          }
        });
  }
Esempio n. 2
0
  private JPanel createPanelDiff(final Type_Diff type) {

    GridBagConstraints cTabSite = new DefaultGridBagConstraints();
    JPanel tabSite = new JPanel(new GridBagLayout());

    cTabSite.weightx = 1;
    cTabSite.fill = GridBagConstraints.HORIZONTAL;
    cTabSite.gridwidth = 2;

    final String name = type.getName();
    final JCheckBox boxSiteDiff = new JCheckBox(getLabelFor(name + "_DIFF"));

    tabSite.add(boxSiteDiff, cTabSite);
    this.addView(boxSiteDiff, name + "_DIFF");

    final String fieldSiren = "SIREN_" + name;
    if (getTable().contains(fieldSiren)) {
      final JLabel labelSrenSite = new JLabel(getLabelFor(fieldSiren));
      labelSrenSite.setHorizontalAlignment(SwingConstants.RIGHT);
      cTabSite.gridwidth = 1;
      cTabSite.gridx = 2;
      cTabSite.weightx = 0;
      tabSite.add(labelSrenSite, cTabSite);

      cTabSite.gridx++;
      cTabSite.weightx = 1;
      if (type == Type_Diff.SITE) {
        throw new IllegalArgumentException("Le siren n'est pas à renseigné pour le site");
      }
      final JTextField siren = this.sirenDonneur;
      tabSite.add(siren, cTabSite);
      this.addView(siren, fieldSiren);
      DefaultGridBagConstraints.lockMinimumSize(siren);
    }
    cTabSite.gridy++;
    cTabSite.gridx = 0;
    cTabSite.weightx = 0;
    cTabSite.fill = GridBagConstraints.HORIZONTAL;
    cTabSite.gridwidth = 1;
    final JLabel labelSiteDes = new JLabel(getLabelFor("DESIGNATION_" + name));

    labelSiteDes.setHorizontalAlignment(SwingConstants.RIGHT);

    tabSite.add(labelSiteDes, cTabSite);
    cTabSite.gridx++;
    cTabSite.weightx = 1;
    final JTextField designation = type == Type_Diff.SITE ? this.desSite : this.desDonneur;
    tabSite.add(designation, cTabSite);
    this.addView(designation, "DESIGNATION_" + name);
    DefaultGridBagConstraints.lockMinimumSize(designation);

    final JLabel labelTelSite = new JLabel(getLabelFor("TEL_" + name));
    labelTelSite.setHorizontalAlignment(SwingConstants.RIGHT);
    cTabSite.gridx++;
    cTabSite.weightx = 0;
    tabSite.add(labelTelSite, cTabSite);

    cTabSite.gridx++;
    cTabSite.weightx = 1;
    final JTextField tel = type == Type_Diff.SITE ? this.telSite : this.telDonneur;
    tabSite.add(tel, cTabSite);
    this.addView(tel, "TEL_" + name);
    DefaultGridBagConstraints.lockMinimumSize(tel);

    final JLabel labelSiteAdr = new JLabel(getLabelFor("ADRESSE_" + name));
    labelSiteAdr.setHorizontalAlignment(SwingConstants.RIGHT);
    cTabSite.gridy++;
    cTabSite.gridx = 0;
    cTabSite.weightx = 0;
    tabSite.add(labelSiteAdr, cTabSite);

    cTabSite.gridx++;
    cTabSite.weightx = 1;
    final ITextArea adresse = type == Type_Diff.SITE ? this.adrSite : this.adrDonneur;
    tabSite.add(adresse, cTabSite);
    this.addView(adresse, "ADRESSE_" + name);
    DefaultGridBagConstraints.lockMinimumSize(adresse);

    final JLabel labelTelPSite = new JLabel(getLabelFor("TEL_P_" + name));
    labelTelPSite.setHorizontalAlignment(SwingConstants.RIGHT);
    cTabSite.gridx++;
    cTabSite.weightx = 0;
    tabSite.add(labelTelPSite, cTabSite);

    cTabSite.gridx++;
    cTabSite.weightx = 1;
    final JTextField telP = type == Type_Diff.SITE ? this.telPSite : this.telPDonneur;
    tabSite.add(telP, cTabSite);
    this.addView(telP, "TEL_P_" + name);

    cTabSite.gridy++;
    cTabSite.gridx = 0;
    cTabSite.weightx = 0;
    final JLabel labelVilleAdr = new JLabel(getLabelFor("VILLE_" + name));
    labelVilleAdr.setHorizontalAlignment(SwingConstants.RIGHT);
    tabSite.add(labelVilleAdr, cTabSite);

    cTabSite.gridx++;
    cTabSite.weightx = 1;
    final ITextComboVilleViewer ville = type == Type_Diff.SITE ? this.villeSite : this.villeDonneur;
    tabSite.add(ville, cTabSite);
    this.addView(ville, "VILLE_" + name);
    DefaultGridBagConstraints.lockMinimumSize(ville);

    cTabSite.gridx++;
    cTabSite.weightx = 0;

    final JLabel labelFaxSite = new JLabel(getLabelFor("FAX_" + name));
    labelFaxSite.setHorizontalAlignment(SwingConstants.RIGHT);
    tabSite.add(labelFaxSite, cTabSite);

    cTabSite.gridx++;
    cTabSite.weightx = 1;
    final JTextField fax = type == Type_Diff.SITE ? this.faxSite : this.faxDonneur;
    tabSite.add(fax, cTabSite);
    this.addView(fax, "FAX_" + name);
    DefaultGridBagConstraints.lockMinimumSize(fax);

    cTabSite.gridy++;
    cTabSite.gridx = 0;
    cTabSite.weightx = 0;

    final JLabel labelContactSite = new JLabel(getLabelFor("CONTACT_" + name));
    labelContactSite.setHorizontalAlignment(SwingConstants.RIGHT);
    tabSite.add(labelContactSite, cTabSite);

    cTabSite.gridx++;
    cTabSite.weightx = 1;
    final JTextField contact = type == Type_Diff.SITE ? this.contactSite : this.contactDonneur;
    tabSite.add(contact, cTabSite);
    this.addView(contact, "CONTACT_" + name);

    cTabSite.gridx++;
    cTabSite.weightx = 0;

    final JLabel labelMailSite = new JLabel(getLabelFor("MAIL_" + name));
    labelMailSite.setHorizontalAlignment(SwingConstants.RIGHT);
    tabSite.add(labelMailSite, cTabSite);

    cTabSite.gridx++;
    cTabSite.weightx = 1;
    final JTextField mail = type == Type_Diff.SITE ? this.mailSite : this.mailDonneur;
    tabSite.add(mail, cTabSite);
    this.addView(mail, "MAIL_" + name);

    boxSiteDiff.addItemListener(
        new ItemListener() {

          @Override
          public void itemStateChanged(ItemEvent e) {
            final boolean selected = boxSiteDiff.isSelected();
            setSiteEnabled(selected, type);
            if (!selected) {
              clearFieldDiff(type);
            }
          }
        });
    return tabSite;
  }
Esempio n. 3
0
  @Override
  public void addViews() {
    setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

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

    c.gridy++;
    c.gridwidth = 1;
    final JLabel labelNumero = new JLabel(getLabelFor("NUMERO"));
    labelNumero.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNumero, c);

    // Ligne 1: Numero du devis

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

    // Date

    c.gridx++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    final JLabel labelDate = new JLabel(getLabelFor("DATE"));

    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);

    this.add(labelDate, c);
    c.gridx++;

    c.weightx = 1;

    c.fill = GridBagConstraints.NONE;
    final JDate dateDevis = new JDate(true);
    this.add(dateDevis, c);

    // Etat devis
    this.radioEtat.setLayout(new VFlowLayout());
    this.radioEtat.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_ETAT_DEVIS")));
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 5;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    c.gridx += 2;
    this.radioEtat.initLocalization(
        new ITransformer<String, String>() {
          @Override
          public String transformChecked(String id) {
            return id;
            // return TranslationManager.getInstance().getTranslationForItem(id);
          }
        });
    this.add(this.radioEtat, c);
    // this.radioEtat.setVisible(false);

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

    c.weightx = 0;

    final JLabel labelObjet = new JLabel(getLabelFor("OBJET"));
    labelObjet.setHorizontalAlignment(SwingConstants.RIGHT);

    this.add(labelObjet, c);

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

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

    this.add(labelCommercial, c);

    final ElementComboBox comboCommercial = new ElementComboBox(false, 25);

    comboCommercial.setListIconVisible(false);
    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;

    this.add(comboCommercial, c);
    addRequiredSQLObject(comboCommercial, field);

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

    final ElementComboBox comboClient = new ElementComboBox();
    c.gridx++;
    c.gridwidth = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(comboClient, c);
    addRequiredSQLObject(comboClient, "ID_CLIENT");

    final ElementComboBox boxTarif = new ElementComboBox();

    if (getTable().getFieldsName().contains("DATE_VALIDITE")) {
      c.gridx++;
      this.add(new JLabel(getLabelFor("DATE_VALIDITE")), c);
      c.gridx++;
      JDate dateValidite = new JDate();
      this.add(dateValidite, c);
      this.addView(dateValidite, "DATE_VALIDITE");
    }

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

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

            @Override
            public void propertyChange(PropertyChangeEvent evt) {

              SQLRow selectedRow =
                  boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
              table.setTarif(selectedRow, !isFilling());
            }
          });
    }

    // Table d'élément
    this.table = new DevisItemTable();

    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy += 5;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(this.table, c);
    this.addView(this.table.getRowValuesTable(), "");

    // Panel en bas
    final JPanel bottomPanel = new JPanel(new GridBagLayout());
    final GridBagConstraints cBottom = new DefaultGridBagConstraints();
    // 1ere Colonne : Infos
    cBottom.weightx = 1;
    bottomPanel.add(new TitledSeparator(getLabelFor("INFOS")), cBottom);
    cBottom.gridy++;
    cBottom.fill = GridBagConstraints.BOTH;
    cBottom.weighty = 0;

    final JScrollPane scrollPane = new JScrollPane(this.infos);
    scrollPane.setBorder(null);
    bottomPanel.add(scrollPane, cBottom);

    // 2eme Colonne : Poids total
    final JPanel panel = new JPanel(new GridBagLayout());

    this.textPoidsTotal = new JTextField(8);
    this.textPoidsTotal.setText("0.0");
    final GridBagConstraints cPanel = new DefaultGridBagConstraints();
    panel.add(new JLabel(getLabelFor("T_POIDS")), cPanel);
    cPanel.weightx = 0;
    cPanel.gridx++;
    panel.add(this.textPoidsTotal, cPanel);
    this.textPoidsTotal.setEnabled(false);
    this.textPoidsTotal.setEditable(false);
    this.textPoidsTotal.setHorizontalAlignment(SwingConstants.RIGHT);
    this.textPoidsTotal.setDisabledTextColor(Color.BLACK);

    // Port
    cPanel.gridy++;
    cPanel.gridx = 0;
    panel.add(new JLabel(getLabelFor("PORT_HT"), SwingConstants.RIGHT), cPanel);

    cPanel.gridx++;
    final DeviseField textPortHT = new DeviseField();
    panel.add(textPortHT, cPanel);

    // Remise HT
    final JRadioButton radioEuros = new JRadioButton("en €");
    final JRadioButton radioPourCent = new JRadioButton("en %");
    final ButtonGroup radioGroup = new ButtonGroup();
    radioGroup.add(radioEuros);
    radioGroup.add(radioPourCent);
    radioEuros.setSelected(true);

    final JPanel panelRemise = new JPanel(new GridBagLayout());
    final GridBagConstraints cRemise = new DefaultGridBagConstraints();
    cRemise.insets = new Insets(0, 0, 1, 0);
    final JLabel labelRemise = new JLabel(getLabelFor("REMISE_HT"));
    panelRemise.add(labelRemise, cRemise);
    cRemise.gridx++;
    panelRemise.add(radioEuros, cRemise);

    cRemise.gridx++;
    cRemise.weightx = 0;
    this.textRemiseHT = new DeviseField();
    panelRemise.add(this.textRemiseHT, cRemise);
    this.textRemiseHT.setMinimumSize(new Dimension(150, 20));
    this.textRemiseHT.setPreferredSize(new Dimension(150, 20));

    cRemise.gridx = 1;
    cRemise.gridy++;
    cRemise.weightx = 0;
    panelRemise.add(radioPourCent, cRemise);

    this.textPourcentRemise = new JTextField(5);
    DefaultGridBagConstraints.lockMinimumSize(this.textPourcentRemise);
    cRemise.gridx++;
    panelRemise.add(this.textPourcentRemise, cRemise);

    cPanel.gridx = 0;
    cPanel.gridy++;
    cPanel.gridwidth = 2;
    panel.add(panelRemise, cPanel);

    cBottom.gridy = 0;
    cBottom.gridx++;
    cBottom.weighty = 0;
    cBottom.weightx = 1;
    cBottom.gridheight = 2;
    cBottom.fill = GridBagConstraints.HORIZONTAL;
    cBottom.anchor = GridBagConstraints.NORTHEAST;
    DefaultGridBagConstraints.lockMinimumSize(panel);
    // bottomPanel.add(panel, cBottom);

    addSQLObject(this.textRemiseHT, "REMISE_HT");
    addSQLObject(textPortHT, "PORT_HT");
    // this.checkImpression.setSelected(true);

    // Total
    this.fieldHT = new DeviseField();
    final DeviseField fieldTVA = new DeviseField();
    final DeviseField fieldTTC = new DeviseField();
    final DeviseField fieldDevise = new DeviseField();
    final DeviseField fieldService = new DeviseField();
    this.fieldHT.setEditable(false);
    fieldTVA.setEditable(false);
    fieldTTC.setEditable(false);
    fieldService.setEditable(false);

    addRequiredSQLObject(this.fieldHT, "T_HT");
    addRequiredSQLObject(fieldTVA, "T_TVA");
    addSQLObject(fieldDevise, "T_DEVISE");
    addRequiredSQLObject(fieldTTC, "T_TTC");
    addRequiredSQLObject(fieldService, "T_SERVICE");
    JTextField poids = new JTextField();
    // addSQLObject(poids, "T_POIDS");

    // FIXME Field add field T_HA dans installation avec recalcul des devis deja saisis
    final DeviseField fieldHA = new DeviseField();

    if (getTable().contains("PREBILAN")) {
      addSQLObject(fieldHA, "PREBILAN");
    } else if (getTable().contains("T_HA")) {

      addSQLObject(fieldHA, "T_HA");
    }

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

    cBottom.gridy = 0;
    cBottom.gridx += 2;
    cBottom.gridheight = 2;
    cBottom.gridwidth = 1;
    cBottom.fill = GridBagConstraints.NONE;
    cBottom.weightx = 0;
    cBottom.anchor = GridBagConstraints.NORTHEAST;
    DefaultGridBagConstraints.lockMinimumSize(totalTTC);
    bottomPanel.add(totalTTC, cBottom);

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

    c.gridx = 0;
    c.gridy++;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.SOUTHEAST;

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

    textPortHT
        .getDocument()
        .addDocumentListener(
            new SimpleDocumentListener() {

              @Override
              public void update(final DocumentEvent e) {
                totalTTC.updateTotal();
              }
            });

    this.textRemiseHT
        .getDocument()
        .addDocumentListener(
            new SimpleDocumentListener() {

              @Override
              public void update(final DocumentEvent e) {
                totalTTC.updateTotal();
              }
            });

    this.textPourcentRemise
        .getDocument()
        .addDocumentListener(
            new SimpleDocumentListener() {

              @Override
              public void update(final DocumentEvent e) {
                calculPourcentage();
              }
            });

    radioEuros.addChangeListener(
        new ChangeListener() {

          public void stateChanged(final ChangeEvent e) {
            DevisSQLComponent.this.textRemiseHT.setEnabled(radioEuros.isSelected());
            DevisSQLComponent.this.textPourcentRemise.setEnabled(!radioEuros.isSelected());
          }
        });

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

              public void tableChanged(final TableModelEvent e) {
                DevisSQLComponent.this.textPoidsTotal.setText(
                    String.valueOf(DevisSQLComponent.this.table.getPoidsTotal()));
              }
            });

    addSQLObject(textObjet, "OBJET");
    addSQLObject(this.textPoidsTotal, "T_POIDS");
    addRequiredSQLObject(dateDevis, "DATE");
    addRequiredSQLObject(this.radioEtat, "ID_ETAT_DEVIS");
    addRequiredSQLObject(this.numeroUniqueDevis, "NUMERO");
    addSQLObject(this.infos, "INFOS");
    comboClient.addModelListener(
        "wantedID",
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent arg0) {
            if (!isFilling()) {
              Integer id = comboClient.getWantedID();

              if (id > 1) {

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

                  SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                  if (!foreignRow.isUndefined()
                      && (boxTarif.getSelectedRow() == null
                          || boxTarif.getSelectedId() != foreignRow.getID())
                      && JOptionPane.showConfirmDialog(
                              null, "Appliquer les tarifs associés au client?")
                          == JOptionPane.YES_OPTION) {
                    boxTarif.setValue(foreignRow.getID());
                    // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
                    // true);
                  } else {
                    boxTarif.setValue(foreignRow.getID());
                  }

                  // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                  // if (foreignRow.isUndefined() &&
                  // !row.getForeignRow("ID_DEVISE").isUndefined()) {
                  // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
                  // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
                  // foreignRow = rowValsD;
                  //
                  // }
                  // table.setTarif(foreignRow, true);
                }
              }
            }
          }
        });
    DefaultGridBagConstraints.lockMinimumSize(comboCommercial);
    DefaultGridBagConstraints.lockMinimumSize(comboClient);
  }