use of com.haulmont.cuba.gui.data.PropertyDatasource in project cuba by cuba-platform.
the class RemoveAction method checkRemovePermission.
protected boolean checkRemovePermission() {
CollectionDatasource ds = target.getDatasource();
if (ds instanceof PropertyDatasource) {
PropertyDatasource propertyDatasource = (PropertyDatasource) ds;
MetaClass parentMetaClass = propertyDatasource.getMaster().getMetaClass();
MetaProperty metaProperty = propertyDatasource.getProperty();
boolean modifyPermitted = security.isEntityAttrPermitted(parentMetaClass, metaProperty.getName(), EntityAttrAccess.MODIFY);
if (!modifyPermitted) {
return false;
}
if (metaProperty.getRange().getCardinality() != Range.Cardinality.MANY_TO_MANY) {
boolean deletePermitted = security.isEntityOpPermitted(ds.getMetaClass(), EntityOp.DELETE);
if (!deletePermitted) {
return false;
}
}
} else {
boolean entityOpPermitted = security.isEntityOpPermitted(ds.getMetaClass(), EntityOp.DELETE);
if (!entityOpPermitted) {
return false;
}
}
return true;
}
use of com.haulmont.cuba.gui.data.PropertyDatasource in project cuba by cuba-platform.
the class EditAction method actionPerform.
/**
* This method is invoked by the action owner component.
*
* @param component component invoking the action
*/
@Override
public void actionPerform(Component component) {
if (beforeActionPerformedHandler != null) {
if (!beforeActionPerformedHandler.beforeActionPerformed())
return;
}
final Set selected = target.getSelected();
if (selected.size() == 1) {
Datasource parentDs = null;
final CollectionDatasource datasource = target.getDatasource();
if (datasource instanceof PropertyDatasource) {
MetaProperty metaProperty = ((PropertyDatasource) datasource).getProperty();
if (metaProperty.getType().equals(MetaProperty.Type.COMPOSITION)) {
parentDs = datasource;
}
}
Map<String, Object> params = prepareWindowParams();
internalOpenEditor(datasource, datasource.getItem(), parentDs, params);
} else if (selected.size() > 1 && bulkEditorIntegration.isEnabled()) {
UserSession userSession = AppBeans.get(UserSessionSource.class).getUserSession();
boolean isBulkEditorPermitted = userSession.isSpecificPermitted(BulkEditor.PERMISSION);
if (isBulkEditorPermitted) {
// if bulk editor integration enabled and permitted for user
Map<String, Object> params = ParamsMap.of("metaClass", target.getDatasource().getMetaClass(), "selected", selected, "exclude", bulkEditorIntegration.getExcludePropertiesRegex(), "fieldValidators", bulkEditorIntegration.getFieldValidators(), "modelValidators", bulkEditorIntegration.getModelValidators());
LegacyFrame frameOwner = (LegacyFrame) target.getFrame().getFrameOwner();
Window bulkEditor = frameOwner.openWindow("bulkEditor", bulkEditorIntegration.getOpenType(), params);
bulkEditor.addCloseListener(actionId -> {
if (Window.COMMIT_ACTION_ID.equals(actionId)) {
target.getDatasource().refresh();
}
if (target instanceof Component.Focusable) {
((Component.Focusable) target).focus();
}
Consumer<BulkEditorCloseEvent> afterEditorCloseHandler = bulkEditorIntegration.getAfterEditorCloseHandler();
if (afterEditorCloseHandler != null) {
afterEditorCloseHandler.accept(new BulkEditorCloseEvent(this, bulkEditor, actionId));
}
});
}
}
}
use of com.haulmont.cuba.gui.data.PropertyDatasource in project cuba by cuba-platform.
the class ExcludeAction method checkRemovePermission.
@Override
protected boolean checkRemovePermission() {
CollectionDatasource ds = target.getDatasource();
if (ds instanceof PropertyDatasource) {
PropertyDatasource propertyDatasource = (PropertyDatasource) ds;
MetaClass parentMetaClass = propertyDatasource.getMaster().getMetaClass();
MetaProperty metaProperty = propertyDatasource.getProperty();
boolean attrPermitted = security.isEntityAttrPermitted(parentMetaClass, metaProperty.getName(), EntityAttrAccess.MODIFY);
if (!attrPermitted) {
return false;
}
}
return true;
}
use of com.haulmont.cuba.gui.data.PropertyDatasource in project cuba by cuba-platform.
the class AddAction method isPermitted.
@Override
protected boolean isPermitted() {
if (target == null || target.getDatasource() == null) {
return false;
}
CollectionDatasource ownerDs = target.getDatasource();
if (ownerDs instanceof PropertyDatasource) {
PropertyDatasource datasource = (PropertyDatasource) ownerDs;
MetaClass parentMetaClass = datasource.getMaster().getMetaClass();
MetaProperty metaProperty = datasource.getProperty();
boolean attrPermitted = security.isEntityAttrPermitted(parentMetaClass, metaProperty.getName(), EntityAttrAccess.MODIFY);
if (!attrPermitted) {
return false;
}
}
return super.isPermitted();
}
Aggregations