public Object getKey(ModelNode item) {
return item.get(FILE_NAME);
}
};
selectionModel = new SingleSelectionModel<>(providesKey);
ModelNodeCellTable table = new ModelNodeCellTable(10, providesKey);
table.setSelectionModel(selectionModel);
dataProvider = new ListDataProvider<>(providesKey);
dataProvider.addDataDisplay(table);
// TODO Somehow sorting does not work
sortHandler = new ColumnSortEvent.ListHandler<ModelNode>(dataProvider.getList());
table.addColumnSortHandler(sortHandler);
panel.add(table);
DefaultPager pager = new DefaultPager();
pager.setDisplay(table);
panel.add(pager);
// column: name
TextColumn<ModelNode> nameColumn = new TextColumn<ModelNode>() {
@Override
public String getValue(ModelNode node) {
return node.get(FILE_NAME).asString();
}
};
nameColumn.setSortable(true);
sortHandler.setComparator(nameColumn, new Comparator<ModelNode>() {
@Override
public int compare(ModelNode node1, ModelNode node2) {
return node1.get(FILE_NAME).asString().compareTo(node2.get(FILE_NAME).asString());
}
});
table.addColumn(nameColumn, "Log File Name");
// column: last modified
TextColumn<ModelNode> lastModifiedColumn = new TextColumn<ModelNode>() {
@Override
public String getValue(ModelNode node) {
return node.get(LAST_MODIFIED_DATE).asString();
}
};
lastModifiedColumn.setSortable(true);
sortHandler.setComparator(lastModifiedColumn, new Comparator<ModelNode>() {
@Override
public int compare(ModelNode node1, ModelNode node2) {
return node1.get(LAST_MODIFIED_DATE).asString().compareTo(node2.get(LAST_MODIFIED_DATE).asString());
}
});
table.addColumn(lastModifiedColumn, "Date - Time (UTC)");
// column: size
TextColumn<ModelNode> sizeColumn = new TextColumn<ModelNode>() {
@Override
public String getValue(ModelNode node) {
double size = node.get(LogStore.FILE_SIZE).asLong() / 1024.0;
return SIZE_FORMAT.format(size);
}
};
sizeColumn.setSortable(true);
sortHandler.setComparator(sizeColumn, new Comparator<ModelNode>() {
@Override
public int compare(ModelNode node1, ModelNode node2) {
return node1.get(FILE_SIZE).asInt() - node2.get(FILE_SIZE).asInt();
}
});
table.addColumn(sizeColumn, "Size (MB)");
ScrollPanel scroll = new ScrollPanel(panel);
LayoutPanel layout = new LayoutPanel();
layout.add(scroll);
layout.setWidgetTopHeight(scroll, 0, PX, 100, Style.Unit.PCT);