Search in sources :

Example 1 with GetAllRichGroups

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

the class VoGroupsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "groups");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    // VO Groups request
    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:lastSuccessSynchronizationTimestamp");
    attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationTimestamp");
    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 GetAllRichGroups groups = new GetAllRichGroups(voId, attrNames);
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(groups);
    if (!session.isVoAdmin(voId))
        groups.setCheckable(false);
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    // add new group button
    CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createGroup(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(vo));
        }
    });
    if (!session.isVoAdmin(voId))
        createButton.setEnabled(false);
    menu.addWidget(createButton);
    // delete selected groups button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteGroup());
    removeButton.addClickHandler(new ClickHandler() {

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

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

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

        public void searchFor(String text) {
            groups.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    // add a table with a onclick
    CellTable<RichGroup> table = groups.getTable(new FieldUpdater<RichGroup, String>() {

        public void update(int index, RichGroup group, String value) {
            session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
        }
    });
    // 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(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(groups, table, removeButton);
    // fixme - temporary only for perun admin
    if (session.isPerunAdmin()) {
        JsonUtils.addTableManagedButton(groups, table, moveButton);
        moveButton.setEnabled(false);
    }
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichGroup(cz.metacentrum.perun.webgui.model.RichGroup) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) CreateGroupTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.CreateGroupTabItem) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) GetAllRichGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichGroups) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) DeleteGroups(cz.metacentrum.perun.webgui.json.groupsManager.DeleteGroups) MoveGroupsTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.MoveGroupsTabItem)

Example 2 with GetAllRichGroups

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

the class GroupsTabItem method draw.

public Widget draw() {
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // Horizontal menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    // call
    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:lastSuccessSynchronizationTimestamp");
    attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationTimestamp");
    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 GetAllRichGroups groups = new GetAllRichGroups(voId, attrNames);
    groups.setCheckable(false);
    // listbox
    final ListBoxWithObjects<VirtualOrganization> vos = new ListBoxWithObjects<VirtualOrganization>();
    menu.addWidget(new HTML("<strong>Selected VO: </strong>"));
    menu.addWidget(vos);
    menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            groups.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    menu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
    menu.addWidget(new HTML("<strong>Select VO to see groups that you can manage.</strong>"));
    final TabItem tab = this;
    // groups table
    CellTable<RichGroup> table = groups.getEmptyTable(new FieldUpdater<RichGroup, String>() {

        public void update(int index, RichGroup group, String value) {
            session.getTabManager().addTab(new GroupDetailTabItem(group));
            // close group selection tab when group is selected
            session.getTabManager().closeTab(tab, isRefreshParentOnClose());
        }
    });
    // listbox change => load vo's groups
    vos.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            groups.setVoId(vos.getSelectedObject().getId());
            groups.clearTable();
            groups.retrieveData();
        }
    });
    // initial fill listbox and trigger groups loading
    GetVos vosCall = new GetVos(new JsonCallbackEvents() {

        public void onLoadingStart() {
            vos.clear();
            vos.addItem("Loading...");
        }

        public void onFinished(JavaScriptObject jso) {
            vos.clear();
            ArrayList<VirtualOrganization> returnedVos = JsonUtils.jsoAsList(jso);
            returnedVos = new TableSorter<VirtualOrganization>().sortByName(returnedVos);
            if (returnedVos == null || returnedVos.isEmpty()) {
                vos.addItem("No VO available");
                return;
            }
            // put and set selected
            for (int i = 0; i < returnedVos.size(); i++) {
                vos.addItem(returnedVos.get(i));
                if (voId == returnedVos.get(i).getId()) {
                    vos.setSelected(returnedVos.get(i), true);
                }
            }
            // trigger loading of groups for selected VO
            groups.setVoId(vos.getSelectedObject().getId());
            groups.clearTable();
            groups.retrieveData();
        }

        public void onError(PerunError error) {
            vos.clear();
            vos.addItem("Error while loading");
        }
    });
    vosCall.retrieveData();
    // set width to 100%
    table.setWidth("100%");
    // add menu and table to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    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) RichGroup(cz.metacentrum.perun.webgui.model.RichGroup) ArrayList(java.util.ArrayList) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetAllRichGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichGroups) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Aggregations

JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)2 GetAllRichGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichGroups)2 RichGroup (cz.metacentrum.perun.webgui.model.RichGroup)2 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)2 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)2 ArrayList (java.util.ArrayList)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 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 DeleteGroups (cz.metacentrum.perun.webgui.json.groupsManager.DeleteGroups)1 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)1 PerunError (cz.metacentrum.perun.webgui.model.PerunError)1 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)1 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)1 CreateGroupTabItem (cz.metacentrum.perun.webgui.tabs.groupstabs.CreateGroupTabItem)1 GroupDetailTabItem (cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem)1 MoveGroupsTabItem (cz.metacentrum.perun.webgui.tabs.groupstabs.MoveGroupsTabItem)1