Search in sources :

Example 1 with TagModel

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

the class SearchPanelPresenterWidget method setTags.

public void setTags(List<TagModel> tags) {
    List<String> tagString = new ArrayList<>();
    for (TagModel tagModel : tags) {
        tagString.add(tagModel.getName().getEntity());
    }
    model.setTagStrings(tagString);
    if (isVisible()) {
        model.executeCommand(model.getSearchCommand());
    }
}
Also used : ArrayList(java.util.ArrayList) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel)

Example 2 with TagModel

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

the class TagObject method from.

private static TagObject from(TagModel model, boolean includeChildren) {
    TagObject result = JavaScriptObject.createObject().cast();
    // $NON-NLS-1$
    result.setValueAsString("description", model.getDescription().getEntity());
    // $NON-NLS-1$
    result.setValueAsString("name", model.getName().getEntity());
    // $NON-NLS-1$
    result.setValueAsBoolean("selected", model.getSelection());
    if (includeChildren) {
        JsArray<TagObject> children = JavaScriptObject.createArray().cast();
        for (TagModel child : model.getChildren()) {
            children.push(TagObject.from(child, true));
        }
        // $NON-NLS-1$
        result.setValueAsJavaScriptObject("children", children);
    }
    return result;
}
Also used : TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel)

Example 3 with TagModel

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

the class HostListModel method postOnAssignTags.

@Override
public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
    TagListModel model = (TagListModel) getWindow();
    ArrayList<Guid> hostIds = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        VDS vds = (VDS) item;
        hostIds.add(vds.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> prmsToAttach = new ArrayList<>();
    for (Guid tag_id : tagsToAttach) {
        prmsToAttach.add(new AttachEntityToTagParameters(tag_id, hostIds));
    }
    Frontend.getInstance().runMultipleAction(ActionType.AttachVdsToTag, prmsToAttach);
    ArrayList<ActionParametersBase> prmsToDetach = new ArrayList<>();
    for (Guid tag_id : tagsToDetach) {
        prmsToDetach.add(new AttachEntityToTagParameters(tag_id, hostIds));
    }
    Frontend.getInstance().runMultipleAction(ActionType.DetachVdsFromTag, prmsToDetach);
    cancel();
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ArrayList(java.util.ArrayList) AttachEntityToTagParameters(org.ovirt.engine.core.common.action.AttachEntityToTagParameters) JsSingleValueStringObject(org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject) 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 4 with TagModel

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

the class UserListModel method postOnAssignTags.

@Override
public void postOnAssignTags(Map<Guid, Boolean> attachedTags) {
    TagListModel model = (TagListModel) getWindow();
    ArrayList<Guid> userIds = new ArrayList<>();
    ArrayList<Guid> grpIds = new ArrayList<>();
    for (Object item : getSelectedItems()) {
        DbUser user = (DbUser) item;
        if (user.isGroup()) {
            grpIds.add(user.getId());
        } else {
            userIds.add(user.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> usersToAttach = new ArrayList<>();
    ArrayList<ActionParametersBase> grpsToAttach = new ArrayList<>();
    for (Guid tag_id : tagsToAttach) {
        if (userIds.size() > 0) {
            usersToAttach.add(new AttachEntityToTagParameters(tag_id, userIds));
        }
        if (grpIds.size() > 0) {
            grpsToAttach.add(new AttachEntityToTagParameters(tag_id, grpIds));
        }
    }
    if (usersToAttach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.AttachUserToTag, usersToAttach);
    }
    if (grpsToAttach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.AttachUserGroupToTag, grpsToAttach);
    }
    ArrayList<ActionParametersBase> usersToDetach = new ArrayList<>();
    ArrayList<ActionParametersBase> grpsToDetach = new ArrayList<>();
    for (Guid tag_id : tagsToDetach) {
        if (userIds.size() > 0) {
            usersToDetach.add(new AttachEntityToTagParameters(tag_id, userIds));
        }
        if (grpIds.size() > 0) {
            grpsToDetach.add(new AttachEntityToTagParameters(tag_id, grpIds));
        }
    }
    if (usersToDetach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.DetachUserFromTag, usersToDetach);
    }
    if (grpsToDetach.size() > 0) {
        Frontend.getInstance().runMultipleAction(ActionType.DetachUserGroupFromTag, grpsToDetach);
    }
    cancel();
}
Also used : 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) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 5 with TagModel

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

the class TagsView method updateTags.

@Override
public void updateTags(Collection<TagModel> tags) {
    emptyTagsColumn.setVisible(tags.isEmpty());
    rootListGroup.clear();
    for (TagModel model : tags) {
        addChildTags(model.getChildren(), rootListGroup, 0);
    }
}
Also used : TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel)

Aggregations

TagModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagModel)8 ArrayList (java.util.ArrayList)4 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)3 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)3 Guid (org.ovirt.engine.core.compat.Guid)3 TagListModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 Anchor (org.gwtbootstrap3.client.ui.Anchor)1 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)1 ListGroupItem (org.gwtbootstrap3.client.ui.ListGroupItem)1 ListItem (org.gwtbootstrap3.client.ui.ListItem)1 Span (org.gwtbootstrap3.client.ui.html.Span)1 VDS (org.ovirt.engine.core.common.businessentities.VDS)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)1 JsSingleValueStringObject (org.ovirt.engine.ui.frontend.utils.JsSingleValueStringObject)1