Search in sources :

Example 6 with GroupDetailTabItem

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

the class VoManagersTabItem method fillContentGroups.

private Widget fillContentGroups(final GetAdminGroups adminGroups, TabMenu menu) {
    adminGroups.clearTableSelectedSet();
    // refresh
    menu.addWidget(0, UiElements.getRefreshButton(this));
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(adminGroups);
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToVo(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddVoManagerGroupTabItem(vo, events), true);
        }
    });
    if (!session.isVoAdmin(voId))
        addButton.setEnabled(false);
    menu.addWidget(1, addButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerGroupFromVo());
    menu.addWidget(2, removeButton);
    removeButton.addClickHandler(new ClickHandler() {

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

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < adminsForRemoving.size(); i++) {
                        RemoveAdmin request;
                        if (i == adminsForRemoving.size() - 1) {
                            request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeVoAdminGroup(vo, adminsForRemoving.get(i));
                    }
                }
            });
        }
    });
    // get the table
    CellTable<Group> table = adminGroups.getTable(new FieldUpdater<Group, String>() {

        public void update(int i, Group grp, String s) {
            session.getTabManager().addTab(new GroupDetailTabItem(grp));
        }
    });
    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(adminGroups, table, removeButton);
    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) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Example 7 with GroupDetailTabItem

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

the class AssignGroupTabItem method draw.

public Widget draw() {
    titleWidget.setText("Assign group");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    final GetAllGroups voGroups = new GetAllGroups(resource.getVoId());
    voGroups.setCoreGroupsCheckable(true);
    final CellTable<Group> table = voGroups.getEmptyTable(new FieldUpdater<Group, String>() {

        public void update(int index, Group object, String value) {
            session.getTabManager().addTab(new GroupDetailTabItem(object));
        }
    });
    // remove already assigned groups from offering
    voGroups.setEvents(new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            final GetAssignedGroups alreadyAssigned = new GetAssignedGroups(resourceId, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    JsArray<Group> groupsToRemove = JsonUtils.jsoAsArray(jso);
                    for (int i = 0; i < groupsToRemove.length(); i++) {
                        voGroups.removeFromTable(groupsToRemove.get(i));
                    }
                    // if single group, select
                    if (voGroups.getList().size() == 1) {
                        table.getSelectionModel().setSelected(voGroups.getList().get(0), true);
                    }
                }
            });
            alreadyAssigned.retrieveData();
        }
    });
    // checbox is selected by default
    final CheckBox chb = new CheckBox();
    chb.setText(WidgetTranslation.INSTANCE.configureGroupBeforeAssign());
    chb.setTitle(WidgetTranslation.INSTANCE.configureGroupBeforeAssignTitle());
    chb.setValue(false);
    final TabItem tab = this;
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedGroupsToResource());
    assignButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Group> groupsToAssign = voGroups.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(groupsToAssign)) {
                if (chb.getValue() == false) {
                    AssignGroupsToResource request = new AssignGroupsToResource(JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab, true));
                    request.assignGroupsToResource(groupsToAssign, resource);
                }
                if (chb.getValue() == true) {
                    session.getTabManager().addTabToCurrentTab(new ManageGroupsBeforeAssigning(resource, groupsToAssign), true);
                }
            }
        }
    });
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, isRefreshParentOnClose());
        }
    }));
    menu.addFilterWidget(new ExtendedSuggestBox(voGroups.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            voGroups.filterTable(text);
            // if single group, select
            if (voGroups.getList().size() == 1) {
                table.getSelectionModel().setSelected(voGroups.getList().get(0), true);
            }
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    if (session.isPerunAdmin()) {
        // TODO - now is for testing so perun admin only
        menu.addWidget(chb);
    }
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(voGroups, table, assignButton);
    voGroups.retrieveData();
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizeSmallTabPanel(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) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetAllGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) GetAssignedGroups(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedGroups) AssignGroupsToResource(cz.metacentrum.perun.webgui.json.resourcesManager.AssignGroupsToResource) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject)

Example 8 with GroupDetailTabItem

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

the class PerunWebSession method setActiveGroup.

/**
 * Sets currently active Group (refresh links in menu)
 *
 * @param group Group which user is editing now
 */
public void setActiveGroup(Group group) {
    this.activeGroup = group;
    addObjectToEntitiesHistory(group.cast());
    getUiElements().getMenu().setMenuTabItem(MainMenu.GROUP_ADMIN, new GroupDetailTabItem(group));
    getUiElements().getMenu().updateLinks(MainMenu.GROUP_ADMIN);
}
Also used : GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem)

Example 9 with GroupDetailTabItem

use of cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem 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

GroupDetailTabItem (cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem)9 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)7 ArrayList (java.util.ArrayList)7 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)5 Group (cz.metacentrum.perun.webgui.model.Group)5 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)5 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4 RemoveAdmin (cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 GetAssignedGroups (cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedGroups)2 Scheduler (com.google.gwt.core.client.Scheduler)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)1 GetAllowedGroups (cz.metacentrum.perun.webgui.json.facilitiesManager.GetAllowedGroups)1 GetAllowedVos (cz.metacentrum.perun.webgui.json.facilitiesManager.GetAllowedVos)1 DeleteGroups (cz.metacentrum.perun.webgui.json.groupsManager.DeleteGroups)1 GetAllGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups)1