Search in sources :

Example 36 with RowDeleteEvent

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

the class RowSelectionModelStructuralChangeEventHandlerTest method shouldFireRowSelectionEventOnDelete.

@Test
public void shouldFireRowSelectionEventOnDelete() {
    // 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);
    // Delete the selected row
    this.listFixture.remove(4);
    this.bodyDataLayer.fireLayerEvent(new RowDeleteEvent(this.bodyDataLayer, 4));
    assertEquals(0, this.selectionLayer.getSelectedRowCount());
    assertEquals(3, this.listener.getEventsCount());
    assertTrue(this.listener.containsInstanceOf(RowSelectionEvent.class));
    event = (RowSelectionEvent) this.listener.getReceivedEvents().get(1);
    assertEquals(1, event.getRowPositionRanges().size());
    assertEquals(4, event.getRowPositionRanges().iterator().next().start);
    assertEquals(5, event.getRowPositionRanges().iterator().next().end);
}
Also used : RowSelectionEvent(org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent) RowDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent) SelectRowsCommand(org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand) Test(org.junit.Test)

Aggregations

RowDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent)36 Test (org.junit.Test)35 UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)10 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)9 ArrayList (java.util.ArrayList)5 SelectRowsCommand (org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand)4 SelectionLayerStructuralChangeEventHandler (org.eclipse.nebula.widgets.nattable.selection.event.SelectionLayerStructuralChangeEventHandler)4 DiscardDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.DiscardDataChangesCommand)2 SaveDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.SaveDataChangesCommand)2 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)2 RowInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowInsertEvent)2 EventList (ca.odell.glazedlists.EventList)1 FilterList (ca.odell.glazedlists.FilterList)1 SortedList (ca.odell.glazedlists.SortedList)1 TransformedList (ca.odell.glazedlists.TransformedList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 NatTable (org.eclipse.nebula.widgets.nattable.NatTable)1 AbstractRegistryConfiguration (org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration)1 ConfigRegistry (org.eclipse.nebula.widgets.nattable.config.ConfigRegistry)1