use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer 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);
}
use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer 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);
}
use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.
the class SummaryRowIntegrationTest method initLayerStackWithSummaryRow.
@Before
public void initLayerStackWithSummaryRow() {
this.dataList = RowDataListFixture.getList().subList(0, 4);
// Rows 0, 1, 2, 3; Summary row would be position 4
assertEquals(4, this.dataList.size());
this.dataProvider = new ListDataProvider<RowDataFixture>(this.dataList, new ReflectiveColumnPropertyAccessor<RowDataFixture>(RowDataListFixture.getPropertyNames()));
IConfigRegistry configRegistry = new ConfigRegistry();
this.dataLayer = new DataLayer(this.dataProvider);
this.summaryRowLayer = new SummaryRowLayer(this.dataLayer, configRegistry);
IUniqueIndexLayer columnReorderLayer = new ColumnReorderLayer(this.summaryRowLayer);
IUniqueIndexLayer columnHideShowLayer = new ColumnHideShowLayer(columnReorderLayer);
IUniqueIndexLayer selectionLayer = new SelectionLayer(columnHideShowLayer);
this.layerStackWithSummary = new ViewportLayer(selectionLayer);
// NatTableFixture initializes the client area
this.natTable = new NatTableFixture(this.layerStackWithSummary, false);
this.natTable.setConfigRegistry(configRegistry);
this.natTable.addConfiguration(new TestSummaryRowConfiguration());
this.natTable.configure();
}
use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateReorderOnInsert.
@Test
public void shouldUpdateReorderOnInsert() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
body.doCommand(new ColumnReorderCommand(body, 3, 6));
body.doCommand(new ColumnReorderCommand(body, 3, 5));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
}
use of org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer in project nebula.widgets.nattable by eclipse.
the class ColumnStructuralChangeEventIntegrationTest method shouldUpdateOnInsertAndDelete.
@Test
public void shouldUpdateOnInsertAndDelete() {
DefaultBodyLayerStack body = this.grid.getBodyLayer();
ColumnReorderLayer reorderLayer = body.getColumnReorderLayer();
ColumnHideShowLayer hideShowLayer = body.getColumnHideShowLayer();
body.doCommand(new ColumnReorderCommand(body, 3, 6));
body.doCommand(new ColumnReorderCommand(body, 3, 5));
body.doCommand(new MultiColumnHideCommand(body, new int[] { 2, 3, 5 }));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(7);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnInsertEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 3, 6, 5, 4]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 4, 6]", hideShowLayer.getHiddenColumnIndexes().toString());
this.provider.setColumnCount(6);
this.grid.getBodyDataLayer().fireLayerEvent(new ColumnDeleteEvent(this.grid.getBodyDataLayer(), 3));
assertEquals("[0, 1, 2, 5, 4, 3]", reorderLayer.getColumnIndexOrder().toString());
assertEquals("[2, 3, 5]", hideShowLayer.getHiddenColumnIndexes().toString());
}
Aggregations