Search in sources :

Example 6 with ListHandler

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

the class GetBlacklistWithDescription method getTable.

/**
	 * Returns the table widget with VOs.
	 * @return The table Widget
	 */
public CellTable<Pair<User, String>> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<Pair<User, String>>(list);
    // Cell table
    table = new PerunTable<Pair<User, String>>(list);
    // prevent double loading when clicked on vo name
    table.setHyperlinksAllowed(false);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Pair<User, String>> columnSortHandler = new ListHandler<Pair<User, String>>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Pair<User, String>>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("Blacklist is empty.");
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    Column<Pair<User, String>, String> idColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Pair<User, String>, String>() {

        public String getValue(Pair<User, String> object) {
            return String.valueOf(object.getLeft().getId());
        }
    }, tableFieldUpdater);
    idColumn.setSortable(true);
    // comparator
    columnSortHandler.setComparator(idColumn, new Comparator<Pair<User, String>>() {

        @Override
        public int compare(Pair<User, String> o1, Pair<User, String> o2) {
            return o1.getLeft().getId() - o2.getLeft().getId();
        }
    });
    // adding columns
    table.addColumn(idColumn, "User ID");
    table.setColumnWidth(idColumn, "150px");
    Column<Pair<User, String>, String> nameColumn = JsonUtils.addColumn(new CustomClickableTextCell(), new JsonUtils.GetValue<Pair<User, String>, String>() {

        @Override
        public String getValue(Pair<User, String> object) {
            return object.getLeft().getFullNameWithTitles();
        }
    }, tableFieldUpdater);
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(nameColumn, new Comparator<Pair<User, String>>() {

        public int compare(Pair<User, String> o1, Pair<User, String> o2) {
            return o1.getLeft().getFullName().compareToIgnoreCase(o2.getLeft().getFullName());
        }
    });
    table.addColumn(nameColumn, "Name");
    table.setColumnWidth(nameColumn, "40%");
    // Type column
    TextColumn<Pair<User, String>> reasonColumn = new TextColumn<Pair<User, String>>() {

        @Override
        public String getValue(Pair<User, String> pair) {
            return pair.getRight();
        }
    };
    // sort type column
    reasonColumn.setSortable(true);
    columnSortHandler.setComparator(reasonColumn, new Comparator<Pair<User, String>>() {

        public int compare(Pair<User, String> o1, Pair<User, String> o2) {
            return o1.getRight().compareToIgnoreCase(o2.getRight());
        }
    });
    // Add columns to table
    table.addColumn(reasonColumn, "Reason");
    table.setColumnWidth(reasonColumn, "50%");
    return table;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Example 7 with ListHandler

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

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

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

the class GetCompleteRichUsers method getTable.

/**
	 * Returns table of users.
	 * @return
	 */
public CellTable<User> getTable() {
    // retrieve data
    retrieveData();
    // 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) {
            return user.getFullName();
        }
    }, tableFieldUpdater);
    nameColumn.setSortable(true);
    columnSortHandler.setComparator(nameColumn, new Comparator<User>() {

        public int compare(User o1, User o2) {
            return o1.getLastName().compareToIgnoreCase(o2.getLastName());
        }
    });
    // 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");
            String value = "";
            if (at != null) {
                value = at.getValue();
            }
            return value;
        }
    }, 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");
            String value = "";
            if (at != null) {
                value = at.getValue();
                // replace "," to " " in emails
                value = value.replace(",", " ");
            }
            return value;
        }
    }, 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));
    // 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);
        }
    });
    // 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 10 with ListHandler

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

the class GetServicesPackages method getEmptyTable.

/**
	 * Returns empty table of ServicePackages
	 *
	 * @return empty table widget
	 */
public CellTable<ServicesPackage> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<ServicesPackage>(list);
    // Cell table
    table = new PerunTable<ServicesPackage>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<ServicesPackage> columnSortHandler = new ListHandler<ServicesPackage>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<ServicesPackage>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("There are no services packages.");
    // checkbox column column
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("ServicesPackage Id", tableFieldUpdater, 110);
    if (!editable) {
        table.addNameColumn(tableFieldUpdater);
        table.addDescriptionColumn(tableFieldUpdater);
    } else {
        // NAME COLUMN
        final Column<ServicesPackage, String> nameColumn = new Column<ServicesPackage, String>(new TextInputCell()) {

            public String getValue(ServicesPackage object) {
                return object.getName();
            }
        };
        nameColumn.setFieldUpdater(new FieldUpdater<ServicesPackage, String>() {

            @Override
            public void update(int i, final ServicesPackage object, final String s) {
                object.setName(s.trim());
                selectionModel.setSelected(object, true);
            }
        });
        nameColumn.setSortable(true);
        columnSortHandler.setComparator(nameColumn, new Comparator<ServicesPackage>() {

            public int compare(ServicesPackage o1, ServicesPackage o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        // DESCRIPTION COLUMN
        final Column<ServicesPackage, String> descriptionColumn = new Column<ServicesPackage, String>(new TextInputCell()) {

            public String getValue(ServicesPackage object) {
                return object.getDescription();
            }
        };
        descriptionColumn.setFieldUpdater(new FieldUpdater<ServicesPackage, String>() {

            @Override
            public void update(int i, final ServicesPackage object, final String s) {
                object.setDescription(s.trim());
                selectionModel.setSelected(object, true);
            }
        });
        descriptionColumn.setSortable(true);
        columnSortHandler.setComparator(descriptionColumn, new Comparator<ServicesPackage>() {

            public int compare(ServicesPackage o1, ServicesPackage o2) {
                return o1.getDescription().compareTo(o2.getDescription());
            }
        });
        // Link COLUMN
        final Column<ServicesPackage, String> linkColumn = new Column<ServicesPackage, String>(new CustomClickableTextCell()) {

            public String getValue(ServicesPackage object) {
                return "View services in package";
            }
        };
        linkColumn.setFieldUpdater(tableFieldUpdater);
        table.addColumn(nameColumn, "Name");
        table.setColumnWidth(nameColumn, "250px");
        table.addColumn(descriptionColumn, "Description");
        table.setColumnWidth(descriptionColumn, "250px");
        table.addColumn(linkColumn, "Manage services");
    }
    return table;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) TextInputCell(com.google.gwt.cell.client.TextInputCell) Column(com.google.gwt.user.cellview.client.Column) ServicesPackage(cz.metacentrum.perun.webgui.model.ServicesPackage)

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