Search in sources :

Example 31 with DummyGridLayerStack

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

the class MultiColumnResizeCommandTest method testMultiResizeWithDownscale.

@Test
public void testMultiResizeWithDownscale() {
    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, true);
    gridLayer.doCommand(resizeCommand);
    // command executed with down scaling enabled, therefore set width 150
    // is first down scaled on setting the value and then up scaled to 150
    // again on accessing the width
    assertEquals(125, gridLayer.getColumnWidthByPosition(2));
    assertEquals(150, gridLayer.getColumnWidthByPosition(3));
    assertEquals(150, gridLayer.getColumnWidthByPosition(4));
    assertEquals(150, 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 32 with DummyGridLayerStack

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

the class MultiRowResizeCommandTest method testMultiResizeWithDownscale.

@Test
public void testMultiResizeWithDownscale() {
    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, true);
    gridLayer.doCommand(resizeCommand);
    // command executed with down scaling enabled, therefore set height 50
    // is first down scaled on setting the value and then up scaled to 50
    // again on accessing the height
    assertEquals(25, gridLayer.getRowHeightByPosition(2));
    assertEquals(50, gridLayer.getRowHeightByPosition(3));
    assertEquals(50, gridLayer.getRowHeightByPosition(4));
    assertEquals(50, 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 33 with DummyGridLayerStack

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

the class MultiRowResizeCommandTest 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 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));
    // select rows
    gridLayer.doCommand(new SelectRowsCommand(gridLayer, 1, new int[] { 3, 4, 5 }, false, true, -1));
    // resize one of the selected columns
    RowResizeCommand columnResizeCommand = new RowResizeCommand(gridLayer, 3, 50);
    gridLayer.doCommand(columnResizeCommand);
    // 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) ConfigureScalingCommand(org.eclipse.nebula.widgets.nattable.layer.command.ConfigureScalingCommand) SelectRowsCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand) Test(org.junit.Test)

Example 34 with DummyGridLayerStack

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

the class SelectionDragModeTest method setup.

@Before
public void setup() {
    this.gridLayer = new DummyGridLayerStack();
    this.natTable = new NatTable(new Shell(Display.getDefault()), this.gridLayer);
    this.natTable.setSize(400, 400);
    this.natTable.doCommand(new InitializeClientAreaCommandFixture());
    this.dragMode = new CellSelectionDragMode();
    Event event = new Event();
    event.widget = new Shell();
    event.x = 100;
    event.y = 100;
    this.mouseEvent = new MouseEvent(event);
    this.listener = new LayerListenerFixture();
    this.gridLayer.addLayerListener(this.listener);
}
Also used : Shell(org.eclipse.swt.widgets.Shell) InitializeClientAreaCommandFixture(org.eclipse.nebula.widgets.nattable.test.fixture.InitializeClientAreaCommandFixture) MouseEvent(org.eclipse.swt.events.MouseEvent) DummyGridLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DummyGridLayerStack) Event(org.eclipse.swt.widgets.Event) MouseEvent(org.eclipse.swt.events.MouseEvent) ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) Before(org.junit.Before)

Example 35 with DummyGridLayerStack

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

the class EditIntegrationTest method testDataValidation.

@Test
public void testDataValidation() {
    DummyGridLayerStack gridLayerStack = new DummyGridLayerStack(5, 5);
    this.natTable = new NatTableFixture(gridLayerStack);
    // Register custom validation
    DataLayer bodyDataLayer = (DataLayer) gridLayerStack.getBodyDataLayer();
    this.natTable.registerLabelOnColumn(bodyDataLayer, 0, TEST_LABEL);
    this.natTable.registerLabelOnColumn(bodyDataLayer, 1, TEST_LABEL_2);
    this.natTable.enableEditingOnAllCells();
    this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, IDataValidator.NEVER_VALID, DisplayMode.EDIT, TEST_LABEL);
    this.natTable.getConfigRegistry().registerConfigAttribute(EditConfigAttributes.DATA_VALIDATOR, IDataValidator.ALWAYS_VALID, DisplayMode.EDIT, TEST_LABEL_2);
    ILayerCell cell = this.natTable.getCellByPosition(1, 1);
    assertEquals("Col: 1, Row: 1", cell.getDataValue());
    // Column index 0 never valid
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    assertFalse(this.natTable.getActiveCellEditor().validateCanonicalValue(cell.getDataValue()));
    cell = this.natTable.getCellByPosition(2, 1);
    assertEquals("Col: 2, Row: 1", cell.getDataValue());
    // Column index 1 always valid
    this.natTable.doCommand(new EditCellCommand(this.natTable, this.natTable.getConfigRegistry(), cell));
    assertTrue(this.natTable.getActiveCellEditor().validateCanonicalValue(cell.getDataValue()));
}
Also used : SpanningDataLayer(org.eclipse.nebula.widgets.nattable.layer.SpanningDataLayer) 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) ILayerCell(org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell) EditCellCommand(org.eclipse.nebula.widgets.nattable.edit.command.EditCellCommand) 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