Problem using SortColumnCommand on a table with a CompositeFreezeLayer [message #1790958] |
Wed, 20 June 2018 15:31 |
Tom Wheeler Messages: 17 Registered: June 2018 |
Junior Member |
|
|
Hello,
I have configured a body layer stack with a CompositeFreezeLayer on top. The table have 6 columns. Using NatTable 1.5.0.
My ColumnHeaderLayer looks like this:
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer(columnHeaderDataLayer, aBodyLayerStack.getCompositeFreezeLayer(), aBodyLayerStack.getSelectionLayer(), false);
And here is my SortHeaderLayer:
aSortHeaderLayer = new SortHeaderLayer<TABLEENTRY>(columnHeaderLayer, new GlazedListsSortModel<TABLEENTRY>(aBodyLayerStack.getSortedList(), columnAccessor, columnPropertyResolverImpl, configRegistry, columnHeaderDataLayer));
When initializing the table, I would like to:
- have no columns frozen.
- have column #1 sorted.
After doing aNatTable.configure(), I issue this command:
aNatTable.doCommand(new SortColumnCommand(aSortHeaderLayer, 1, SortDirectionEnum.ASC));
Whenever no columns are frozen or the sort column index is greater than the index of the frozen column, I get this exception when issuing the SortColumnCommand:
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:418)
at java.util.ArrayList.get(ArrayList.java:431)
at ca.odell.glazedlists.gui.AbstractTableComparatorChooser.getComparatorsForColumn(AbstractTableComparatorChooser.java:178)
at org.eclipse.nebula.widgets.nattable.extension.glazedlists.NatTableComparatorChooser.sort(NatTableComparatorChooser.java:36)
at org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel.sort(GlazedListsSortModel.java:114)
at org.eclipse.nebula.widgets.nattable.sort.command.SortCommandHandler$1.run(SortCommandHandler.java:50)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.nebula.widgets.nattable.sort.command.SortCommandHandler.doCommand(SortCommandHandler.java:53)
at org.eclipse.nebula.widgets.nattable.sort.command.SortCommandHandler.doCommand(SortCommandHandler.java:1)
at org.eclipse.nebula.widgets.nattable.command.AbstractLayerCommandHandler.doCommand(AbstractLayerCommandHandler.java:21)
at org.eclipse.nebula.widgets.nattable.layer.AbstractLayer.doCommand(AbstractLayer.java:186)
at org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform.doCommand(AbstractLayerTransform.java:101)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.doCommandOnChildLayers(CompositeLayer.java:159)
at org.eclipse.nebula.widgets.nattable.layer.CompositeLayer.doCommand(CompositeLayer.java:151)
at org.eclipse.nebula.widgets.nattable.NatTable.doCommand(NatTable.java:820)
The '-1' is obtained from this line in the SortCommandHandler.doCommand():
final int columnIndex = command.getLayer().getColumnIndexByPosition(command.getColumnPosition());
- and afterwards '-1' is passed further down, eventually resulting in the above exception.
The ColumnHeaderLayer is a DimensionallyDependentLayer.
From DimensionallyDependentLayer.getColumnIndexByPosition(1), I can see that horizontalLayerDependency is-a CompositeFreezeLayer
So the call horizontalLayerDependency.getColumnIndexByPosition(1) returns '-1':
public int getColumnIndexByPosition(int columnPosition) {
return this.horizontalLayerDependency.getColumnIndexByPosition(columnPosition);
}
I have tried a few times single-stepping down the call horizontalLayerDependency.getColumnIndexByPosition(columnPosition), but I get lost in the transformation algorithms...
If I freeze column #1 or higher index before issuing the SortColumnCommand on column #1, everything seems to work fine:
aNatTable.doCommand(new FreezeColumnCommand(aBodyLayerStack.getCompositeFreezeLayer(), 1));
If I use another layer argument for the SortColumnCommand, like columnHeaderDataLayer or columnHeaderLayer, I get not effect at all, ie. no exception and no sorting.
Does anybody know how to make this work?
Thanks,
Tom
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03042 seconds