use of com.haulmont.cuba.gui.components.actions.RemoveAction in project cuba by cuba-platform.
the class UiPermissionsFrame method init.
@Override
public void init(Map<String, Object> params) {
super.init(params);
WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
Collection<WindowInfo> windows = sortWindowInfos(windowConfig.getWindows());
Map<String, Object> screens = new LinkedHashMap<>();
for (WindowInfo windowInfo : windows) {
String id = windowInfo.getId();
String menuId = "menu-config." + id;
String localeMsg = messages.getMessage(AppConfig.getMessagesPack(), menuId);
String title = menuId.equals(localeMsg) ? id : localeMsg + " (" + id + ")";
screens.put(title, id);
}
screenFilter.setOptionsMap(screens);
companion.initPermissionsColoredColumns(uiPermissionsTable);
uiPermissionTargetsDs.addItemChangeListener(e -> {
if (!selectedComponentPanel.isVisible() && (e.getItem() != null)) {
selectedComponentPanel.setVisible(true);
}
if (selectedComponentPanel.isVisible() && (e.getItem() == null)) {
selectedComponentPanel.setVisible(false);
}
updateCheckBoxes(e.getItem());
});
uiPermissionTargetsDs.addItemPropertyChangeListener(e -> {
if ("permissionVariant".equals(e.getProperty())) {
updateCheckBoxes(uiPermissionsTable.getSingleSelected());
}
});
attachCheckBoxListener(readOnlyCheckBox, UiPermissionVariant.READ_ONLY);
attachCheckBoxListener(hideCheckBox, UiPermissionVariant.HIDE);
attachCheckBoxListener(showCheckBox, UiPermissionVariant.SHOW);
uiPermissionTargetsDs.setPermissionDs(uiPermissionsDs);
uiPermissionsDs.refresh();
uiPermissionTargetsDs.refresh();
boolean isCreatePermitted = security.isEntityOpPermitted(Permission.class, EntityOp.CREATE);
boolean isDeletePermitted = security.isEntityOpPermitted(Permission.class, EntityOp.DELETE);
boolean isRoleEditPermitted = security.isEntityOpPermitted(metadata.getClass(Role.class), EntityOp.UPDATE);
final boolean hasPermissionsToModifyPermission = isCreatePermitted && isDeletePermitted && isRoleEditPermitted;
RemoveAction removeAction = new RemoveAction(uiPermissionsTable, false);
removeAction.setAfterRemoveHandler(removedItems -> {
if (!removedItems.isEmpty()) {
UiPermissionTarget removedPermission = (UiPermissionTarget) removedItems.iterator().next();
markItemPermission(UiPermissionVariant.NOTSET, removedPermission);
}
});
removeAction.setEnabled(hasPermissionsToModifyPermission);
removeAction.setIcon(null);
removeAction.setCaption(getMessage("actions.RemoveSelected"));
removePermissionBtn.setAction(removeAction);
uiPermissionsTable.addAction(removeAction);
editPane.setEnabled(security.isEntityOpPermitted(Role.class, EntityOp.UPDATE));
applyPermissions(hasPermissionsToModifyPermission);
}
use of com.haulmont.cuba.gui.components.actions.RemoveAction in project cuba by cuba-platform.
the class UserLookup method init.
@Override
public void init(Map<String, Object> params) {
if (WindowParams.MULTI_SELECT.getBool(getContext())) {
usersTable.setMultiSelect(true);
}
RemoveAction removeAction = new UserRemoveAction(usersTable, userManagementService);
usersTable.addAction(removeAction);
}
use of com.haulmont.cuba.gui.components.actions.RemoveAction in project cuba by cuba-platform.
the class FileFrameController method init.
@Override
public void init(Map<String, Object> params) {
super.init(params);
uploadField = (FileUploadField) getComponent("uploadField");
filesTable = (Table) getComponent("files");
initGeneratedColumn();
ds = (CollectionDatasource) getDsContext().get("filesDs");
Button remove = (Button) getComponentNN("remove");
remove.setAction(new RemoveAction(filesTable, false));
uploadField.addFileUploadSucceedListener(e -> {
fd = metadata.create(FileDescriptor.class);
fd.setName(uploadField.getFileName());
fd.setExtension(FilenameUtils.getExtension(uploadField.getFileName()));
FileUploadingAPI fileUploading = AppBeans.get(FileUploadingAPI.NAME);
File file = fileUploading.getFile(uploadField.getFileId());
fd.setSize(file.length());
fd.setCreateDate(AppBeans.get(TimeSource.class).currentTimestamp());
saveFile();
ds.addItem(fd);
showNotification(getMessage("uploadSuccess"), NotificationType.HUMANIZED);
});
uploadField.addFileUploadErrorListener(e -> showNotification(getMessage("uploadUnsuccess"), NotificationType.HUMANIZED));
}
Aggregations