Search in sources :

Example 36 with Attribute

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

Example 37 with Attribute

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;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) PerunAttributeValueCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell) PerunAttributeDescriptionCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeDescriptionCell) Attribute(cz.metacentrum.perun.webgui.model.Attribute) PerunAttributeNameCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeNameCell)

Example 38 with Attribute

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

Example 39 with Attribute

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

Example 40 with Attribute

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);
}
Also used : Attribute(cz.metacentrum.perun.webgui.model.Attribute) HTML(com.google.gwt.user.client.ui.HTML)

Aggregations

Attribute (cz.metacentrum.perun.webgui.model.Attribute)58 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)17 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)17 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)16 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)16 ArrayList (java.util.ArrayList)16 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)15 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)15 HashMap (java.util.HashMap)14 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)12 PerunError (cz.metacentrum.perun.webgui.model.PerunError)10 SetAttributes (cz.metacentrum.perun.webgui.json.attributesManager.SetAttributes)9 PerunAttributeValueCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell)9 Map (java.util.Map)9 RemoveAttributes (cz.metacentrum.perun.webgui.json.attributesManager.RemoveAttributes)8 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)7 GeneralObject (cz.metacentrum.perun.webgui.model.GeneralObject)7 PerunAttributeDescriptionCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeDescriptionCell)7 PerunAttributeNameCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeNameCell)7 Column (com.google.gwt.user.cellview.client.Column)6