public void deleteForm() { final Object itemId = view.getTable().getValue(); if (itemId != null) { ConfirmDialog.Listener konfirmDialogListener = new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { // Confirmed to continue try { model.getsMerkJpaService().removeObject(model.getItemHeader()); model.getBeanItemContainerHeader().removeItem(itemId); view.getTable().refreshRowCache(); view.setDisplay(); Notification.show("Delete Sukses", Notification.TYPE_TRAY_NOTIFICATION); } catch (Exception ex) { Notification.show("Error Delete!!", Notification.TYPE_TRAY_NOTIFICATION); } } else { // User did not confirm } view.getTable().focus(); } }; final ConfirmDialog d = ConfirmDialog.show( view.getUI(), "Konfirmasi Hapus", "Yakin akan hapus data?", "Oke Delete..", "Cancel", konfirmDialogListener); final ShortcutListener enter = new ShortcutListener("Oke", KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { d.close(); } }; d.setStyleName("dialog"); d.getOkButton().setStyleName("small"); d.getCancelButton().setStyleName("small"); d.focus(); } else { Notification.show("Tidak ada yang dipilih!!!", Notification.TYPE_TRAY_NOTIFICATION); } }
@Override public ConfirmDialog create( String caption, String message, String okCaption, String cancelCaption, String notOkCaption) { ConfirmDialog d = super.create(caption, message, okCaption, cancelCaption, notOkCaption); d.getContent().setStyleName("custom-dialog"); d.getContent().setHeightUndefined(); d.setHeightUndefined(); Button ok = d.getOkButton(); ok.setStyleName(UIConstants.BUTTON_ACTION); HorizontalLayout buttons = (HorizontalLayout) ok.getParent(); buttons.setHeightUndefined(); Button cancelBtn = d.getCancelButton(); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); cancelBtn.focus(); return d; }
public int discardForm() { ConfirmDialog discardDialog = ConfirmDialog.show( view.getUI(), "Konfirmasi Discard", "Yakin keluar mode editing(discard)?", "Yes", "No", new ConfirmDialog.Listener() { public void onClose(ConfirmDialog dialog) { if (dialog.isConfirmed()) { // Confirmed to continue try { // 1. form discard model.getBinderHeader().discard(); model.setOperationStatus(EnumOperationStatus.OPEN.getStrCode()); view.setFormButtonAndTextState(); // 2. focust ke table view.getTable().focus(); } catch (Exception ex) { Notification.show( "Terjadi Kesalahan Discard", Notification.TYPE_TRAY_NOTIFICATION); } view.closeWindowForm(); } else { view.focustIdOrDesc(); } } }); discardDialog.setStyleName("dialog"); discardDialog.getOkButton().setStyleName("small"); discardDialog.getCancelButton().setStyleName("small"); // Jangan lupa discardDialog.focus(); return 0; }
@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 }