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;
}
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;
}
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();
}
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();
}
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;
}
Aggregations