Search in sources :

Example 1 with RemoveGroupsFromResource

use of cz.metacentrum.perun.webgui.json.resourcesManager.RemoveGroupsFromResource in project perun by CESNET.

the class ResourceAssignedGroupsTabItem method draw.

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

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

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

                @Override
                public void onClick(ClickEvent clickEvent) {
                    RemoveGroupsFromResource request = new RemoveGroupsFromResource(JsonCallbackEvents.disableButtonEvents(removeGroupButton, localEvents));
                    request.removeGroupsFromResource(groupsForRemoving, resource);
                }
            });
        }
    });
    if (!session.isVoAdmin(resource.getVoId())) {
        resourceGroups.setCheckable(false);
        assignGroupButton.setEnabled(false);
    }
    menu.addWidget(assignGroupButton);
    menu.addWidget(removeGroupButton);
    menu.addFilterWidget(new ExtendedSuggestBox(resourceGroups.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            resourceGroups.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    // display menu to vo admin only
    if (session.isVoAdmin(resource.getVoId())) {
        resourceGroups.setCheckable(true);
        vp.add(menu);
        vp.setCellHeight(menu, "30px");
    } else {
        resourceGroups.setCheckable(false);
    }
    // table with field updater which leads to group detail
    CellTable<Group> table = resourceGroups.getTable(new FieldUpdater<Group, String>() {

        public void update(int index, Group object, String value) {
            session.getTabManager().addTab(new GroupDetailTabItem(object));
        }
    });
    removeGroupButton.setEnabled(false);
    if (session.isVoAdmin(resource.getVoId()))
        JsonUtils.addTableManagedButton(resourceGroups, table, removeGroupButton);
    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 : GetAssignedGroups(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedGroups) JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) RemoveGroupsFromResource(cz.metacentrum.perun.webgui.json.resourcesManager.RemoveGroupsFromResource) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) 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 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 GetAssignedGroups (cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedGroups)1 RemoveGroupsFromResource (cz.metacentrum.perun.webgui.json.resourcesManager.RemoveGroupsFromResource)1 Group (cz.metacentrum.perun.webgui.model.Group)1 GroupDetailTabItem (cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem)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