FixedSummaryRowLayer [message #1715334] |
Sun, 22 November 2015 06:33  |
Eclipse User |
|
|
|
Hello,
I would need some directions on how to set the FixedSummaryRowLayer, and hints on how the correct order of the layers should be.
I have the following body layer stack:
bodyDataLayer = new DataLayer(rowDataProvider); // rowDataProvider - custom created row provider
final HoverLayer hoverLayer = new HoverLayer(bodyDataLayer);
selectionLayer = new SelectionLayer(hoverLayer);
selectionProvider = new RowSelectionProvider<NatTreeNode>(selectionLayer, rowDataProvider, false);
treeLayer = new TreeLayer(selectionLayer, new TreeRowModel<NatTreeNode>(rowDataProvider));
setUnderlyingLayer(new ViewportLayer(treeLayer));
and i would like to know where exactly should the FixedSummaryRowLayer be created. I tried multiple times, took in consideration the fact that it must be created as closer to the data layer as it can get, before any other layers that are able to transform indexes and positions are added. I even tried creating a separate data layer as suggested in another post on this forum, but no luck. Please let me know what would be the best solution.
Thank you very much!
|
|
|
|
|
|
|
Re: FixedSummaryRowLayer [message #1724999 is a reply to message #1723997] |
Sun, 28 February 2016 23:24   |
Eclipse User |
|
|
|
Dirk Fauth wrote on Fri, 19 February 2016 15:13This is not supported
Hi Dirk. What may be implementation?
Is it possible to fix the ViewportLayer?
Implemented something:
public class MyViewportLayer extends ViewportLayer {
private NatTable natTable;
private GridLayer gridLayer;
private FixedSummaryRowLayer summaryRowLayer;
public MyViewportLayer(IUniqueIndexLayer underlyingLayer) {
super(underlyingLayer);
}
@Override
public int getHeight() {
return natTable.getClientArea().height - summaryRowLayer.getHeight() -
gridLayer.getColumnHeaderLayer().getHeight();
}
@Override
public int getRowPositionByY(int y) {
return getRowPositionByY(this, y);
}
private int getRowPositionByY(ILayer layer, int y) {
int height = super.getHeight();
if (y < 0) {
return -1;
}else if (y>=height){
return findRowPosition(0, 0, layer, y, height, super.getRowCount());
}
return findRowPosition(0, 0, layer, y, height, layer.getRowCount());
}
private int findRowPosition(
int yOffset, int rowOffset, ILayer layer, int y, int totalHeight, int rowCount) {
double size = (double) (totalHeight - yOffset) / (rowCount - rowOffset);
int rowPosition = rowOffset + (int) ((y - yOffset) / size);
int startY = layer.getStartYOfRowPosition(rowPosition);
int endY = startY + layer.getRowHeightByPosition(rowPosition);
if (y < startY) {
if (startY == totalHeight) {
return rowCount;
}
return findRowPosition(yOffset, rowOffset, layer, y, startY, rowPosition);
}
else if (y >= endY) {
return findRowPosition(endY, rowPosition + 1, layer, y, totalHeight, rowCount);
}
else {
return rowPosition;
}
}
public NatTable getNatTable() {
return natTable;
}
public void setNatTable(NatTable natTable) {
this.natTable = natTable;
}
public GridLayer getGridLayer() {
return gridLayer;
}
public void setGridLayer(GridLayer gridLayer) {
this.gridLayer = gridLayer;
}
public FixedSummaryRowLayer getSummaryRowLayer() {
return summaryRowLayer;
}
public void setSummaryRowLayer(FixedSummaryRowLayer summaryRowLayer) {
this.summaryRowLayer = summaryRowLayer;
}
}
[Updated on: Wed, 02 March 2016 23:51] by Moderator
|
|
|
Re: FixedSummaryRowLayer [message #1725381 is a reply to message #1724999] |
Thu, 03 March 2016 02:50  |
Eclipse User |
|
|
|
Might work but it is a dirty hack. You probably get serious issues regarding interactions.
As I said, this is not supported in NatTable because there is nothing that increases one layer in a composition to some maximum. The only thing that might work is to create two NatTable instances, one for the content and one for the summary row, connect the two viewports for scrolling and layout using a SWT layout manager.
|
|
|
Powered by
FUDForum. Page generated in 0.20097 seconds