Search in sources :

Example 1 with CustomClickableTextCell

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

the class GetAllowedGroups 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);
    loaderImage.setEmptyResultMessage("No groups are allowed to access/use this facility.");
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("Group ID", tableFieldUpdater);
    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);
    Column<Group, String> vosColumn = new Column<Group, String>(new CustomClickableTextCell()) {

        @Override
        public String getValue(Group group) {
            for (VirtualOrganization v : vos) {
                if (group.getVoId() == v.getId()) {
                    return v.getName();
                }
            }
            return String.valueOf(group.getVoId());
        }
    };
    vosColumn.setFieldUpdater(tableFieldUpdater);
    columnSortHandler.setComparator(vosColumn, new Comparator<Group>() {

        @Override
        public int compare(Group o1, Group o2) {
            return o1.getVoId() - o2.getVoId();
        }
    });
    vosColumn.setSortable(true);
    table.addColumn(vosColumn, "Virtual organization");
    return table;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) Group(cz.metacentrum.perun.webgui.model.Group) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Column(com.google.gwt.user.cellview.client.Column) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization)

Example 2 with CustomClickableTextCell

use of cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell 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 3 with CustomClickableTextCell

use of cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell 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)

Example 4 with CustomClickableTextCell

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

the class GetApplicationsForUser method getTable.

/**
	 * Returns just the celltable
	 * @return
	 */
public CellTable<Application> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<Application>(list);
    // Cell table
    table = new PerunTable<Application>(list);
    table.removeRowCountChangeHandler();
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Application> columnSortHandler = new ListHandler<Application>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Application>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("You have no applications submitted.");
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("App ID", tableFieldUpdater, 100);
    // DATE COLUMN
    Column<Application, String> dateColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            // return only day
            return object.getCreatedAt().split(" ")[0];
        }
    }, tableFieldUpdater);
    dateColumn.setSortable(true);
    columnSortHandler.setComparator(dateColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return arg0.getCreatedAt().compareToIgnoreCase(arg1.getCreatedAt());
        }
    });
    table.addColumn(dateColumn, "Created date");
    table.setColumnWidth(dateColumn, "150px");
    // Type column
    Column<Application, String> typeColumn = new Column<Application, String>(new CustomClickableTextCell()) {

        @Override
        public String getValue(Application object) {
            return object.getTranslatedType(object.getType());
        }

        @Override
        public String getCellStyleNames(Cell.Context context, Application object) {
            if (tableFieldUpdater != null) {
                return super.getCellStyleNames(context, object) + " pointer";
            } else {
                return super.getCellStyleNames(context, object);
            }
        }
    };
    typeColumn.setFieldUpdater(tableFieldUpdater);
    typeColumn.setSortable(true);
    columnSortHandler.setComparator(typeColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return (arg0.getType()).compareToIgnoreCase(arg1.getType());
        }
    });
    table.addColumn(typeColumn, "Type");
    table.setColumnWidth(typeColumn, "60px");
    // State column
    Column<Application, String> stateColumn = new Column<Application, String>(new CustomClickableTextCell()) {

        @Override
        public String getValue(Application object) {
            return object.getTranslatedState(object.getState());
        }

        @Override
        public String getCellStyleNames(Cell.Context context, Application object) {
            if (tableFieldUpdater != null) {
                return super.getCellStyleNames(context, object) + " pointer";
            } else {
                return super.getCellStyleNames(context, object);
            }
        }
    };
    stateColumn.setFieldUpdater(tableFieldUpdater);
    stateColumn.setSortable(true);
    columnSortHandler.setComparator(stateColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return (arg0.getTranslatedState(arg0.getState())).compareToIgnoreCase(arg1.getTranslatedState(arg1.getState()));
        }
    });
    table.addColumn(stateColumn, "State");
    table.setColumnWidth(stateColumn, "120px");
    // VO COLUMN
    Column<Application, String> voColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            return object.getVo().getName();
        }
    }, tableFieldUpdater);
    voColumn.setSortable(true);
    columnSortHandler.setComparator(voColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return (arg0.getVo().getName()).compareToIgnoreCase(arg1.getVo().getName());
        }
    });
    table.addColumn(voColumn, "Virtual organization");
    // GROUP COLUMN
    Column<Application, String> groupColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            if (object.getGroup() != null) {
                return object.getGroup().getName();
            } else {
                return "---";
            }
        }
    }, tableFieldUpdater);
    groupColumn.setSortable(true);
    columnSortHandler.setComparator(groupColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            String name1 = "";
            String name2 = "";
            if (arg0.getGroup() != null) {
                name1 = arg0.getGroup().getName();
            } else {
                name1 = "---";
            }
            if (arg1.getGroup() != null) {
                name2 = arg1.getGroup().getName();
            } else {
                name2 = "---";
            }
            return (name1).compareToIgnoreCase(name2);
        }
    });
    table.addColumn(groupColumn, "Group");
    // FED INFO COLUMN
    /*
			 Column<Application, String> fedInfoColumn = JsonUtils.addColumn(
			 new ClickableTextCell() {
			 @Override
			 public void render(
			 com.google.gwt.cell.client.Cell.Context context,
			 SafeHtml value, SafeHtmlBuilder sb) {
			 if (value != null) {
			 sb.appendHtmlConstant("<div class=\"customClickableTextCell\">");
			 sb.append(value);
			 sb.appendHtmlConstant("</div>");
			 }
			 }
			 },
			 new JsonUtils.GetValue<Application, String>() {
			 public String getValue(Application object) {
			 return object.getFedInfo();
			 }
			 }, tableFieldUpdater);

			 fedInfoColumn.setSortable(true);
			 columnSortHandler.setComparator(fedInfoColumn, new Comparator<Application>(){
			 public int compare(Application arg0, Application arg1) {
			 return (arg0.getFedInfo()).compareToIgnoreCase(arg1.getFedInfo());
			 }
			 });
			 table.addColumn(fedInfoColumn, "Federation information");
			 */
    table.setRowStyles(new RowStyles<Application>() {

        public String getStyleNames(Application application, int i) {
            if ("NEW".equalsIgnoreCase(application.getState())) {
                return "rowgreen";
            } else if ("VERIFIED".equalsIgnoreCase(application.getState())) {
                return "rowyellow";
            } else if ("APPROVED".equalsIgnoreCase(application.getState())) {
                return "rowdarkgreen";
            } else if ("REJECTED".equalsIgnoreCase(application.getState())) {
                return "rowred";
            }
            return "";
        }
    });
    return table;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Column(com.google.gwt.user.cellview.client.Column) Application(cz.metacentrum.perun.webgui.model.Application)

Example 5 with CustomClickableTextCell

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

the class JsonUtils method addColumn.

/**
	 * Returns a column with a header and with automatic cell selection
	 *
	 * @param <R> the row type
	 * @param getter the value getter for the cell
	 * @param fieldUpdater Field updater - on click action
	 */
public static <R> Column<R, String> addColumn(final GetValue<R, String> getter, final FieldUpdater<R, String> fieldUpdater) {
    Cell<String> cell;
    if (fieldUpdater == null) {
        cell = new TextCell();
    } else {
        cell = new CustomClickableTextCell();
    }
    Column<R, String> column = new Column<R, String>(cell) {

        @Override
        public String getValue(R object) {
            return getter.getValue(object);
        }

        @Override
        public String getCellStyleNames(Cell.Context context, R object) {
            if (fieldUpdater != null) {
                return super.getCellStyleNames(context, object) + " pointer";
            } else {
                return super.getCellStyleNames(context, object);
            }
        }
    };
    if (fieldUpdater != null) {
        column.setFieldUpdater(fieldUpdater);
    }
    return column;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) Column(com.google.gwt.user.cellview.client.Column) JsArrayString(com.google.gwt.core.client.JsArrayString) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) TextCell(com.google.gwt.cell.client.TextCell)

Aggregations

CustomClickableTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)9 Column (com.google.gwt.user.cellview.client.Column)8 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)8 Application (cz.metacentrum.perun.webgui.model.Application)5 Cell (com.google.gwt.cell.client.Cell)3 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 PerunAppTypeCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell)3 TextCell (com.google.gwt.cell.client.TextCell)1 TextInputCell (com.google.gwt.cell.client.TextInputCell)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 TextColumn (com.google.gwt.user.cellview.client.TextColumn)1 Group (cz.metacentrum.perun.webgui.model.Group)1 ServicesPackage (cz.metacentrum.perun.webgui.model.ServicesPackage)1 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)1