Search in sources :

Example 31 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) {
                                session.getTabManager().closeTab(tab, isRefreshParentOnClose());
                            }
                        }));
                        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)31 Label (org.gwtbootstrap3.client.ui.Label)16 MultiSelectionModel (com.google.gwt.view.client.MultiSelectionModel)12 SingleSelectionModel (com.google.gwt.view.client.SingleSelectionModel)9 Column (com.google.gwt.user.cellview.client.Column)6 ArrayList (java.util.ArrayList)5 TextCell (com.google.gwt.cell.client.TextCell)4 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)4 Group (cz.metacentrum.perun.webgui.model.Group)4 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 Handler (com.google.gwt.view.client.SelectionChangeEvent.Handler)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)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 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)2