Search in sources :

Example 41 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture 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)

Example 42 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture in project nebula.widgets.nattable by eclipse.

the class ColumnReorderLayerTest method getStartXForReorderedColumn.

@Test
public void getStartXForReorderedColumn() throws Exception {
    this.underlyingLayer = new DataLayerFixture();
    this.columnReorderLayer = new ColumnReorderLayer(this.underlyingLayer);
    // 0 1 2 3 4 - see DataLayerFixture
    this.columnReorderLayer.reorderColumnPosition(0, 5);
    // Index: 1 2 3 4 0 Width: 100 35 100 80 150
    assertEquals(0, this.columnReorderLayer.getStartXOfColumnPosition(0));
    assertEquals(100, this.columnReorderLayer.getStartXOfColumnPosition(1));
    assertEquals(135, this.columnReorderLayer.getStartXOfColumnPosition(2));
    assertEquals(235, this.columnReorderLayer.getStartXOfColumnPosition(3));
    assertEquals(315, this.columnReorderLayer.getStartXOfColumnPosition(4));
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) Test(org.junit.Test)

Example 43 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture in project nebula.widgets.nattable by eclipse.

the class ColumnReorderLayerTest method canHandleColumnReorderCommand.

@Test
public void canHandleColumnReorderCommand() throws Exception {
    ColumnReorderLayer reorderLayer = new ColumnReorderLayer(new DataLayerFixture());
    ColumnReorderCommand reorderCommand = new ColumnReorderCommand(reorderLayer, 0, 2);
    assertTrue(reorderLayer.doCommand(reorderCommand));
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) ColumnReorderCommand(org.eclipse.nebula.widgets.nattable.reorder.command.ColumnReorderCommand) Test(org.junit.Test)

Example 44 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture in project nebula.widgets.nattable by eclipse.

the class ColumnReorderLayerTest method getWidthForReorderedColumns.

@Test
public void getWidthForReorderedColumns() throws Exception {
    this.underlyingLayer = new DataLayerFixture();
    this.columnReorderLayer = new ColumnReorderLayer(this.underlyingLayer);
    // 0 1 2 3 4 - see DataLayerFixture
    this.columnReorderLayer.reorderColumnPosition(0, 5);
    // 1 2 3 4 0
    Assert.assertEquals(100, this.columnReorderLayer.getColumnWidthByPosition(0));
    Assert.assertEquals(35, this.columnReorderLayer.getColumnWidthByPosition(1));
    Assert.assertEquals(100, this.columnReorderLayer.getColumnWidthByPosition(2));
    Assert.assertEquals(80, this.columnReorderLayer.getColumnWidthByPosition(3));
    Assert.assertEquals(150, this.columnReorderLayer.getColumnWidthByPosition(4));
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) Test(org.junit.Test)

Example 45 with DataLayerFixture

use of org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture in project nebula.widgets.nattable by eclipse.

the class ColumnReorderLayerTest method getWidthForMultipleColumnsReordering.

@SuppressWarnings("boxing")
@Test
public void getWidthForMultipleColumnsReordering() throws Exception {
    this.underlyingLayer = new DataLayerFixture();
    this.columnReorderLayer = new ColumnReorderLayer(this.underlyingLayer);
    // 0 1 2 3 4 - see DataLayerFixture
    this.columnReorderLayer.reorderMultipleColumnPositions(Arrays.asList(1, 2), 5);
    // 0 3 4 1 2
    assertEquals(150, this.columnReorderLayer.getColumnWidthByPosition(0));
    assertEquals(100, this.columnReorderLayer.getColumnWidthByPosition(1));
    assertEquals(80, this.columnReorderLayer.getColumnWidthByPosition(2));
    assertEquals(100, this.columnReorderLayer.getColumnWidthByPosition(3));
    assertEquals(35, this.columnReorderLayer.getColumnWidthByPosition(4));
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) Test(org.junit.Test)

Aggregations

DataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture)57 Test (org.junit.Test)28 Before (org.junit.Before)27 BaseDataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture)11 LayerListenerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.LayerListenerFixture)7 Rectangle (org.eclipse.swt.graphics.Rectangle)7 DefaultBodyLayerStack (org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack)6 ViewportLayer (org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer)6 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)5 IClientAreaProvider (org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider)5 SelectionLayer (org.eclipse.nebula.widgets.nattable.selection.SelectionLayer)4 ColumnOverrideLabelAccumulator (org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator)3 LayerCommandFixture (org.eclipse.nebula.widgets.nattable.test.fixture.command.LayerCommandFixture)3 ColumnGroupModelFixture (org.eclipse.nebula.widgets.nattable.test.fixture.group.ColumnGroupModelFixture)3 Properties (java.util.Properties)2 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)2 IDataProvider (org.eclipse.nebula.widgets.nattable.data.IDataProvider)2 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)2 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)2 RowHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.RowHideShowLayer)2