Search in sources :

Example 1 with PerunCheckboxCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell in project perun by CESNET.

the class GetAssignedGroups method getTable.

/**
 * Returns table with assigned groups
 *
 * @return table widget
 */
public CellTable<Group> getTable() {
    // retrieve data
    retrieveData();
    // 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
    if (singleSelection) {
        table.setSelectionModel(singleSelectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());
    } else {
        table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());
    }
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("Resource has no groups assigned.");
    // checkbox column column
    if (checkable) {
        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.
                if (singleSelection) {
                    object.setChecked(singleSelectionModel.isSelected(object));
                } else {
                    object.setChecked(selectionModel.isSelected(object));
                }
                return object;
            }
        };
        // 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);
                    }
                }
            }
        });
        // updates the columns size
        table.setColumnWidth(checkBoxColumn, 60.0, Style.Unit.PX);
        if (singleSelection) {
            // single selection withou "check all"
            table.addColumn(checkBoxColumn);
        } else {
            // multi selection with header
            table.addColumn(checkBoxColumn, checkBoxHeader);
        }
    }
    table.addIdColumn("Group ID", tableFieldUpdater);
    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);
    return table;
}
Also used : Group(cz.metacentrum.perun.webgui.model.Group) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Header(com.google.gwt.user.cellview.client.Header) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)

Example 2 with PerunCheckboxCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell in project perun by CESNET.

the class GetAutoRegistrationGroups 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("No groups are set for auto registration.");
    }
    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;
}
Also used : Group(cz.metacentrum.perun.webgui.model.Group) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Header(com.google.gwt.user.cellview.client.Header) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)

Example 3 with PerunCheckboxCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell in project perun by CESNET.

the class GetEntitylessAttributes method getEmptyTable.

public CellTable<Attribute> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<>(list);
    // Cell table
    table = new PerunTable<>(list);
    // remove row count change handler
    table.removeRowCountChangeHandler();
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ColumnSortEvent.ListHandler<Attribute> columnSortHandler = new ColumnSortEvent.ListHandler<>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No attributes found. Use 'Add' button to add new key=value.");
    // because of tab index
    table.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);
    // checkbox column
    if (checkable) {
        // checkbox column column
        Column<Attribute, Attribute> checkBoxColumn = new Column<Attribute, Attribute>(new PerunCheckboxCell<>(true, false, false)) {

            @Override
            public Attribute getValue(Attribute object) {
                // Get the value from the selection model.
                GeneralObject go = object.cast();
                go.setChecked(selectionModel.isSelected(object));
                return go.cast();
            }
        };
        // updates the columns size
        table.setColumnWidth(checkBoxColumn, 40.0, Style.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(value -> {
            // sets selected to all, if value = true, unselect otherwise
            for (Attribute obj : list) {
                if (obj.isWritable()) {
                    selectionModel.setSelected(obj, value);
                }
            }
        });
        // table selection
        table.setSelectionModel(selectionModel, DefaultSelectionEventManager.createCheckboxManager(0));
        table.addColumn(checkBoxColumn, checkBoxHeader);
    }
    // Key column
    TextColumn<Attribute> keyColumn = new TextColumn<Attribute>() {

        @Override
        public String getValue(Attribute attribute) {
            return attribute.getKey();
        }
    };
    keyColumn.setSortable(true);
    table.addColumn(keyColumn, "Key");
    this.table.setColumnWidth(keyColumn, 200.0, Style.Unit.PX);
    // Value column
    Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell());
    valueColumn.setFieldUpdater((index, object, value) -> {
        object = value;
        selectionModel.setSelected(object, object.isAttributeValid());
    });
    // Add sorting
    this.table.addColumnSortHandler(columnSortHandler);
    // Add the columns.
    this.table.addColumn(valueColumn, "Value");
    return this.table;
}
Also used : PerunAttributeValueCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell) Attribute(cz.metacentrum.perun.webgui.model.Attribute) ColumnSortEvent(com.google.gwt.user.cellview.client.ColumnSortEvent) Header(com.google.gwt.user.cellview.client.Header) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 4 with PerunCheckboxCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell in project perun by CESNET.

the class GetRequiredAttributesV2 method getEmptyTable.

/**
 * Returns empty table widget with attributes
 *
 * @return table widget
 */
public CellTable<Attribute> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Attribute>(list);
    // Cell table
    table = new PerunTable<Attribute>(list);
    // remove row count change handler
    table.removeRowCountChangeHandler();
    // 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);
    loaderImage.setEmptyResultMessage("No settings found. Use 'Add' button to add new setting.");
    // because of tab index
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    // checkbox column
    if (checkable) {
        // checkbox column column
        Column<Attribute, Attribute> checkBoxColumn = new Column<Attribute, Attribute>(new PerunCheckboxCell<Attribute>(true, false, false)) {

            @Override
            public Attribute getValue(Attribute object) {
                // Get the value from the selection model.
                GeneralObject go = object.cast();
                go.setChecked(selectionModel.isSelected(object));
                return go.cast();
            }
        };
        // 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 (Attribute obj : list) {
                    if (obj.isWritable()) {
                        selectionModel.setSelected(obj, value);
                    }
                }
            }
        });
        // table selection
        table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager(0));
        table.addColumn(checkBoxColumn, checkBoxHeader);
    }
    // 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());
        }
    });
    // Sorting name column
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(nameColumn, new Comparator<Attribute>() {

        public int compare(Attribute o1, Attribute o2) {
            Collator customCollator = Collator.getInstance();
            String key1 = o1.getDisplayName();
            String key2 = o2.getDisplayName();
            return customCollator.compare(key1, key2);
        }
    });
    // Add sorting
    this.table.addColumnSortHandler(columnSortHandler);
    // updates the columns size
    this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);
    // Add the columns.
    this.table.addColumn(nameColumn, "Name");
    this.table.addColumn(valueColumn, "Value");
    this.table.addColumn(descriptionColumn, "Description");
    return this.table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) PerunAttributeValueCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell) Attribute(cz.metacentrum.perun.webgui.model.Attribute) PerunAttributeNameCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeNameCell) Collator(cz.metacentrum.perun.webgui.client.resources.Collator) PerunAttributeDescriptionCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeDescriptionCell) Header(com.google.gwt.user.cellview.client.Header) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject)

Example 5 with PerunCheckboxCell

use of cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell in project perun by CESNET.

the class GetResourceRequiredAttributesV2 method getEmptyTable.

/**
 * Returns empty table widget with attributes
 *
 * @return table widget
 */
public CellTable<Attribute> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Attribute>(list);
    // Cell table
    table = new PerunTable<Attribute>(list);
    // remove row count change handler
    table.removeRowCountChangeHandler();
    // 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);
    // because of tab index
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    // checkbox column
    if (checkable) {
        // checkbox column column
        Column<Attribute, Attribute> checkBoxColumn = new Column<Attribute, Attribute>(new PerunCheckboxCell<Attribute>(true, false, false)) {

            @Override
            public Attribute getValue(Attribute object) {
                // Get the value from the selection model.
                GeneralObject go = object.cast();
                go.setChecked(selectionModel.isSelected(object));
                return go.cast();
            }
        };
        // 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 (Attribute obj : list) {
                    if (obj.isWritable()) {
                        selectionModel.setSelected(obj, value);
                    }
                }
            }
        });
        // table selection
        table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Attribute>createCheckboxManager(0));
        table.addColumn(checkBoxColumn, checkBoxHeader);
    }
    // Create ID column.
    table.addIdColumn("Attr ID", null, 90);
    // Name column
    Column<Attribute, Attribute> nameColumn = JsonUtils.addColumn(new PerunAttributeNameCell());
    // 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());
        }
    });
    // Description column
    Column<Attribute, Attribute> descriptionColumn = JsonUtils.addColumn(new PerunAttributeDescriptionCell());
    // 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);
    // updates the columns size
    this.table.setColumnWidth(nameColumn, 200.0, Unit.PX);
    // Add the columns.
    this.table.addColumn(nameColumn, "Name");
    this.table.addColumn(valueColumn, "Value");
    this.table.addColumn(descriptionColumn, "Description");
    return this.table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) PerunAttributeValueCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell) Attribute(cz.metacentrum.perun.webgui.model.Attribute) PerunAttributeNameCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeNameCell) PerunAttributeDescriptionCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeDescriptionCell) Header(com.google.gwt.user.cellview.client.Header) Column(com.google.gwt.user.cellview.client.Column) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject)

Aggregations

CheckboxCell (com.google.gwt.cell.client.CheckboxCell)16 Column (com.google.gwt.user.cellview.client.Column)16 Header (com.google.gwt.user.cellview.client.Header)16 PerunCheckboxCell (cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)16 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)14 GeneralObject (cz.metacentrum.perun.webgui.model.GeneralObject)9 Attribute (cz.metacentrum.perun.webgui.model.Attribute)7 Group (cz.metacentrum.perun.webgui.model.Group)5 PerunAttributeValueCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell)4 PerunAttributeDescriptionCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeDescriptionCell)3 PerunAttributeNameCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeNameCell)3 ColumnSortEvent (com.google.gwt.user.cellview.client.ColumnSortEvent)2 IsClickableCell (cz.metacentrum.perun.webgui.json.columnProviders.IsClickableCell)2 MemberColumnProvider (cz.metacentrum.perun.webgui.json.columnProviders.MemberColumnProvider)2 RichMember (cz.metacentrum.perun.webgui.model.RichMember)2 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)1 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 TextColumn (com.google.gwt.user.cellview.client.TextColumn)1