Search in sources :

Example 56 with GridLayer

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

the class GridLayerTest method initRowHeaderHeight.

@Test
public void initRowHeaderHeight() throws Exception {
    GridLayer gridLayer = new GridLayerFixture();
    gridLayer.doCommand(new InitializeClientAreaCommandFixture());
    ILayer rowHeader = gridLayer.getRowHeaderLayer();
    // Only visible rows are counted
    Assert.assertEquals(100, rowHeader.getHeight());
    Assert.assertEquals(40, rowHeader.getWidth());
}
Also used : InitializeClientAreaCommandFixture(org.eclipse.nebula.widgets.nattable.test.fixture.InitializeClientAreaCommandFixture) ILayer(org.eclipse.nebula.widgets.nattable.layer.ILayer) GridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) GridLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture) Test(org.junit.Test)

Example 57 with GridLayer

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

the class RowSizeConfigurationCommandTest method testSetSizeInColumnHeaderRegion.

@Test
public void testSetSizeInColumnHeaderRegion() {
    GridLayer grid = new DummyGridLayerStack();
    assertEquals(20, grid.getColumnHeaderLayer().getRowHeightByPosition(0));
    assertEquals(20, grid.getBodyLayer().getRowHeightByPosition(0));
    assertEquals(20, grid.getBodyLayer().getRowHeightByPosition(9));
    grid.doCommand(new RowSizeConfigurationCommand(GridRegion.COLUMN_HEADER, 50, false));
    assertEquals(50, grid.getColumnHeaderLayer().getRowHeightByPosition(0));
    assertEquals(20, grid.getBodyLayer().getRowHeightByPosition(0));
    assertEquals(20, grid.getBodyLayer().getRowHeightByPosition(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 58 with GridLayer

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

the class RowSizeConfigurationCommandTest method testSetSizeInBodyRegion.

@Test
public void testSetSizeInBodyRegion() {
    GridLayer grid = new DummyGridLayerStack();
    assertEquals(20, grid.getColumnHeaderLayer().getRowHeightByPosition(0));
    assertEquals(20, grid.getBodyLayer().getRowHeightByPosition(0));
    assertEquals(20, grid.getBodyLayer().getRowHeightByPosition(9));
    grid.doCommand(new RowSizeConfigurationCommand(GridRegion.BODY, 50, false));
    assertEquals(20, grid.getColumnHeaderLayer().getRowHeightByPosition(0));
    assertEquals(50, grid.getBodyLayer().getRowHeightByPosition(0));
    assertEquals(50, grid.getBodyLayer().getRowHeightByPosition(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 59 with GridLayer

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

the class AutoResizeColumnsTest method shouldAutoResizeCorrectlyIfMultipleColumnsAreSelected.

/**
 * Scenario: Multiple columns are selected but a non selected column is auto
 * resized.
 */
@Test
public void shouldAutoResizeCorrectlyIfMultipleColumnsAreSelected() throws Exception {
    GridLayer gridLayer = new DefaultGridLayer(RowDataListFixture.getList(), RowDataListFixture.getPropertyNames(), RowDataListFixture.getPropertyToLabelMap());
    setClientAreaProvider(gridLayer);
    // Resize grid column 1, 2
    gridLayer.doCommand(new ColumnResizeCommand(gridLayer, 1, 10));
    gridLayer.doCommand(new ColumnResizeCommand(gridLayer, 2, 10));
    assertEquals(10, gridLayer.getColumnWidthByPosition(1));
    assertEquals(10, gridLayer.getColumnWidthByPosition(2));
    // Fully select columns 1, 2
    SelectionLayer selectionLayer = ((DefaultBodyLayerStack) gridLayer.getBodyLayer()).getSelectionLayer();
    selectionLayer.doCommand(new SelectColumnCommand(selectionLayer, 0, 0, false, false));
    selectionLayer.doCommand(new SelectColumnCommand(selectionLayer, 1, 0, true, false));
    assertEquals(2, selectionLayer.getFullySelectedColumnPositions().length);
    // Resize grid column 5
    gridLayer.doCommand(new ColumnResizeCommand(gridLayer, 5, 10));
    assertEquals(10, gridLayer.getColumnWidthByPosition(5));
    // Auto resize column 5
    InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(gridLayer, 5, this.configRegistry, this.gcFactory);
    gridLayer.doCommand(command);
    // Columns 1 and 2 should not be resized
    assertEquals(10, gridLayer.getColumnWidthByPosition(1));
    assertEquals(10, gridLayer.getColumnWidthByPosition(2));
    assertTrue(gridLayer.getColumnWidthByPosition(5) > 10);
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) SelectColumnCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectColumnCommand) 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) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) Test(org.junit.Test)

Example 60 with GridLayer

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

the class ColumnSizeConfigurationCommandTest method testSetSizeInColumnHeaderRegion.

@Test
public void testSetSizeInColumnHeaderRegion() {
    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.ROW_HEADER, 150, false));
    assertEquals(150, grid.getRowHeaderLayer().getColumnWidthByPosition(0));
    assertEquals(100, grid.getBodyLayer().getColumnWidthByPosition(0));
    assertEquals(100, 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

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