use of com.haulmont.cuba.gui.app.security.entity.AttributePermissionVariant in project cuba by cuba-platform.
the class AttributePermissionsFrame method attachAllCheckboxListener.
protected void attachAllCheckboxListener(CheckBox checkBox, final AttributePermissionVariant activeVariant) {
checkBox.addValueChangeListener(e -> {
if (itemChanging) {
return;
}
if (propertyPermissionsTable.getSelected().isEmpty()) {
return;
}
itemChanging = true;
MultiplePermissionTarget item = propertyPermissionsTable.getSingleSelected();
if (item != null) {
for (AttributePermissionControl control : permissionControls) {
AttributePermissionVariant permissionVariant = PermissionUiHelper.getCheckBoxVariant(e.getValue(), activeVariant);
control.markTargetPermission(permissionVariant);
control.updateCheckers(permissionVariant);
}
// todo enforce value change
propertyPermissionsTable.repaint();
allModifyCheck.setValue(isAllModified());
allReadOnlyCheck.setValue(isAllReadOnly());
allHideCheck.setValue(isAllHide());
}
itemChanging = false;
});
}
use of com.haulmont.cuba.gui.app.security.entity.AttributePermissionVariant 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