Search in sources :

Example 6 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class FreezeHandlerTest method testFreezeReorderToAllColumns.

@Test
public void testFreezeReorderToAllColumns() {
    this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 1500, 400);
        }
    });
    // Fire this command so that the viewport can be initialized
    this.compositeFreezeLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL)));
    // freeze all-1 columns
    this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 8));
    assertEquals(9, this.freezeLayer.getColumnCount());
    assertEquals(1, this.viewportLayer.getColumnCount());
    assertEquals(900, this.viewportLayer.getOrigin().getX());
    this.compositeFreezeLayer.doCommand(new ColumnReorderCommand(this.compositeFreezeLayer, 9, 7));
    assertEquals(10, this.freezeLayer.getColumnCount());
    assertEquals(0, this.viewportLayer.getColumnCount());
    assertEquals(1000, this.viewportLayer.getOrigin().getX());
}
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) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 7 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class FreezeHandlerTest method testFreezeAllRowsResize.

@Test
public void testFreezeAllRowsResize() {
    this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 1500, 400);
        }
    });
    // Shoot this command so that the viewport can be initialized
    this.compositeFreezeLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.H_SCROLL | SWT.V_SCROLL)));
    this.compositeFreezeLayer.doCommand(new FreezeRowCommand(this.compositeFreezeLayer, 9));
    assertEquals(10, this.freezeLayer.getRowCount());
    assertEquals(0, this.viewportLayer.getRowCount());
    assertEquals(200, this.viewportLayer.getOrigin().getY());
    this.compositeFreezeLayer.doCommand(new RowResizeCommand(this.freezeLayer, 2, 120));
    assertEquals(10, this.freezeLayer.getRowCount());
    assertEquals(0, this.viewportLayer.getRowCount());
    assertEquals(300, this.viewportLayer.getOrigin().getY());
}
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) RowResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.RowResizeCommand) Test(org.junit.Test)

Example 8 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerSelectionTest method setup.

@Before
public void setup() {
    this.dataProvider = new ListDataProvider<>(getNumberValues(), new ReflectiveColumnPropertyAccessor<>("columnOneNumber", "columnTwoNumber", "columnThreeNumber", "columnFourNumber", "columnFiveNumber", "columnSixNumber", "columnSevenNumber", "columnEightNumber", "columnNineNumber", "columnTenNumber"));
    this.gridLayer = new GridLayerFixture(this.dataProvider);
    this.model = new ColumnGroupModel();
    // 10 columns in header
    this.columnGroupLayer = new ColumnGroupHeaderLayer(this.gridLayer.getColumnHeaderLayer(), this.gridLayer.getBodyLayer().getSelectionLayer(), this.model, false);
    this.columnGroupLayer.addConfiguration(new DefaultColumnGroupHeaderLayerConfiguration(this.model, true));
    this.gridLayer.getBodyLayer().getViewportLayer().registerCommandHandler(new ViewportSelectColumnGroupCommandHandler(this.gridLayer.getBodyLayer().getViewportLayer(), this.columnGroupLayer));
    this.columnGroupLayer.addColumnsIndexesToGroup(TEST_GROUP_NAME_1, 0, 1, 2);
    this.columnGroupLayer.addColumnsIndexesToGroup(TEST_GROUP_NAME_2, 5, 6);
    this.columnGroupLayer.addColumnsIndexesToGroup(TEST_GROUP_NAME_3, 8, 9);
    this.gridLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 1050, 200);
        }
    });
    this.gridLayer.doCommand(new ClientAreaResizeCommand(new Shell(Display.getDefault(), SWT.V_SCROLL | SWT.H_SCROLL)));
    this.layerListener = new LayerListenerFixture();
    this.gridLayer.getBodyLayer().addLayerListener(this.layerListener);
}
Also used : IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) ClientAreaResizeCommand(org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand) Rectangle(org.eclipse.swt.graphics.Rectangle) DefaultColumnGroupHeaderLayerConfiguration(org.eclipse.nebula.widgets.nattable.group.config.DefaultColumnGroupHeaderLayerConfiguration) ReflectiveColumnPropertyAccessor(org.eclipse.nebula.widgets.nattable.data.ReflectiveColumnPropertyAccessor) Shell(org.eclipse.swt.widgets.Shell) ViewportSelectColumnGroupCommandHandler(org.eclipse.nebula.widgets.nattable.group.command.ViewportSelectColumnGroupCommandHandler) LayerListenerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture) GridLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture) Before(org.junit.Before)

Example 9 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class ColumnGroupHeaderLayerTest method setup.

@Before
public void setup() {
    this.gridLayer = new GridLayerFixture();
    this.model = new ColumnGroupModel();
    // 10 columns in header
    this.columnGroupLayer = new ColumnGroupHeaderLayer(this.gridLayer.getColumnHeaderLayer(), this.gridLayer.getBodyLayer().getSelectionLayer(), this.model);
    this.columnGroupLayer.addColumnsIndexesToGroup(TEST_GROUP_NAME_1, 0, 1);
    this.columnGroupLayer.addColumnsIndexesToGroup(TEST_GROUP_NAME_2, 5, 6);
    this.columnGroupLayer.addColumnsIndexesToGroup(TEST_GROUP_NAME_3, 8, 9);
    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)));
}
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) GridLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture) Before(org.junit.Before)

Example 10 with IClientAreaProvider

use of org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider in project nebula.widgets.nattable by eclipse.

the class ResizeEventDiffTest method before.

@Before
public void before() {
    DataLayerFixture dataLayer = new DataLayerFixture(20, 20, 100, 40);
    this.viewportLayer = new ViewportLayer(dataLayer);
    this.viewportLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 400, 400);
        }
    });
    this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(2));
    this.viewportLayer.setOriginY(this.viewportLayer.getStartYOfRowPosition(2));
    this.event = new ColumnResizeEvent(dataLayer, 2);
}
Also used : IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) ColumnResizeEvent(org.eclipse.nebula.widgets.nattable.resize.event.ColumnResizeEvent) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) Before(org.junit.Before)

Aggregations

IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)31 Rectangle (org.eclipse.swt.graphics.Rectangle)30 Shell (org.eclipse.swt.widgets.Shell)18 ClientAreaResizeCommand (org.eclipse.nebula.widgets.nattable.grid.command.ClientAreaResizeCommand)17 Before (org.junit.Before)17 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)8 Test (org.junit.Test)7 DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)5 GridLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture)5 DefaultGridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer)4 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)3 DefaultNatTableStyleConfiguration (org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration)3 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)3 TestLayer (org.eclipse.nebula.widgets.nattable.test.fixture.TestLayer)3 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)2 CompositeFreezeLayer (org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer)2 FreezeLayer (org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer)2 RowHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)2