예제 #1
0
  private void addComponents() {
    getWidgetLayout().numColumns = 2;
    getWidgetLayout().makeColumnsEqualWidth = false;
    getContainer().setLayout(getWidgetLayout());

    CIDescriptor desc = new CIDescriptor();
    desc.setClazz(Valuta.class);
    desc.setInput(BorgCache.getValute());
    desc.setTextMethodName(Valuta.EXTERNAL_REFLECT_GET_ACRONIM);
    desc.setImageMethodName(Valuta.EXTERNAL_REFLECT_GET_IMAGE);
    desc.setToolItemStyle(ComboImage.ADD_ADD);
    desc.setAddContentProposal(isViewEnabled());

    new Label(getContainer(), SWT.NONE).setText("Valuta");
    this.comboValuta = new ComboImage(getContainer(), desc);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.CENTER)
        .applyTo(this.comboValuta);
    this.comboValuta.getItemAdd().addListener(SWT.Selection, this);
    this.comboValuta.getItemAdd().setToolTipText("Adaugare valuta");

    desc = new CIDescriptor();
    desc.setClazz(Banca.class);
    desc.setInput(this.mapBanci);
    desc.setTextMethodName(Banca.EXTERNAL_REFLECT_GET_COD);
    desc.setImageMethodName(Banca.EXTERNAL_REFLECT_GET_SIGLA);
    desc.setToolItemStyle(ComboImage.ADD_ADD);
    desc.setAddContentProposal(isViewEnabled());

    new Label(getContainer(), SWT.NONE).setText("Banca");
    this.comboBanca = new ComboImage(getContainer(), desc);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.CENTER)
        .applyTo(this.comboBanca);
    this.comboBanca.getItemAdd().addListener(SWT.Selection, this);
    this.comboBanca.getItemAdd().setToolTipText("Adaugare banca");

    new Label(getContainer(), SWT.NONE).setText("Data");
    this.textData = new Text(getContainer(), SWT.BORDER);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.CENTER)
        .applyTo(this.textData);
    this.textData.setEnabled(false);
    this.textData.setText(EncodeLive.getSQLDateLogin().toString());

    new Label(getContainer(), SWT.NONE).setText("Curs");
    this.textCurs = new FormattedText(getContainer(), SWT.BORDER);
    GridDataFactory.fillDefaults()
        .grab(true, false)
        .align(SWT.FILL, SWT.CENTER)
        .span(getWidgetLayout().numColumns - 1, 1)
        .applyTo(this.textCurs.getControl());
    this.textCurs.setFormatter(NumberUtil.getFormatter(4, false));
    ((NumberFormatter) this.textCurs.getFormatter()).setFixedLengths(false, true);

    WidgetCompositeUtil.addColoredFocusListener2Childrens(getContainer());
  }
예제 #2
0
 @Override
 protected boolean save(final SQL conn) {
   try {
     this.cursValutar.setCurs(new BigDecimal(this.textCurs.getValue().toString()));
     if (getViewMode() == AbstractView.MODE_ADD) {
       this.cursValutar.setData(EncodeLive.getSQLDateLogin());
     }
     this.cursValutar.setIdBanca(this.comboBanca.getSelectedObjectId());
     this.cursValutar.setIdValuta(this.comboValuta.getSelectedObjectId());
     this.cursValutar.setIdUser(EncodeLive.getIdUserCurent());
     if (this.cursValutar.getId() == 0) {
       this.cursValutar.insert(conn);
     } else {
       this.cursValutar.update(conn);
     }
     conn.commit();
   } catch (Exception exc) {
     AbstractView.processSaveErr(exc, conn);
     return false;
   }
   return true;
 }