Search in sources :

Example 1 with AttributeTarget

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++;
    }
}
Also used : MetaClass(com.haulmont.chile.core.model.MetaClass) AttributeTarget(com.haulmont.cuba.gui.app.security.entity.AttributeTarget)

Example 2 with AttributeTarget

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;
    });
}
Also used : AttributePermissionVariant(com.haulmont.cuba.gui.app.security.entity.AttributePermissionVariant) Label(com.haulmont.cuba.gui.components.Label) AttributeTarget(com.haulmont.cuba.gui.app.security.entity.AttributeTarget)

Aggregations

AttributeTarget (com.haulmont.cuba.gui.app.security.entity.AttributeTarget)2 MetaClass (com.haulmont.chile.core.model.MetaClass)1 AttributePermissionVariant (com.haulmont.cuba.gui.app.security.entity.AttributePermissionVariant)1 Label (com.haulmont.cuba.gui.components.Label)1