public Widget asWidget() {
principalItem = new ReadOnlyItem<RoleAssignment>("principal", type == Principal.Type.GROUP ? "Group" : "User") {
@Override
public String asString() {
StringBuilder builder = new StringBuilder();
RoleAssignment assignment = getValue();
if (assignment != null) {
builder.append(assignment.getPrincipal().getName());
if (assignment.getRealm() != null) {
builder.append("@").append(assignment.getRealm());
}
}
return builder.toString();
}
};
principalItem.setEnabled(false);
includeExcludeFormItem = new IncludeExcludeFormItem("n/a", "Roles");
form.setFields(principalItem, includeExcludeFormItem);
// form.setFieldsInGroup(Console.CONSTANTS.common_label_advanced(), new DisclosureGroupRenderer(), excludesItem);
form.setEnabled(false);
form.setToolsCallback(new FormCallback() {
@Override
public void onSave(final Map changeset) {
RoleAssignment edited = form.getEditedEntity();
if (edited != null) {
// create a new role assignment to calculate the include / exclude diffs
Map<IncludeExcludeFormItem.Type, Set<Role>> includesExcludes = includeExcludeFormItem.getValue();
RoleAssignment newRoleAssignment = new RoleAssignment(edited.getPrincipal());
newRoleAssignment.setRealm(edited.getRealm());
newRoleAssignment.addRoles(includesExcludes.get(INCLUDE));
newRoleAssignment.addExcludes(includesExcludes.get(EXCLUDE));
presenter.saveRoleAssignment(newRoleAssignment, edited);
}
}
@Override