Search in sources :

Example 1 with RemoveMember

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

the class MemberGroupsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": groups");
    // main widget panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    final GetMemberGroups groupsCall = new GetMemberGroups(memberId);
    menu.addWidget(UiElements.getRefreshButton(this));
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, "Add member to new group", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new MemberAddToGroupTabItem(member), true);
        }
    });
    if (session.isVoObserver(member.getVoId()) && !session.isVoAdmin(member.getVoId())) {
        addButton.setEnabled(false);
        groupsCall.setCheckable(false);
    }
    menu.addWidget(addButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove member from selected group(s)");
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            final ArrayList<Group> list = groupsCall.getTableSelectedList();
            String confirmText = member.getUser().getFullName() + " will be removed from following groups.";
            UiElements.showDeleteConfirm(list, confirmText, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    RemoveMember request = new RemoveMember(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(groupsCall)));
                    request.removeMemberFromGroups(member, list);
                }
            });
        }
    });
    removeButton.setEnabled(false);
    menu.addWidget(removeButton);
    menu.addFilterWidget(new ExtendedSuggestBox(groupsCall.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            groupsCall.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    CellTable<Group> table = groupsCall.getTable(new FieldUpdater<Group, String>() {

        @Override
        public void update(int i, Group group, String s) {
            if (session.isVoAdmin(group.getVoId()) || session.isVoObserver(group.getVoId()) || session.isGroupAdmin(group.getId())) {
                session.getTabManager().addTab(new GroupDetailTabItem(group));
            } else {
                UiElements.generateInfo("Not privileged", "You are not manager of selected group or it's VO.");
            }
        }
    });
    if (session.isVoAdmin(member.getVoId()) || session.isGroupAdmin(groupId))
        JsonUtils.addTableManagedButton(groupsCall, table, removeButton);
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    vp.add(sp);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : Group(cz.metacentrum.perun.webgui.model.Group) RemoveMember(cz.metacentrum.perun.webgui.json.groupsManager.RemoveMember) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) 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) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) GetMemberGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetMemberGroups)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)1 GetMemberGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetMemberGroups)1 RemoveMember (cz.metacentrum.perun.webgui.json.groupsManager.RemoveMember)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