Search in sources :

Example 16 with ClientAreaResizeCommand

use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.

the class ResizeColumnHideShowLayerTest method testHideResizeShowFixedPercentageSizedColumns.

@Test
public void testHideResizeShowFixedPercentageSizedColumns() {
    this.bodyDataLayer.setColumnWidthPercentageByPosition(0, 15);
    this.bodyDataLayer.setColumnWidthPercentageByPosition(1, 15);
    this.bodyDataLayer.setColumnWidthPercentageByPosition(2, 15);
    this.bodyDataLayer.setColumnWidthPercentageByPosition(3, 15);
    this.bodyDataLayer.setColumnWidthPercentageByPosition(4, 40);
    ClientAreaResizeCommand cmd = new ClientAreaResizeCommand(null);
    cmd.setCalcArea(new Rectangle(0, 0, 600, 100));
    this.hideShowLayer.doCommand(cmd);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(90, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(240, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.hideColumnPositions(1, 2);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(129, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(129, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(342, this.hideShowLayer.getColumnWidthByPosition(4));
    // resize a column - minor rounding issues in double to int
    this.bodyDataLayer.setColumnWidthByPosition(0, 99);
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(100, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(0, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(159, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(341, this.hideShowLayer.getColumnWidthByPosition(4));
    this.hideShowLayer.showAllColumns();
    // with some rounding issues and corrections this will be the result
    // at least all columns in an appropriate ratio are visible again
    assertEquals(600, this.hideShowLayer.getWidth());
    assertEquals(77, this.hideShowLayer.getColumnWidthByPosition(0));
    assertEquals(70, this.hideShowLayer.getColumnWidthByPosition(1));
    assertEquals(69, this.hideShowLayer.getColumnWidthByPosition(2));
    assertEquals(122, this.hideShowLayer.getColumnWidthByPosition(3));
    assertEquals(262, this.hideShowLayer.getColumnWidthByPosition(4));
}
Also used : ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 17 with ClientAreaResizeCommand

use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.

the class RowSizeConfigurationCommandTest method testSetPercentage.

@Test
public void testSetPercentage() {
    assertEquals(20, this.dataLayer.getRowHeightByPosition(0));
    assertEquals(20, this.dataLayer.getRowHeightByPosition(1));
    assertEquals(20, this.dataLayer.getRowHeightByPosition(2));
    assertEquals(20, this.dataLayer.getRowHeightByPosition(3));
    this.dataLayer.doCommand(new RowSizeConfigurationCommand("ROW_0", 100, false));
    this.dataLayer.doCommand(new RowSizeConfigurationCommand("ROW_1", 100, false));
    this.dataLayer.doCommand(new RowSizeConfigurationCommand("ROW_2", null, true));
    this.dataLayer.doCommand(new RowSizeConfigurationCommand("ROW_3", null, true));
    // recalculate percentages
    ClientAreaResizeCommand resizeCommand = new ClientAreaResizeCommand(null);
    resizeCommand.setCalcArea(new Rectangle(0, 0, 500, 500));
    this.dataLayer.doCommand(resizeCommand);
    assertEquals(100, this.dataLayer.getRowHeightByPosition(0));
    assertEquals(100, this.dataLayer.getRowHeightByPosition(1));
    assertEquals(150, this.dataLayer.getRowHeightByPosition(2));
    assertEquals(150, this.dataLayer.getRowHeightByPosition(3));
}
Also used : ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 18 with ClientAreaResizeCommand

use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.

the class RowSizeConfigurationCommandTest method testPercentageSizing.

@Test
public void testPercentageSizing() {
    assertEquals(20, this.dataLayer.getRowHeightByPosition(0));
    assertEquals(20, this.dataLayer.getRowHeightByPosition(1));
    assertEquals(20, this.dataLayer.getRowHeightByPosition(2));
    assertEquals(20, this.dataLayer.getRowHeightByPosition(3));
    RowSizeConfigurationCommand command = new RowSizeConfigurationCommand(null, null, true);
    this.dataLayer.doCommand(command);
    // recalculate percentages
    ClientAreaResizeCommand resizeCommand = new ClientAreaResizeCommand(null);
    resizeCommand.setCalcArea(new Rectangle(0, 0, 500, 500));
    this.dataLayer.doCommand(resizeCommand);
    assertEquals(125, this.dataLayer.getRowHeightByPosition(0));
    assertEquals(125, this.dataLayer.getRowHeightByPosition(1));
    assertEquals(125, this.dataLayer.getRowHeightByPosition(2));
    assertEquals(125, this.dataLayer.getRowHeightByPosition(3));
}
Also used : ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Example 19 with ClientAreaResizeCommand

use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.

the class SearchGridCommandHandlerTest method setUp.

@Before
public void setUp() {
    this.gridLayer = new GridLayerFixture();
    this.gridLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 1050, 250);
        }
    });
    this.gridLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
    this.configRegistry = new ConfigRegistry();
    new DefaultNatTableStyleConfiguration().configureRegistry(this.configRegistry);
    this.commandHandler = new SearchGridCellsCommandHandler(this.gridLayer.getBodyLayer().getSelectionLayer());
    selectCell(3, 3);
}
Also used : ConfigRegistry(org.eclipse.nebula.widgets.nattable.config.ConfigRegistry) Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) DefaultNatTableStyleConfiguration(org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration) Rectangle(org.eclipse.swt.graphics.Rectangle) GridLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture) Before(org.junit.Before)

Example 20 with ClientAreaResizeCommand

use of org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand in project nebula.widgets.nattable by eclipse.

the class ColumnSizeConfigurationCommandTest method testSetPercentage.

@Test
public void testSetPercentage() {
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(0));
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(1));
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(2));
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(3));
    this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_0", 100, false));
    this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_1", 100, false));
    this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_2", null, true));
    this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_3", null, true));
    // recalculate percentages
    ClientAreaResizeCommand resizeCommand = new ClientAreaResizeCommand(null);
    resizeCommand.setCalcArea(new Rectangle(0, 0, 500, 500));
    this.dataLayer.doCommand(resizeCommand);
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(0));
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(1));
    assertEquals(150, this.dataLayer.getColumnWidthByPosition(2));
    assertEquals(150, this.dataLayer.getColumnWidthByPosition(3));
}
Also used : ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) Test(org.junit.Test)

Aggregations

ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)48 Rectangle (org.eclipse.swt.graphics.Rectangle)46 Test (org.junit.Test)31 IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)17 Shell (org.eclipse.swt.widgets.Shell)17 Before (org.junit.Before)9 GridLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture)4 Properties (java.util.Properties)3 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)3 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)3 DefaultGridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer)3 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)2 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)2 ColumnReorderCommand (org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand)2 ColumnResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand)2 RowResizeCommand (org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand)2 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 StructuralRefreshCommand (org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand)1 ReflectiveColumnPropertyAccessor (org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor)1 CellEditorCreatedEvent (org.eclipse.nebula.widgets.nattable.edit.CellEditorCreatedEvent)1