Search in sources :

Example 11 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class UserListModel method assignTags.

public void assignTags() {
    if (getWindow() != null) {
        return;
    }
    TagListModel model = new TagListModel();
    setWindow(model);
    model.setTitle(ConstantsManager.getInstance().getConstants().assignTagsTitle());
    model.setHelpTag(HelpTag.assign_tags_users);
    // $NON-NLS-1$
    model.setHashName("assign_tags_users");
    getAttachedTagsToSelectedUsers(model);
    // $NON-NLS-1$
    UICommand tempVar = UICommand.createDefaultOkUiCommand("OnAssignTags", this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand("Cancel", this);
    model.getCommands().add(tempVar2);
}
Also used : UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)

Example 12 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class VmListModel method postOnAssignTags.

@Override
public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
    TagListModel model = (TagListModel) getWindow();
    ArrayList<Guid> vmIds = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VM vm = (VM) item;
        vmIds.add(vm.getId());
    }
    // prepare attach/detach lists
    ArrayList<Guid> tagsToAttach = new ArrayList<>();
    ArrayList<Guid> tagsToDetach = new ArrayList<>();
    if (model.getItems() != null && model.getItems().size() > 0) {
        ArrayList<TagModel> tags = (ArrayList<TagModel>) model.getItems();
        TagModel rootTag = tags.get(0);
        TagModel.recursiveEditAttachDetachLists(rootTag, attachedTags, tagsToAttach, tagsToDetach);
    }
    ArrayList<ActionParametersBase> parameters = new ArrayList<>();
    for (Guid a : tagsToAttach) {
        parameters.add(new AttachEntityToTagParameters(a, vmIds));
    }
    Frontend.getInstance().runMultipleAction(ActionType.AttachVmsToTag, parameters);
    parameters = new ArrayList<>();
    for (Guid a : tagsToDetach) {
        parameters.add(new AttachEntityToTagParameters(a, vmIds));
    }
    Frontend.getInstance().runMultipleAction(ActionType.DetachVmFromTag, parameters);
    cancel();
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) ArrayList(java.util.ArrayList) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel) Guid(org.ovirt.engine.core.compat.Guid) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 13 with TagListModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel in project ovirt-engine by oVirt.

the class VmListModel method onAssignTags.

private void onAssignTags() {
    TagListModel model = (TagListModel) getWindow();
    getAttachedTagsToSelectedVMs(model);
}
Also used : TagListModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)

Aggregations

TagListModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)13 ArrayList (java.util.ArrayList)6 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)6 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)6 Guid (org.ovirt.engine.core.compat.Guid)6 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)6 TagModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagModel)6 Inject (com.google.inject.Inject)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 ActionUtils (org.ovirt.engine.core.common.ActionUtils)3 ActionType (org.ovirt.engine.core.common.action.ActionType)3 Tags (org.ovirt.engine.core.common.businessentities.Tags)3 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)3 SearchType (org.ovirt.engine.core.common.interfaces.SearchType)3 QueryType (org.ovirt.engine.core.common.queries.QueryType)3 SearchParameters (org.ovirt.engine.core.common.queries.SearchParameters)3 SearchObjects (org.ovirt.engine.core.searchbackend.SearchObjects)3 Frontend (org.ovirt.engine.ui.frontend.Frontend)3