Search in sources :

Example 1 with AssignResourceTag

use of cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag 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)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 AssignResourceTag (cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag)1 GetAllResourcesTags (cz.metacentrum.perun.webgui.json.resourcesManager.GetAllResourcesTags)1 ResourceTag (cz.metacentrum.perun.webgui.model.ResourceTag)1 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1 ArrayList (java.util.ArrayList)1