Search in sources :

Example 6 with Group

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

the class GetAllGroupsWithHierarchy method getTable.

/**
	 * Returns table with groups in hierarchical structure and with custom field updater
	 *
	 * @return table widget
	 */
public CellTable<Group> getTable() {
    // retrieve data
    retrieveData();
    dataProvider = new ListDataProvider<Group>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    table.setVisibleRange(0, 1000);
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());
    // Updates the selection model = when selection changed, highlights the group children
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        public void onSelectionChange(SelectionChangeEvent event) {
            highlightRowsWhenChanged();
        }
    });
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // Checkbox column. This table will uses a checkbox column for
    // selection.
    Column<Group, Group> checkBoxColumn = new Column<Group, Group>(new PerunCheckboxCell<Group>(true, false, coreGroupsCheckable)) {

        @Override
        public Group getValue(Group object) {
            // Get the value from the selection model.
            object.setChecked(selectionModel.isSelected(object));
            return object;
        }
    };
    // Create ID column.
    Column<Group, String> idColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Group, String>() {

        public String getValue(Group g) {
            return String.valueOf(g.getId());
        }
    }, tableFieldUpdater);
    // Name column
    Column<Group, Group> nameColumn = new Column<Group, Group>(new PerunGroupCell()) {

        @Override
        public Group getValue(Group object) {
            return object;
        }
    };
    nameColumn.setFieldUpdater(new FieldUpdater<Group, Group>() {

        public void update(int index, Group object, Group value) {
            tableFieldUpdater.update(index, object, value.getName());
        }
    });
    // Create description column.
    Column<Group, String> descriptionColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Group, String>() {

        public String getValue(Group group) {
            return group.getDescription();
        }
    }, tableFieldUpdater);
    // updates the columns size
    table.setColumnWidth(checkBoxColumn, 40.0, Unit.PX);
    table.setColumnWidth(idColumn, 80.0, Unit.PX);
    // Add the columns.
    table.addColumn(checkBoxColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    table.addColumn(idColumn, "ID");
    table.addColumn(nameColumn, "Name");
    table.addColumn(descriptionColumn, "Description");
    return table;
}
Also used : Group(cz.metacentrum.perun.webgui.model.Group) SelectionChangeEvent(com.google.gwt.view.client.SelectionChangeEvent) Column(com.google.gwt.user.cellview.client.Column) JsonUtils(cz.metacentrum.perun.webgui.json.JsonUtils) PerunGroupCell(cz.metacentrum.perun.webgui.widgets.cells.PerunGroupCell)

Example 7 with Group

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

the class GetGroupUnions method getTable.

@Override
public CellTable<Group> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<Group>(list);
    // Cell table
    table = new PerunTable<>(list);
    table.setHyperlinksAllowed(false);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ColumnSortEvent.ListHandler<Group> columnSortHandler = new ColumnSortEvent.ListHandler<>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("Group has no unions.");
    // checkbox column column
    Column<Group, Group> checkBoxColumn = new Column<Group, Group>(new PerunCheckboxCell<Group>(true, false, true)) {

        @Override
        public Group getValue(Group object) {
            // Get the value from the selection model.
            GeneralObject go = object.cast();
            go.setChecked(selectionModel.isSelected(object));
            return go.cast();
        }
    };
    // updates the columns size
    table.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
    // Add the columns
    // Checkbox column header
    CheckboxCell cb = new CheckboxCell();
    Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {

        public Boolean getValue() {
            //return true to see a checked checkbox.
            return false;
        }
    };
    checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {

        public void update(Boolean value) {
            // sets selected to all, if value = true, unselect otherwise
            for (Group obj : list) {
                selectionModel.setSelected(obj, value);
            }
        }
    });
    table.addColumn(checkBoxColumn, checkBoxHeader);
    table.addIdColumn("Group ID", tableFieldUpdater);
    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);
    return table;
}
Also used : Group(cz.metacentrum.perun.webgui.model.Group) ColumnSortEvent(com.google.gwt.user.cellview.client.ColumnSortEvent) Header(com.google.gwt.user.cellview.client.Header) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject)

Example 8 with Group

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

the class GetMemberGroups 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 (Group 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 group matching '" + text + "' found.");
    } else {
        loaderImage.setEmptyResultMessage("User is not member of any group.");
    }
    dataProvider.flush();
    dataProvider.refresh();
    loaderImage.loadingFinished();
}
Also used : Group(cz.metacentrum.perun.webgui.model.Group)

Example 9 with Group

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

the class GetSubGroups 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 (Group 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 : Group(cz.metacentrum.perun.webgui.model.Group)

Example 10 with Group

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

the class GetAllowedGroups method getEmptyTable.

/**
	 * Returns table with groups in hierarchical structure and with custom field updater
	 *
	 * @return table widget
	 */
public CellTable<Group> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Group>(list);
    // Cell table
    table = new PerunTable<Group>(list);
    table.setHyperlinksAllowed(false);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Group> columnSortHandler = new ListHandler<Group>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No groups are allowed to access/use this facility.");
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("Group ID", tableFieldUpdater);
    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);
    Column<Group, String> vosColumn = new Column<Group, String>(new CustomClickableTextCell()) {

        @Override
        public String getValue(Group group) {
            for (VirtualOrganization v : vos) {
                if (group.getVoId() == v.getId()) {
                    return v.getName();
                }
            }
            return String.valueOf(group.getVoId());
        }
    };
    vosColumn.setFieldUpdater(tableFieldUpdater);
    columnSortHandler.setComparator(vosColumn, new Comparator<Group>() {

        @Override
        public int compare(Group o1, Group o2) {
            return o1.getVoId() - o2.getVoId();
        }
    });
    vosColumn.setSortable(true);
    table.addColumn(vosColumn, "Virtual organization");
    return table;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) Group(cz.metacentrum.perun.webgui.model.Group) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Column(com.google.gwt.user.cellview.client.Column) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization)

Aggregations

Group (cz.metacentrum.perun.webgui.model.Group)41 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)17 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)17 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)17 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)17 ArrayList (java.util.ArrayList)15 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)14 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)11 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)10 Column (com.google.gwt.user.cellview.client.Column)6 GetAllGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups)6 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)6 GroupDetailTabItem (cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem)5 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)4 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)4 Header (com.google.gwt.user.cellview.client.Header)4 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)4 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)4