Search in sources :

Example 31 with RowDeleteEvent

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

the class SelectionLayerStructuralChangeEventHandlerTest method shouldClearSelectionIfListIsCleared.

@Test
public void shouldClearSelectionIfListIsCleared() {
    this.selectionModel.addSelection(3, 4);
    SelectionLayerStructuralChangeEventHandler handler = new SelectionLayerStructuralChangeEventHandler(this.selectionLayer);
    handler.handleLayerEvent(new RowDeleteEvent(this.dataLayer, new Range(0, 9)));
    Assert.assertTrue(this.selectionModel.isEmpty());
}
Also used : SelectionLayerStructuralChangeEventHandler(org.eclipse.nebula.widgets.nattable.selection.event.SelectionLayerStructuralChangeEventHandler) RowDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent) Range(org.eclipse.nebula.widgets.nattable.coordinate.Range) Test(org.junit.Test)

Example 32 with RowDeleteEvent

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

the class SelectionModelStructuralChangeEventHandlerTest method shouldLeaveSelectionUnchangedIfTheFollowingRowIsModified.

@Test
public void shouldLeaveSelectionUnchangedIfTheFollowingRowIsModified() {
    this.selectionModel.addSelection(3, 4);
    this.selectionModel.handleLayerEvent(new RowDeleteEvent(this.dataLayer, 5));
    Assert.assertFalse(this.selectionModel.isEmpty());
    Assert.assertTrue(this.selectionModel.isRowPositionSelected(4));
}
Also used : RowDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent) Test(org.junit.Test)

Example 33 with RowDeleteEvent

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

the class SelectionModelStructuralChangeEventHandlerTest method shouldLeaveSelectionUnchangedIfASelectedRowIsNotModified.

@Test
public void shouldLeaveSelectionUnchangedIfASelectedRowIsNotModified() {
    this.selectionModel.addSelection(2, 3);
    this.selectionModel.handleLayerEvent(new RowDeleteEvent(this.dataLayer, 5));
    Assert.assertFalse(this.selectionModel.isEmpty());
    Assert.assertTrue(this.selectionModel.isRowPositionSelected(3));
}
Also used : RowDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent) Test(org.junit.Test)

Example 34 with RowDeleteEvent

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

the class RowStructuralChangeEventIntegrationTest method testDeleteLastRow.

@Test
public void testDeleteLastRow() {
    testInit();
    // delete last row
    int index = this.contents.size() - 1;
    this.contents.remove(index);
    this.underlyingLayer.fireLayerEvent(new RowDeleteEvent(this.underlyingLayer, index));
    assertEquals(4, this.viewportLayer.getRowCount());
}
Also used : RowDeleteEvent(org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent) Test(org.junit.Test)

Example 35 with RowDeleteEvent

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

the class RowSelectionModelStructuralChangeEventHandlerTest method shouldRemoveSelectionOnDelete.

@Test
public void shouldRemoveSelectionOnDelete() {
    assertEquals(0, this.selectionLayer.getFullySelectedRowPositions().length);
    this.nattable.doCommand(new SelectRowsCommand(this.nattable, 1, 1, false, false));
    assertEquals(1, this.selectionLayer.getFullySelectedRowPositions().length);
    // Ford motor at top and selected
    assertEquals("B Ford Motor", this.nattable.getDataValueByPosition(2, 1).toString());
    assertEquals("B Ford Motor", getSelected().getSecurity_description());
    this.listFixture.remove(0);
    // fire event to trigger structural refresh
    this.bodyDataLayer.fireLayerEvent(new RowDeleteEvent(this.bodyDataLayer, 0));
    // another value on top now
    assertEquals("A Alphabet Co.", this.nattable.getDataValueByPosition(2, 1).toString());
    // selection should be empty since the selected row was deleted
    assertEquals(0, this.selectionLayer.getFullySelectedRowPositions().length);
    assertEquals(0, this.selectionLayer.getSelectedRowCount());
}
Also used : 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