Search in sources :

Example 11 with BaseDataLayerFixture

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

the class RowReorderLayerVisibleChangeTest method returnsCorrectPositionRectangleForMultiColumnReorderRightCase.

@SuppressWarnings("boxing")
@Test
public /**
 * 	Index		2	3	0	1 ... 20
 *          --------------------
 *  Position 	0 	1	2	3 ... 20
 */
void returnsCorrectPositionRectangleForMultiColumnReorderRightCase() {
    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 from beginning of grid
    List<Integer> fromRowPositions = Arrays.asList(new Integer[] { 0, 1 });
    reorderLayer.reorderMultipleRowPositions(fromRowPositions, 2);
    // Reorder to middle 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);
    // Reorder to end of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(0, 10, 20, 10));
    fromRowPositions = Arrays.asList(new Integer[] { 10, 11, 12, 13 });
    reorderLayer.reorderMultipleRowPositions(fromRowPositions, 19);
}
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)

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