Search in sources :

Example 6 with DummyGridLayerStack

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));
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) Test(org.junit.Test)

Example 7 with DummyGridLayerStack

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);
    }
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) SelectAllCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectAllCommand) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) InitializeAutoResizeColumnsCommand(org.eclipse.nebula.widgets.nattable.resize.command.InitializeAutoResizeColumnsCommand) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 8 with DummyGridLayerStack

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));
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) Test(org.junit.Test)

Example 9 with DummyGridLayerStack

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));
}
Also used : DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) Test(org.junit.Test)

Example 10 with DummyGridLayerStack

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));
}
Also used : DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) Test(org.junit.Test)

Aggregations

DummyGridLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack)38 Test (org.junit.Test)23 GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)13 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)13 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)11 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)9 AbstractDpiConverter (org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter)8 IDpiConverter (org.eclipse.nebula.widgets.nattable.layer.IDpiConverter)8 ConfigureScalingCommand (org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand)8 Before (org.junit.Before)6 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)5 Shell (org.eclipse.swt.widgets.Shell)4 IUniqueIndexLayer (org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer)3 SelectColumnCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand)3 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)3 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)2 RowHideCommand (org.eclipse.nebula.widgets.nattable.hideshow.command.RowHideCommand)2 HideRowPositionsEvent (org.eclipse.nebula.widgets.nattable.hideshow.event.HideRowPositionsEvent)2 ColumnResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand)2 SelectRowsCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand)2