Search in sources :

Example 11 with SelectionChangeEvent

use of com.google.gwt.view.client.SelectionChangeEvent in project perun by CESNET.

the class AddVoManagerGroupTabItem method fillGroupsContent.

private Widget fillGroupsContent(GetAllGroups groups, TabMenu tabMenu, final ListBoxWithObjects<VirtualOrganization> box) {
    getAllGroups = groups;
    getAllGroups.setCoreGroupsCheckable(true);
    final CellTable<Group> table = getAllGroups.getTable();
    getAllGroups.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        private boolean found = false;

        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            for (Group g : getAllGroups.getTableSelectedList()) {
                if (g.isCoreGroup()) {
                    if (!found) {
                        // display only once
                        UiElements.generateInfo("You have selected 'all vo members' group", "If this group will be added as 'manager group', all new members of VO " + box.getSelectedObject().getName() + " will be automatically managers of your VO and all removed members will lose management rights.");
                    }
                    found = true;
                    return;
                }
            }
            found = false;
        }
    });
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersGroupToVo());
    tabMenu.addWidget(0, addButton);
    final TabItem tab = this;
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Group> list = getAllGroups.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                for (int i = 0; i < list.size(); i++) {
                    if (i == list.size() - 1) {
                        AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                            public void onFinished(JavaScriptObject jso) {
                                // close tab and refresh table
                                if (refreshEvents != null)
                                    refreshEvents.onFinished(null);
                                session.getTabManager().closeTab(tab, false);
                            }
                        }));
                        request.addVoAdminGroup(vo, list.get(i));
                    } else {
                        AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton));
                        request.addVoAdminGroup(vo, list.get(i));
                    }
                }
            }
        }
    });
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(getAllGroups, table, addButton);
    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) AddAdmin(cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)11 Column (com.google.gwt.user.cellview.client.Column)6 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)5 TextCell (com.google.gwt.cell.client.TextCell)4 Group (cz.metacentrum.perun.webgui.model.Group)4 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)3 AddAdmin (cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin)3 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)3 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)3 ArrayList (java.util.ArrayList)3 Revision (org.eclipse.che.api.git.shared.Revision)3 DoubleClickEvent (com.google.gwt.event.dom.client.DoubleClickEvent)2 DoubleClickHandler (com.google.gwt.event.dom.client.DoubleClickHandler)2 ImageResourceCell (com.google.gwt.cell.client.ImageResourceCell)1 SafeHtmlCell (com.google.gwt.cell.client.SafeHtmlCell)1 ImageResource (com.google.gwt.resources.client.ImageResource)1