Search in sources :

Example 1 with SelectionTreeNodeModel

use of org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel in project ovirt-engine by oVirt.

the class RoleListModel method setAttachedActionGroups.

void setAttachedActionGroups(List<ActionGroup> attachedActions) {
    Role role = getSelectedItem();
    RoleModel model = (RoleModel) getWindow();
    ArrayList<SelectionTreeNodeModel> selectionTree = RoleTreeView.getRoleTreeView(model.getIsNew() ? false : role.isReadonly(), model.getIsAdminRole().getEntity());
    for (SelectionTreeNodeModel sm : selectionTree) {
        for (SelectionTreeNodeModel smChild : sm.getChildren()) {
            smChild.setParent(sm);
            smChild.setIsSelectedNotificationPrevent(false);
            for (SelectionTreeNodeModel smGrandChild : smChild.getChildren()) {
                smGrandChild.setParent(smChild);
                smGrandChild.setIsSelectedNotificationPrevent(false);
                if (attachedActions.contains(ActionGroup.valueOf(smGrandChild.getTitle()))) {
                    smGrandChild.setIsSelectedNullable(true);
                    smGrandChild.updateParentSelection();
                }
                if (smChild.getChildren().get(0).equals(smGrandChild)) {
                    smGrandChild.updateParentSelection();
                }
            }
        }
    }
    model.setPermissionGroupModels(selectionTree);
}
Also used : Role(org.ovirt.engine.core.common.businessentities.Role) SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel)

Example 2 with SelectionTreeNodeModel

use of org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel in project ovirt-engine by oVirt.

the class RoleListModel method onReset.

public void onReset() {
    RoleModel model = (RoleModel) getWindow();
    ArrayList<ActionGroup> attachedActions = commandType == CommandType.New ? new ArrayList<ActionGroup>() : publicAttachedActions;
    for (SelectionTreeNodeModel sm : model.getPermissionGroupModels()) {
        for (SelectionTreeNodeModel smChild : sm.getChildren()) {
            for (SelectionTreeNodeModel smGrandChild : smChild.getChildren()) {
                smGrandChild.setIsSelectedNullable(attachedActions.contains(ActionGroup.valueOf(smGrandChild.getTitle())));
            }
        }
    }
}
Also used : SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel) ActionGroup(org.ovirt.engine.core.common.businessentities.ActionGroup)

Example 3 with SelectionTreeNodeModel

use of org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel in project ovirt-engine by oVirt.

the class RoleTreeView method getRoleTreeView.

public static ArrayList<SelectionTreeNodeModel> getRoleTreeView(boolean isReadOnly, boolean isAdmin) {
    RoleNode tree = initTreeView();
    ArrayList<SelectionTreeNodeModel> roleTreeView = new ArrayList<>();
    SelectionTreeNodeModel firstNode;
    SelectionTreeNodeModel secondNode;
    SelectionTreeNodeModel thirdNode;
    for (RoleNode first : tree.getLeafRoles()) {
        firstNode = createSelectionTreeNodeModel(isReadOnly, first);
        for (RoleNode second : first.getLeafRoles()) {
            secondNode = createSelectionTreeNodeModel(isReadOnly, second);
            secondNode.setTooltip(second.getTooltip());
            for (RoleNode third : second.getLeafRoles()) {
                thirdNode = createLeafSelectionTreeNodeModel(isReadOnly, third);
                if (isAdmin || isUser(thirdNode)) {
                    secondNode.getChildren().add(thirdNode);
                }
            }
            if (secondNode.getChildren().size() > 0) {
                firstNode.getChildren().add(secondNode);
            }
        }
        if (firstNode.getChildren().size() > 0) {
            roleTreeView.add(firstNode);
        }
    }
    return roleTreeView;
}
Also used : SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel) ArrayList(java.util.ArrayList)

Example 4 with SelectionTreeNodeModel

use of org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel in project ovirt-engine by oVirt.

the class RoleTreeView method createSelectionTreeNodeModel.

protected static SelectionTreeNodeModel createSelectionTreeNodeModel(boolean isReadOnly, RoleNode roleNode) {
    SelectionTreeNodeModel nodeModel;
    nodeModel = new SelectionTreeNodeModel();
    nodeModel.setTitle(roleNode.getName());
    nodeModel.setDescription(roleNode.getDesc());
    nodeModel.setIsChangeable(!isReadOnly);
    return nodeModel;
}
Also used : SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel)

Example 5 with SelectionTreeNodeModel

use of org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel in project ovirt-engine by oVirt.

the class TagListModel method createTree.

public SelectionTreeNodeModel createTree(TagModel tag) {
    SelectionTreeNodeModel node = new SelectionTreeNodeModel();
    node.setDescription(tag.getName().getEntity());
    node.setIsSelectedNullable(tag.getSelection());
    node.setIsChangeable(tag.getIsChangable());
    node.setIsSelectedNotificationPrevent(true);
    node.setEntity(tag);
    node.getPropertyChangedEvent().addListener(this);
    if (tag.getChildren().isEmpty()) {
        getSelectionNodeList().add(node);
        return node;
    }
    for (TagModel childTag : tag.getChildren()) {
        SelectionTreeNodeModel childNode = createTree(childTag);
        childNode.setParent(node);
        node.getChildren().add(childNode);
    }
    return node;
}
Also used : SelectionTreeNodeModel(org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel)

Aggregations

SelectionTreeNodeModel (org.ovirt.engine.ui.uicommonweb.models.common.SelectionTreeNodeModel)10 ArrayList (java.util.ArrayList)4 ActionGroup (org.ovirt.engine.core.common.businessentities.ActionGroup)2 EventSubscriber (org.ovirt.engine.core.common.businessentities.EventSubscriber)2 Role (org.ovirt.engine.core.common.businessentities.Role)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 MissingResourceException (java.util.MissingResourceException)1 AuditLogType (org.ovirt.engine.core.common.AuditLogType)1 EventNotificationEntity (org.ovirt.engine.core.common.EventNotificationEntity)1 ActionGroupsToRoleParameter (org.ovirt.engine.core.common.action.ActionGroupsToRoleParameter)1 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 EventSubscriptionParametesBase (org.ovirt.engine.core.common.action.EventSubscriptionParametesBase)1 RoleWithActionGroupsParameters (org.ovirt.engine.core.common.action.RoleWithActionGroupsParameters)1 RolesOperationsParameters (org.ovirt.engine.core.common.action.RolesOperationsParameters)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 EnumTranslator (org.ovirt.engine.ui.uicompat.EnumTranslator)1 Translator (org.ovirt.engine.ui.uicompat.Translator)1