use of cz.metacentrum.perun.webgui.widgets.cells.CustomTextCell in project perun by CESNET.
the class GetAuditMessagesByCount method getTable.
public CellTable<AuditMessage> getTable() {
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<AuditMessage>(list);
// Cell table
table = new PerunTable<AuditMessage>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<AuditMessage> columnSortHandler = new ListHandler<AuditMessage>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<AuditMessage>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("No audit messages found.");
if (checkable) {
// checkbox column column
table.addCheckBoxColumn();
}
table.addIdColumn("Message ID", null, 120);
// Event name column
Column<AuditMessage, String> eventNameColumn = JsonUtils.addColumn(new CustomTextCell(), this::getAuditEventName, null);
eventNameColumn.setSortable(true);
columnSortHandler.setComparator(eventNameColumn, (o1, o2) -> (getAuditEventName(o1)).compareToIgnoreCase(getAuditEventName(o2)));
// Event objects column
Column<AuditMessage, String> objectsColumn = JsonUtils.addColumn(new CustomTextCell(), AuditMessage::getAuditEventObjectsMessage, null);
eventNameColumn.setSortable(true);
columnSortHandler.setComparator(eventNameColumn, (o1, o2) -> (o1.getAuditEventObjectsMessage()).compareToIgnoreCase(o2.getAuditEventObjectsMessage()));
// Actor column
Column<AuditMessage, String> actorColumn = JsonUtils.addColumn(new CustomTextCell(), AuditMessage::getActor, null);
eventNameColumn.setSortable(true);
columnSortHandler.setComparator(eventNameColumn, (o1, o2) -> (o1.getActor()).compareToIgnoreCase(o2.getActor()));
// TIME COLUMN
TextColumn<AuditMessage> timeColumn = new TextColumn<AuditMessage>() {
public String getValue(AuditMessage msg) {
if (msg.getCreatedAt().contains(".")) {
return msg.getCreatedAt().substring(0, msg.getCreatedAt().indexOf("."));
} else {
// oracle timestamp doesn't have ending ".12345" in "2020-01-01 12:00:00.12345"
return msg.getCreatedAt();
}
}
};
timeColumn.setSortable(true);
columnSortHandler.setComparator(timeColumn, new Comparator<AuditMessage>() {
public int compare(AuditMessage o1, AuditMessage o2) {
return o1.getCreatedAt().compareToIgnoreCase(o2.getCreatedAt());
}
});
table.addColumn(timeColumn, "Created at");
table.setColumnWidth(timeColumn, "180px");
table.addColumn(eventNameColumn, "Event name");
table.setColumnWidth(eventNameColumn, "250px");
table.addColumn(actorColumn, "Actor");
table.setColumnWidth(actorColumn, "150px");
table.addColumn(objectsColumn, "Related objects");
return table;
}
use of cz.metacentrum.perun.webgui.widgets.cells.CustomTextCell in project perun by CESNET.
the class GetAuditMessages method getTable.
public CellTable<AuditMessage> getTable() {
retrieveData();
// Table data provider.
dataProvider = new ListDataProvider<AuditMessage>(list);
// Cell table
table = new PerunTable<AuditMessage>(list);
// Connect the table to the data provider.
dataProvider.addDataDisplay(table);
// Sorting
ListHandler<AuditMessage> columnSortHandler = new ListHandler<AuditMessage>(dataProvider.getList());
table.addColumnSortHandler(columnSortHandler);
// table selection
table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<AuditMessage>createCheckboxManager());
// set empty content & loader
table.setEmptyTableWidget(loaderImage);
loaderImage.setEmptyResultMessage("No audit messages found.");
if (checkable) {
// checkbox column column
table.addCheckBoxColumn();
}
table.addIdColumn("Message ID", null, 120);
// MESSAGE COLUMN
Column<AuditMessage, String> messageColumn = JsonUtils.addColumn(new CustomTextCell(), new JsonUtils.GetValue<AuditMessage, String>() {
public String getValue(AuditMessage msg) {
return msg.getActor() + ": " + msg.getMessage();
}
}, null);
messageColumn.setSortable(true);
columnSortHandler.setComparator(messageColumn, new Comparator<AuditMessage>() {
public int compare(AuditMessage o1, AuditMessage o2) {
return (o1.getActor() + ": " + o1.getMessage()).compareToIgnoreCase(o2.getActor() + ": " + o2.getMessage());
}
});
// TIME COLUMN
TextColumn<AuditMessage> timeColumn = new TextColumn<AuditMessage>() {
public String getValue(AuditMessage msg) {
return msg.getCreatedAt().substring(0, msg.getCreatedAt().indexOf("."));
}
};
timeColumn.setSortable(true);
columnSortHandler.setComparator(timeColumn, new Comparator<AuditMessage>() {
public int compare(AuditMessage o1, AuditMessage o2) {
return o1.getCreatedAt().compareToIgnoreCase(o2.getCreatedAt());
}
});
table.addColumn(timeColumn, "Created at");
table.setColumnWidth(timeColumn, "180px");
table.addColumn(messageColumn, "Message");
return table;
}
Aggregations