use of io.jmix.core.accesscontext.InMemoryCrudEntityContext in project jmix by jmix-framework.
the class EditAction method refreshState.
@Override
public void refreshState() {
super.refreshState();
if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
return;
}
if (!captionInitialized) {
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
UiEntityContext entityContext = new UiEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
InMemoryCrudEntityContext inMemoryContext = new InMemoryCrudEntityContext(metaClass, applicationContext);
accessManager.applyRegisteredConstraints(inMemoryContext);
if (metaClass != null) {
Object entity = target.getSingleSelected();
if (entityContext.isEditPermitted() && (inMemoryContext.updatePredicate() == null || entity != null && inMemoryContext.isUpdatePermitted(entity))) {
super.setCaption(messages.getMessage("actions.Edit"));
} else {
super.setCaption(messages.getMessage("actions.View"));
}
}
}
}
Aggregations