Search in sources :

Example 21 with DataLayerFixture

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

the class MultiColumnResizeCommandTest method getColumnWidthWhenTheColumnPositionsHaveBeenConverted.

@Test
public void getColumnWidthWhenTheColumnPositionsHaveBeenConverted() {
    DataLayerFixture dataLayer = new DataLayerFixture();
    // Indexes re-ordered: 4 1 0 2 3
    ColumnReorderLayer reorderLayerFixture = new ColumnReorderLayerFixture(dataLayer);
    MultiColumnResizeCommand resizeCommand = new MultiColumnResizeCommand(reorderLayerFixture, new int[] { 1, 2 }, new int[] { 100, 150 });
    reorderLayerFixture.doCommand(resizeCommand);
    // As the Commands goes down the stack - positions might get converted
    // to entirely different values.
    assertEquals(-1, resizeCommand.getCommonColumnWidth());
    assertEquals(-1, resizeCommand.getColumnWidth(5));
    assertEquals(-1, resizeCommand.getColumnWidth(12));
    assertEquals(100, resizeCommand.getColumnWidth(1));
    assertEquals(150, resizeCommand.getColumnWidth(0));
}
Also used : DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnReorderLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.ColumnReorderLayerFixture) Test(org.junit.Test)

Example 22 with DataLayerFixture

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

the class ColumnReorderLayerTest method getConfigLabelsByPosition.

@Test
public void getConfigLabelsByPosition() throws Exception {
    DataLayer underlyingLayer = new DataLayerFixture();
    this.columnReorderLayer = new ColumnReorderLayer(underlyingLayer);
    ColumnOverrideLabelAccumulator columnLabelAccumulator = new ColumnOverrideLabelAccumulator(underlyingLayer);
    registerCellStyleAccumulators(underlyingLayer, columnLabelAccumulator);
    columnLabelAccumulator.registerColumnOverrides(4, "INDEX_4_LABEL");
    List<String> labelsForIndex4 = this.columnReorderLayer.getConfigLabelsByPosition(4, 0).getLabels();
    assertEquals(2, labelsForIndex4.size());
    assertEquals("INDEX_4_LABEL", labelsForIndex4.get(0));
    assertEquals("EVEN_BODY", labelsForIndex4.get(1));
    // 0 1 2 3 4 - see DataLayerFixture
    this.columnReorderLayer.reorderColumnPosition(0, 5);
    // Index: 1 2 3 4 0 Width: 100 35 100 80 150
    labelsForIndex4 = this.columnReorderLayer.getConfigLabelsByPosition(3, 0).getLabels();
    assertEquals(2, labelsForIndex4.size());
    assertEquals("INDEX_4_LABEL", labelsForIndex4.get(0));
    assertEquals("EVEN_BODY", labelsForIndex4.get(1));
}
Also used : DataLayer(org.eclipse.nebula.widgets.nattable.layer.DataLayer) DataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.DataLayerFixture) BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) ColumnOverrideLabelAccumulator(org.eclipse.nebula.widgets.nattable.layer.cell.ColumnOverrideLabelAccumulator) Test(org.junit.Test)

Example 23 with DataLayerFixture

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

the class ColumnReorderLayerTest method commandPassedOnToParentIfCannotBeHandled.

@Test
public void commandPassedOnToParentIfCannotBeHandled() throws Exception {
    ColumnReorderLayer reorderLayer = new ColumnReorderLayer(new DataLayerFixture());
    assertFalse(reorderLayer.doCommand(new LayerCommandFixture()));
}
Also used : LayerCommandFixture(org.eclipse.nebula.widgets.nattable.test.fixture.command.LayerCommandFixture) 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 24 with DataLayerFixture

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

the class RowReorderLayerTest method getHeightForMultipleRowsReordering.

@SuppressWarnings("boxing")
@Test
public void getHeightForMultipleRowsReordering() throws Exception {
    this.underlyingLayer = new DataLayerFixture();
    this.rowReorderLayer = new RowReorderLayer(this.underlyingLayer);
    // 0 1 2 3 4 - see DataLayerFixture
    this.rowReorderLayer.reorderMultipleRowPositions(Arrays.asList(1, 2), 7);
    // 0 3 4 1 2
    assertEquals(40, this.rowReorderLayer.getRowHeightByPosition(0));
    assertEquals(40, this.rowReorderLayer.getRowHeightByPosition(1));
    assertEquals(50, this.rowReorderLayer.getRowHeightByPosition(2));
    assertEquals(40, this.rowReorderLayer.getRowHeightByPosition(3));
    assertEquals(100, this.rowReorderLayer.getRowHeightByPosition(4));
    assertEquals(70, this.rowReorderLayer.getRowHeightByPosition(5));
    assertEquals(25, this.rowReorderLayer.getRowHeightByPosition(6));
}
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 25 with DataLayerFixture

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

the class RowReorderLayerTest method getHeightForReorderedRows.

@Test
public void getHeightForReorderedRows() throws Exception {
    this.underlyingLayer = new DataLayerFixture();
    this.rowReorderLayer = new RowReorderLayer(this.underlyingLayer);
    // 0 1 2 3 4 - see DataLayerFixture
    this.rowReorderLayer.reorderRowPosition(0, 7);
    // 1 2 3 4 0
    Assert.assertEquals(70, this.rowReorderLayer.getRowHeightByPosition(0));
    Assert.assertEquals(25, this.rowReorderLayer.getRowHeightByPosition(1));
    Assert.assertEquals(40, this.rowReorderLayer.getRowHeightByPosition(2));
    Assert.assertEquals(50, this.rowReorderLayer.getRowHeightByPosition(3));
    Assert.assertEquals(40, this.rowReorderLayer.getRowHeightByPosition(4));
    Assert.assertEquals(100, this.rowReorderLayer.getRowHeightByPosition(5));
    Assert.assertEquals(40, this.rowReorderLayer.getRowHeightByPosition(6));
}
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