Search in sources :

Example 1 with GetAllRichSubGroups

use of cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichSubGroups in project perun by CESNET.

the class SubgroupsTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": subgroups");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // if members group, hide
    if (group.isCoreGroup()) {
        vp.add(new HTML("<h2>Members group cannot have subgroups.</h2>"));
        this.contentWidget.setWidget(vp);
        return getWidget();
    }
    // GROUP TABLE with onclick
    ArrayList<String> attrNames = new ArrayList<>();
    attrNames.add("urn:perun:group:attribute-def:def:synchronizationEnabled");
    attrNames.add("urn:perun:group:attribute-def:def:synchronizationInterval");
    attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationState");
    attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationTimestamp");
    attrNames.add("urn:perun:group:attribute-def:def:lastSuccessSynchronizationTimestamp");
    attrNames.add("urn:perun:group:attribute-def:def:authoritativeGroup");
    attrNames.add("urn:perun:group:attribute-def:def:groupSynchronizationTimes");
    attrNames.add("urn:perun:group:attribute-def:def:startOfLastSuccessfulSynchronization");
    attrNames.add("urn:perun:group:attribute-def:def:startOfLastSynchronization");
    final GetAllRichSubGroups subgroups = new GetAllRichSubGroups(groupId, attrNames);
    // Events for reloading when group is created
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(subgroups);
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createSubGroup(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            // creates a new form
            session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(group));
        }
    });
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) {
        createButton.setEnabled(false);
        subgroups.setCheckable(false);
    }
    menu.addWidget(createButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteSubGroup());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<RichGroup> itemsToRemove = subgroups.getTableSelectedList();
            String text = "Following groups (including all sub-groups) will be deleted.";
            UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    DeleteGroups request = new DeleteGroups(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                    request.deleteGroups(itemsToRemove);
                }
            });
        }
    });
    menu.addWidget(removeButton);
    // move button
    CustomButton moveButton = TabMenu.getPredefinedButton(ButtonType.MOVE, true, ButtonTranslation.INSTANCE.moveGroup(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<RichGroup> groupsToMove = subgroups.getTableSelectedList();
            session.getTabManager().addTabToCurrentTab(new MoveGroupsTabItem(group, groupsToMove));
        }
    });
    if (session.isPerunAdmin()) {
        // FIXME - temporary for perun admin
        if (!session.isVoAdmin(group.getVoId()))
            moveButton.setEnabled(false);
        menu.addWidget(moveButton);
    }
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(subgroups.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            subgroups.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<RichGroup> table = subgroups.getTable(new FieldUpdater<RichGroup, String>() {

        @Override
        public void update(int arg0, RichGroup group, String arg2) {
            session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
        }
    });
    removeButton.setEnabled(false);
    if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
        JsonUtils.addTableManagedButton(subgroups, table, removeButton);
    // FIXME - temporary for perun admin
    if (session.isPerunAdmin()) {
        JsonUtils.addTableManagedButton(subgroups, table, moveButton);
        moveButton.setEnabled(false);
    }
    // if (session.isVoAdmin(group.getVoId())) JsonUtils.addTableManagedButton(subgroups, table, moveButton);
    // adds the table into the panel
    table.addStyleName("perun-table");
    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 : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) GetAllRichSubGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichSubGroups) RichGroup(cz.metacentrum.perun.webgui.model.RichGroup) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) DeleteGroups(cz.metacentrum.perun.webgui.json.groupsManager.DeleteGroups)

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 DeleteGroups (cz.metacentrum.perun.webgui.json.groupsManager.DeleteGroups)1 GetAllRichSubGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichSubGroups)1 RichGroup (cz.metacentrum.perun.webgui.model.RichGroup)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