Search in sources :

Example 11 with RichGroup

use of cz.metacentrum.perun.webgui.model.RichGroup in project perun by CESNET.

the class GetRichSubGroups method filterTable.

public void filterTable(String text) {
    // store list only for first time
    if (fullBackup.isEmpty() || fullBackup == null) {
        fullBackup.addAll(list);
    }
    // always clear selected items
    selectionModel.clear();
    list.clear();
    if (text.equalsIgnoreCase("")) {
        list.addAll(fullBackup);
    } else {
        for (RichGroup grp : fullBackup) {
            // store facility by filter
            if (grp.getName().toLowerCase().startsWith(text.toLowerCase()) || grp.getName().toLowerCase().contains(":" + text.toLowerCase())) {
                list.add(grp);
            }
        }
    }
    if (list.isEmpty() && !text.isEmpty()) {
        loaderImage.setEmptyResultMessage("No sub-group matching '" + text + "' found.");
    } else {
        loaderImage.setEmptyResultMessage("Group has no sub-groups.");
    }
    dataProvider.flush();
    dataProvider.refresh();
    loaderImage.loadingFinished();
}
Also used : RichGroup(cz.metacentrum.perun.webgui.model.RichGroup)

Example 12 with RichGroup

use of cz.metacentrum.perun.webgui.model.RichGroup 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");
    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, false);
        }
    });
    // 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)

Example 13 with RichGroup

use of cz.metacentrum.perun.webgui.model.RichGroup 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");
    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);
    // 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);
    // 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

RichGroup (cz.metacentrum.perun.webgui.model.RichGroup)13 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)5 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)5 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)4 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)4 Column (com.google.gwt.user.cellview.client.Column)3 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)3 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)3 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)3 CustomClickableInfoCellWithImageResource (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableInfoCellWithImageResource)3 ArrayList (java.util.ArrayList)3 DeleteGroups (cz.metacentrum.perun.webgui.json.groupsManager.DeleteGroups)2 GetAllRichGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichGroups)2 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)2 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)2 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 Header (com.google.gwt.user.cellview.client.Header)1