Search in sources :

Example 21 with ListHandler

use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler 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 22 with ListHandler

use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.

the class GetAttributesV2 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 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)

Example 23 with ListHandler

use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.

the class FindCompleteRichUsers method getEmptyTable.

/**
	 * Returns empty table definition
	 * @return
	 */
public CellTable<User> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<User>(list);
    // Cell table
    table = new PerunTable<User>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<User> columnSortHandler = new ListHandler<User>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<User>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("User ID", tableFieldUpdater);
    // NAME COLUMN
    Column<User, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User user) {
            // display full name with titles
            return user.getFullNameWithTitles();
        }
    }, tableFieldUpdater);
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(nameColumn, new Comparator<User>() {

        public int compare(User o1, User o2) {
            // sort by name without titles
            return o1.getFullName().compareToIgnoreCase(o2.getFullName());
        }
    });
    // SERVICE COLUMN
    Column<User, String> serviceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User user) {
            if (user.isServiceUser()) {
                return "Service";
            } else if (user.isSponsoredUser()) {
                return "Sponsored";
            } else {
                return "Person";
            }
        }
    }, tableFieldUpdater);
    serviceColumn.setSortable(true);
    columnSortHandler.setComparator(serviceColumn, new Comparator<User>() {

        public int compare(User o1, User o2) {
            String type1 = "Person";
            if (o1.isServiceUser()) {
                type1 = "Service";
            } else if (o1.isSponsoredUser()) {
                type1 = "Sponsored";
            }
            String type2 = "Person";
            if (o2.isServiceUser()) {
                type2 = "Service";
            } else if (o2.isSponsoredUser()) {
                type2 = "Sponsored";
            }
            return type1.compareTo(type2);
        }
    });
    // Create organization column.
    Column<User, String> organizationColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User object) {
            Attribute at = object.getAttribute("urn:perun:user:attribute-def:def:organization");
            if (at != null && at.getValue() != null && !"null".equalsIgnoreCase(at.getValue())) {
                return at.getValue();
            }
            return "";
        }
    }, this.tableFieldUpdater);
    // Create e-mail column.
    Column<User, String> emailColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User object) {
            Attribute at = object.getAttribute("urn:perun:user:attribute-def:def:preferredMail");
            if (at != null && at.getValue() != null && !"null".equalsIgnoreCase(at.getValue())) {
                return at.getValue().replace(",", " ");
            }
            return "";
        }
    }, this.tableFieldUpdater);
    // Create name column.
    Column<User, String> loginsColumn = JsonUtils.addColumn(new JsonUtils.GetValue<User, String>() {

        public String getValue(User object) {
            return object.getLogins();
        }
    }, this.tableFieldUpdater);
    organizationColumn.setSortable(true);
    columnSortHandler.setComparator(organizationColumn, new RichUserComparator(RichUserComparator.Column.ORGANIZATION));
    emailColumn.setSortable(true);
    columnSortHandler.setComparator(emailColumn, new RichUserComparator(RichUserComparator.Column.EMAIL));
    // Add the other columns.
    table.addColumn(nameColumn, "Name");
    table.addColumn(organizationColumn, "Organization");
    table.addColumn(emailColumn, "E-mail");
    table.addColumn(loginsColumn, "Logins");
    table.addColumn(serviceColumn, "User type");
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) User(cz.metacentrum.perun.webgui.model.User) RichUserComparator(cz.metacentrum.perun.webgui.json.comparators.RichUserComparator) Attribute(cz.metacentrum.perun.webgui.model.Attribute)

Example 24 with ListHandler

use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.

the class GetUserExtSources method getTable.

/**
	 * Return table with checkboxes containing user external sources
	 *
	 * @return table containing user ext sources
	 */
public CellTable<UserExtSource> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<UserExtSource>(list);
    // Cell table
    table = new PerunTable<UserExtSource>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<UserExtSource> columnSortHandler = new ListHandler<UserExtSource>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<UserExtSource>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // checkbox column column
    com.google.gwt.user.cellview.client.Column<UserExtSource, UserExtSource> checkBoxColumn = new com.google.gwt.user.cellview.client.Column<UserExtSource, UserExtSource>(new PerunCheckboxCell<UserExtSource>(true, false, false)) {

        @Override
        public UserExtSource getValue(UserExtSource 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(new ValueUpdater<Boolean>() {

        public void update(Boolean value) {
            // sets selected to all, if value = true, unselect otherwise
            for (UserExtSource obj : list) {
                if (!obj.isPersistent()) {
                    selectionModel.setSelected(obj, value);
                }
            }
        }
    });
    table.addColumn(checkBoxColumn, checkBoxHeader);
    table.addIdColumn("UES ID", tableFieldUpdater, 100);
    // Name column
    Column<UserExtSource, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<UserExtSource, String>() {

        public String getValue(UserExtSource extSource) {
            return String.valueOf(extSource.getExtSource().getName());
        }
    }, tableFieldUpdater);
    // Login column
    Column<UserExtSource, String> loginColumn = JsonUtils.addColumn(new JsonUtils.GetValue<UserExtSource, String>() {

        public String getValue(UserExtSource extSource) {
            return String.valueOf(extSource.getLogin());
        }
    }, tableFieldUpdater);
    // LOA column
    Column<UserExtSource, String> loaColumn = JsonUtils.addColumn(new JsonUtils.GetValue<UserExtSource, String>() {

        public String getValue(UserExtSource extSource) {
            return String.valueOf(extSource.getLoa());
        }
    }, tableFieldUpdater);
    // sort name column
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(nameColumn, new GeneralComparator<UserExtSource>(GeneralComparator.Column.NAME));
    // sort login column
    loginColumn.setSortable(true);
    columnSortHandler.setComparator(loginColumn, new Comparator<UserExtSource>() {

        public int compare(UserExtSource o1, UserExtSource o2) {
            return o1.getLogin().compareTo(o2.getLogin());
        }
    });
    // sort login column
    loaColumn.setSortable(true);
    columnSortHandler.setComparator(loaColumn, new Comparator<UserExtSource>() {

        public int compare(UserExtSource o1, UserExtSource o2) {
            return o1.getLoa() - o2.getLoa();
        }
    });
    table.addColumn(nameColumn, "External source name");
    table.addColumn(loginColumn, "ID in external source");
    table.addColumn(loaColumn, "Level of assurance");
    return table;
}
Also used : 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) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Header(com.google.gwt.user.cellview.client.Header) UserExtSource(cz.metacentrum.perun.webgui.model.UserExtSource)

Example 25 with ListHandler

use of com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler in project perun by CESNET.

the class GetVosWhereUserIsAdmin method getTable.

/**
	 * Returns the table widget with VOs.
	 * @return The table Widget
	 */
public CellTable<VirtualOrganization> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<VirtualOrganization>(list);
    // Cell table
    table = new PerunTable<VirtualOrganization>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<VirtualOrganization> columnSortHandler = new ListHandler<VirtualOrganization>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<VirtualOrganization>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    // checkbox column column
    if (checkable) {
        table.addCheckBoxColumn();
    }
    VoColumnProvider columnProvider = new VoColumnProvider(table, tableFieldUpdater);
    IsClickableCell<GeneralObject> authz = VoColumnProvider.getDefaultClickableAuthz();
    columnProvider.addIdColumn(authz, 100);
    columnProvider.addShortNameColumn(authz, 200);
    columnProvider.addNameColumn(authz, 0);
    return table;
}
Also used : VoColumnProvider(cz.metacentrum.perun.webgui.json.columnProviders.VoColumnProvider) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) GeneralObject(cz.metacentrum.perun.webgui.model.GeneralObject)

Aggregations

ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)44 Column (com.google.gwt.user.cellview.client.Column)28 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)13 Header (com.google.gwt.user.cellview.client.Header)13 PerunCheckboxCell (cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)13 Attribute (cz.metacentrum.perun.webgui.model.Attribute)12 GeneralObject (cz.metacentrum.perun.webgui.model.GeneralObject)11 CustomClickableTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)8 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)6 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)6 TextColumn (com.google.gwt.user.cellview.client.TextColumn)5 Application (cz.metacentrum.perun.webgui.model.Application)5 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)5 PerunAttributeDescriptionCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeDescriptionCell)5 PerunAttributeNameCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeNameCell)5 PerunAttributeValueCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell)5 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 VoColumnProvider (cz.metacentrum.perun.webgui.json.columnProviders.VoColumnProvider)4 RichUserComparator (cz.metacentrum.perun.webgui.json.comparators.RichUserComparator)4