use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerTempStorageTest method shouldUpdateToNullAndBackAgain.
@Test
public void shouldUpdateToNullAndBackAgain() {
assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, null));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
assertEquals(null, 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));
}
use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerTempStorageTest method shouldDiscardChanges.
@Test
public void shouldDiscardChanges() {
assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 1));
this.dataChangeLayer.doCommand(new DiscardDataChangesCommand());
assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
assertEquals("Simpson", this.dataChangeLayer.getDataValueByPosition(1, 1));
assertFalse("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
assertFalse("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(1));
assertFalse("Cell is not 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());
}
use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerTempStorageTest method shouldSaveAfterDelete.
@Test
public void shouldSaveAfterDelete() {
assertEquals("Simpson", this.dataLayer.getDataValue(1, 9));
assertEquals("Flanders", this.dataLayer.getDataValue(1, 10));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 9, "Lovejoy"));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 9));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 9));
assertEquals("Flanders", this.dataLayer.getDataValue(1, 10));
// delete a row before the change
this.dataModel.remove(2);
this.dataLayer.fireLayerEvent(new RowDeleteEvent(this.dataLayer, 2));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 8));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 8));
assertEquals("Flanders", this.dataLayer.getDataValue(1, 9));
assertEquals("Flanders", this.dataChangeLayer.getDataValueByPosition(1, 9));
assertTrue("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 8).hasLabel(DataChangeLayer.DIRTY));
assertTrue("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
assertTrue("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(8));
assertTrue("Cell is not dirty", this.dataChangeLayer.isCellDirty(1, 8));
assertFalse("changed columns are empty", this.dataChangeLayer.changedColumns.isEmpty());
assertFalse("changed rows are empty", this.dataChangeLayer.changedRows.isEmpty());
assertFalse("changes are empty", this.dataChangeLayer.dataChanges.isEmpty());
// now discard and check that previous state is restored correctly
this.dataChangeLayer.doCommand(new SaveDataChangesCommand());
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 8));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 8));
assertEquals("Flanders", this.dataLayer.getDataValue(1, 9));
assertEquals("Flanders", this.dataChangeLayer.getDataValueByPosition(1, 9));
assertFalse("Dirty label set", this.dataChangeLayer.getConfigLabelsByPosition(1, 8).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Column 1 is dirty", this.dataChangeLayer.isColumnDirty(1));
assertFalse("Row 1 is dirty", this.dataChangeLayer.isRowDirty(8));
assertFalse("Cell is dirty", this.dataChangeLayer.isCellDirty(1, 8));
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());
}
use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerTempStorageTest method shouldNotBeDirtyForSameValue.
@Test
public void shouldNotBeDirtyForSameValue() {
assertEquals("Simpson", this.dataLayer.getDataValue(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));
}
use of org.eclipse.nebula.widgets.nattable.edit.command.UpdateDataCommand in project nebula.widgets.nattable by eclipse.
the class DataChangeLayerTempStorageTest method shouldSaveChanges.
@Test
public void shouldSaveChanges() {
assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Lovejoy"));
assertEquals("Simpson", this.dataLayer.getDataValue(1, 1));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 1));
this.dataChangeLayer.doCommand(new SaveDataChangesCommand());
assertEquals("Lovejoy", this.dataLayer.getDataValue(1, 1));
assertEquals("Lovejoy", this.dataChangeLayer.getDataValueByPosition(1, 1));
assertFalse("Dirty label not set", this.dataChangeLayer.getConfigLabelsByPosition(1, 1).hasLabel(DataChangeLayer.DIRTY));
assertFalse("Column 1 is not dirty", this.dataChangeLayer.isColumnDirty(1));
assertFalse("Row 1 is not dirty", this.dataChangeLayer.isRowDirty(1));
assertFalse("Cell is not 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());
assertEquals(1, this.listener.getReceivedEvents().size());
assertTrue(this.listener.getReceivedEvents().get(0) instanceof DataUpdateEvent);
}
Aggregations