use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class GetAllGroups method onFinished.
/**
* Called, when operation finishes successfully.
*/
public void onFinished(JavaScriptObject jso) {
clearTable();
for (Group g : JsonUtils.<Group>jsoAsList(jso)) {
if (g.isCoreGroup()) {
insertToTable(0, g);
} else {
addToTable(g);
}
}
//sortTable(); groups are sorted from RPC
session.getUiElements().setLogText("Groups loaded: " + list.size());
events.onFinished(jso);
loaderImage.loadingFinished();
}
use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class GetAllGroups 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);
if (!session.isVoAdmin(voId)) {
loaderImage.setEmptyResultMessage("You are not manager of any group in this VO.");
} else {
loaderImage.setEmptyResultMessage("VO has no groups.");
}
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;
}
};
// updates the columns size
table.setColumnWidth(checkBoxColumn, 40.0, 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) {
if (!obj.isCoreGroup()) {
selectionModel.setSelected(obj, value);
}
}
}
});
if (checkable) {
table.addColumn(checkBoxColumn, checkBoxHeader);
}
table.addIdColumn("Group ID", tableFieldUpdater);
table.addNameColumn(tableFieldUpdater);
table.addDescriptionColumn(tableFieldUpdater);
// set row styles based on: isCoreGroup()
table.setRowStyles(new RowStyles<Group>() {
public String getStyleNames(Group row, int rowIndex) {
if (row.isCoreGroup()) {
return "bold";
}
return "";
}
});
return table;
}
use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class GetAllGroupsWithHierarchy method retrieveAdminsAndMembers.
/**
* Retrieves groups: administrators, members
*/
private void retrieveAdminsAndMembers() {
// add member and admins groups
JsonCallbackEvents externalEvents = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
Group grp = jso.cast();
grp.setIndent(1);
insertToTable(grp, 0);
}
};
GetGroupByName members = new GetGroupByName("members", voId, externalEvents);
members.retrieveData();
//GetGroupByName admins = new GetGroupByName("administrators" ,voId, externalEvents);
//admins.retrieveData();
}
use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class GetAllGroupsWithHierarchy method recursiveGroups.
/**
* Loads recursively the groups
* Tries to parse the JSO as an array, if not succeeded, add the object.
*
* @param jso returned objects (array) from RPC
* @param parentGroup parent group
* @param previousGroup previouse group
* @param weight indent
* @return group or null
*/
private Group recursiveGroups(JavaScriptObject jso, Group parentGroup, Group previousGroup, int weight) {
// if null
if (jso == null) {
return null;
}
// ? array
if (!JsonUtils.isJsArray(jso)) {
// not array - add to list
ArrayList<Group> list = this.list;
Group g = (Group) jso;
// set type
g.setObjectType("Group");
g.setIndent(weight);
// new parent
parentGroup = previousGroup;
g.setParentGroup(parentGroup);
list.add(g);
return g;
}
// if no parent set
if (weight == 2 && parentGroup == null) {
parentGroup = previousGroup;
}
// array conversion
JsArray<JavaScriptObject> groupsList = JsonUtils.jsoAsArray(jso);
for (int i = 0; i < groupsList.length(); i++) {
Group tmpGroup = recursiveGroups(groupsList.get(i), parentGroup, previousGroup, weight + 1);
if (tmpGroup != null) {
previousGroup = tmpGroup;
}
}
return null;
}
use of cz.metacentrum.perun.webgui.model.Group in project perun by CESNET.
the class GetGroupUnions method setList.
@Override
public void setList(ArrayList<Group> list) {
clearTable();
this.list.addAll(list);
for (Group g : list) {
oracle.add(g.getName());
}
dataProvider.flush();
dataProvider.refresh();
}
Aggregations