use of cz.metacentrum.perun.webgui.widgets.cells.WhetherEnabledCell 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;
}
Aggregations