Search in sources :

Example 36 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class AddGroupManagerGroupTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add manager group");
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    final TabMenu tabMenu = new TabMenu();
    final ListBoxWithObjects<VirtualOrganization> box = new ListBoxWithObjects<VirtualOrganization>();
    // pass empty items to menu to ensure drawing of rest
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    tabMenu.addWidget(new HTML(""));
    tabMenu.addWidget(new HTML(""));
    tabMenu.addWidget(3, new HTML("<strong>Select VO:</strong>"));
    tabMenu.addWidget(4, box);
    // get the table
    final ScrollPanel sp = new ScrollPanel();
    sp.addStyleName("perun-tableScrollPanel");
    box.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
        }
    });
    if (box.getAllObjects().isEmpty()) {
        GetVos vos = new GetVos(new JsonCallbackEvents() {

            @Override
            public void onFinished(JavaScriptObject jso) {
                box.clear();
                ArrayList<VirtualOrganization> list = new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso));
                if (list != null && !list.isEmpty()) {
                    box.addAllItems(list);
                    sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
                } else {
                    box.addItem("No VOs found");
                }
            }

            @Override
            public void onError(PerunError error) {
                box.clear();
                box.addItem("Error while loading");
            }

            @Override
            public void onLoadingStart() {
                box.clear();
                box.addItem("Loading...");
            }
        });
        vos.retrieveData();
    }
    final TabItem tab = this;
    tabMenu.addWidget(2, TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            if (refreshEvents != null)
                refreshEvents.onFinished(null);
            session.getTabManager().closeTab(tab, false);
        }
    }));
    // add menu and the table to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    firstTabPanel.add(sp);
    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) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetAllGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 37 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class AddGroupManagerGroupTabItem 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 Group and all removed members will lose management rights.");
                    }
                    found = true;
                    return;
                }
            }
            found = false;
        }
    });
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersGroupToGroup());
    tabMenu.addWidget(1, 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.addGroupAdminGroup(group, list.get(i));
                    } else {
                        AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton));
                        request.addGroupAdminGroup(group, 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)

Example 38 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class AddGroupManagerTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add manager");
    // MAIN PANEL
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // if members or admins group, hide
    if (group.isCoreGroup()) {
        vp.add(new HTML("<p>Group \"" + group.getName() + "\" can't have managers managed from Group manager section. Please use VO manager section.</p>"));
        this.contentWidget.setWidget(vp);
        return getWidget();
    }
    final CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
    this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // if found 1 item, select
            ArrayList<User> list = JsonUtils.jsoAsList(jso);
            if (list != null && list.size() == 1) {
                users.getSelectionModel().setSelected(list.get(0), true);
            }
        }
    }));
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // get the table
    final CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = users.getTable(new FieldUpdater<User, String>() {

            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = users.getTable();
    }
    final TabItem tab = this;
    // already added
    rebuildAlreadyAddedWidget();
    // search textbox
    final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            startSearching(text);
            searchString = text;
        }
    }, searchButton);
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToGroup());
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
            final ArrayList<User> list = users.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                for (int i = 0; i < list.size(); i++) {
                    final int n = i;
                    AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // put names to already added
                            alreadyAddedList.add(list.get(n));
                            rebuildAlreadyAddedWidget();
                            // unselect added person
                            users.getSelectionModel().setSelected(list.get(n), false);
                            // clear search
                            searchBox.getTextBox().setText("");
                        }
                    }));
                    request.addGroupAdmin(group, list.get(i));
                }
            }
        }
    });
    tabMenu.addWidget(addButton);
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
        }
    }));
    // if some text has been searched before
    if (!searchString.equals("")) {
        searchBox.getTextBox().setText(searchString);
        startSearching(searchString);
    }
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(users, table, addButton);
    // 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(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    firstTabPanel.add(alreadyAdded);
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FindCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) AddAdmin(cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) 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)

Example 39 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class AddGroupUnionTabItem method draw.

@Override
public Widget draw() {
    titleWidget.setText("Add group union");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(new HTML(""));
    final GetAllGroups groups = new GetAllGroups(group.getVoId());
    groups.setCoreGroupsCheckable(true);
    // remove already added union groups from offering
    JsonCallbackEvents localEvents = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // second callback
            final GetGroupUnions alreadyAssigned = new GetGroupUnions(group, false, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    JsArray<Group> esToRemove = JsonUtils.jsoAsArray(jso);
                    for (int i = 0; i < esToRemove.length(); i++) {
                        groups.removeFromTable(esToRemove.get(i));
                    }
                    // remove itself
                    groups.removeFromTable(group);
                }
            });
            alreadyAssigned.retrieveData();
        }
    };
    groups.setEvents(localEvents);
    final ExtendedSuggestBox box = new ExtendedSuggestBox(groups.getOracle());
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedExtSource());
    final TabItem tab = this;
    assignButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Group> groupsToAdd = groups.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(groupsToAdd)) {
                // FIXME - Should have only one callback to core
                for (int i = 0; i < groupsToAdd.size(); i++) {
                    final int n = i;
                    AddGroupUnion request = new AddGroupUnion(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // unselect added person
                            groups.getSelectionModel().setSelected(groupsToAdd.get(n), false);
                            alreadyAddedList.add(groupsToAdd.get(n));
                            rebuildAlreadyAddedWidget();
                            // clear search
                            box.getSuggestBox().setText("");
                        }
                    }));
                    request.createGroupUnion(group, groupsToAdd.get(i));
                }
            }
        }
    });
    menu.addFilterWidget(box, new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            groups.filterTable(text);
        }
    }, "Filter by ext source name or type");
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
        }
    }));
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(alreadyAdded);
    CellTable<Group> table = groups.getTable();
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(groups, table, assignButton);
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    // do not use resizePerunTable() when tab is in overlay - wrong width is calculated
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) JsArray(com.google.gwt.core.client.JsArray) AddGroupUnion(cz.metacentrum.perun.webgui.json.groupsManager.AddGroupUnion) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) HTML(com.google.gwt.user.client.ui.HTML) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetAllGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetGroupUnions(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupUnions) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 40 with TabItem

use of cz.metacentrum.perun.webgui.tabs.TabItem in project perun by CESNET.

the class AssignGroupTabItem method draw.

public Widget draw() {
    // set tab name
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": assign to resource");
    // main content
    VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    // callback
    final GetRichResources callback = new GetRichResources(group.getVoId());
    callback.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            for (RichResource rr : resources) {
                callback.removeFromTable(rr);
            }
            ArrayList<RichResource> temp = new ArrayList<RichResource>();
            temp.addAll(callback.getList());
            callback.setList(temp);
        }
    });
    CellTable<RichResource> table = callback.getTable();
    // close tab event
    final TabItem tab = this;
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            callback.filterTable(text);
            // if single group, select
            if (callback.getList().size() == 1) {
                callback.getSelectionModel().setSelected(callback.getList().get(0), true);
            }
        }
    }, ButtonTranslation.INSTANCE.filterResources());
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignGroupToSelectedResources());
    assignButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<RichResource> toAssign = callback.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(toAssign)) {
                AssignGroupToResources request = new AssignGroupToResources(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        alreadyAddedList.addAll(toAssign);
                        for (RichResource r : toAssign) {
                            callback.getSelectionModel().setSelected(r, false);
                        }
                        rebuildAlreadyAddedWidget();
                    }
                }));
                request.assignGroupToResources(group, toAssign);
            }
        }
    });
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(callback, table, assignButton);
    // add menu and the table to the main panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    // do not use resizePerunTable() in overlay mode - calculated width is wrong
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    mainTab.add(menu);
    mainTab.setCellHeight(menu, "30px");
    rebuildAlreadyAddedWidget();
    mainTab.add(alreadyAdded);
    mainTab.add(sp);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichResource(cz.metacentrum.perun.webgui.model.RichResource) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) AssignGroupToResources(cz.metacentrum.perun.webgui.json.resourcesManager.AssignGroupToResources) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetRichResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetRichResources) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)84 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)76 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)76 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)71 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)68 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)56 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)54 ArrayList (java.util.ArrayList)47 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)30 PerunError (cz.metacentrum.perun.webgui.model.PerunError)21 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)19 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)14 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)13 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)13 User (cz.metacentrum.perun.webgui.model.User)13 Group (cz.metacentrum.perun.webgui.model.Group)11 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)11 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)10 GetAllGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups)10 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)10