Search in sources :

Example 6 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer 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 7 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer 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)

Example 8 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer 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 9 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer 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 10 with GridLayer

use of org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer in project nebula.widgets.nattable by eclipse.

the class ViewportIntegrationTest method shouldInitWithNoScroll.

@Test
public void shouldInitWithNoScroll() {
    List<String> contents = new ArrayList<>(Arrays.asList("one", "two", "three", "four", "five"));
    IDataProvider bodyDataProvider = new ListDataProvider<>(contents, new IColumnAccessor<String>() {

        @Override
        public Object getDataValue(String rowObject, int columnIndex) {
            return rowObject;
        }

        @Override
        public void setDataValue(String rowObject, int columnIndex, Object newValue) {
        // ignore
        }

        @Override
        public int getColumnCount() {
            return 1;
        }
    });
    SelectionLayer selectionLayer = new SelectionLayer(new DataLayer(bodyDataProvider));
    ViewportLayer viewportLayer = new ViewportLayer(selectionLayer);
    IDataProvider colDataProvider = new DummyColumnHeaderDataProvider(bodyDataProvider);
    ColumnHeaderLayer colHeader = new ColumnHeaderLayer(new DataLayer(colDataProvider), viewportLayer, selectionLayer);
    IDataProvider rowDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
    RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(new DataLayer(rowDataProvider), viewportLayer, selectionLayer);
    CornerLayer cornerLayer = new CornerLayer(new DataLayer(new DefaultCornerDataProvider(colDataProvider, rowDataProvider)), rowHeaderLayer, colHeader);
    GridLayer grid = new GridLayer(viewportLayer, colHeader, rowHeaderLayer, cornerLayer);
    // create the table with no scrollbars
    NatTable natTable = new NatTable(new Shell(), SWT.NO_BACKGROUND | SWT.NO_REDRAW_RESIZE | SWT.DOUBLE_BUFFERED, grid);
    // this caused a NPE for scrollbar initialization
    natTable.setSize(600, 600);
}
Also used : ListDataProvider(org.eclipse.nebula.widgets.nattable.data.ListDataProvider) ColumnHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer) ArrayList(java.util.ArrayList) DefaultRowHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider) DefaultCornerDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider) IDataProvider(org.eclipse.nebula.widgets.nattable.data.IDataProvider) DummyColumnHeaderDataProvider(org.eclipse.nebula.widgets.nattable.grid.data.DummyColumnHeaderDataProvider) DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) RowHeaderLayer(org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer) Shell(org.eclipse.swt.widgets.Shell) CornerLayer(org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) NatTable(org.eclipse.nebula.widgets.nattable.NatTable) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) Test(org.junit.Test)

Aggregations

GridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer)98 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)75 DefaultCornerDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultCornerDataProvider)74 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)74 ColumnHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.ColumnHeaderLayer)73 CornerLayer (org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer)73 RowHeaderLayer (org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer)72 DefaultRowHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultRowHeaderDataProvider)69 ILayer (org.eclipse.nebula.widgets.nattable.layer.ILayer)67 DefaultColumnHeaderDataProvider (org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider)66 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)62 DefaultRowHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultRowHeaderDataLayer)61 HashMap (java.util.HashMap)57 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)54 DefaultColumnHeaderDataLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultColumnHeaderDataLayer)54 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)46 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)39 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)34 PopupMenuBuilder (org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder)32 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)31