use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.
the class GetAllResourcesTags method getTable.
/**
* Returns just the celltable
* @return
*/
public CellTable<ResourceTag> getTable() {
// retrieve data
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<ResourceTag>(list);
// Cell table
table = new PerunTable<ResourceTag>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<ResourceTag> columnSortHandler = new ListHandler<ResourceTag>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<ResourceTag>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity)) {
loaderImage.setEmptyResultMessage("VO has no resource tags defined.");
} else if (PerunEntity.RESOURCE.equals(entity)) {
loaderImage.setEmptyResultMessage("Resource has no tags assigned.");
}
// columns
if (checkable) {
table.addCheckBoxColumn();
}
table.addIdColumn("Tag ID", tableFieldUpdater);
if (editable) {
// DISPLAY NAME COLUMN
final Column<ResourceTag, String> nameColumn = new Column<ResourceTag, String>(new TextInputCell()) {
public String getValue(ResourceTag tag) {
return tag.getName();
}
};
nameColumn.setFieldUpdater(new FieldUpdater<ResourceTag, String>() {
@Override
public void update(int i, final ResourceTag tag, final String s) {
tag.setName(s.trim());
selectionModel.setSelected(tag, true);
}
});
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new Comparator<ResourceTag>() {
public int compare(ResourceTag arg0, ResourceTag arg1) {
return (arg0.getName().compareToIgnoreCase(arg1.getName()));
}
});
table.addColumn(nameColumn, "Tag name");
} else {
// name column
Column<ResourceTag, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<ResourceTag, String>() {
public String getValue(ResourceTag object) {
return object.getName();
}
}, tableFieldUpdater);
nameColumn.setSortable(true);
columnSortHandler.setComparator(nameColumn, new Comparator<ResourceTag>() {
public int compare(ResourceTag arg0, ResourceTag arg1) {
return (arg0.getName().compareToIgnoreCase(arg1.getName()));
}
});
table.addColumn(nameColumn, "Tag name");
}
return table;
}
use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.
the class GetAllResourcesTags method setList.
public void setList(ArrayList<ResourceTag> list) {
clearTable();
this.list.addAll(list);
for (ResourceTag r : list) {
oracle.add(r.getName());
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.
the class GetRichResources method addToTable.
/**
* Add object as new row to table
*
* @param object Resource to be added as new row
*/
public void addToTable(RichResource object) {
list.add(object);
oracle.add(object.getName());
for (ResourceTag rt : object.getResourceTags()) {
oracle.add(rt.getName() + " (tag)");
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.
the class GetAssignedRichResources 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 (RichResource res : fullBackup) {
// store resource by filter
if (res.getName().toLowerCase().contains(filter.toLowerCase())) {
list.add(res);
}
for (ResourceTag r : res.getResourceTags()) {
// remove " (tag)" after tag name
if (r.getName().contains(filter.substring(0, (filter.length() > 6) ? filter.length() - 6 : filter.length()).trim())) {
list.add(res);
break;
}
}
}
}
dataProvider.flush();
dataProvider.refresh();
loaderImage.loadingFinished();
}
use of cz.metacentrum.perun.webgui.model.ResourceTag in project perun by CESNET.
the class GetAssignedRichResources method setList.
public void setList(ArrayList<RichResource> list) {
clearTable();
this.list.addAll(list);
for (RichResource r : list) {
oracle.add(r.getName());
for (ResourceTag rt : r.getResourceTags()) {
oracle.add(rt.getName() + " (tag)");
}
}
dataProvider.flush();
dataProvider.refresh();
}
Aggregations