Search in sources :

Example 11 with DummyGridLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack 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));
}
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 12 with DummyGridLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack in project nebula.widgets.nattable by eclipse.

the class MultiColumnResizeCommandTest method testMultiResizeWithoutDownscale.

@Test
public void testMultiResizeWithoutDownscale() {
    GridLayer gridLayer = new DummyGridLayerStack();
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    setClientAreaProvider(gridLayer);
    // scaling enabled, therefore default width of 100 pixels is up scaled
    // to 125
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(125, gridLayer.getColumnWidthByPosition(3));
    assertEquals(125, gridLayer.getColumnWidthByPosition(4));
    assertEquals(125, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
    MultiColumnResizeCommand resizeCommand = new MultiColumnResizeCommand(gridLayer, new int[] { 3, 4, 5 }, 150);
    gridLayer.doCommand(resizeCommand);
    // command executed with down scaling disabled, therefore set width 150
    // is up scaled to 188
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(188, gridLayer.getColumnWidthByPosition(3));
    assertEquals(188, gridLayer.getColumnWidthByPosition(4));
    assertEquals(188, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) Test(org.junit.Test)

Example 13 with DummyGridLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack in project nebula.widgets.nattable by eclipse.

the class MultiColumnResizeCommandTest method testMultiResizeWithoutDownscaleOnSelection.

@Test
public void testMultiResizeWithoutDownscaleOnSelection() {
    DummyGridLayerStack gridLayer = new DummyGridLayerStack();
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    setClientAreaProvider(gridLayer);
    // scaling enabled, therefore default width of 100 pixels is up scaled
    // to 125
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(125, gridLayer.getColumnWidthByPosition(3));
    assertEquals(125, gridLayer.getColumnWidthByPosition(4));
    assertEquals(125, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
    // select columns
    gridLayer.doCommand(new SelectColumnCommand(gridLayer, 3, 1, false, false));
    gridLayer.doCommand(new SelectColumnCommand(gridLayer, 4, 1, false, true));
    gridLayer.doCommand(new SelectColumnCommand(gridLayer, 5, 1, false, true));
    // resize one of the selected columns
    ColumnResizeCommand columnResizeCommand = new ColumnResizeCommand(gridLayer, 3, 150);
    gridLayer.doCommand(columnResizeCommand);
    // command executed with down scaling disabled, therefore set width 150
    // is up scaled to 188
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(188, gridLayer.getColumnWidthByPosition(3));
    assertEquals(188, gridLayer.getColumnWidthByPosition(4));
    assertEquals(188, gridLayer.getColumnWidthByPosition(5));
    assertEquals(125, gridLayer.getColumnWidthByPosition(6));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) SelectColumnCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) Test(org.junit.Test)

Example 14 with DummyGridLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack in project nebula.widgets.nattable by eclipse.

the class MultiRowResizeCommandTest method testMultiResizeWithoutDownscale.

@Test
public void testMultiResizeWithoutDownscale() {
    GridLayer gridLayer = new DummyGridLayerStack();
    IDpiConverter dpiConverter = new AbstractDpiConverter() {

        @Override
        protected void readDpiFromDisplay() {
            this.dpi = 120;
        }
    };
    gridLayer.doCommand(new ConfigureScalingCommand(dpiConverter, dpiConverter));
    setClientAreaProvider(gridLayer);
    // scaling enabled, therefore default height of 20 pixels is up scaled
    // to 25
    assertEquals(25, gridLayer.getRowHeightByPosition(2));
    assertEquals(25, gridLayer.getRowHeightByPosition(3));
    assertEquals(25, gridLayer.getRowHeightByPosition(4));
    assertEquals(25, gridLayer.getRowHeightByPosition(5));
    assertEquals(25, gridLayer.getRowHeightByPosition(6));
    MultiRowResizeCommand resizeCommand = new MultiRowResizeCommand(gridLayer, new int[] { 3, 4, 5 }, 50);
    gridLayer.doCommand(resizeCommand);
    // command executed with down scaling disabled, therefore set height 50
    // is up scaled to 63
    assertEquals(25, gridLayer.getRowHeightByPosition(2));
    assertEquals(63, gridLayer.getRowHeightByPosition(3));
    assertEquals(63, gridLayer.getRowHeightByPosition(4));
    assertEquals(63, gridLayer.getRowHeightByPosition(5));
    assertEquals(25, gridLayer.getRowHeightByPosition(6));
}
Also used : AbstractDpiConverter(org.eclipse.nebula.widgets.nattable.layer.AbstractDpiConverter) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) IDpiConverter(org.eclipse.nebula.widgets.nattable.layer.IDpiConverter) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) Test(org.junit.Test)

Example 15 with DummyGridLayerStack

use of org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack in project nebula.widgets.nattable by eclipse.

the class EditIntegrationTest method setup.

@Before
public void setup() {
    this.gridLayerStack = new DummyGridLayerStack(5, 5);
    this.natTable = new NatTableFixture(this.gridLayerStack);
    // Ensure no active editor (static) is present
    // Although deprecated this needs to still work for backwards
    // compatibility
    assertNull(this.natTable.getActiveCellEditor());
    assertNull(ActiveCellEditorRegistry.getActiveCellEditor());
}
Also used : DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) NatTableFixture(org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture) Before(org.junit.Before)

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