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) } ); }
@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(); }) }); }
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) }); } } }
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")); } }
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); } }
protected void confirmAndRemove(Set<Entity> selected) { Dialogs dialogs = ComponentsHelper.getScreenContext(target.getFrame()).getDialogs(); dialogs.createOptionDialog() .withCaption(getConfirmationTitle()) .withMessage(getConfirmationMessage()) .withActions( new DialogAction(Type.OK, Status.PRIMARY).withHandler(event -> { try { remove(selected); } finally { if (target instanceof Component.Focusable) { ((Component.Focusable) target).focus(); } Set<Entity> filtered = new HashSet<>(selected); filtered.retainAll(target.getDatasource().getItems()); //noinspection unchecked target.setSelected(filtered); } }), new DialogAction(Type.CANCEL).withHandler(event -> { // move focus to owner if (target instanceof Component.Focusable) { ((Component.Focusable) target).focus(); } })) .show(); }
@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) } ); } }
@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(); }
/** * Shows standard unsaved changes dialog with Discard and Cancel actions. * * @param origin screen controller * @param closeAction close action * @return result */ public UnsavedChangesDialogResult showUnsavedChangesDialog(FrameOwner origin, @SuppressWarnings("unused") CloseAction closeAction) { UnsavedChangesDialogResult result = new UnsavedChangesDialogResult(); Dialogs dialogs = getScreenContext(origin).getDialogs(); dialogs.createOptionDialog() .withCaption(messages.getMainMessage("closeUnsaved.caption")) .withMessage(messages.getMainMessage("closeUnsaved")) .withType(Dialogs.MessageType.WARNING) .withActions( new DialogAction(DialogAction.Type.YES) .withHandler(e -> { result.discard(); }), new DialogAction(DialogAction.Type.NO, Action.Status.PRIMARY) .withHandler(e -> { Frame frame = UiControllerUtils.getFrame(origin); ComponentsHelper.focusChildComponent(frame); result.cancel(); }) ) .show(); return result; }
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 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(); }); } }
@Override public void init(Map<String, Object> params) { super.init(params); getDialogOptions().setWidthAuto(); copyBtn.setAction(new BaseAction("deployBtn") .withPrimary(true) .withHandler(e -> { if (usersDs.getItem() == null) { showNotification( getMessage("selectUser"), NotificationType.HUMANIZED); } else { showOptionDialog( getMessage("confirmCopy.title"), getMessage("confirmCopy.msg"), MessageType.CONFIRMATION, new Action[]{ new DialogAction(Type.YES).withHandler(event -> copySettings()), new DialogAction(Type.NO, Action.Status.PRIMARY) } ); } })); cancelBtn.setAction(new AbstractAction("cancelBtn") { @Override public void actionPerform(Component component) { close("cancel"); } }); }
new Action[]{ new DialogAction(DialogAction.Type.YES) .withHandler(event -> resetScreenSettings()), new DialogAction(DialogAction.Type.NO) })
.withActions( new DialogAction(Type.YES) .withHandler(event -> { UserSessionSource userSessionSource = AppBeans.get(UserSessionSource.NAME);
/** * 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(); } }
Frame.MessageType.WARNING_HTML, new Action[]{ new DialogAction(DialogAction.Type.OK).withHandler(event -> { JavaScript js = Page.getCurrent().getJavaScript(); js.execute("window.close();");
}), new DialogAction(DialogAction.Type.CANCEL, Action.Status.PRIMARY) .withHandler(event -> {