use of org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack 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.layer.stack.DummyGridLayerStack in project nebula.widgets.nattable by eclipse.
the class AutoResizeColumnsTest method autoResizeOneColumn.
/**
* These sequence of actions were causing a nasty bug in AutoResize
*/
@Test
public void autoResizeOneColumn() throws Exception {
GridLayer gridLayer = new DummyGridLayerStack();
setClientAreaProvider(gridLayer);
// Resize column
gridLayer.doCommand(new ColumnResizeCommand(gridLayer, 2, 10));
assertEquals(10, gridLayer.getColumnWidthByPosition(2));
// Auto resize the one column
InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(gridLayer, 2, this.configRegistry, this.gcFactory);
gridLayer.doCommand(command);
// Note: the actual resized width is platform specific (font
// dependency),
// hence we can't compare against a fixed value.
int columnWidth = gridLayer.getColumnWidthByPosition(2);
assertTrue(columnWidth > 10);
// Reorder columns
gridLayer.doCommand(new ColumnReorderCommand(gridLayer, 2, 1));
assertEquals(columnWidth, gridLayer.getColumnWidthByPosition(1));
// Select all columns
gridLayer.doCommand(new SelectAllCommand());
// Resize all selected columns
command = new InitializeAutoResizeColumnsCommand(gridLayer, 1, this.configRegistry, this.gcFactory);
gridLayer.doCommand(command);
for (int columnPosition = 1; columnPosition <= 20; columnPosition++) {
assertTrue("column " + columnPosition + " should have been resized, but it is still its original width", gridLayer.getColumnWidthByPosition(columnPosition) != 100);
}
}
use of org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack 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.layer.stack.DummyGridLayerStack in project nebula.widgets.nattable by eclipse.
the class ColumnSizeConfigurationCommandTest method testSetSizeInGrid.
@Test
public void testSetSizeInGrid() {
GridLayer grid = new DummyGridLayerStack();
assertEquals(40, grid.getRowHeaderLayer().getColumnWidthByPosition(0));
assertEquals(100, grid.getBodyLayer().getColumnWidthByPosition(0));
assertEquals(100, grid.getBodyLayer().getColumnWidthByPosition(9));
grid.doCommand(new ColumnSizeConfigurationCommand(null, 150, false));
assertEquals(150, grid.getRowHeaderLayer().getColumnWidthByPosition(0));
assertEquals(150, grid.getBodyLayer().getColumnWidthByPosition(0));
assertEquals(150, grid.getBodyLayer().getColumnWidthByPosition(9));
}
use of org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack in project nebula.widgets.nattable by eclipse.
the class ColumnSizeConfigurationCommandTest method testSetSizeInBodyRegion.
@Test
public void testSetSizeInBodyRegion() {
GridLayer grid = new DummyGridLayerStack();
assertEquals(40, grid.getRowHeaderLayer().getColumnWidthByPosition(0));
assertEquals(100, grid.getBodyLayer().getColumnWidthByPosition(0));
assertEquals(100, grid.getBodyLayer().getColumnWidthByPosition(9));
grid.doCommand(new ColumnSizeConfigurationCommand(GridRegion.BODY, 150, false));
assertEquals(40, grid.getRowHeaderLayer().getColumnWidthByPosition(0));
assertEquals(150, grid.getBodyLayer().getColumnWidthByPosition(0));
assertEquals(150, grid.getBodyLayer().getColumnWidthByPosition(9));
}
Aggregations