Search in sources :

Example 16 with IClientAreaProvider

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

the class NatExporter method setClientAreaToMaximum.

/**
 * Increase the client area so it can include the whole {@link ILayer}.
 *
 * @param layer
 *            The {@link ILayer} for which the client area should be
 *            maximized.
 *
 * @since 1.5
 */
protected void setClientAreaToMaximum(ILayer layer) {
    final Rectangle maxClientArea = new Rectangle(0, 0, layer.getWidth(), layer.getHeight());
    layer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return maxClientArea;
        }
    });
    layer.doCommand(new PrintEntireGridCommand());
}
Also used : IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) Rectangle(org.eclipse.swt.graphics.Rectangle) PrintEntireGridCommand(org.eclipse.nebula.widgets.nattable.print.command.PrintEntireGridCommand)

Example 17 with IClientAreaProvider

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

the class CompositeFreezeLayerTest method testFreezeSelectionInMiddle.

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

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 300, 120);
        }
    });
    this.selectionLayer.setSelectedCell(2, 2);
    this.viewportLayer.setOriginX(this.viewportLayer.getStartXOfColumnPosition(1));
    this.viewportLayer.setOriginY(this.viewportLayer.getStartYOfRowPosition(1));
    this.compositeFreezeLayer.doCommand(new FreezeSelectionCommand());
    TestLayer expectedLayer = new TestLayer(3, 3, "1:0;100 | 2:0;100 | 3:1;100", "1:0;40  | 2:0;40  | 3:1;40", "B1~:FROZEN_REGION        | C1~:FROZEN_ROW_REGION                      | D1~:FROZEN_ROW_REGION \n" + "B2~:FROZEN_COLUMN_REGION | C2~SELECT:selectionAnchor,NONFROZEN_REGION | D2~:NONFROZEN_REGION \n" + "B3~:FROZEN_COLUMN_REGION | C3~:NONFROZEN_REGION                       | D3~:NONFROZEN_REGION \n");
    LayerAssert.assertLayerEquals(expectedLayer, this.compositeFreezeLayer);
}
Also used : IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) Rectangle(org.eclipse.swt.graphics.Rectangle) TestLayer(org.eclipse.nebula.widgets.nattable.test.fixture.TestLayer) FreezeSelectionCommand(org.eclipse.nebula.widgets.nattable.freeze.command.FreezeSelectionCommand) Test(org.junit.Test)

Example 18 with IClientAreaProvider

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

the class CompositeFreezeLayerTest method setup.

@Before
public void setup() {
    TestLayer dataLayer = new TestLayer(4, 4, "0:0;100 | 1:1;100 | 2:2;100 | 3:3;100", "0:0;40  | 1:1;40  | 2:2;40  | 3:3;40", "A0 | B0 | C0 | D0 \n" + "A1 | B1 | C1 | D1 \n" + "A2 | B2 | C2 | D2 \n" + "A3 | B3 | C3 | D3 \n");
    this.reorderLayer = new ColumnReorderLayer(dataLayer);
    this.hideShowLayer = new ColumnHideShowLayer(this.reorderLayer);
    this.selectionLayer = new SelectionLayer(this.hideShowLayer);
    this.viewportLayer = new ViewportLayer(this.selectionLayer);
    this.freezeLayer = new FreezeLayer(this.selectionLayer);
    this.compositeFreezeLayer = new CompositeFreezeLayer(this.freezeLayer, this.viewportLayer, this.selectionLayer);
    this.compositeFreezeLayer.setClientAreaProvider(new IClientAreaProvider() {

        @Override
        public Rectangle getClientArea() {
            return new Rectangle(0, 0, 400, 160);
        }
    });
    this.compositeFreezeLayer.doCommand(new InitializeClientAreaCommandFixture());
}
Also used : InitializeClientAreaCommandFixture(org.eclipse.nebula.widgets.nattable.test.fixture.InitializeClientAreaCommandFixture) IClientAreaProvider(org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider) SelectionLayer(org.eclipse.nebula.widgets.nattable.selection.SelectionLayer) FreezeLayer(org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer) CompositeFreezeLayer(org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer) Rectangle(org.eclipse.swt.graphics.Rectangle) TestLayer(org.eclipse.nebula.widgets.nattable.test.fixture.TestLayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) CompositeFreezeLayer(org.eclipse.nebula.widgets.nattable.freeze.CompositeFreezeLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) ViewportLayer(org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer) Before(org.junit.Before)

Example 19 with IClientAreaProvider

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

the class FreezeHandlerTest method testFreezeColumnResize.

@Test
public void testFreezeColumnResize() {
    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)));
    this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 2));
    assertEquals(3, this.freezeLayer.getColumnCount());
    assertEquals(7, this.viewportLayer.getColumnCount());
    assertEquals(300, this.viewportLayer.getOrigin().getX());
    this.compositeFreezeLayer.doCommand(new ColumnResizeCommand(this.freezeLayer, 2, 200));
    assertEquals(3, this.freezeLayer.getColumnCount());
    assertEquals(7, this.viewportLayer.getColumnCount());
    assertEquals(400, this.viewportLayer.getOrigin().getX());
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) 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) Test(org.junit.Test)

Example 20 with IClientAreaProvider

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

the class FreezeHandlerTest method testFreezeAllColumnsResize.

@Test
public void testFreezeAllColumnsResize() {
    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)));
    this.compositeFreezeLayer.doCommand(new FreezeColumnCommand(this.compositeFreezeLayer, 9));
    assertEquals(10, this.freezeLayer.getColumnCount());
    assertEquals(0, this.viewportLayer.getColumnCount());
    assertEquals(1000, this.viewportLayer.getOrigin().getX());
    this.compositeFreezeLayer.doCommand(new ColumnResizeCommand(this.freezeLayer, 2, 200));
    assertEquals(10, this.freezeLayer.getColumnCount());
    assertEquals(0, this.viewportLayer.getColumnCount());
    assertEquals(1100, this.viewportLayer.getOrigin().getX());
}
Also used : ColumnResizeCommand(org.eclipse.nebula.widgets.nattable.resize.command.ColumnResizeCommand) 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) Test(org.junit.Test)

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