Search in sources :

Example 11 with StructuralRefreshEvent

use of org.eclipse.nebula.widgets.nattable.layer.event.StructuralRefreshEvent in project nebula.widgets.nattable by eclipse.

the class RowSelectionModelStructuralChangeEventHandlerTest method shouldFireRowSelectionEventOnClear.

@Test
public void shouldFireRowSelectionEventOnClear() {
    // Select single row
    this.nattable.doCommand(new SelectRowsCommand(this.nattable, 5, 5, false, false));
    assertEquals(1, this.selectionLayer.getSelectedRowCount());
    assertEquals(1, this.listener.getEventsCount());
    assertTrue(this.listener.containsInstanceOf(RowSelectionEvent.class));
    RowSelectionEvent event = (RowSelectionEvent) this.listener.getReceivedEvents().get(0);
    assertEquals(4, event.getRowPositionRanges().iterator().next().start);
    assertEquals(5, event.getRowPositionRanges().iterator().next().end);
    // clear
    this.listFixture.clear();
    this.bodyDataLayer.fireLayerEvent(new StructuralRefreshEvent(this.bodyDataLayer));
    assertEquals(0, this.selectionLayer.getSelectedRowCount());
    assertEquals(3, this.listener.getEventsCount());
    assertTrue(this.listener.containsInstanceOf(RowSelectionEvent.class));
    event = (RowSelectionEvent) this.listener.getReceivedEvents().get(1);
    // since the underlying collection is cleared the ranges should be empty
    assertEquals(0, event.getRowPositionRanges().size());
}
Also used : RowSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent) StructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.StructuralRefreshEvent) RowStructuralRefreshEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent) SelectRowsCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand) Test(org.junit.Test)

Aggregations

RowStructuralRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowStructuralRefreshEvent)11 StructuralRefreshEvent (org.eclipse.nebula.widgets.nattable.layer.event.StructuralRefreshEvent)11 Test (org.junit.Test)11 SelectRowsCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand)9 RowDataFixture (org.eclipse.nebula.widgets.nattable.dataset.fixture.data.RowDataFixture)4 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)2 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)2 ListDataProvider (org.eclipse.nebula.widgets.nattable.data.ListDataProvider)2 DataLayer (org.eclipse.nebula.widgets.nattable.layer.DataLayer)2 NatTableFixture (org.eclipse.nebula.widgets.nattable.test.fixture.NatTableFixture)2 GridLayerFixture (org.eclipse.nebula.widgets.nattable.test.fixture.layer.GridLayerFixture)2 RowSelectionEvent (org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent)1