Search in sources :

Example 6 with TagModel

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

the class TagsView method addChildTags.

private void addChildTags(List<TagModel> tagModels, HasWidgets group, final int indent) {
    int newIndent = indent + 1;
    for (TagModel model : tagModels) {
        ListGroupItem tagItem = new ListGroupItem();
        tagItem.getElement().getStyle().setPaddingLeft(indent * INDENT_WIDTH, Unit.PX);
        ButtonGroup buttonGroup = new ButtonGroup();
        buttonGroup.add(createActivateButton(model));
        buttonGroup.add(createAddButton(model));
        buttonGroup.add(createEditButton(model));
        buttonGroup.add(createRemoveButton(model));
        buttonGroup.addStyleName(Styles.PULL_RIGHT);
        tagItem.add(buttonGroup);
        tagItem.setText(model.getName().getEntity());
        group.add(tagItem);
        List<TagModel> children = model.getChildren();
        if (children != null && !children.isEmpty()) {
            addChildTags(model.getChildren(), group, newIndent);
        }
    }
}
Also used : ButtonGroup(org.gwtbootstrap3.client.ui.ButtonGroup) ListGroupItem(org.gwtbootstrap3.client.ui.ListGroupItem) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel)

Example 7 with TagModel

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

the class AbstractMainWithDetailsTableView method setActiveTags.

public void setActiveTags(List<TagModel> tags) {
    resultList.clear();
    for (final TagModel tag : tags) {
        ListItem tagItem = new ListItem();
        Span label = new Span();
        label.addStyleName(Styles.LABEL);
        label.addStyleName(PatternflyConstants.PF_LABEL_INFO);
        label.setText(tag.getName().getEntity());
        Anchor deactivateAnchor = new Anchor();
        Span closeIconSpan = new Span();
        closeIconSpan.addStyleName(PatternflyIconType.PF_BASE.getCssName());
        closeIconSpan.addStyleName(PatternflyIconType.PF_CLOSE.getCssName());
        deactivateAnchor.add(closeIconSpan);
        deactivateAnchor.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                tag.setSelection(false);
            }
        });
        label.add(deactivateAnchor);
        tagItem.add(label);
        resultList.add(tagItem);
    }
    resultRow.setVisible(!tags.isEmpty());
}
Also used : Anchor(org.gwtbootstrap3.client.ui.Anchor) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ListItem(org.gwtbootstrap3.client.ui.ListItem) TagModel(org.ovirt.engine.ui.uicommonweb.models.tags.TagModel) Span(org.gwtbootstrap3.client.ui.html.Span)

Example 8 with TagModel

use of org.ovirt.engine.ui.uicommonweb.models.tags.TagModel 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)

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