/** * Creates either Remove or Exclude action depending on property type */ protected RemoveAction createRemoveAction(MetaProperty metaProperty, Table table) { RemoveAction result; switch (metaProperty.getType()) { case COMPOSITION: result = new com.haulmont.cuba.gui.components.actions.RemoveAction(table); break; case ASSOCIATION: result = new com.haulmont.cuba.gui.components.actions.ExcludeAction(table); result.setShortcut(configuration.getConfig(ClientConfig.class).getTableRemoveShortcut()); break; default: throw new IllegalArgumentException("property must contain an entity"); } result.setAutocommit(false); return result; }
protected void remove(Set<Entity> selected) { doRemove(selected, autocommit); // move focus to owner if (target instanceof Component.Focusable) { ((Component.Focusable) target).focus(); } afterRemove(selected); if (afterRemoveHandler != null) { afterRemoveHandler.handle(selected); } }
@Override public Action createAction(ListComponent holder) { return RemoveAction.create(holder); } },
/** * This method is invoked by the action owner component. * * @param component component invoking the action */ @Override public void actionPerform(Component component) { if (!isEnabled()) { return; } if (beforeActionPerformedHandler != null) { if (!beforeActionPerformedHandler.beforeActionPerformed()) return; } @SuppressWarnings("unchecked") Set<Entity> selected = target.getSelected(); if (!selected.isEmpty()) { if (confirm) { confirmAndRemove(selected); } else { remove(selected); } } }
RemoveAction removeAction = new RemoveAction(uiPermissionsTable, false); removeAction.setAfterRemoveHandler(removedItems -> { if (!removedItems.isEmpty()) { UiPermissionTarget removedPermission = (UiPermissionTarget) removedItems.iterator().next(); removeAction.setEnabled(hasPermissionsToModifyPermission); removeAction.setIcon(null); removeAction.setCaption(getMessage("actions.RemoveSelected"));
protected void initScreens() { screenTable.addAction(new RemoveAction(screenTable, false)); List<WindowInfo> windowInfoCollection = new ArrayList<>(windowConfig.getWindows());
EditSubstitutedAction editSubstitutedAction = new EditSubstitutedAction(); substTable.addAction(editSubstitutedAction); RemoveAction removeSubstitutedAction = new RemoveAction(substTable, false); substTable.addAction(removeSubstitutedAction); removeSubstitutedAction.setEnabled(isSubstitutedUserDeletePermitted && isUserUpdatePermitted);
@Override protected void afterRemove(Set selected) { super.afterRemove(selected); orderParameters(); } });
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(); }
removeAction.setEnabled(enabled); }); removeAction.setBeforeActionPerformedHandler(() -> { Set<ProcInstance> selected = procInstancesTable.getSelected(); for (ProcInstance procInstance : selected) {
@Override protected void doRemove(Set selected, boolean autocommit) { removingStencil = true; super.doRemove(selected, autocommit); removingStencil = false; }
stencilsTableRemoveAction.setAutocommit(false); stencilsTable.addAction(stencilsTableRemoveAction); removeBtn.setAction(stencilsTableRemoveAction);
@Override public String getConfirmationMessage() { if (hasDefaultRole) return getMessage("dialogs.Confirmation.RemoveDefaultRole"); else return super.getConfirmationMessage(); }
@Override protected void confirmAndRemove(Set<Entity> selected) { hasDefaultRole = hasDefaultRole(selected); super.confirmAndRemove(selected); }
/** * Check permissions for Action */ @Override protected boolean isPermitted() { if (target == null || target.getDatasource() == null) { return false; } if (!checkRemovePermission()) { return false; } return super.isPermitted(); }
@Override public void actionPerform(Component component) { if (!isEnabled()) { return; } ReportGroup group = (ReportGroup) target.getSingleSelected(); if (group != null) { if (group.getSystemFlag()) { showNotification(getMessage("unableToDeleteSystemReportGroup"), NotificationType.WARNING); } else { LoadContext<Report> loadContext = new LoadContext<>(Report.class); loadContext.setView("report.view"); LoadContext.Query query = new LoadContext.Query("select r from report$Report r where r.group.id = :groupId"); query.setMaxResults(1); query.setParameter("groupId", group.getId()); loadContext.setQuery(query); DataSupplier dataService = getDsContext().getDataSupplier(); Report report = dataService.load(loadContext); if (report != null) { showNotification(getMessage("unableToDeleteNotEmptyReportGroup"), NotificationType.WARNING); } else { super.actionPerform(component); } } } } }
protected void initValuesFormats() { CreateAction formatCreateAction = CreateAction.create(formatsTable, OpenType.DIALOG); formatCreateAction.setInitialValuesSupplier(() -> ParamsMap.of("report", getItem()) ); formatsTable.addAction(formatCreateAction); formatsTable.addAction(new RemoveAction(formatsTable, false)); formatsTable.addAction(new EditAction(formatsTable, OpenType.DIALOG)); }
@Override protected void afterRemove(Set selected) { super.afterRemove(selected); Report report = getItem(); ReportTemplate defaultTemplate = report.getDefaultTemplate(); if (defaultTemplate != null && selected.contains(defaultTemplate)) { ReportTemplate newDefaultTemplate = null; if (templatesDs.getItems().size() == 1) { newDefaultTemplate = templatesDs.getItems().iterator().next(); } report.setDefaultTemplate(newDefaultTemplate); } } });
@Override protected void doRemove(Set selected, boolean autocommit) { long activeProcessesCount = processRuntimeService.getActiveProcessesCount(procDefinitionsDs.getItem()); if (activeProcessesCount > 0) { showNotification(getMessage("cannotRemoveActiveProcesses"), NotificationType.ERROR); } else { super.doRemove(selected, autocommit); for (Object selectedItem : selected) { processRepositoryService.undeployProcess(((ProcDefinition)selectedItem).getActId()); } } } }
@Override public void init(Map<String, Object> params) { getDialogOptions().setWidth(themeConstants.get("cuba.gui.AttributeEditor.width")); fieldWidth = themeConstants.get("cuba.gui.AttributeEditor.field.width"); initLocalizedFrame(); initFieldGroup(); Action createAction = initCreateScreenAndComponentAction(); targetScreensTable.addAction(createAction); Action removeAction = new RemoveAction(targetScreensTable); removeAction.setCaption(getMessage("targetScreensTable.remove")); targetScreensTable.addAction(removeAction); }