Search in sources :

Example 1 with BaseDataLayerFixture

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

the class FreezeLayerTest method setup.

@Before
public void setup() {
    this.reorderLayer = new ColumnReorderLayer(new BaseDataLayerFixture(10, 10));
    this.hideShowLayer = new ColumnHideShowLayer(this.reorderLayer);
    this.freezeLayer = new FreezeLayer(this.hideShowLayer);
    this.freezeLayer.setTopLeftPosition(1, 0);
    this.freezeLayer.setBottomRightPosition(3, 3);
}
Also used : BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) FreezeLayer(org.eclipse.nebula.widgets.nattable.freeze.FreezeLayer) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnHideShowLayer(org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer) Before(org.junit.Before)

Example 2 with BaseDataLayerFixture

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

the class ColumnGroupReorderLayerTest method setUp.

@Before
public void setUp() {
    this.modelFixture = new ColumnGroupModelFixture();
    this.reorderLayer = new ColumnReorderLayer(new BaseDataLayerFixture(24, 20));
    this.layer = new ColumnGroupReorderLayer(this.reorderLayer, this.modelFixture);
}
Also used : BaseDataLayerFixture(org.eclipse.nebula.widgets.nattable.test.fixture.layer.BaseDataLayerFixture) ColumnGroupModelFixture(org.eclipse.nebula.widgets.nattable.test.fixture.group.ColumnGroupModelFixture) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) Before(org.junit.Before)

Example 3 with BaseDataLayerFixture

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

the class ColumnReorderLayerVisibleChangeTest method returnsCorrectPositionRectangleForMultiColumnReorderLeftCase.

@SuppressWarnings("boxing")
@Test
public /**
 * 	Index		10	11	12	13 ... 20
 *          --------------------
 *  Position 	0 	1	2	3 ... 20
 */
void returnsCorrectPositionRectangleForMultiColumnReorderLeftCase() {
    ColumnReorderLayer reorderLayer = new ColumnReorderLayer(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) {
            ColumnReorderEvent multiReorder = (ColumnReorderEvent) event;
            assertTrue(multiReorder.getChangedPositionRectangles().containsAll(expectedPositions));
        }
    });
    // Reorder to beginning of grid
    List<Integer> fromColumnPositions = Arrays.asList(new Integer[] { 10, 11, 12, 13 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 0);
    // Reorder to middle of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(10, 0, 10, 20));
    fromColumnPositions = Arrays.asList(new Integer[] { 19, 18, 17, 16 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 10);
    // Reorder to end of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(5, 0, 15, 20));
    fromColumnPositions = Arrays.asList(new Integer[] { 5, 6, 7, 8 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 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) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnReorderEvent(org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent) ILayerListener(org.eclipse.nebula.widgets.nattable.layer.ILayerListener) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with BaseDataLayerFixture

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

the class ColumnReorderLayerVisibleChangeTest method returnsCorrectPositionRectangleForMultiColumnReorderRightCase.

@SuppressWarnings("boxing")
@Test
public /**
 * 	Index		2	3	0	1 ... 20
 *          --------------------
 *  Position 	0 	1	2	3 ... 20
 */
void returnsCorrectPositionRectangleForMultiColumnReorderRightCase() {
    ColumnReorderLayer reorderLayer = new ColumnReorderLayer(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) {
            ColumnReorderEvent multiReorder = (ColumnReorderEvent) event;
            assertTrue(multiReorder.getChangedPositionRectangles().containsAll(expectedPositions));
        }
    });
    // Reorder from beginning of grid
    List<Integer> fromColumnPositions = Arrays.asList(new Integer[] { 0, 1 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 2);
    // Reorder to middle of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(5, 0, 15, 20));
    fromColumnPositions = Arrays.asList(new Integer[] { 5, 6, 7, 8 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 10);
    // Reorder to end of grid
    expectedPositions.clear();
    expectedPositions.add(new Rectangle(10, 0, 10, 20));
    fromColumnPositions = Arrays.asList(new Integer[] { 10, 11, 12, 13 });
    reorderLayer.reorderMultipleColumnPositions(fromColumnPositions, 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) ColumnReorderLayer(org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer) ColumnReorderEvent(org.eclipse.nebula.widgets.nattable.reorder.event.ColumnReorderEvent) ILayerListener(org.eclipse.nebula.widgets.nattable.layer.ILayerListener) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with BaseDataLayerFixture

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

the class RowReorderLayerTest method setUp.

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

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