Search in sources :

Example 1 with VoManagersTabItem

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

the class GroupManagersTabItem method fillContentGroups.

private Widget fillContentGroups(final GetAdminGroups admins, TabMenu menu) {
    admins.clearTableSelectedSet();
    boolean isMembersGroup = group.isCoreGroup();
    menu.addWidget(0, UiElements.getRefreshButton(this));
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerGroupFromGroup());
    if (!isMembersGroup) {
        CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToGroup(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new AddGroupManagerGroupTabItem(group, events), true);
            }
        });
        if (!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(group.getId()))
            addButton.setEnabled(false);
        menu.addWidget(1, addButton);
        removeButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final ArrayList<Group> itemsToRemove = admins.getTableSelectedList();
                String text = "Members of following groups won't be group managers anymore.";
                UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent clickEvent) {
                        // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                        for (int i = 0; i < itemsToRemove.size(); i++) {
                            RemoveAdmin request;
                            if (i == itemsToRemove.size() - 1) {
                                request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                            } else {
                                request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton));
                            }
                            request.removeGroupAdminGroup(group, itemsToRemove.get(i));
                        }
                    }
                });
            }
        });
        menu.addWidget(2, removeButton);
    } else {
        // is core group
        menu.addWidget(1, new Image(SmallIcons.INSTANCE.helpIcon()));
        Anchor a = new Anchor("<strong>To edit VO managers use VO manager section in menu.</strong>", true);
        a.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                session.getTabManager().addTab(new VoManagersTabItem(group.getVoId()));
            }
        });
        menu.addWidget(2, a);
    }
    // get the table
    CellTable<Group> table = admins.getTable(new FieldUpdater<Group, String>() {

        public void update(int i, Group grp, String s) {
            session.getTabManager().addTab(new GroupDetailTabItem(grp));
        }
    });
    removeButton.setEnabled(false);
    if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
        JsonUtils.addTableManagedButton(admins, table, removeButton);
    }
    table.setStyleName("perun-table");
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) VoManagersTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoManagersTabItem) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Example 2 with VoManagersTabItem

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

the class GroupManagersTabItem method fillContentUsers.

private Widget fillContentUsers(final GetRichAdminsWithAttributes admins, TabMenu menu) {
    admins.clearTableSelectedSet();
    boolean isMembersGroup = group.isCoreGroup();
    menu.addWidget(0, UiElements.getRefreshButton(this));
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromGroup());
    if (!isMembersGroup) {
        CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToGroup(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new AddGroupManagerTabItem(group), true);
            }
        });
        if (!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(group.getId()))
            addButton.setEnabled(false);
        menu.addWidget(1, addButton);
        removeButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final ArrayList<User> itemsToRemove = admins.getTableSelectedList();
                String text = "Following users won't be group managers anymore.";
                UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent clickEvent) {
                        // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                        for (int i = 0; i < itemsToRemove.size(); i++) {
                            RemoveAdmin request;
                            if (i == itemsToRemove.size() - 1) {
                                request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                            } else {
                                request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton));
                            }
                            request.removeGroupAdmin(group, itemsToRemove.get(i));
                        }
                    }
                });
            }
        });
        menu.addWidget(2, removeButton);
    } else {
        // is core group
        menu.addWidget(1, new Image(SmallIcons.INSTANCE.helpIcon()));
        Anchor a = new Anchor("<strong>To edit VO managers use VO manager section in menu.</strong>", true);
        a.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                session.getTabManager().addTab(new VoManagersTabItem(group.getVoId()));
            }
        });
        menu.addWidget(2, a);
    }
    // get the table
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = admins.getTable(new FieldUpdater<User, String>() {

            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = admins.getTable();
    }
    removeButton.setEnabled(false);
    if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
        JsonUtils.addTableManagedButton(admins, table, removeButton);
    }
    table.setStyleName("perun-table");
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) VoManagersTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoManagersTabItem) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)2 RemoveAdmin (cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)2 VoManagersTabItem (cz.metacentrum.perun.webgui.tabs.vostabs.VoManagersTabItem)2 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)2 ArrayList (java.util.ArrayList)2 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)1 Group (cz.metacentrum.perun.webgui.model.Group)1 User (cz.metacentrum.perun.webgui.model.User)1 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)1