use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class GetAttributesDefinitionV2 method removeFromTable.
/**
* Removes object as row from table
*
* @param object Attribute to be removed as row
*/
public void removeFromTable(Attribute object) {
selectionModel.getSelectedSet().remove(object);
Iterator<Attribute> it = list.iterator();
while (it.hasNext()) {
Attribute a = it.next();
if (a.getId() == object.getId()) {
it.remove();
}
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class GetAttributesDefinitionV2 method getTable.
/**
* Returns table widget with attributes definitions
*
* @return table widget
*/
public CellTable<Attribute> getTable() {
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<Attribute>(list);
// Cell table
table = new PerunTable<Attribute>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<Attribute> columnSortHandler = new ListHandler<Attribute>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
// checkbox column column
if (checkable) {
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager(0));
table.addCheckBoxColumn();
}
// Create ID column.
table.addIdColumn("Attr ID", null, 90);
// Name column
Column<Attribute, Attribute> nameColumn = JsonUtils.addColumn(new PerunAttributeNameCell());
// Description column
Column<Attribute, Attribute> descriptionColumn = JsonUtils.addColumn(new PerunAttributeDescriptionCell());
// Value column
Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell());
valueColumn.setFieldUpdater(new FieldUpdater<Attribute, Attribute>() {
public void update(int index, Attribute object, Attribute value) {
object = value;
selectionModel.setSelected(object, object.isAttributeValid());
}
});
// updates the columns size
this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);
// Sorting name column
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_NAME));
// Sorting description column
descriptionColumn.setSortable(true);
columnSortHandler.setComparator(descriptionColumn, new AttributeComparator<Attribute>(AttributeComparator.Column.TRANSLATED_DESCRIPTION));
// Add sorting
this.table.addColumnSortHandler(columnSortHandler);
// Add the columns.
this.table.addColumn(nameColumn, "Name");
this.table.addColumn(valueColumn, "Value");
this.table.addColumn(descriptionColumn, "Description");
return table;
}
use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class GetAttributesDefinitionWithRights method removeFromTable.
/**
* Removes object as row from table
*
* @param object Attribute to be removed as row
*/
public void removeFromTable(Attribute object) {
selectionModel.getSelectedSet().remove(object);
Iterator<Attribute> it = list.iterator();
while (it.hasNext()) {
Attribute a = it.next();
if (a.getId() == object.getId()) {
it.remove();
}
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class GetAttributesDefinitionWithRights method filterTable.
public void filterTable(String filter) {
// store list only for first time
if (fullBackup.isEmpty() || fullBackup == null) {
fullBackup.addAll(list);
}
// always clear selected items
selectionModel.clear();
list.clear();
if (filter.equalsIgnoreCase("")) {
list.addAll(fullBackup);
} else {
for (Attribute attr : fullBackup) {
// store facility by filter
if (attr.getFriendlyName().toLowerCase().startsWith(filter.toLowerCase())) {
list.add(attr);
}
}
}
dataProvider.flush();
dataProvider.refresh();
loaderImage.loadingFinished();
}
use of cz.metacentrum.perun.webgui.model.Attribute in project perun by CESNET.
the class GetAttributesV2 method onFinished.
/**
* Called, when operation finishes successfully.
*/
public void onFinished(JavaScriptObject jso) {
loaderImage.loadingFinished();
friendlyTable.clear();
if (!ownClear)
clearTable();
int counter = 0;
for (Attribute a : JsonUtils.<Attribute>jsoAsList(jso)) {
if (!a.getDefinition().equals("core")) {
addToTable(a);
}
friendlyTable.setWidget(counter, 0, new HTML("<strong>" + a.getFriendlyName() + "</strong>"));
friendlyTable.setText(counter, 1, a.getValue());
counter++;
}
sortTable();
loaderImage.loadingFinished();
session.getUiElements().setLogText("Attributes loaded: " + list.size());
events.onFinished(jso);
}
Aggregations