use of io.jmix.ui.accesscontext.UiBulkEditContext in project jmix by jmix-framework.
the class BulkEditAction method execute.
/**
* Executes the action.
*/
@SuppressWarnings("unchecked")
@Override
public void execute() {
if (!(target.getItems() instanceof EntityDataUnit)) {
throw new IllegalStateException("BulkEditAction target Items is null " + "or does not implement EntityDataUnit");
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
throw new IllegalStateException("Target is not bound to entity");
}
UiBulkEditContext context = new UiBulkEditContext();
accessManager.applyRegisteredConstraints(context);
if (!context.isPermitted()) {
if (target.getFrame() != null) {
Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
notifications.create(NotificationType.ERROR).withCaption(messages.getMessage("accessDenied.message")).show();
}
return;
}
if (target.getSelected().isEmpty() && target.getFrame() != null) {
Notifications notifications = getScreenContext(target.getFrame()).getNotifications();
notifications.create(NotificationType.ERROR).withCaption(messages.getMessage("actions.BulkEdit.emptySelection")).show();
return;
}
Window window = ComponentsHelper.getWindowNN(target);
BulkEditorBuilder<?> builder = bulkEditors.builder(metaClass, target.getSelected(), window.getFrameOwner()).withListComponent(target);
if (columnsMode != null) {
builder = builder.withColumnsMode(columnsMode);
}
if (exclude != null) {
builder = builder.withExclude(exclude);
}
if (fieldSorter != null) {
builder = builder.withFieldSorter(fieldSorter);
}
if (includeProperties != null) {
builder = builder.withIncludeProperties(includeProperties);
}
if (openMode != null) {
builder = builder.withOpenMode(openMode);
}
if (useConfirmDialog != null) {
builder = builder.withUseConfirmDialog(useConfirmDialog);
}
builder.create().show();
}
use of io.jmix.ui.accesscontext.UiBulkEditContext in project jmix by jmix-framework.
the class BulkEditAction method setAccessManager.
@Autowired
@Override
protected void setAccessManager(AccessManager accessManager) {
super.setAccessManager(accessManager);
UiBulkEditContext context = new UiBulkEditContext();
accessManager.applyRegisteredConstraints(context);
visibleBySpecificUiPermission = context.isPermitted();
}
Aggregations