use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class RowHideShowLayerStructuralChangeEventTest method testHandleMultipleRowDeleteEvent.
@Test
public void testHandleMultipleRowDeleteEvent() {
// test start order: 0 1 2 3 4
assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
assertEquals(2, this.rowHideShowLayer.getRowIndexByPosition(2));
assertEquals(3, this.rowHideShowLayer.getRowIndexByPosition(3));
assertEquals(4, this.rowHideShowLayer.getRowIndexByPosition(4));
assertEquals("one", this.rowHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.rowHideShowLayer.getDataValueByPosition(0, 1));
assertEquals("three", this.rowHideShowLayer.getDataValueByPosition(0, 2));
assertEquals("four", this.rowHideShowLayer.getDataValueByPosition(0, 3));
assertEquals("five", this.rowHideShowLayer.getDataValueByPosition(0, 4));
// hide row at position 2: 0 1 3 4
List<Integer> rowsToHide = new ArrayList<Integer>();
rowsToHide.add(2);
this.rowHideShowLayer.hideRowPositions(rowsToHide);
assertEquals(4, this.rowHideShowLayer.getRowCount());
assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
assertEquals(3, this.rowHideShowLayer.getRowIndexByPosition(2));
assertEquals(4, this.rowHideShowLayer.getRowIndexByPosition(3));
assertEquals(-1, this.rowHideShowLayer.getRowIndexByPosition(4));
assertEquals("one", this.rowHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("two", this.rowHideShowLayer.getDataValueByPosition(0, 1));
assertEquals("four", this.rowHideShowLayer.getDataValueByPosition(0, 2));
assertEquals("five", this.rowHideShowLayer.getDataValueByPosition(0, 3));
// delete rows in the middle
this.contents.remove(1);
this.contents.remove(1);
this.contents.remove(1);
this.underlyingLayer.fireLayerEvent(new RowDeleteEvent(this.underlyingLayer, new Range(1, 4)));
assertEquals(2, this.rowHideShowLayer.getRowCount());
assertEquals(0, this.rowHideShowLayer.getRowIndexByPosition(0));
assertEquals(1, this.rowHideShowLayer.getRowIndexByPosition(1));
assertEquals(-1, this.rowHideShowLayer.getRowIndexByPosition(2));
assertEquals("one", this.rowHideShowLayer.getDataValueByPosition(0, 0));
assertEquals("five", this.rowHideShowLayer.getDataValueByPosition(0, 1));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class SelectionLayerStructuralChangeEventHandlerTest method shouldLeaveSelectionUnchangedIfASelectedRowIsNotModified.
@Test
public void shouldLeaveSelectionUnchangedIfASelectedRowIsNotModified() throws Exception {
this.selectionModel.addSelection(2, 3);
SelectionLayerStructuralChangeEventHandler handler = new SelectionLayerStructuralChangeEventHandler(this.selectionLayer);
handler.handleLayerEvent(new RowDeleteEvent(this.dataLayer, 5));
Assert.assertFalse(this.selectionModel.isEmpty());
Assert.assertTrue(this.selectionModel.isRowPositionSelected(3));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class SelectionLayerStructuralChangeEventHandlerTest method shouldLeaveSelectionUnchangedIfTheFollowingRowIsModified.
@Test
public void shouldLeaveSelectionUnchangedIfTheFollowingRowIsModified() throws Exception {
this.selectionModel.addSelection(3, 4);
SelectionLayerStructuralChangeEventHandler handler = new SelectionLayerStructuralChangeEventHandler(this.selectionLayer);
handler.handleLayerEvent(new RowDeleteEvent(this.dataLayer, 5));
Assert.assertFalse(this.selectionModel.isEmpty());
Assert.assertTrue(this.selectionModel.isRowPositionSelected(4));
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class SelectionLayerStructuralChangeEventHandlerTest method shouldClearSelectionIfASelectedRowIsModified.
@Test
public void shouldClearSelectionIfASelectedRowIsModified() throws Exception {
this.selectionModel.addSelection(2, 3);
SelectionLayerStructuralChangeEventHandler handler = new SelectionLayerStructuralChangeEventHandler(this.selectionLayer);
handler.handleLayerEvent(new RowDeleteEvent(this.dataLayer, 3));
Assert.assertTrue(this.selectionModel.isEmpty());
}
use of org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent in project nebula.widgets.nattable by eclipse.
the class SelectionModelStructuralChangeEventHandlerTest method shouldClearSelectionIfListIsCleared.
@Test
public void shouldClearSelectionIfListIsCleared() {
this.selectionModel.addSelection(3, 4);
this.selectionModel.handleLayerEvent(new RowDeleteEvent(this.dataLayer, new Range(0, 9)));
Assert.assertTrue(this.selectionModel.isEmpty());
}
Aggregations