use of io.jmix.security.constraint.PolicyStore in project jmix by jmix-framework.
the class EntityLogBrowser method onInstancePickerLookup.
@Subscribe("instancePicker.lookup")
public void onInstancePickerLookup(Action.ActionPerformedEvent event) {
final MetaClass metaClass = instancePicker.getMetaClass();
if (instancePicker.isEditable()) {
if (metaClass == null) {
throw new IllegalStateException("Please specify metaclass or property for PickerField");
}
if (!secureOperations.isEntityReadPermitted(metaClass, policyStore)) {
notifications.create(Notifications.NotificationType.ERROR).withCaption(messages.getMessage(EntityLogBrowser.class, "entityAccessDeniedMessage")).show();
return;
}
try {
Screen lookup = screenBuilders.lookup(instancePicker).withSelectHandler(items -> {
if (!items.isEmpty()) {
Object item = items.iterator().next();
instancePicker.setValue(item);
}
}).build();
lookup.addAfterCloseListener(afterCloseEvent -> instancePicker.focus());
lookup.show();
} catch (AccessDeniedException ex) {
notifications.create(Notifications.NotificationType.ERROR).withCaption(messages.getMessage(EntityLogBrowser.class, "entityScreenAccessDeniedMessage")).show();
return;
}
}
}
Aggregations