Search in sources :

Example 1 with RichGroup

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

the class GetAllRichGroups method setList.

public void setList(ArrayList<RichGroup> list) {
    clearTable();
    this.list.addAll(list);
    for (RichGroup g : list) {
        oracle.add(g.getName());
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : RichGroup(cz.metacentrum.perun.webgui.model.RichGroup)

Example 2 with RichGroup

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

the class GetAllRichSubGroups 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 3 with RichGroup

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

the class GetAllRichSubGroups method getTable.

/**
	 * Returns the table with subgroups.
	 * @return
	 */
public CellTable<RichGroup> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<RichGroup>(list);
    // Cell table
    table = new PerunTable<RichGroup>(list);
    table.setHyperlinksAllowed(false);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<RichGroup> columnSortHandler = new ListHandler<RichGroup>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichGroup>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("Group has no sub-groups.");
    // checkbox column column
    table.addCheckBoxColumn();
    table.addIdColumn("Group ID", tableFieldUpdater);
    // Add a synchronization clicable icon column.
    Column<RichGroup, RichGroup> syncColumn = new Column<RichGroup, RichGroup>(new CustomClickableInfoCellWithImageResource("click")) {

        @Override
        public RichGroup getValue(RichGroup object) {
            return object;
        }

        @Override
        public String getCellStyleNames(Cell.Context context, RichGroup object) {
            if (tableFieldUpdater != null) {
                return super.getCellStyleNames(context, object) + " pointer image-hover";
            } else {
                return super.getCellStyleNames(context, object);
            }
        }
    };
    syncColumn.setFieldUpdater(new FieldUpdater<RichGroup, RichGroup>() {

        @Override
        public void update(int index, final RichGroup object, RichGroup value) {
            GetEntityById get = new GetEntityById(PerunEntity.RICH_GROUP, object.getId(), new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    final RichGroup object = jso.cast();
                    String name, syncEnabled, syncInterval, syncTimestamp, syncSuccessTimestamp, syncState, authGroup;
                    name = object.getName();
                    if (object.isSyncEnabled()) {
                        syncEnabled = "enabled";
                    } else {
                        syncEnabled = "disabled";
                    }
                    if (object.getSynchronizationInterval() == null) {
                        syncInterval = "N/A";
                    } else {
                        if (JsonUtils.checkParseInt(object.getSynchronizationInterval())) {
                            int time = Integer.parseInt(object.getSynchronizationInterval()) * 5 / 60;
                            if (time == 0) {
                                time = Integer.parseInt(object.getSynchronizationInterval()) * 5;
                                syncInterval = time + " minute(s)";
                            } else {
                                syncInterval = time + " hour(s)";
                            }
                        } else {
                            syncInterval = object.getSynchronizationInterval();
                        }
                    }
                    if (object.getLastSynchronizationState() == null) {
                        if (object.getLastSuccessSynchronizationTimestamp() != null) {
                            syncState = "OK";
                        } else {
                            syncState = "Not synced yet";
                        }
                    } else {
                        if (session.isPerunAdmin()) {
                            syncState = object.getLastSynchronizationState();
                        } else {
                            syncState = "Internal Error";
                        }
                    }
                    if (object.getLastSynchronizationTimestamp() == null) {
                        syncTimestamp = "N/A";
                    } else {
                        syncTimestamp = object.getLastSynchronizationTimestamp().split("\\.")[0];
                    }
                    if (object.getLastSuccessSynchronizationTimestamp() == null) {
                        syncSuccessTimestamp = "N/A";
                    } else {
                        syncSuccessTimestamp = object.getLastSuccessSynchronizationTimestamp().split("\\.")[0];
                    }
                    if (object.getAuthoritativeGroup() != null && object.getAuthoritativeGroup().equals("1")) {
                        authGroup = "Yes";
                    } else {
                        authGroup = "No";
                    }
                    String html = "Group name: <b>" + name + "</b><br>";
                    html += "Synchronization: <b>" + syncEnabled + "</b><br>";
                    if (object.isSyncEnabled()) {
                        html += "Last sync. state: <b>" + syncState + "</b><br>";
                        html += "Last sync. timestamp: <b>" + syncTimestamp + "</b><br>";
                        html += "Last successful sync. timestamp: <b>" + syncSuccessTimestamp + "</b><br>";
                        html += "Sync. Interval: <b>" + syncInterval + "</b><br>";
                        html += "Authoritative group: <b>" + authGroup + "</b><br>";
                    }
                    FlexTable layout = new FlexTable();
                    layout.setWidget(0, 0, new HTML("<p>" + new Image(LargeIcons.INSTANCE.informationIcon())));
                    layout.setHTML(0, 1, "<p style=\"line-height: 1.2;\">" + html);
                    layout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
                    layout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
                    layout.getFlexCellFormatter().setStyleName(0, 0, "alert-box-image");
                    final CustomButton okButton = new CustomButton("Force synchronization", SmallIcons.INSTANCE.arrowRefreshIcon());
                    okButton.addClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            ForceGroupSynchronization call = new ForceGroupSynchronization(JsonCallbackEvents.disableButtonEvents(okButton));
                            call.synchronizeGroup(object.getId());
                        }
                    });
                    if (!session.isVoAdmin(object.getVoId()) && !session.isGroupAdmin(object.getId()))
                        okButton.setEnabled(false);
                    okButton.setVisible(object.isSyncEnabled());
                    final Confirm c = new Confirm("Group synchronization info", layout, okButton, null, true);
                    c.setHideOnButtonClick(false);
                    c.setCancelIcon(SmallIcons.INSTANCE.acceptIcon());
                    c.setCancelButtonText("OK");
                    c.setCancelClickHandler(new ClickHandler() {

                        @Override
                        public void onClick(ClickEvent event) {
                            c.hide();
                        }
                    });
                    c.show();
                }
            });
            get.retrieveData();
        }

        ;
    });
    syncColumn.setSortable(true);
    columnSortHandler.setComparator(syncColumn, new Comparator<RichGroup>() {

        @Override
        public int compare(RichGroup o1, RichGroup o2) {
            if (o1 != null && o2 != null) {
                int o1val = 0;
                int o2val = 0;
                if (o1.isSyncEnabled())
                    o1val = 5;
                if (o2.isSyncEnabled())
                    o2val = 5;
                if (o1.getAuthoritativeGroup() != null && o1.getAuthoritativeGroup().equalsIgnoreCase("1"))
                    o1val = o1val + 3;
                if (o2.getAuthoritativeGroup() != null && o2.getAuthoritativeGroup().equalsIgnoreCase("1"))
                    o2val = o2val + 3;
                return o1val - o2val;
            }
            return 0;
        }
    });
    table.addColumn(syncColumn, "Sync");
    table.setColumnWidth(syncColumn, "70px");
    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichGroup(cz.metacentrum.perun.webgui.model.RichGroup) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) Image(com.google.gwt.user.client.ui.Image) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) Column(com.google.gwt.user.cellview.client.Column) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) FlexTable(com.google.gwt.user.client.ui.FlexTable) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomClickableInfoCellWithImageResource(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableInfoCellWithImageResource)

Example 4 with RichGroup

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

the class GetRichSubGroups method setList.

public void setList(ArrayList<RichGroup> list) {
    clearTable();
    this.list.addAll(list);
    for (RichGroup g : list) {
        oracle.add(g.getName());
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : RichGroup(cz.metacentrum.perun.webgui.model.RichGroup)

Example 5 with RichGroup

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

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