I am trying examples from here
I commented rowHeaderLayer, ColumnHeaderLayer, CornerLayer, GridLayer and directly set viewPortLayer to nattable. Tree shows up but I am not able to expand and collapse the tree though I have rowHideShowLayer.
Here is code snippet :
EventList<Datum> eventList = GlazedLists.eventList(datums.values());
SortedList<Datum> sortedList = new SortedList<Datum>(eventList, null);
String[] propertyNames = new String[] { "self", "bar" };
IColumnPropertyAccessor<Datum> columnPropertyAccessor = new ReflectiveColumnPropertyAccessor<Datum>(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);
// Body layer
ColumnReorderLayer columnReorderLayer = new ColumnReorderLayer(bodyDataLayer);
ColumnHideShowLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
SelectionLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(selectionLayer);
final TreeLayer treeLayer = new TreeLayer(rowHideShowLayer, new GlazedListTreeRowModel<Datum>(treeData));
ViewportLayer viewportLayer = new ViewportLayer(treeLayer);
NatTable natTable = new NatTable(parent, viewportLayer, false);`
答案 0 :(得分:0)
Phew,我们的代码可以找到的地方真的很奇怪......
我不会考虑googlesource,而是在Eclipse基础架构中托管我们的源代码,而IIRC则在GitHub上复制源代码。所以更好的例子是
关于您的问题,您不需要RowHideShowLayer,我建议将其删除。由于不使用网格组合,因此需要将必要的区域标签设置为ViewportLayer以启用已配置的UI绑定。因此,您需要在创建ViewportLayer
之后添加以下代码行viewportLayer.setRegionName(GridRegion.BODY);