예제 #1
0
  protected void handleAction(JButton source, ActionEvent e) {
    if (source == this.buttonModifier) {

      if (this.editFrame == null) {
        this.editFrame = new EditFrame(this.element, EditFrame.MODIFICATION);
      }
      this.editFrame.selectionId(this.getListe().getSelectedId());
      this.editFrame.pack();
      this.editFrame.setVisible(true);

      SQLRow ecritureRow =
          new EcritureSQLElement().getTable().getRow(this.getListe().getSelectedId());

      MouvementSQLElement.showSource(ecritureRow.getInt("ID_MOUVEMENT"));

    } else {

      super.handleAction(source, e);
    }
  }
  private ListeAddPanel getPanel(
      final SQLElement eltCmd,
      final SQLTableModelSourceOnline tableSource,
      final List<RowAction> allowedActions) {
    final ListeAddPanel panel =
        new ListeAddPanel(eltCmd, new IListe(tableSource)) {
          @Override
          protected void createUI() {
            super.createUI();
            this.btnMngr.setAdditional(
                this.buttonEffacer,
                new ITransformer<JButton, String>() {

                  @Override
                  public String transformChecked(JButton input) {

                    SQLRowAccessor row = getListe().fetchSelectedRow();

                    BigDecimal b = getAvancement(row);

                    if (b.signum() != 0) {
                      return "Vous ne pouvez pas supprimer une commande facturée !";
                    }
                    return null;
                  }
                });
            this.btnMngr.setAdditional(
                this.buttonModifier,
                new ITransformer<JButton, String>() {

                  @Override
                  public String transformChecked(JButton input) {

                    SQLRowAccessor row = getListe().fetchSelectedRow();

                    BigDecimal b = getAvancement(row);

                    if (b.signum() != 0) {
                      return "Vous ne pouvez pas modifier une commande facturée !";
                    }
                    return null;
                  }
                });
          }
        };

    final List<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>> fields =
        new ArrayList<Tuple2<? extends SQLTableModelColumn, IListTotalPanel.Type>>(2);
    fields.add(
        Tuple2.create(
            panel.getListe().getSource().getColumn(eltCmd.getTable().getField("T_HT")),
            IListTotalPanel.Type.SOMME));
    fields.add(Tuple2.create(this.colAvancement, IListTotalPanel.Type.AVANCEMENT_TTC));
    final IListTotalPanel totalPanel =
        new IListTotalPanel(panel.getListe(), fields, null, "Total des commandes de la liste");

    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.EAST;
    c.weightx = 1;
    c.gridy = 4;

    // Date panel
    final IListFilterDatePanel datePanel =
        new IListFilterDatePanel(
            panel.getListe(),
            eltCmd.getTable().getField("DATE"),
            IListFilterDatePanel.getDefaultMap());

    panel
        .getListe()
        .addIListeActions(
            new MouseSheetXmlListeListener(CommandeClientXmlSheet.class) {
              @Override
              public List<RowAction> addToMenu() {
                return allowedActions;
              }
            }.getRowActions());

    datePanel.setFilterOnDefault();

    final JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());
    bottomPanel.setOpaque(false);
    final GridBagConstraints c2 = new DefaultGridBagConstraints();
    c2.fill = GridBagConstraints.NONE;
    c2.weightx = 1;
    bottomPanel.add(datePanel, c2);

    c2.gridx++;
    c2.weightx = 0;
    c2.anchor = GridBagConstraints.EAST;
    bottomPanel.add(totalPanel, c2);

    panel.add(bottomPanel, c);
    return panel;
  }