Search in sources :

Example 6 with BaseDataLayerFixture

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

the class RowReorderLayerTest method reorderMultipleRowsLargeArrayToEdges.

@SuppressWarnings("boxing")
@Test
public /**
 * 	Index		2	3	0	1 ... 20
 *          --------------------
 *  Position 	0 	1	2	3 ... 20
 */
void reorderMultipleRowsLargeArrayToEdges() throws Exception {
    RowReorderLayer reorderLayer = new RowReorderLayer(new BaseDataLayerFixture(20, 20));
    List<Integer> fromRowPositions = Arrays.asList(new Integer[] { 10, 11, 12, 13 });
    reorderLayer.reorderMultipleRowPositions(fromRowPositions, 0);
    assertEquals(10, reorderLayer.getRowIndexByPosition(0));
    assertEquals(11, reorderLayer.getRowIndexByPosition(1));
    assertEquals(12, reorderLayer.getRowIndexByPosition(2));
    assertEquals(13, reorderLayer.getRowIndexByPosition(3));
    assertEquals(0, reorderLayer.getRowIndexByPosition(4));
    fromRowPositions = Arrays.asList(new Integer[] { 8, 9, 10, 11 });
    reorderLayer.reorderMultipleRowPositions(fromRowPositions, 8);
    assertEquals(4, reorderLayer.getRowIndexByPosition(8));
    assertEquals(5, reorderLayer.getRowIndexByPosition(9));
    assertEquals(6, reorderLayer.getRowIndexByPosition(10));
    assertEquals(7, reorderLayer.getRowIndexByPosition(11));
    fromRowPositions = Arrays.asList(new Integer[] { 8, 9, 10, 11 });
    reorderLayer.reorderMultipleRowPositions(fromRowPositions, reorderLayer.getColumnCount());
    assertEquals(7, reorderLayer.getRowIndexByPosition(19));
    assertEquals(6, reorderLayer.getRowIndexByPosition(18));
    assertEquals(5, reorderLayer.getRowIndexByPosition(17));
    assertEquals(4, reorderLayer.getRowIndexByPosition(16));
}
Also used : BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) Test(org.junit.Test)

Example 7 with BaseDataLayerFixture

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

the class RowReorderLayerVisibleChangeTest method returnsCorrectPositionRectangleForMultiColumnReorderLeftCase.

@SuppressWarnings("boxing")
@Test
public /**
 * 	Index		10	11	12	13 ... 20
 *          --------------------
 *  Position 	0 	1	2	3 ... 20
 */
void returnsCorrectPositionRectangleForMultiColumnReorderLeftCase() {
    RowReorderLayer reorderLayer = new RowReorderLayer(new BaseDataLayerFixture(20, 20));
    // Build expected cell positions to redraw
    final Set<Rectangle> expectedPositions = new HashSet<Rectangle>();
    expectedPositions.add(new Rectangle(0, 0, 20, 20));
    reorderLayer.addLayerListener(new ILayerListener() {

        @Override
        public void handleLayerEvent(ILayerEvent event) {
            RowReorderEvent multiReorder = (RowReorderEvent) event;
            assertTrue(multiReorder.getChangedPositionRectangles().containsAll(expectedPositions));
        }
    });
    // Reorder to beginning of grid
    List<Integer> fromRowPositions = Arrays.asList(new Integer[] { 10, 11, 12, 13 });
    reorderLayer.reorderMultipleRowPositions(fromRowPositions, 0);
    // Reorder to middle of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(0, 10, 20, 10));
    fromRowPositions = Arrays.asList(new Integer[] { 19, 18, 17, 16 });
    reorderLayer.reorderMultipleRowPositions(fromRowPositions, 10);
    // Reorder to end of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(0, 5, 20, 15));
    fromRowPositions = Arrays.asList(new Integer[] { 5, 6, 7, 8 });
    reorderLayer.reorderMultipleRowPositions(fromRowPositions, 10);
}
Also used : ILayerEvent(org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent) BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) Rectangle(org.eclipse.swt.graphics.Rectangle) ILayerListener(org.eclipse.nebula.widgets.nattable.layer.ILayerListener) RowReorderEvent(org.eclipse.nebula.widgets.nattable.reorder.event.RowReorderEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with BaseDataLayerFixture

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

the class GridLayerTest method setup.

@Before
public void setup() {
    this.bodyDataLayer = new BaseDataLayerFixture();
    this.columnHeaderDataLayer = new BaseDataLayerFixture();
    this.rowHeaderDataLayer = new BaseDataLayerFixture();
    this.cornerDataLayer = new BaseDataLayerFixture();
    this.gridLayerUnderTest = new DefaultGridLayer(this.bodyDataLayer, this.columnHeaderDataLayer, this.rowHeaderDataLayer, this.cornerDataLayer);
}
Also used : BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) DefaultGridLayer(org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer) Before(org.junit.Before)

Example 9 with BaseDataLayerFixture

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

the class ColumnReorderLayerTest method setUp.

@Before
public void setUp() {
    this.underlyingLayer = new BaseDataLayerFixture(4, 4);
    this.columnReorderLayer = new ColumnReorderLayer(this.underlyingLayer);
}
Also used : BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) Before(org.junit.Before)

Example 10 with BaseDataLayerFixture

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

the class ColumnReorderLayerTest method reorderMultipleColumnsLargeArrayToEdges.

@SuppressWarnings("boxing")
@Test
public /**
 * 	Index		2	3	0	1 ... 20
 *          --------------------
 *  Position 	0 	1	2	3 ... 20
 */
void reorderMultipleColumnsLargeArrayToEdges() throws Exception {
    ColumnReorderLayer reorderLayer = new ColumnReorderLayer(new BaseDataLayerFixture(20, 20));
    List<Integer> fromColumnPositions = Arrays.asList(new Integer[] { 10, 11, 12, 13 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 0);
    assertEquals(10, reorderLayer.getColumnIndexByPosition(0));
    assertEquals(11, reorderLayer.getColumnIndexByPosition(1));
    assertEquals(12, reorderLayer.getColumnIndexByPosition(2));
    assertEquals(13, reorderLayer.getColumnIndexByPosition(3));
    assertEquals(0, reorderLayer.getColumnIndexByPosition(4));
    fromColumnPositions = Arrays.asList(new Integer[] { 8, 9, 10, 11 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 8);
    assertEquals(4, reorderLayer.getColumnIndexByPosition(8));
    assertEquals(5, reorderLayer.getColumnIndexByPosition(9));
    assertEquals(6, reorderLayer.getColumnIndexByPosition(10));
    assertEquals(7, reorderLayer.getColumnIndexByPosition(11));
    fromColumnPositions = Arrays.asList(new Integer[] { 8, 9, 10, 11 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, reorderLayer.getColumnCount());
    /*
         * System.out.println("\n"); // See output for idea on what is going on
         * for (int i = 0; i < reorderLayer.getColumnCount(); i++)
         * System.out.println(i + "\t" +
         * reorderLayer.getColumnIndexByPosition(i));
         */
    assertEquals(7, reorderLayer.getColumnIndexByPosition(19));
    assertEquals(6, reorderLayer.getColumnIndexByPosition(18));
    assertEquals(5, reorderLayer.getColumnIndexByPosition(17));
    assertEquals(4, reorderLayer.getColumnIndexByPosition(16));
}
Also used : BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) Test(org.junit.Test)

Aggregations

BaseDataLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture)11 Test (org.junit.Test)6 Before (org.junit.Before)5 HashSet (java.util.HashSet)4 ILayerListener (org.eclipse.nebula.widgets.nattable.layer.ILayerListener)4 ILayerEvent (org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent)4 ColumnReorderLayer (org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 ColumnReorderEvent (org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent)2 RowReorderEvent (org.eclipse.nebula.widgets.nattable.reorder.event.RowReorderEvent)2 FreezeLayer (org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer)1 DefaultGridLayer (org.eclipse.nebula.widgets.nattable.grid.layer.DefaultGridLayer)1 ColumnHideShowLayer (org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer)1 ColumnGroupModelFixture (org.eclipse.nebula.widgets.nattable.test.fixture.group.ColumnGroupModelFixture)1