Search in sources :

Example 1 with ClickableTextCell

use of com.google.gwt.cell.client.ClickableTextCell in project rstudio by rstudio.

the class EnvironmentObjectList method createExpandColumn.

private void createExpandColumn() {
    // the column containing the expand command; available only on objects
    // with contents (such as lists and data frames).
    SafeHtmlRenderer<String> expanderRenderer = new AbstractSafeHtmlRenderer<String>() {

        @Override
        public SafeHtml render(String object) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            sb.appendHtmlConstant(object);
            return sb.toSafeHtml();
        }
    };
    objectExpandColumn_ = new Column<RObjectEntry, String>(new ClickableTextCell(expanderRenderer)) {

        @Override
        public String getValue(RObjectEntry object) {
            String imageUri = "";
            String imageStyle = style_.expandIcon();
            if (object.canExpand()) {
                imageStyle = imageStyle + " " + ThemeStyles.INSTANCE.handCursor();
                ImageResource expandImage = object.isExpanding ? CoreResources.INSTANCE.progress() : object.expanded ? new ImageResource2x(EnvironmentResources.INSTANCE.collapseIcon2x()) : new ImageResource2x(EnvironmentResources.INSTANCE.expandIcon2x());
                imageUri = expandImage.getSafeUri().asString();
            } else if (object.hasTraceInfo()) {
                imageUri = new ImageResource2x(EnvironmentResources.INSTANCE.tracedFunction2x()).getSafeUri().asString();
                imageStyle += (" " + style_.unclickableIcon());
            }
            if (imageUri.length() > 0) {
                return "<input type=\"image\" src=\"" + imageUri + "\" " + "class=\"" + imageStyle + "\" />";
            }
            return "";
        }
    };
    objectExpandColumn_.setFieldUpdater(new FieldUpdater<RObjectEntry, String>() {

        @Override
        public void update(int index, RObjectEntry object, String value) {
            if (!object.canExpand())
                return;
            expandObject(index, object);
        }
    });
}
Also used : AbstractSafeHtmlRenderer(com.google.gwt.text.shared.AbstractSafeHtmlRenderer) ImageResource(com.google.gwt.resources.client.ImageResource) ImageResource2x(org.rstudio.core.client.resources.ImageResource2x) JsArrayString(com.google.gwt.core.client.JsArrayString) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell)

Example 2 with ClickableTextCell

use of com.google.gwt.cell.client.ClickableTextCell in project perun by CESNET.

the class GetApplicationsForMember 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);
    // 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);
    if (groupId == 0) {
        loaderImage.setEmptyResultMessage("No member's applications found for this VO or it's groups.");
    } else {
        loaderImage.setEmptyResultMessage("No member's applications found for this group.");
    }
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("App ID", tableFieldUpdater, 85);
    // 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, "120px");
    // Type column
    Column<Application, String> typeColumn = new Column<Application, String>(new PerunAppTypeCell()) {

        @Override
        public String getValue(Application object) {
            return object.getType();
        }
    };
    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 ("NEW".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowgreen";
            } else if ("VERIFIED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowyellow";
            } else if ("APPROVED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowdarkgreen";
            } else if ("REJECTED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowred";
            } 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");
    Column<Application, String> extSourceColumn = 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) {
            if (object.getUser() != null) {
                return object.getUser().getFullNameWithTitles();
            }
            return Utils.convertCertCN(object.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(object.getExtSourceName()));
        }
    }, tableFieldUpdater);
    extSourceColumn.setSortable(true);
    columnSortHandler.setComparator(extSourceColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            String compare1 = "";
            String compare2 = "";
            if (arg0.getUser() != null) {
                compare1 = arg0.getUser().getFullName();
            } else {
                compare1 = Utils.convertCertCN(arg0.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(arg0.getExtSourceName()));
            }
            if (arg1.getUser() != null) {
                compare2 = arg1.getUser().getFullName();
            } else {
                compare2 = Utils.convertCertCN(arg1.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(arg1.getExtSourceName()));
            }
            return compare1.compareToIgnoreCase(compare2);
        }
    });
    table.addColumn(extSourceColumn, "Submitted by");
    Column<Application, String> loaColumn = JsonUtils.addColumn(new ClickableTextCell() {

        @Override
        public void render(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 String.valueOf(object.getExtSourceLoa());
        }
    }, tableFieldUpdater);
    loaColumn.setSortable(true);
    columnSortHandler.setComparator(loaColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return arg0.getExtSourceLoa() - arg1.getExtSourceLoa();
        }
    });
    table.addColumn(loaColumn, "LoA");
    table.setColumnWidth(loaColumn, "40px");
    // 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");
    Column<Application, String> modifiedColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            return Utils.convertCertCN(object.getModifiedBy());
        }
    }, tableFieldUpdater);
    table.addColumn(modifiedColumn, "Modified by");
    modifiedColumn.setSortable(true);
    columnSortHandler.setComparator(modifiedColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return Utils.convertCertCN(arg0.getModifiedBy()).compareTo(Utils.convertCertCN(arg1.getModifiedBy()));
        }
    });
    table.setRowStyles(new RowStyles<Application>() {

        public String getStyleNames(Application application, int i) {
            if (application.getType().equalsIgnoreCase("INITIAL")) {
                return "rowlightgreen";
            } else {
                return "rowlightyellow";
            }
        }
    });
    return table;
}
Also used : PerunAppTypeCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Column(com.google.gwt.user.cellview.client.Column) Application(cz.metacentrum.perun.webgui.model.Application) PerunAppTypeCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell) Cell(com.google.gwt.cell.client.Cell) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell)

Example 3 with ClickableTextCell

use of com.google.gwt.cell.client.ClickableTextCell in project perun by CESNET.

the class GetApplicationsForVo 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);
    // 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("No applications matching search criteria found for this VO or it's groups.");
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("App ID", tableFieldUpdater, 85);
    // 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, "120px");
    // Type column
    Column<Application, String> typeColumn = new Column<Application, String>(new PerunAppTypeCell()) {

        @Override
        public String getValue(Application object) {
            return object.getType();
        }
    };
    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 ("NEW".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowgreen";
            } else if ("VERIFIED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowyellow";
            } else if ("APPROVED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowdarkgreen";
            } else if ("REJECTED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowred";
            } 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");
    Column<Application, String> extSourceColumn = 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) {
            if (object.getUser() != null) {
                return object.getUser().getFullNameWithTitles();
            }
            return Utils.convertCertCN(object.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(object.getExtSourceName()));
        }
    }, tableFieldUpdater);
    extSourceColumn.setSortable(true);
    columnSortHandler.setComparator(extSourceColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            String compare1 = "";
            String compare2 = "";
            if (arg0.getUser() != null) {
                compare1 = arg0.getUser().getFullName();
            } else {
                compare1 = Utils.convertCertCN(arg0.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(arg0.getExtSourceName()));
            }
            if (arg1.getUser() != null) {
                compare2 = arg1.getUser().getFullName();
            } else {
                compare2 = Utils.convertCertCN(arg1.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(arg1.getExtSourceName()));
            }
            return compare1.compareToIgnoreCase(compare2);
        }
    });
    table.addColumn(extSourceColumn, "Submitted by");
    Column<Application, String> loaColumn = 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 String.valueOf(object.getExtSourceLoa());
        }
    }, tableFieldUpdater);
    loaColumn.setSortable(true);
    columnSortHandler.setComparator(loaColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return arg0.getExtSourceLoa() - arg1.getExtSourceLoa();
        }
    });
    table.addColumn(loaColumn, "LoA");
    table.setColumnWidth(loaColumn, "40px");
    // 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");
    Column<Application, String> modifiedColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            return Utils.convertCertCN(object.getModifiedBy());
        }
    }, tableFieldUpdater);
    table.addColumn(modifiedColumn, "Modified by");
    modifiedColumn.setSortable(true);
    columnSortHandler.setComparator(modifiedColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return Utils.convertCertCN(arg0.getModifiedBy()).compareTo(Utils.convertCertCN(arg1.getModifiedBy()));
        }
    });
    table.setRowStyles(new RowStyles<Application>() {

        public String getStyleNames(Application application, int i) {
            if (application.getType().equalsIgnoreCase("INITIAL")) {
                return "rowlightgreen";
            } else {
                return "rowlightyellow";
            }
        }
    });
    return table;
}
Also used : PerunAppTypeCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Column(com.google.gwt.user.cellview.client.Column) Application(cz.metacentrum.perun.webgui.model.Application) PerunAppTypeCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell) Cell(com.google.gwt.cell.client.Cell) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell)

Example 4 with ClickableTextCell

use of com.google.gwt.cell.client.ClickableTextCell in project perun by CESNET.

the class GetApplicationsForGroup 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);
    // 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("No applications matching search criteria found for this group.");
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("App ID", tableFieldUpdater, 85);
    // 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, "120px");
    // Type column
    Column<Application, String> typeColumn = new Column<Application, String>(new PerunAppTypeCell()) {

        @Override
        public String getValue(Application object) {
            return object.getType();
        }
    };
    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 ("NEW".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowgreen";
            } else if ("VERIFIED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowyellow";
            } else if ("APPROVED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowdarkgreen";
            } else if ("REJECTED".equalsIgnoreCase(object.getState())) {
                return super.getCellStyleNames(context, object) + " rowred";
            } 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");
    Column<Application, String> extSourceColumn = 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) {
            if (object.getUser() != null) {
                return object.getUser().getFullNameWithTitles();
            }
            return Utils.convertCertCN(object.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(object.getExtSourceName()));
        }
    }, tableFieldUpdater);
    extSourceColumn.setSortable(true);
    columnSortHandler.setComparator(extSourceColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            String compare1 = "";
            String compare2 = "";
            if (arg0.getUser() != null) {
                compare1 = arg0.getUser().getFullName();
            } else {
                compare1 = Utils.convertCertCN(arg0.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(arg0.getExtSourceName()));
            }
            if (arg1.getUser() != null) {
                compare2 = arg1.getUser().getFullName();
            } else {
                compare2 = Utils.convertCertCN(arg1.getCreatedBy()) + " / " + Utils.translateIdp(Utils.convertCertCN(arg1.getExtSourceName()));
            }
            return compare1.compareToIgnoreCase(compare2);
        }
    });
    table.addColumn(extSourceColumn, "Submitted by");
    Column<Application, String> loaColumn = 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 String.valueOf(object.getExtSourceLoa());
        }
    }, tableFieldUpdater);
    loaColumn.setSortable(true);
    columnSortHandler.setComparator(loaColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return arg0.getExtSourceLoa() - arg1.getExtSourceLoa();
        }
    });
    table.addColumn(loaColumn, "LoA");
    table.setColumnWidth(loaColumn, "40px");
    Column<Application, String> modifiedColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Application, String>() {

        public String getValue(Application object) {
            return Utils.convertCertCN(object.getModifiedBy());
        }
    }, tableFieldUpdater);
    table.addColumn(modifiedColumn, "Modified by");
    modifiedColumn.setSortable(true);
    columnSortHandler.setComparator(modifiedColumn, new Comparator<Application>() {

        public int compare(Application arg0, Application arg1) {
            return Utils.convertCertCN(arg0.getModifiedBy()).compareTo(Utils.convertCertCN(arg1.getModifiedBy()));
        }
    });
    table.setRowStyles(new RowStyles<Application>() {

        public String getStyleNames(Application application, int i) {
            if (application.getType().equalsIgnoreCase("INITIAL")) {
                return "rowlightgreen";
            } else {
                return "rowlightyellow";
            }
        }
    });
    return table;
}
Also used : PerunAppTypeCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) Column(com.google.gwt.user.cellview.client.Column) Application(cz.metacentrum.perun.webgui.model.Application) PerunAppTypeCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell) Cell(com.google.gwt.cell.client.Cell) CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) ClickableTextCell(com.google.gwt.cell.client.ClickableTextCell)

Aggregations

ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)4 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)4 Cell (com.google.gwt.cell.client.Cell)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)3 Column (com.google.gwt.user.cellview.client.Column)3 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)3 Application (cz.metacentrum.perun.webgui.model.Application)3 CustomClickableTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)3 PerunAppTypeCell (cz.metacentrum.perun.webgui.widgets.cells.PerunAppTypeCell)3 JsArrayString (com.google.gwt.core.client.JsArrayString)1 ImageResource (com.google.gwt.resources.client.ImageResource)1 AbstractSafeHtmlRenderer (com.google.gwt.text.shared.AbstractSafeHtmlRenderer)1 ImageResource2x (org.rstudio.core.client.resources.ImageResource2x)1