propertyNames);
// Column header layer
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
propertyNames);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(
columnHeaderDataProvider);
ISortModel sortModel = new GlazedListsSortModel<Datum>(sortedList,
columnPropertyAccessor, configRegistry, columnHeaderDataLayer);
final TreeList<Datum> treeList = new TreeList<Datum>(sortedList,
new DatumTreeFormat(sortModel), new DatumExpansionModel());
GlazedListTreeData<Datum> treeData = new DatumTreeData(treeList);
GlazedListsDataProvider<Datum> bodyDataProvider = new GlazedListsDataProvider<Datum>(
treeList, columnPropertyAccessor);
final DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
// Handle update of CheckBoxField objects in column 0
bodyDataLayer.registerCommandHandler(new UpdateDataCommandHandler(
bodyDataLayer) {
@Override
protected boolean doCommand(UpdateDataCommand command) {
int columnPosition = command.getColumnPosition();
int rowPosition = command.getRowPosition();
if (columnPosition == 0) {
Datum datum = (Datum) bodyDataLayer.getDataProvider()
.getDataValue(columnPosition, rowPosition);
datum.setOn((Boolean) command.getNewValue());
bodyDataLayer.fireLayerEvent(new CellVisualChangeEvent(
bodyDataLayer, columnPosition, rowPosition));
return true;
} else {
return super.doCommand(command);
}
}
});
// Body layer
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(
bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(
columnReorderLayer);
SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
// Switch the ITreeRowModel implementation between using native grid
// Hide/Show or GlazedList TreeList Hide/Show
// TreeLayer treeLayer = new TreeLayer(selectionLayer, new
// TreeRowModel<Datum>(treeData), true);
final TreeLayer treeLayer = new TreeLayer(selectionLayer,
new GlazedListTreeRowModel<Datum>(treeData));
ViewportLayer viewportLayer = new ViewportLayer(treeLayer);
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(
columnHeaderDataLayer, viewportLayer, selectionLayer);
// Note: The column header layer is wrapped in a filter row composite.
// This plugs in the filter row functionality
ColumnOverrideLabelAccumulator labelAccumulator = new ColumnOverrideLabelAccumulator(
columnHeaderDataLayer);
columnHeaderDataLayer.setConfigLabelAccumulator(labelAccumulator);
// Register labels
SortHeaderLayer<Datum> sortHeaderLayer = new SortHeaderLayer<Datum>(
columnHeaderLayer, sortModel, false);
// Row header layer
DefaultRowHeaderDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
bodyDataProvider);
DefaultRowHeaderDataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(
rowHeaderDataProvider);
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer,
viewportLayer, selectionLayer);
// Corner layer
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(
columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
// CornerLayer cornerLayer = new CornerLayer(cornerDataLayer,
// rowHeaderLayer, columnHeaderLayer);
CornerLayer cornerLayer = new CornerLayer(cornerDataLayer,
rowHeaderLayer, sortHeaderLayer);