public void kill() { Set<UserSessionEntity> selected = sessionsTable.getSelected(); if (selected.isEmpty()) return; showOptionDialog( messages.getMainMessage("dialogs.Confirmation"), messages.getMessage(getClass(), "killConfirm"), MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.OK) .withHandler(event -> disconnectSession(selected)), new DialogAction(Type.CANCEL, Status.PRIMARY) } ); }
@Nullable protected DialogAction findFirstActionWithType(Action[] actions, EnumSet<DialogAction.Type> types) { for (Action action : actions) { if (action instanceof DialogAction) { DialogAction.Type actionType = ((DialogAction) action).getType(); if (types.contains(actionType)) { return (DialogAction) action; } } } return null; } }
/** * Dead code. Must to be tested after platform fixes in com.haulmont.cuba.web.WebWindowManager * Web modal editor window always closed forced, therefore that preClose method is not called * <p> * Confirm closing without save if regions are created */ @Override public boolean preClose(String actionId) { if (!COMMIT_ACTION_ID.equals(actionId) && reportRegionsDs.getItems() != null) { showOptionDialog(getMessage("dialogs.Confirmation"), getMessage("interruptConfirm"), MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.YES) { @Override public void actionPerform(Component component) { ReportWizardCreator.this.close(CLOSE_ACTION_ID, true); } }, new DialogAction(Type.NO, Status.PRIMARY) }); } return false; }
.withMessage(messages.getMainMessage("saveUnsaved")) .withActions( new DialogAction(DialogAction.Type.OK, Action.Status.PRIMARY) .withCaption(messages.getMainMessage("closeUnsaved.save")) .withHandler(e -> { new DialogAction(DialogAction.Type.CANCEL) .withIcon(null) .withHandler(e -> { Frame frame = UiControllerUtils.getFrame(origin);
@Override public void actionPerform(Component component) { DialogAction cancelAction = new DialogAction(DialogAction.Type.CANCEL); Messages messages = AppBeans.get(Messages.NAME); if (isDataAvailable()) { Action yesAction = new DialogAction(DialogAction.Type.OK) { @Override public void actionPerform(Component component) { cancelAction.setPrimary(true);
public MessageDialogBuilderImpl() { window = new CubaWindow(); window.setModal(true); window.setResizable(false); layout = new VerticalLayout(); layout.setStyleName("c-app-message-dialog"); layout.setMargin(false); layout.setSpacing(true); messageLabel = new CubaLabel(); messageLabel.setStyleName("c-app-message-dialog-text"); messageLabel.setWidth(100, Sizeable.Unit.PERCENTAGE); DialogAction action = new DialogAction(DialogAction.Type.OK); okButton = createButton(action); okButton.setClickHandler(me -> { try { action.actionPerform(ui.getTopLevelWindow()); } finally { ui.removeWindow(window); } }); layout.addComponent(messageLabel); layout.addComponent(okButton); layout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT); window.setContent(layout); ThemeConstants theme = ui.getApp().getThemeConstants(); window.setWidth(theme.get("cuba.web.WebWindowManager.messageDialog.width")); }
protected void confirmOverwriteFile(String fileName, File targetFile) { showOptionDialog( getMessage("replaceConfirmation"), formatMessage(getMessage("replaceMessage"), fileName), MessageType.CONFIRMATION, new Action[]{ new DialogAction(DialogAction.Type.OK) { @Override public void actionPerform(Component component) { writeToFile(targetFile); } }, new DialogAction(DialogAction.Type.CANCEL) } ); }
@Override public void actionPerform(Component component) { if (filterEntity == adHocFilter) return; windowManager.showOptionDialog( getMainMessage("filter.removeDialogTitle"), getMainMessage("filter.removeDialogMessage"), MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.YES).withHandler(event -> { removeFilterEntity(); settingsBtn.focus(); }), new DialogAction(Type.NO, Status.PRIMARY).withHandler(event -> { settingsBtn.focus(); }) }); }
MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.YES) { @Override public void actionPerform(Component component) { new DialogAction(Type.NO, Status.PRIMARY) }); } else {
public CubaButton createButton(Action action) { CubaButton button = new CubaButton(); if (action instanceof DialogAction) { DialogAction.Type type = ((DialogAction) action).getType(); button.setCaption(messages.getMainMessage(type.getMsgKey())); String iconPath = icons.get(type.getIconKey()); button.setIcon(iconResolver.getIconResource(iconPath)); } button.setEnabled(action.isEnabled()); if (StringUtils.isNotEmpty(action.getCaption())) { button.setCaption(action.getCaption()); } if (StringUtils.isNotEmpty(action.getDescription())) { button.setDescription(action.getDescription()); } if (StringUtils.isNotEmpty(action.getIcon())) { button.setIcon(iconResolver.getIconResource(action.getIcon())); } return button; }
public void cancelChanges() { if (hasChanges()) { showOptionDialog(messages.getMainMessage("closeUnsaved.caption"), messages.getMainMessage("closeUnsaved"), MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.YES).withHandler(event -> { close(CLOSE_ACTION_ID, true); }), new DialogAction(Type.NO, Status.PRIMARY) }); } else { close(CLOSE_ACTION_ID, true); } }
@Override public void actionPerform(Component component) { if (wizard.regionsTable.getSingleSelected() != null) { wizard.showOptionDialog( wizard.getMessage("dialogs.Confirmation"), wizard.formatMessage("deleteRegion", wizard.regionsTable.getSingleSelected().getName()), Frame.MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.YES) { @Override public void actionPerform(Component component) { wizard.reportRegionsDs.removeItem(wizard.regionsTable.getSingleSelected()); normalizeRegionPropertiesOrderNum(); wizard.regionsTable.refresh(); wizard.setupButtonsVisibility(); } }, new DialogAction(Type.NO, Status.PRIMARY) }); } }
@Override public void perform(final Folder folder) { App.getInstance().getWindowManager().showOptionDialog( messages.getMainMessage("dialogs.Confirmation"), messages.getMainMessage("folders.removeFolderConfirmation"), Frame.MessageType.CONFIRMATION, new com.haulmont.cuba.gui.components.Action[]{ new DialogAction(Type.YES).withHandler(event -> { removeFolder(folder); refreshFolders(); }), new DialogAction(Type.NO, Status.PRIMARY) } ); } }
@Override public void actionPerform(Component component) { try { wizard.outputFileName.validate(); } catch (ValidationException e) { wizard.showNotification(wizard.getMessage("validationFail.caption"), e.getMessage(), Frame.NotificationType.TRAY); return; } if (wizard.getItem().getReportRegions().isEmpty()) { wizard.showOptionDialog( wizard.getMessage("dialogs.Confirmation"), wizard.getMessage("confirmSaveWithoutRegions"), Frame.MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.OK) { @Override public void actionPerform(Component component) { convertToReportAndForceCloseWizard(); } }, new DialogAction(Type.NO, Status.PRIMARY) }); } else { convertToReportAndForceCloseWizard(); } }
protected void removeAppliedFilter() { if (!appliedFilters.isEmpty()) { if (appliedFilters.size() == 1) { AppliedFilterHolder holder = appliedFilters.removeLast(); appliedFiltersLayout.remove(holder.layout); adapter.unpinAllQuery(); this.layout.remove(appliedFiltersLayout); } else { windowManager.showOptionDialog( messages.getMainMessage("removeApplied.title"), messages.getMainMessage("removeApplied.message"), MessageType.WARNING, new Action[]{ new DialogAction(Type.YES).withHandler(event -> { for (AppliedFilterHolder holder : appliedFilters) { appliedFiltersLayout.remove(holder.layout); FilterDelegateImpl.this.layout.remove(appliedFiltersLayout); } appliedFilters.clear(); adapter.unpinAllQuery(); }), new DialogAction(Type.NO, Status.PRIMARY) }); } } }
@Override public void accept(HasValue.ValueChangeEvent e) { if (!wizard.getItem().getReportRegions().isEmpty()) { wizard.showOptionDialog( wizard.getMessage("dialogs.Confirmation"), wizard.getMessage("regionsClearConfirm"), Frame.MessageType.CONFIRMATION, new AbstractAction[]{ okAction.setValue(e.getValue()), new DialogAction(Type.NO, Status.PRIMARY) }); } else { wizard.needUpdateEntityModel = true; clearQueryAndFilter(); } if (wizard.setQueryButton != null) { wizard.setQueryButton.setVisible( wizard.reportTypeOptionGroup.getValue() == ReportType.LIST_OF_ENTITIES_WITH_QUERY); } } }
protected void showRestoreDialog() { final Set<Entity> entityList = entitiesTable.getSelected(); Entity entity = entitiesDs.getItem(); if (entityList != null && entity != null && entityList.size() > 0) { if (entity instanceof SoftDelete) { showOptionDialog( getMessage("dialogs.Confirmation"), getMessage("dialogs.Message"), MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.OK).withHandler(event -> { restoreService.restoreEntities(entityList); entitiesTable.refresh(); entitiesTable.focus(); }), new DialogAction(Type.CANCEL, Status.PRIMARY).withHandler(event -> { entitiesTable.focus(); }) } ); } } else { showNotification(getMessage("entityRestore.restoreMsg")); } }
public void resetRememberMe() { if (usersTable.getSelected().isEmpty()) { showOptionDialog( getMessage("resetRememberMeTitle"), getMessage("resetRememberMeQuestion"), MessageType.CONFIRMATION, new Action[]{ new BaseAction("actions.ResetAll") .withCaption(getMessage("actions.ResetAll")) .withHandler(event -> resetRememberMeAll()), new DialogAction(Type.CANCEL, Status.PRIMARY) } ); } else { showOptionDialog( getMessage("resetRememberMeTitle"), getMessage("resetRememberMeQuestion"), MessageType.CONFIRMATION, new Action[]{ new BaseAction("actions.ResetOptionSelected") .withCaption(getMessage("actions.ResetOptionSelected")) .withHandler(event -> resetRememberMe(usersTable.getSelected())), new BaseAction("actions.ResetOptionAll") .withCaption(getMessage("actions.ResetOptionAll")) .withHandler(event -> resetRememberMeAll()), new DialogAction(Type.CANCEL, Status.PRIMARY) } ); } }
public void enableLogging() { if (globalConfig.getUserSessionLogEnabled()) { showOptionDialog(getMessage("dialogs.Confirmation"), getMessage("confirmDisable"), MessageType.CONFIRMATION, new Action[] { new DialogAction(DialogAction.Type.YES, true).withHandler(actionPerformedEvent -> { globalConfig.setUserSessionLogEnabled(false); enableBtn.setCaption(getMessage("enableLogging")); }), new DialogAction(DialogAction.Type.NO) }); } else { globalConfig.setUserSessionLogEnabled(true); enableBtn.setCaption(getMessage("disableLogging")); } } }
protected void logoutPrompt() { Dialogs dialogs = ((AppUI) getUI()).getDialogs(); dialogs.createOptionDialog(MessageType.WARNING) .withCaption(messages.getMainMessage("exceptionDialog.logoutCaption")) .withMessage(messages.getMainMessage("exceptionDialog.logoutMessage")) .withActions( new BaseAction("close") .withCaption(messages.getMainMessage("closeApplication")) .withIcon("icons/ok.png") .withHandler(event -> forceLogout()), new DialogAction(Type.CANCEL, Status.PRIMARY) ) .show(); }