Search in sources :

Example 31 with Column

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

the class GetApplicationsForUserForAppFormGui 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);
    // 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, ApplicationMessages.INSTANCE.createdDate());
    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, ApplicationMessages.INSTANCE.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, ApplicationMessages.INSTANCE.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, ApplicationMessages.INSTANCE.virtualOrganization());
    // 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, ApplicationMessages.INSTANCE.group());
    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 32 with Column

use of com.google.gwt.user.cellview.client.Column 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 33 with Column

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

the class GetApplicationMails method getTable.

/**
	 * Returns just the celltable
	 * @return
	 */
public CellTable<ApplicationMail> getTable() {
    // retrieve data
    retrieveData();
    // Table data provider.
    dataProvider = new ListDataProvider<ApplicationMail>(list);
    // Cell table
    table = new PerunTable<ApplicationMail>(list);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<ApplicationMail> columnSortHandler = new ListHandler<ApplicationMail>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<ApplicationMail>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity)) {
        loaderImage.setEmptyResultMessage("No mail notifications found for this VO.");
    } else if (PerunEntity.GROUP.equals(entity)) {
        loaderImage.setEmptyResultMessage("No mail notifications found for this group.");
    }
    // columns
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("E-mail ID", tableFieldUpdater, 90);
    // MAIL TYPE COLUMN
    Column<ApplicationMail, String> mailTypeColumn = JsonUtils.addColumn(new JsonUtils.GetValue<ApplicationMail, String>() {

        public String getValue(ApplicationMail object) {
            return ApplicationMail.getTranslatedMailType(object.getMailType());
        }
    }, tableFieldUpdater);
    mailTypeColumn.setSortable(true);
    columnSortHandler.setComparator(mailTypeColumn, new Comparator<ApplicationMail>() {

        public int compare(ApplicationMail arg0, ApplicationMail arg1) {
            return (ApplicationMail.getTranslatedMailType(arg0.getMailType())).compareToIgnoreCase(ApplicationMail.getTranslatedMailType(arg1.getMailType()));
        }
    });
    table.addColumn(mailTypeColumn, "E-mail type");
    // APPLICATION TYPE COLUMN
    Column<ApplicationMail, String> appTypeColumn = JsonUtils.addColumn(new JsonUtils.GetValue<ApplicationMail, String>() {

        public String getValue(ApplicationMail object) {
            return Application.getTranslatedType(object.getAppType());
        }
    }, tableFieldUpdater);
    appTypeColumn.setSortable(true);
    columnSortHandler.setComparator(appTypeColumn, new Comparator<ApplicationMail>() {

        public int compare(ApplicationMail arg0, ApplicationMail arg1) {
            return (Application.getTranslatedType(arg0.getAppType())).compareToIgnoreCase(Application.getTranslatedType(arg1.getAppType()));
        }
    });
    table.addColumn(appTypeColumn, "Application type");
    // ENABLED COLUMN
    Column<ApplicationMail, Boolean> enabledColumn = new Column<ApplicationMail, Boolean>(new WhetherEnabledCell()) {

        @Override
        public Boolean getValue(ApplicationMail object) {
            return object.isSend();
        }
    };
    enabledColumn.setSortable(true);
    columnSortHandler.setComparator(enabledColumn, new Comparator<ApplicationMail>() {

        public int compare(ApplicationMail arg0, ApplicationMail arg1) {
            if (arg0.isSend() == arg1.isSend())
                return 0;
            if (arg0.isSend() == true)
                return -1;
            return 1;
        }
    });
    table.addColumn(enabledColumn, "Sending enabled");
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) WhetherEnabledCell(cz.metacentrum.perun.webgui.widgets.cells.WhetherEnabledCell) Column(com.google.gwt.user.cellview.client.Column) ApplicationMail(cz.metacentrum.perun.webgui.model.ApplicationMail)

Example 34 with Column

use of com.google.gwt.user.cellview.client.Column 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)

Example 35 with Column

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

the class FindCompleteRichMembers method getEmptyTable.

/**
	 * Returns table with RichMembers
	 *
	 * @return CellTable widget
	 */
public CellTable<RichMember> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<RichMember>(list);
    // Cell table
    table = new PerunTable<RichMember>(list);
    table.setHyperlinksAllowed(false);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<RichMember> columnSortHandler = new ListHandler<RichMember>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RichMember>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No member found.");
    Column<RichMember, RichMember> checkBoxColumn = new Column<RichMember, RichMember>(new PerunCheckboxCell<RichMember>(true, false, indirectCheckable)) {

        @Override
        public RichMember getValue(RichMember object) {
            // Get the value from the selection model.
            object.setChecked(selectionModel.isSelected(object));
            return object;
        }
    };
    // 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 (RichMember obj : list) {
                if (!"INDIRECT".equalsIgnoreCase(obj.getMembershipType())) {
                    selectionModel.setSelected(obj, value);
                }
            }
        }
    });
    if (checkable) {
        table.addColumn(checkBoxColumn, checkBoxHeader);
    }
    MemberColumnProvider columnProvider = new MemberColumnProvider(dataProvider, null, table, tableFieldUpdater);
    IsClickableCell<RichMember> authz = new IsClickableCell<RichMember>() {

        @Override
        public boolean isClickable(RichMember object) {
            return true;
        }

        @Override
        public String linkUrl(RichMember object) {
            return null;
        }
    };
    columnProvider.addIdColumn(authz, 110);
    columnProvider.addUserIdColumn(authz, 110);
    columnProvider.addStatusColumn(authz, 20);
    columnProvider.addNameColumn(authz);
    columnProvider.addOrganizationColumn(authz);
    columnProvider.addEmailColumn(authz);
    columnProvider.addLoginsColumn(authz);
    return table;
}
Also used : ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) MemberColumnProvider(cz.metacentrum.perun.webgui.json.columnProviders.MemberColumnProvider) RichMember(cz.metacentrum.perun.webgui.model.RichMember) Header(com.google.gwt.user.cellview.client.Header) Column(com.google.gwt.user.cellview.client.Column) IsClickableCell(cz.metacentrum.perun.webgui.json.columnProviders.IsClickableCell) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) PerunCheckboxCell(cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)

Aggregations

Column (com.google.gwt.user.cellview.client.Column)56 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)28 CheckboxCell (com.google.gwt.cell.client.CheckboxCell)18 Header (com.google.gwt.user.cellview.client.Header)15 PerunCheckboxCell (cz.metacentrum.perun.webgui.widgets.cells.PerunCheckboxCell)14 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 GeneralObject (cz.metacentrum.perun.webgui.model.GeneralObject)10 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)9 TextColumn (com.google.gwt.user.cellview.client.TextColumn)9 TextCell (com.google.gwt.cell.client.TextCell)8 CustomClickableTextCell (cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell)8 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)7 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)6 Attribute (cz.metacentrum.perun.webgui.model.Attribute)6 Group (cz.metacentrum.perun.webgui.model.Group)6 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)6 ImageResource (com.google.gwt.resources.client.ImageResource)5