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));
}
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);
}
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);
}
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);
}
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));
}
Aggregations