Search in sources :

Example 41 with ClientAreaResizeCommand

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

the class AutoResizeColumnsTest method setClientAreaProvider.

private void setClientAreaProvider(ILayer layer) {
    layer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 1050, 250);
        }
    });
    layer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 42 with ClientAreaResizeCommand

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

the class ColumnSizeConfigurationCommandTest method testSetPercentageValue.

@Test
public void testSetPercentageValue() {
    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", 20, true));
    this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_1", 20, true));
    this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_2", 30, true));
    this.dataLayer.doCommand(new ColumnSizeConfigurationCommand("COLUMN_3", 30, true));
    // recalculate percentages
    ClientAreaResizeCommand resizeCommand = new ClientAreaResizeCommand(null);
    resizeCommand.setCalcArea(new Rectangle(0, 0, 1000, 1000));
    this.dataLayer.doCommand(resizeCommand);
    assertEquals(200, this.dataLayer.getColumnWidthByPosition(0));
    assertEquals(200, this.dataLayer.getColumnWidthByPosition(1));
    assertEquals(300, this.dataLayer.getColumnWidthByPosition(2));
    assertEquals(300, 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)

Example 43 with ClientAreaResizeCommand

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

the class ColumnSizeConfigurationCommandTest method testPercentageSizing.

@Test
public void testPercentageSizing() {
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(0));
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(1));
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(2));
    assertEquals(100, this.dataLayer.getColumnWidthByPosition(3));
    ColumnSizeConfigurationCommand command = new ColumnSizeConfigurationCommand(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.getColumnWidthByPosition(0));
    assertEquals(125, this.dataLayer.getColumnWidthByPosition(1));
    assertEquals(125, this.dataLayer.getColumnWidthByPosition(2));
    assertEquals(125, 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)

Example 44 with ClientAreaResizeCommand

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

the class MultiColumnResizeCommandTest method setClientAreaProvider.

private void setClientAreaProvider(ILayer layer) {
    layer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 1050, 250);
        }
    });
    layer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle)

Example 45 with ClientAreaResizeCommand

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

the class DefaultBodyLayerStackTest method setup.

@Before
public void setup() {
    this.layerStack = new DefaultBodyLayerStack(new DataLayerFixture(10, 5, 100, 20));
    this.layerStack.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 2000, 250);
        }
    });
    this.layerStack.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
}
Also used : Shell(org.eclipse.swt.widgets.Shell) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) DefaultBodyLayerStack(org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack) Before(org.junit.Before)

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