// Usually you would create a new layer stack by extending
// AbstractIndexLayerTransform and
// setting the ViewportLayer as underlying layer. But in this case using
// the ViewportLayer
// directly as body layer is also working.
IDataProvider bodyDataProvider = new ListDataProvider<ExtendedPersonWithAddress>(
PersonService.getExtendedPersonsWithAddress(10),
columnPropertyAccessor);
DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(
bodyDataLayer);
ColumnGroupReorderLayer columnGroupReorderLayer = new ColumnGroupReorderLayer(
columnReorderLayer, columnGroupModel);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(
columnGroupReorderLayer);
ColumnGroupExpandCollapseLayer columnGroupExpandCollapseLayer = new ColumnGroupExpandCollapseLayer(
columnHideShowLayer, sndColumnGroupModel, columnGroupModel);
SelectionLayer selectionLayer = new SelectionLayer(
columnGroupExpandCollapseLayer);
ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
// build the column header layer
IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(
propertyNames, propertyToLabelMap);
DataLayer columnHeaderDataLayer = new DefaultColumnHeaderDataLayer(
columnHeaderDataProvider);
ILayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer,
viewportLayer, selectionLayer);
ColumnGroupHeaderLayer columnGroupHeaderLayer = new ColumnGroupHeaderLayer(
columnHeaderLayer, selectionLayer, columnGroupModel);
// configure the column groups
columnGroupHeaderLayer.addColumnsIndexesToGroup("Person", 0, 1, 2, 3);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Address", 4, 5, 6, 7);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Facts", 8, 9, 10);
columnGroupHeaderLayer.addColumnsIndexesToGroup("Personal", 11, 12, 13);
columnGroupHeaderLayer.setStaticColumnIndexesByGroup("Person", 0, 1);
columnGroupHeaderLayer
.setStaticColumnIndexesByGroup("Address", 4, 5, 6);
columnGroupHeaderLayer.setGroupUnbreakable(1);
ColumnGroupGroupHeaderLayer sndGroup = new ColumnGroupGroupHeaderLayer(
columnGroupHeaderLayer, selectionLayer, sndColumnGroupModel);
sndGroup.addColumnsIndexesToGroup("PersonWithAddress", 0, 1, 2, 3, 4,
5, 6, 7);
sndGroup.addColumnsIndexesToGroup("Additional Information", 8, 9, 10,
11, 12, 13);
sndGroup.setStaticColumnIndexesByGroup("PersonWithAddress", 0, 1);
// build the row header layer
IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(
bodyDataProvider);
DataLayer rowHeaderDataLayer = new DefaultRowHeaderDataLayer(
rowHeaderDataProvider);
ILayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer,
viewportLayer, selectionLayer);
// build the corner layer
IDataProvider cornerDataProvider = new DefaultCornerDataProvider(
columnHeaderDataProvider, rowHeaderDataProvider);
DataLayer cornerDataLayer = new DataLayer(cornerDataProvider);
ILayer cornerLayer = new CornerLayer(cornerDataLayer, rowHeaderLayer,
sndGroup);