Search in sources :

Example 1 with ResourceTag

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;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) TextInputCell(com.google.gwt.cell.client.TextInputCell) ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) Column(com.google.gwt.user.cellview.client.Column)

Example 2 with ResourceTag

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();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag)

Example 3 with ResourceTag

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();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag)

Example 4 with ResourceTag

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();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) RichResource(cz.metacentrum.perun.webgui.model.RichResource)

Example 5 with ResourceTag

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();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) RichResource(cz.metacentrum.perun.webgui.model.RichResource)

Aggregations

ResourceTag (cz.metacentrum.perun.webgui.model.ResourceTag)18 RichResource (cz.metacentrum.perun.webgui.model.RichResource)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)3 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)3 GetAllResourcesTags (cz.metacentrum.perun.webgui.json.resourcesManager.GetAllResourcesTags)3 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)3 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)3 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)3 ArrayList (java.util.ArrayList)3 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)2 TextInputCell (com.google.gwt.cell.client.TextInputCell)1 Column (com.google.gwt.user.cellview.client.Column)1 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)1 AssignResourceTag (cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag)1 DeleteResourceTag (cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResourceTag)1 RemoveResourceTag (cz.metacentrum.perun.webgui.json.resourcesManager.RemoveResourceTag)1 UpdateResourceTag (cz.metacentrum.perun.webgui.json.resourcesManager.UpdateResourceTag)1 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)1