use of org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer in project nebula.widgets.nattable by eclipse.
the class RowHideShowLayerTest2 method shouldFireTheCorrectEventOnRowHide.
@Test
public void shouldFireTheCorrectEventOnRowHide() throws Exception {
NatTable natTable = new NatTableFixture(new Shell(), new DummyGridLayerStack() {
@Override
protected void init(IUniqueIndexLayer bodyDataLayer, IUniqueIndexLayer columnHeaderDataLayer, IUniqueIndexLayer rowHeaderDataLayer, IUniqueIndexLayer cornerDataLayer) {
RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(bodyDataLayer);
super.init(rowHideShowLayer, columnHeaderDataLayer, rowHeaderDataLayer, cornerDataLayer);
}
});
LayerListenerFixture listener = new LayerListenerFixture();
natTable.addLayerListener(listener);
// Grid coordinates
natTable.doCommand(new RowHideCommand(natTable, 5));
assertEquals(1, listener.getReceivedEvents().size());
HideRowPositionsEvent hideEvent = (HideRowPositionsEvent) listener.getReceivedEvents().get(0);
Range range = hideEvent.getRowPositionRanges().iterator().next();
assertEquals(5, range.start);
assertEquals(6, range.end);
// The range Before hide: 5 -> 6
// The range After hide: 5 -> 5 (row is not there anymore)
StructuralDiff rowDiff = hideEvent.getRowDiffs().iterator().next();
assertEquals(5, rowDiff.getBeforePositionRange().start);
assertEquals(6, rowDiff.getBeforePositionRange().end);
assertEquals(5, rowDiff.getAfterPositionRange().start);
assertEquals(5, rowDiff.getAfterPositionRange().end);
}
use of org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer in project nebula.widgets.nattable by eclipse.
the class RowHideShowLayerTest2 method scrollAndHideTheLastRow.
/**
* Integration test
*/
@Test
public void scrollAndHideTheLastRow() throws Exception {
// Total rows in fixture - 20 (index 0 - 19)
NatTableFixture natTable = new NatTableFixture(new Shell(), new DummyGridLayerStack() {
@Override
protected void init(IUniqueIndexLayer bodyDataLayer, IUniqueIndexLayer columnHeaderDataLayer, IUniqueIndexLayer rowHeaderDataLayer, IUniqueIndexLayer cornerDataLayer) {
RowHideShowLayer rowHideShowLayer = new RowHideShowLayer(bodyDataLayer);
super.init(rowHideShowLayer, columnHeaderDataLayer, rowHeaderDataLayer, cornerDataLayer);
}
}, 600, 120);
LayerListenerFixture natTableListener = new LayerListenerFixture();
natTable.addLayerListener(natTableListener);
// Scroll to position 15 in grid/15 in body
natTable.scrollToRow(15);
assertEquals(15, natTable.getRowIndexByPosition(1));
// Hide last row - position 5/index 19
assertEquals(19, natTable.getRowIndexByPosition(5));
natTable.doCommand(new RowHideCommand(natTable, 5));
// Assert event received
assertNotNull(natTableListener.getReceivedEvent(HideRowPositionsEvent.class));
HideRowPositionsEvent hideEvent = (HideRowPositionsEvent) natTableListener.getReceivedEvent(HideRowPositionsEvent.class);
// When last row is hidden it is not carrying the following info
assertEquals(1, hideEvent.getRowPositionRanges().size());
// View port adjusted origin to move an extra row in
Range hiddenRange = hideEvent.getRowPositionRanges().iterator().next();
assertEquals(6, hiddenRange.start);
assertEquals(7, hiddenRange.end);
}
use of org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer in project nebula.widgets.nattable by eclipse.
the class SummaryRowIntegrationTest method initLayerStackWithSummaryRow.
@Before
public void initLayerStackWithSummaryRow() {
this.dataList = RowDataListFixture.getList().subList(0, 4);
// Rows 0, 1, 2, 3; Summary row would be position 4
assertEquals(4, this.dataList.size());
this.dataProvider = new ListDataProvider<RowDataFixture>(this.dataList, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
IConfigRegistry configRegistry = new ConfigRegistry();
this.dataLayer = new DataLayer(this.dataProvider);
this.summaryRowLayer = new SummaryRowLayer(this.dataLayer, configRegistry);
IUniqueIndexLayer columnReorderLayer = new ColumnReorderLayer(this.summaryRowLayer);
IUniqueIndexLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
IUniqueIndexLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
this.layerStackWithSummary = new ViewportLayer(selectionLayer);
// NatTableFixture initializes the client area
this.natTable = new NatTableFixture(this.layerStackWithSummary, false);
this.natTable.setConfigRegistry(configRegistry);
this.natTable.addConfiguration(new TestSummaryRowConfiguration());
this.natTable.configure();
}
use of org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer in project nebula.widgets.nattable by eclipse.
the class PersistenceIntegrationTest method setup.
@Before
public void setup() {
this.natTableFixture = new NatTableFixture(new Shell(), new DummyGridLayerStack() {
@Override
protected void init(IUniqueIndexLayer bodyDataLayer, IUniqueIndexLayer columnHeaderDataLayer, IUniqueIndexLayer rowHeaderDataLayer, IUniqueIndexLayer cornerDataLayer) {
RowReorderLayer rowReorderLayer = new RowReorderLayer(bodyDataLayer);
super.init(rowReorderLayer, columnHeaderDataLayer, rowHeaderDataLayer, cornerDataLayer);
}
});
this.properties = new Properties();
}
use of org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer in project nebula.widgets.nattable by eclipse.
the class FreezeHelper method freeze.
/**
* Freezes the grid at the specified position. This method is for internal
* use. Consider using the appropriate commands on the NatTable instead to
* freeze the grid programmatically.
*
* @param freezeLayer
* The FreezeLayer of the grid to perform the freeze action.
* @param viewportLayer
* The ViewportLayer of the grid to perform the freeze action.
* @param topLeftPosition
* The top left position of the freeze area
* @param bottomRightPosition
* The bottom right position of the freeze area
*
* @see FreezeColumnCommand
* @see FreezeRowCommand
* @see FreezePositionCommand
* @see FreezeSelectionCommand
*/
public static void freeze(FreezeLayer freezeLayer, ViewportLayer viewportLayer, PositionCoordinate topLeftPosition, PositionCoordinate bottomRightPosition) {
if (freezeLayer == null || viewportLayer == null) {
// $NON-NLS-1$
throw new IllegalArgumentException("freezeLayer and viewportLayer can not be null!");
}
if (topLeftPosition != null && bottomRightPosition != null) {
freezeLayer.setTopLeftPosition(topLeftPosition.columnPosition, topLeftPosition.rowPosition);
freezeLayer.setBottomRightPosition(bottomRightPosition.columnPosition, bottomRightPosition.rowPosition);
IUniqueIndexLayer scrollableLayer = viewportLayer.getScrollableLayer();
int originX = (bottomRightPosition.columnPosition == scrollableLayer.getColumnCount() - 1) ? scrollableLayer.getWidth() : scrollableLayer.getStartXOfColumnPosition(bottomRightPosition.columnPosition + 1);
int originY = (bottomRightPosition.rowPosition == scrollableLayer.getRowCount() - 1) ? scrollableLayer.getHeight() : scrollableLayer.getStartYOfRowPosition(bottomRightPosition.rowPosition + 1);
viewportLayer.setMinimumOrigin(originX, originY);
viewportLayer.setOriginX(0);
viewportLayer.setOriginY(0);
viewportLayer.fireLayerEvent(new FreezeEvent(viewportLayer));
}
}
Aggregations