Search in sources :

Example 6 with ResourceTag

use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.

the class AssignTagTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add tag");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    final GetAllResourcesTags tags = new GetAllResourcesTags(PerunEntity.VIRTUAL_ORGANIZATION, resource.getVoId());
    final CellTable<ResourceTag> table = tags.getTable();
    final TabItem tab = this;
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedTagsToResource());
    assignButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<ResourceTag> tagsToAssign = tags.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(tagsToAssign)) {
                for (int i = 0; i < tagsToAssign.size(); i++) {
                    if (i != tagsToAssign.size() - 1) {
                        // call json normaly
                        AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.disableButtonEvents(assignButton));
                        request.assignResourceTag(tagsToAssign.get(i));
                    } else {
                        // last change - call json with update
                        AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab));
                        request.assignResourceTag(tagsToAssign.get(i));
                    }
                }
            }
        }
    });
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    menu.addFilterWidget(new ExtendedSuggestBox(tags.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            tags.filterTable(text);
            // if single group, select
            if (tags.getList().size() == 1) {
                table.getSelectionModel().setSelected(tags.getList().get(0), true);
            }
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(tags, table, assignButton);
    tags.retrieveData();
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : AssignResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) GetAllResourcesTags(cz.metacentrum.perun.webgui.json.resourcesManager.GetAllResourcesTags) AssignResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag) ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 7 with ResourceTag

use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.

the class GetAssignedRichResources method insertToTable.

public void insertToTable(int index, RichResource object) {
    list.add(index, object);
    oracle.add(object.getName());
    for (ResourceTag rt : object.getResourceTags()) {
        oracle.add(rt.getName() + " (tag)");
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag)

Example 8 with ResourceTag

use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.

the class GetAssignedRichResources method addToTable.

/**
	 * Add object as new row to table
	 *
	 * @param object Resource to be added as new row
	 */
public void addToTable(RichResource object) {
    list.add(object);
    oracle.add(object.getName());
    for (ResourceTag rt : object.getResourceTags()) {
        oracle.add(rt.getName() + " (tag)");
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag)

Example 9 with ResourceTag

use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.

the class VoResourcesTagsTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources tags");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    // members request
    final GetAllResourcesTags resTags = new GetAllResourcesTags(PerunEntity.VIRTUAL_ORGANIZATION, voId);
    if (!session.isVoAdmin(voId))
        resTags.setCheckable(false);
    if (session.isVoAdmin(voId))
        resTags.setEditable(true);
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resTags);
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createResourceTag(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateVoResourceTagTabItem(voId));
        }
    });
    menu.addWidget(addButton);
    if (!session.isVoAdmin(voId))
        addButton.setEnabled(false);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResourceTag());
    if (!session.isVoAdmin(voId))
        removeButton.setEnabled(false);
    menu.addWidget(removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<ResourceTag> tagsToRemove = resTags.getTableSelectedList();
            String text = "Following tags will be deleted and won't be used to tag VO resources.";
            UiElements.showDeleteConfirm(tagsToRemove, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < tagsToRemove.size(); i++) {
                        DeleteResourceTag request;
                        if (i == tagsToRemove.size() - 1) {
                            request = new DeleteResourceTag(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new DeleteResourceTag(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.deleteResourceTag(tagsToRemove.get(i));
                    }
                }
            });
        }
    });
    menu.addFilterWidget(new ExtendedSuggestBox(resTags.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            resTags.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterTags());
    final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.updateResourceTag());
    menu.addWidget(saveButton);
    if (!session.isVoAdmin(voId))
        saveButton.setEnabled(false);
    saveButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<ResourceTag> tagsToUpdate = resTags.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(tagsToUpdate)) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                for (int i = 0; i < tagsToUpdate.size(); i++) {
                    UpdateResourceTag request;
                    if (i == tagsToUpdate.size() - 1) {
                        request = new UpdateResourceTag(JsonCallbackEvents.disableButtonEvents(saveButton, events));
                    } else {
                        request = new UpdateResourceTag(JsonCallbackEvents.disableButtonEvents(saveButton));
                    }
                    request.updateResourceTag(tagsToUpdate.get(i));
                }
            }
        }
    });
    // get the table
    CellTable<ResourceTag> table = resTags.getTable();
    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    // add menu and the table to the main panel
    firstTabPanel.add(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(resTags, table, removeButton);
    saveButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(resTags, table, saveButton);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) UpdateResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.UpdateResourceTag) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) DeleteResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResourceTag) GetAllResourcesTags(cz.metacentrum.perun.webgui.json.resourcesManager.GetAllResourcesTags) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) DeleteResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResourceTag) ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) UpdateResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.UpdateResourceTag) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 10 with ResourceTag

use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.

the class ResourceTagsTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned tags");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    final GetAllResourcesTags tags = new GetAllResourcesTags(PerunEntity.RESOURCE, resourceId);
    final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(tags);
    CustomButton assignTagsButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignTagsToResource(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AssignTagTabItem(resource), true);
        }
    });
    final CustomButton removeTagsButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedTagsFromResource());
    removeTagsButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<ResourceTag> tagsToRemove = tags.getTableSelectedList();
            String text = "Following groups will be removed from resource.";
            UiElements.showDeleteConfirm(tagsToRemove, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD USE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < tagsToRemove.size(); i++) {
                        if (i == tagsToRemove.size() - 1) {
                            RemoveResourceTag request = new RemoveResourceTag(resource.getId(), JsonCallbackEvents.disableButtonEvents(removeTagsButton, localEvents));
                            request.removeResourceTag(tagsToRemove.get(i));
                        } else {
                            RemoveResourceTag request = new RemoveResourceTag(resource.getId(), JsonCallbackEvents.disableButtonEvents(removeTagsButton));
                            request.removeResourceTag(tagsToRemove.get(i));
                        }
                    }
                }
            });
        }
    });
    if (!session.isVoAdmin(resource.getVoId())) {
        assignTagsButton.setEnabled(false);
        removeTagsButton.setEnabled(false);
        tags.setCheckable(false);
    }
    menu.addWidget(assignTagsButton);
    menu.addWidget(removeTagsButton);
    menu.addFilterWidget(new ExtendedSuggestBox(tags.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            tags.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterTags());
    // display menu to vo admin only
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    // table with field updater which leads to group detail
    CellTable<ResourceTag> table = tags.getTable();
    removeTagsButton.setEnabled(false);
    JsonUtils.addTableManagedButton(tags, table, removeTagsButton);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) RemoveResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.RemoveResourceTag) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetAllResourcesTags(cz.metacentrum.perun.webgui.json.resourcesManager.GetAllResourcesTags) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) RemoveResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.RemoveResourceTag) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Aggregations

ResourceTag (cz.metacentrum.perun.webgui.model.ResourceTag)18 RichResource (cz.metacentrum.perun.webgui.model.RichResource)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 GetAllResourcesTags (cz.metacentrum.perun.webgui.json.resourcesManager.GetAllResourcesTags)3 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)3 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)3 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)3 ArrayList (java.util.ArrayList)3 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)2 TextInputCell (com.google.gwt.cell.client.TextInputCell)1 Column (com.google.gwt.user.cellview.client.Column)1 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)1 AssignResourceTag (cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag)1 DeleteResourceTag (cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResourceTag)1 RemoveResourceTag (cz.metacentrum.perun.webgui.json.resourcesManager.RemoveResourceTag)1 UpdateResourceTag (cz.metacentrum.perun.webgui.json.resourcesManager.UpdateResourceTag)1 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)1