@Override public boolean isApplicable() { return tasksTable.getSelected().size() == 1; } }
protected boolean isSingleSelection() { return entityPermissionsTable.getSelected().size() == 1; }
@Override public void actionPerform(Component component) { for (Entity item : propertiesTable.getSelected()) { reportRegionPropertiesTableDs.removeItem((RegionProperty) item); normalizeRegionPropertiesOrderNum(); } }
public void commit() { if (!enumValuesTable.getSelected().isEmpty()) { CategoryAttributeEnumValue enumValue = enumValuesTable.getSelected().iterator().next(); enumValue.setLocalizedValues( LocaleHelper.convertFromSimpleKeyLocales(enumValue.getValue(), localizedFrame.getValue()) ); } enumValuesDs.commit(); close(Window.COMMIT_ACTION_ID); }
protected void showOrHideSortBtns() { if (propertiesTable.getSelected().size() == reportRegionPropertiesTableDs.getItems().size() || propertiesTable.getSelected().size() == 0) { upItem.setEnabled(false); downItem.setEnabled(false); } else { upItem.setEnabled(isUpdatePermitted()); downItem.setEnabled(isUpdatePermitted()); } }
@Override public void actionPerform(Component component) { Set<Category> selected = categoryTable.getSelected(); if (!selected.isEmpty()) { Category category = selected.iterator().next(); Editor editor = openEditor("sys$Category.edit", category, OpenType.THIS_TAB); ((AbstractWindow) editor).addCloseListener(actionId -> { categoriesDs.refresh(); categoryTable.focus(); }); } } }
public void changePasswordAtLogon() { if (!usersTable.getSelected().isEmpty()) { ResetPasswordsDialog resetPasswordsDialog = (ResetPasswordsDialog) openWindow("sec$User.resetPasswords", OpenType.DIALOG); resetPasswordsDialog.addCloseListener(actionId -> { if (Window.COMMIT_ACTION_ID.equals(actionId)) { boolean sendEmails = resetPasswordsDialog.getSendEmails(); boolean generatePasswords = resetPasswordsDialog.getGeneratePasswords(); Set<User> users = usersTable.getSelected(); resetPasswords(users, sendEmails, generatePasswords); } usersTable.focus(); }); } }
@Override public boolean isPermitted() { if (super.isPermitted()) { Set<ChartSeries> items = seriesTable.getSelected(); if (!CollectionUtils.isEmpty(items) && items.size() == 1) { Integer order = (IterableUtils.get(items, 0)).getOrder(); if (order != null) { return up ? order > 1 : order < seriesDs.size(); } } } return false; } }
public void editAttribute() { Set<ManagedBeanAttribute> selected = attributesTable.getSelected(); if (selected.isEmpty()) { return; } ManagedBeanAttribute mba = selected.iterator().next(); if (!mba.getWriteable()) { return; } AbstractEditor w = openEditor("jmxConsoleEditAttribute", mba, OpenType.DIALOG); w.addCloseListener(actionId -> { if (Window.COMMIT_ACTION_ID.equals(actionId)) { Object item = w.getItem(); reloadAttribute((ManagedBeanAttribute) item); } }); }
@Override public void actionPerform(Component component) { Set selected = entitiesTable.getSelected(); if (selected.size() != 1) return; Entity item = (Entity) selected.iterator().next(); Window window = openWindow("entityInspector.edit", WINDOW_OPEN_TYPE, ParamsMap.of("item", item)); window.addCloseListener(actionId -> { entitiesDs.refresh(); entitiesTable.focus(); }); } }
public void copySettings() { Set<User> selected = usersTable.getSelected(); if (!selected.isEmpty()) { Window copySettingsWindow = openWindow( "sec$User.copySettings", OpenType.DIALOG, ParamsMap.of("users", selected) ); copySettingsWindow.addCloseListener(actionId -> usersTable.focus() ); } }
@Override public void actionPerform(Component component) { Set selected = entitiesTable.getSelected(); if (selected.size() != 1) { return; } Entity editItem = (Entity) selected.toArray()[0]; Map<String, Object> editorParams = new HashMap<>(); editorParams.put("metaClass", editItem.getMetaClass()); editorParams.put("item", editItem); editorParams.put("parent", item); editorParams.put("autocommit", Boolean.FALSE); MetaProperty inverseProperty = metaProperty.getInverse(); if (inverseProperty != null) { editorParams.put("parentProperty", inverseProperty.getName()); } if (metaProperty.getType() == MetaProperty.Type.COMPOSITION) { editorParams.put("parentDs", entitiesDs); } Window window = openWindow("entityInspector.edit", OPEN_TYPE, editorParams); window.addCloseListener(actionId -> entitiesDs.refresh()); } }
@Override public void actionPerform(Component component) { @SuppressWarnings("unchecked") Set<Entity> selected = entitiesTable.getSelected(); if (!selected.isEmpty()) { try { if (exportFormat == ZIP) { byte[] data = entityImportExportService.exportEntitiesToZIP(selected); String resourceName = selectedMeta.getJavaClass().getSimpleName() + ".zip"; exportDisplay.show(new ByteArrayDataProvider(data), resourceName, ZIP); } else if (exportFormat == JSON) { byte[] data = entityImportExportService.exportEntitiesToJSON(selected) .getBytes(StandardCharsets.UTF_8); String resourceName = selectedMeta.getJavaClass().getSimpleName() + ".json"; exportDisplay.show(new ByteArrayDataProvider(data), resourceName, JSON); } } catch (Exception e) { showNotification(getMessage("exportFailed"), e.getMessage(), NotificationType.ERROR); log.error("Entities export failed", e); } } }
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 message() { Set<UserSessionEntity> selected = sessionsTable.getSelected(); Set<UserSessionEntity> all = new HashSet<>(sessionsDs.getItems()); SessionMessageWindow window = (SessionMessageWindow) openWindow("sessionMessageWindow", OpenType.DIALOG, ParamsMap.of("selectedSessions", selected, "allSessions", all)); window.addCloseListener(actionId -> { String result = window.getResult(); if (!StringUtils.isBlank(result)) { showNotification(result, NotificationType.TRAY); sessionsTable.focus(); } }); }
protected void export(ExportFormat exportFormat) { Set<Role> selected = rolesTable.getSelected(); View view = viewRepository.getView(Role.class, "role.export"); if (view == null) { throw new DevelopmentException("View 'role.export' for sec$Role was not found"); } if (!selected.isEmpty()) { try { if (exportFormat == ExportFormat.ZIP) { byte[] data = entityImportExportService.exportEntitiesToZIP(selected, view); exportDisplay.show(new ByteArrayDataProvider(data), "Roles", ExportFormat.ZIP); } else if (exportFormat == ExportFormat.JSON) { byte[] data = entityImportExportService.exportEntitiesToJSON(selected, view) .getBytes(StandardCharsets.UTF_8); exportDisplay.show(new ByteArrayDataProvider(data), "Roles", ExportFormat.JSON); } } catch (Exception e) { showNotification(getMessage("exportFailed"), e.getMessage(), NotificationType.ERROR); log.error("Roles export failed", e); } } } }
@Override public void actionPerform(Component component) { Set<CategoryAttribute> selected = categoryAttrsTable.getSelected(); if (!selected.isEmpty()) { AttributeEditor editor = (AttributeEditor) openEditor( "sys$CategoryAttribute.edit", selected.iterator().next(), OpenType.DIALOG, categoryAttrsTable.getDatasource()); editor.addCloseListener(actionId -> { categoryAttrsTable.getDatasource().refresh(); categoryAttrsTable.focus(); // restore selection from ds categoryAttrsTable.setSelected(categoryAttrsDs.getItem()); }); } } }
@SuppressWarnings("unused") public void applyPermissionMask() { Set<OperationPermissionTarget> selected = entityPermissionsTable.getSelected(); if (!selected.isEmpty() && (selected.size() > 1)) { for (OperationPermissionTarget target : selected) { for (EntityOperationControl control : operationControls) { if (control.isControlVisible() && control.applicableToEntity(target.getEntityClass())) { PermissionVariant variant; if (Boolean.TRUE.equals(control.getAllowChecker().getValue())) { variant = PermissionVariant.ALLOWED; } else if (Boolean.TRUE.equals(control.getDenyChecker().getValue())) { variant = PermissionVariant.DISALLOWED; } else { variant = PermissionVariant.NOTSET; } markTargetPermission(target, control.getMetaProperty(), control.getOperation(), variant); } } } // update all after data change entityPermissionsTable.repaint(); showNotification(getMessage("notification.applied"), NotificationType.HUMANIZED); } }
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")); } }
protected void initUsersTableActions() { userCreateAction = new GroupPropertyCreateAction(usersTable); userCreateAction.setAfterCommitHandler(entity -> usersTable.getDatasource().refresh() ); usersTable.addAction(userCreateAction); usersTable.addAction(new UserRemoveAction(usersTable, userManagementService)); Action moveToGroupAction = new ItemTrackingAction("moveToGroup") .withIcon("icons/move.png") .withCaption(getMessage("moveToGroup")) .withHandler(event -> { Set<User> selected = usersTable.getSelected(); if (!selected.isEmpty()) { moveUsersToGroup(selected); } }); moveToGroupAction.setEnabled(security.isEntityOpPermitted(User.class, EntityOp.UPDATE)); usersTable.addAction(moveToGroupAction); }