예제 #1
0
  public CursValutarView(final Shell parent, final CursValuta cursValutar, final int mode) {
    super(parent, SWT.MIN | SWT.CLOSE, mode);

    this.mapValute.addAll(BorgCache.getValute().values());
    this.mapBanci.addAll(BorgCache.getBanci().values());

    Collections.sort(
        this.mapValute,
        AbstractDB.getComparator(Valuta.class, Valuta.EXTERNAL_REFLECT_GET_ACRONIM));
    Collections.sort(
        this.mapBanci, AbstractDB.getComparator(Banca.class, Banca.EXTERNAL_REFLECT_GET_COD));

    if (cursValutar != null) {
      this.cursValutar = cursValutar.cloneObject();
      setModifiedObject(this.cursValutar);
    } else {
      this.cursValutar = new CursValuta();
    }

    addComponents();
    populateFields();

    if (!isViewEnabled()) {
      WidgetCompositeUtil.enableGUI(getContainer(), false);
    }
  }
예제 #2
0
  @Override
  protected boolean validate() {
    CursValuta test;
    Banca banca;
    Valuta valuta;
    try {
      if (this.comboBanca.getSelectedElement() == null) {
        SWTeXtension.displayMessageW("Nu ati selectat banca de referinta!");
        this.comboBanca.getCombo().setFocus();
        return false;
      }
      banca = (Banca) this.comboBanca.getSelectedElement();

      if (this.comboValuta.getSelectedElement() == null) {
        SWTeXtension.displayMessageW("Nu ati selectat valuta!");
        this.comboValuta.getCombo().setFocus();
        return false;
      }
      valuta = (Valuta) this.comboValuta.getSelectedElement();
      if (Double.parseDouble(this.textCurs.getValue().toString()) == 0) {
        SWTeXtension.displayMessageW("Cursul nu poate fi zero!");
        return false;
      }

      test =
          (CursValuta)
              Database.getDbSingleObjectForUi(
                  CursValuta.class,
                  " AND a."
                      + CursValuta.COL_ID_BANCA
                      + "="
                      + banca.getId()
                      + " AND a."
                      + CursValuta.COL_ID_VALUTA
                      + "="
                      + valuta.getId()
                      + " AND a."
                      + CursValuta.COL_DATA
                      + "='"
                      + this.textData.getText()
                      + "'");
      if ((test != null) && (test.getId() != this.cursValutar.getId())) {
        if (SWTeXtension.displayMessageQ(
                "Atentie! In data de "
                    + this.textData.getText()
                    + ", pentru valuta \""
                    + valuta.getAcronim()
                    + "\" si banca \""
                    + banca.getNume()
                    + "\" exista "
                    + "deja un curs valutar setat! Aceasta valoare va fi actualizata daca veti continua. Continuam?")
            == SWT.NO) {
          return false;
        }
        this.cursValutar = test.cloneObject();
      }
    } catch (Exception exc) {
      AbstractView.processValidateErr(exc);
      return false;
    }
    return true;
  }