public void initListener() { view.getBtnNewForm().addClickListener(this); view.getBtnEditForm().addClickListener(this); view.getBtnCancelForm().addClickListener(this); view.getBtnDeleteForm().addClickListener(this); view.getBtnHelp().addClickListener(this); view.getBtnPrint().addClickListener(this); view.getBtnSaveForm().addClickListener(this); view.getBtnSearch().addClickListener(this); view.getBtnUtility().addClickListener(this); view.getTable().addItemClickListener(this); }
@Override public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub // Antisipasi if (model.getOperationStatus() == null) model.setOperationStatus(EnumOperationStatus.OPEN.getStrCode()); if (model.getOperationStatus().equals("")) model.setOperationStatus(EnumOperationStatus.OPEN.getStrCode()); if (event.getButton() == view.getBtnNewForm()) { addItem(); view.showWindowForm(); } else if (event.getButton() == view.getBtnEditForm()) { view.showWindowForm(); } else if (event.getButton() == view.getBtnDeleteForm()) { deleteForm(); } else if (event.getButton() == view.getBtnSaveForm()) { ConfirmDialog commitDialog = ConfirmDialog.show( view.getUI(), "Konfirmasi Simpan", "Simpan Data?", "Save", "No", new ConfirmDialog.Listener() { public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { // Confirmed to continue try { if (model .getOperationStatus() .equals(EnumOperationStatus.ADDING.getStrCode())) { if (insertAndValidateForm() == 0) { view.getTable().focus(); view.closeWindowForm(); } else { view.focustIdOrDesc(); } } else if (model .getOperationStatus() .equals(EnumOperationStatus.EDITING.getStrCode())) { if (updateAndValidateForm() == 0) { view.getTable().focus(); view.closeWindowForm(); } else { view.focustIdOrDesc(); } } } catch (Exception ex) { Notification.show("Terjadi Kesalahan Simpan"); } } else { view.focustIdOrDesc(); } } }); commitDialog.setStyleName("dialog"); commitDialog.getOkButton().setStyleName("small"); commitDialog.getCancelButton().setStyleName("small"); // Jangan lupa commitDialog.focus(); } else if (event.getButton() == view.getBtnCancelForm()) { if (model.getOperationStatus().equals(EnumOperationStatus.ADDING.getStrCode())) { discardForm(); } else if (model.getOperationStatus().equals(EnumOperationStatus.ADDING.getStrCode()) || model.getOperationStatus().equals(EnumOperationStatus.EDITING.getStrCode())) { if (view.getFormLayout().isVisible()) { discardForm(); } } else { view.getTable().focus(); } // discardForm(operationStatus); } else if (event.getButton() == view.getBtnSearch()) { searchForm(); } else if (event.getButton() == view.getBtnPrint()) { printForm(); } else if (event.getButton() == view.getBtnHelp()) { helpForm(); } else if (event.getButton() == view.getBtnUtility()) { view.showWindowUtility(); } // Tidak semua akan di refresh container nya >> Jadi refresh container tidak bisa di taruh // disini }