use of com.haulmont.cuba.gui.app.security.entity.AttributeTarget in project cuba by cuba-platform.
the class AttributePermissionsFrame method initPermissionControls.
private void initPermissionControls(MultiplePermissionTarget item, GridLayout editGrid) {
int i = 0;
MetaClass metaClass = item.getEntityMetaClass();
for (AttributeTarget target : item.getPermissions()) {
if (!userSession.isEntityAttrPermitted(metaClass, target.getId(), EntityAttrAccess.VIEW)) {
continue;
}
AttributePermissionControl control = new AttributePermissionControl(item, target.getId());
int gridRow = i + 2;
editGrid.add(control.getAttributeLabel(), 0, gridRow);
editGrid.add(control.getModifyCheckBox(), 1, gridRow);
editGrid.add(control.getReadOnlyCheckBox(), 2, gridRow);
editGrid.add(control.getHideCheckBox(), 3, gridRow);
control.getModifyCheckBox().setAlignment(Alignment.MIDDLE_CENTER);
control.getReadOnlyCheckBox().setAlignment(Alignment.MIDDLE_CENTER);
control.getHideCheckBox().setAlignment(Alignment.MIDDLE_CENTER);
permissionControls.add(control);
i++;
}
}
use of com.haulmont.cuba.gui.app.security.entity.AttributeTarget in project cuba by cuba-platform.
the class AttributePermissionsFrameCompanion method initPermissionColoredColumn.
@Override
public void initPermissionColoredColumn(final Table<MultiplePermissionTarget> propertyPermissionsTable) {
propertyPermissionsTable.addGeneratedColumn("permissionsInfo", target -> {
List<AttributeTarget> permissions = target.getPermissions();
if (permissions.size() == 0)
return null;
Label label = AppConfig.getFactory().createComponent(Label.class);
label.setHtmlEnabled(true);
int i = 0;
StringBuilder builder = new StringBuilder();
Iterator<AttributeTarget> iterator = permissions.iterator();
while (iterator.hasNext() && i < MultiplePermissionTarget.SHOW_PERMISSIONS_COUNT) {
AttributeTarget attributeTarget = iterator.next();
AttributePermissionVariant permissionVariant = attributeTarget.getPermissionVariant();
if (permissionVariant != AttributePermissionVariant.NOTSET) {
if (i < MultiplePermissionTarget.SHOW_PERMISSIONS_COUNT - 1) {
if (i > 0)
builder.append(", ");
builder.append("<span class=\"role-permission-").append(permissionVariant.getColor()).append("\">").append(attributeTarget.getId()).append("</span>");
} else {
builder.append(", ...");
}
i++;
}
}
label.setValue(builder.toString());
return label;
});
}
Aggregations