Search in sources :

Example 36 with UpdateDataCommand

use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerTest method shouldNotDirtyNullToNull.

@Test
public void shouldNotDirtyNullToNull() {
    this.dataLayer.setDataValue(1, 1, null);
    assertNull(this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, null));
    assertNull(this.dataLayer.getDataValue(1, 1));
    assertNull(this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(1));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 1));
}
Also used : UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Example 37 with UpdateDataCommand

use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerTest method shouldDiscardToOriginalAfterMultipleChanges.

@Test
public void shouldDiscardToOriginalAfterMultipleChanges() {
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Flanders"));
    assertEquals("Flanders", this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new DiscardDataChangesCommand());
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(1));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 1));
    assertTrue("changed columns are not empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertTrue("changed rows are not empty", this.dataChangeLayer.changedRows.isEmpty());
    assertTrue("changes are not empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : DiscardDataChangesCommand(org.eclipse.nebula.widgets.nattable.datachange.command.DiscardDataChangesCommand) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Example 38 with UpdateDataCommand

use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerTest method shouldUpdateNullValueAndBackAgain.

@Test
public void shouldUpdateNullValueAndBackAgain() {
    this.dataLayer.setDataValue(1, 1, null);
    assertNull(this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
    assertTrue("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(1));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, null));
    assertNull(this.dataLayer.getDataValue(1, 1));
    assertNull(this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(1));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 1));
}
Also used : UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Example 39 with UpdateDataCommand

use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerTest method shouldNotBeDirtyOnSettingSameValue.

@Test
public void shouldNotBeDirtyOnSettingSameValue() {
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
    assertTrue("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(1));
    assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Simpson"));
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
    assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(1));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 1));
}
Also used : UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Example 40 with UpdateDataCommand

use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.

the class DataChangeLayerTest method shouldSaveChanges.

@Test
public void shouldSaveChanges() {
    assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    this.dataChangeLayer.doCommand(new SaveDataChangesCommand());
    assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
    assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 1));
    assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
    assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
    assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(1));
    assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 1));
    assertTrue("changed columns are not empty", this.dataChangeLayer.changedColumns.isEmpty());
    assertTrue("changed rows are not empty", this.dataChangeLayer.changedRows.isEmpty());
    assertTrue("changes are not empty", this.dataChangeLayer.dataChanges.isEmpty());
}
Also used : SaveDataChangesCommand(org.eclipse.nebula.widgets.nattable.datachange.command.SaveDataChangesCommand) UpdateDataCommand(org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand) Test(org.junit.Test)

Aggregations

UpdateDataCommand (org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand)63 Test (org.junit.Test)52 RowDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowDeleteEvent)10 DiscardDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.DiscardDataChangesCommand)7 SaveDataChangesCommand (org.eclipse.nebula.widgets.nattable.datachange.command.SaveDataChangesCommand)6 Person (org.eclipse.nebula.widgets.nattable.dataset.person.Person)6 ILayerCell (org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell)5 Date (java.util.Date)4 Range (org.eclipse.nebula.widgets.nattable.coordinate.Range)4 ColumnDeleteEvent (org.eclipse.nebula.widgets.nattable.layer.event.ColumnDeleteEvent)4 RowInsertEvent (org.eclipse.nebula.widgets.nattable.layer.event.RowInsertEvent)4 StructuralRefreshCommand (org.eclipse.nebula.widgets.nattable.command.StructuralRefreshCommand)3 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 IConfigRegistry (org.eclipse.nebula.widgets.nattable.config.IConfigRegistry)2 PositionCoordinate (org.eclipse.nebula.widgets.nattable.coordinate.PositionCoordinate)2 DataUpdateEvent (org.eclipse.nebula.widgets.nattable.edit.event.DataUpdateEvent)2 ClearAllFiltersCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearAllFiltersCommand)2 ClearFilterCommand (org.eclipse.nebula.widgets.nattable.filterrow.command.ClearFilterCommand)2 CellVisualChangeEvent (org.eclipse.nebula.widgets.nattable.layer.event.CellVisualChangeEvent)2