/** * 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; }
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) } ); }
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) } ); }
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) }); } }
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 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) { 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(); }) }); }
@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(); } }
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 checkGlobalDefaultAndCloseEditor() { List<FilterEntity> otherDefaultFilters = dataManager.loadList(LoadContext.create(FilterEntity.class) .setQuery(LoadContext.createQuery("select f from sec$Filter f where f.globalDefault = true and " + "f.componentId = :componentId and " + "f.id <> :currentId ") .setParameter("componentId", filterEntity.getComponentId()) .setParameter("currentId", filterEntity.getId()))); if (!otherDefaultFilters.isEmpty()) { String otherFilterNamesStr = otherDefaultFilters.stream() .map(FilterEntity::getName) .collect(Collectors.joining(", ")); showOptionDialog(getMessage("filter.editor.anotherGlobalDefaultFilterFound.dialogTitle"), formatMessage("filter.editor.anotherGlobalDefaultFilterFound.dialogMessage", otherFilterNamesStr), MessageType.WARNING, new Action[]{ new DialogAction(DialogAction.Type.YES, Action.Status.PRIMARY).withHandler(e -> { otherDefaultFilters.forEach(otherDefaultFilter -> otherDefaultFilter.setGlobalDefault(false)); modifiedGlobalDefaultFilters = dataManager.commit(new CommitContext(otherDefaultFilters)); close(COMMIT_ACTION_ID, true); }), new DialogAction(DialogAction.Type.NO, Action.Status.NORMAL).withHandler(e -> { filterEntity.setGlobalDefault(false); close(COMMIT_ACTION_ID, true); }), }); } else { close(COMMIT_ACTION_ID, true); } }
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")); } }
@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 initDragAndDrop() { Companion companion = getCompanion(); if (companion != null) { companion.initDragAndDrop(usersTable, groupsTree, (event) -> { if (event.getUsers().size() == 1) { if (moveSelectedUsersToGroup(event)) { showNotification(formatMessage("userMovedToGroup", event.getUsers().get(0).getLogin(), event.getGroup().getName())); } } else { showOptionDialog( messages.getMainMessage("dialogs.Confirmation"), formatMessage("dialogs.moveToGroup.message", event.getGroup().getName(), event.getUsers().size()), MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.OK).withHandler(dialogEvent -> { if (moveSelectedUsersToGroup(event)) { showNotification(formatMessage("usersMovedToGroup", event.getGroup().getName())); } }), new DialogAction(Type.CANCEL, Action.Status.PRIMARY) } ); } }, (groupEvent) -> { userManagementService.changeGroupParent(groupEvent.getGroupId(), groupEvent.getNewParentId()); groupsDs.refresh(); }); } }
@SuppressWarnings("CodeBlock2Expr") protected <E extends Entity> void performActionWithConfirmation(RemoveBuilder<E> builder, List<E> selectedItems) { ScreenContext screenContext = getScreenContext(builder.getOrigin()); Dialogs dialogs = screenContext.getDialogs(); String title = builder.getConfirmationTitle() != null ? builder.getConfirmationTitle() : messages.getMainMessage("dialogs.Confirmation"); String message = builder.getConfirmationTitle() != null ? builder.getConfirmationTitle() : messages.getMainMessage("dialogs.Confirmation.Remove"); dialogs.createOptionDialog() .withCaption(title) .withMessage(message) .withActions( new DialogAction(DialogAction.Type.YES).withHandler(e -> { performAction(builder, selectedItems); }), new DialogAction(DialogAction.Type.NO).withHandler(e -> { focusListComponent(builder); if (builder.getActionCancelledHandler() != null) { ActionCancelledEvent<E> event = new ActionCancelledEvent<>(builder.getOrigin(), selectedItems); builder.getActionCancelledHandler().accept(event); } }) ) .show(); }
.withMessage(claimTaskDialogMsg) .withActions( new DialogAction(Type.YES) .withHandler(event -> { UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME); fireAfterActionListeners(); }), new DialogAction(Type.NO, Status.PRIMARY)
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) } ); } }
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(); }
@Override public void actionPerform(Component component) { if (beforeActionPerformedHandler != null) { if (!beforeActionPerformedHandler.beforeActionPerformed()) return; } Messages messages = AppBeans.get(Messages.NAME); if (target.getSelected().isEmpty() || target.getDatasource().size() <= 1) { showPivotTable(ALL_ROWS); } else { Action[] actions = new Action[]{ new BaseAction("actions.showPivotAction.SELECTED_ROWS") .withCaption(messages.getMainMessage("actions.showPivotAction.SELECTED_ROWS")) .withHandler(event -> showPivotTable(SELECTED_ROWS)), new BaseAction("actions.showPivotAction.ALL_ROWS") .withCaption(messages.getMainMessage("actions.showPivotAction.ALL_ROWS")) .withHandler(event -> showPivotTable(ALL_ROWS)), new DialogAction(DialogAction.Type.CANCEL) }; WindowManager wm = target.getFrame().getWindowManager(); wm.showOptionDialog( messages.getMainMessage("actions.showPivotAction.dialogTitle"), messages.getMainMessage("actions.showPivotAction.dialogMessage"), Frame.MessageType.CONFIRMATION, actions); } }
/** * Check modifications and close all screens in all main windows excluding root screens. * * @return operation result */ public OperationResult checkModificationsAndCloseAll() { if (hasUnsavedChanges()) { UnknownOperationResult result = new UnknownOperationResult(); ui.getDialogs().createOptionDialog() .withCaption(messages.getMainMessage("closeUnsaved.caption")) .withMessage(messages.getMainMessage("discardChangesOnClose")) .withActions( new BaseAction("closeApplication") .withCaption(messages.getMainMessage("closeApplication")) .withIcon(icons.get(CubaIcon.DIALOG_OK)) .withHandler(event -> { closeWindowsInternal(); result.success(); }), new DialogAction(DialogAction.Type.CANCEL, Action.Status.PRIMARY) .withHandler(event -> result.fail()) ) .show(); return result; } else { closeWindowsInternal(); return OperationResult.success(); } }