use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class RowSizeResetCommandTest method testResetAllRegions.
@Test
public void testResetAllRegions() {
DummyGridLayerStack dummyGridLayerStack = new DummyGridLayerStack();
NatTable natTable = new NatTableFixture(dummyGridLayerStack);
assertEquals(20, dummyGridLayerStack.getColumnHeaderDataLayer().getRowHeightByPosition(0));
assertEquals(20, dummyGridLayerStack.getBodyDataLayer().getRowHeightByPosition(2));
((DataLayer) dummyGridLayerStack.getColumnHeaderDataLayer()).setRowHeightByPosition(0, 50);
((DataLayer) dummyGridLayerStack.getBodyDataLayer()).setRowHeightByPosition(2, 50);
assertEquals(50, dummyGridLayerStack.getColumnHeaderDataLayer().getRowHeightByPosition(0));
assertEquals(50, dummyGridLayerStack.getBodyDataLayer().getRowHeightByPosition(2));
natTable.doCommand(new RowHeightResetCommand());
assertEquals(20, dummyGridLayerStack.getColumnHeaderDataLayer().getRowHeightByPosition(0));
assertEquals(20, dummyGridLayerStack.getBodyDataLayer().getRowHeightByPosition(2));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class ReorderColumnEventTest method reorderMultipleNotConsecutiveColumnsInHiddenState.
@Test
public void reorderMultipleNotConsecutiveColumnsInHiddenState() {
DefaultBodyLayerStack underlyingLayer = new DefaultBodyLayerStack(new DataLayerFixture(10, 10, 100, 20));
NatTableFixture natTableFixture = new NatTableFixture(underlyingLayer, 1000, 400, true);
// Add listener
LayerListenerFixture listenerFixture = new LayerListenerFixture();
natTableFixture.addLayerListener(listenerFixture);
assertEquals(10, natTableFixture.getColumnCount());
// hide some columns
natTableFixture.doCommand(new MultiColumnHideCommand(natTableFixture, new int[] { 2, 5, 8 }));
assertEquals(7, natTableFixture.getColumnCount());
List<Integer> columnToMove = Arrays.asList(3, 4, 6, 7);
int destinationPosition = 0;
natTableFixture.doCommand(new MultiColumnReorderCommand(underlyingLayer.getColumnReorderLayer(), columnToMove, destinationPosition));
// verify the event
ColumnReorderEvent event = (ColumnReorderEvent) listenerFixture.getReceivedEvent(ColumnReorderEvent.class);
assertNotNull(event);
assertTrue(StructuralChangeEventHelper.isReorder(event.getColumnDiffs()));
assertEquals(7, natTableFixture.getColumnCount());
assertEquals(0, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(3));
assertEquals(1, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(4));
assertEquals(2, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(6));
assertEquals(3, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(7));
assertEquals(4, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(0));
assertEquals(5, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(1));
assertEquals(6, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(2));
assertEquals(7, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(5));
assertEquals(8, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(8));
assertEquals(9, underlyingLayer.getColumnReorderLayer().getColumnPositionByIndex(9));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class ResizeColumnTest method reiszeColumnInATableWithNoRows.
/**
* Test for bug NTBL-431
*/
@Test
public void reiszeColumnInATableWithNoRows() throws Exception {
NatTableFixture natTable = new NatTableFixture(new DummyGridLayerStack(5, 0), true);
assertEquals(100, natTable.getColumnWidthByPosition(2));
natTable.doCommand(new ColumnResizeCommand(natTable, 2, 150));
assertEquals(150, natTable.getColumnWidthByPosition(2));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture in project nebula.widgets.nattable by eclipse.
the class ColumnSizeResetCommandTest method testResetAllRegions.
@Test
public void testResetAllRegions() {
DummyGridLayerStack dummyGridLayerStack = new DummyGridLayerStack();
NatTable natTable = new NatTableFixture(dummyGridLayerStack);
assertEquals(40, dummyGridLayerStack.getRowHeaderDataLayer().getColumnWidthByPosition(0));
assertEquals(100, dummyGridLayerStack.getBodyDataLayer().getColumnWidthByPosition(2));
((DataLayer) dummyGridLayerStack.getRowHeaderDataLayer()).setColumnWidthByPosition(0, 100);
((DataLayer) dummyGridLayerStack.getBodyDataLayer()).setColumnWidthByPosition(2, 50);
assertEquals(100, dummyGridLayerStack.getRowHeaderDataLayer().getColumnWidthByPosition(0));
assertEquals(50, dummyGridLayerStack.getBodyDataLayer().getColumnWidthByPosition(2));
natTable.doCommand(new ColumnWidthResetCommand());
assertEquals(40, dummyGridLayerStack.getRowHeaderDataLayer().getColumnWidthByPosition(0));
assertEquals(100, dummyGridLayerStack.getBodyDataLayer().getColumnWidthByPosition(2));
}
use of org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture 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();
}
Aggregations