Skip to content

Commit

Permalink
Impl #64 - [Data Changes] Add API to easily check if state is dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
fipro78 committed Apr 29, 2024
1 parent 91bb887 commit 4179d9c
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 15 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.nebula.widgets.nattable.core.test/.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.nebula.widgets.nattable.core.tests</name>
<name>org.eclipse.nebula.widgets.nattable.core.test</name>
<comment>NatTable Core Tests</comment>
<projects>
</projects>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: NatTable Core Tests
Bundle-SymbolicName: org.eclipse.nebula.widgets.nattable.core.tests
Bundle-SymbolicName: org.eclipse.nebula.widgets.nattable.core.test
Bundle-Version: 2.4.0.qualifier
Fragment-Host: org.eclipse.nebula.widgets.nattable.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Expand All @@ -22,4 +22,4 @@ Export-Package: org.eclipse.nebula.widgets.nattable.test.fixture,
org.eclipse.nebula.widgets.nattable.test.fixture.layer,
org.eclipse.nebula.widgets.nattable.test.integration
Bundle-Vendor: Eclipse Nebula NatTable
Automatic-Module-Name: org.eclipse.nebula.widgets.nattable.core.tests
Automatic-Module-Name: org.eclipse.nebula.widgets.nattable.core.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017, 2022 Dirk Fauth.
* Copyright (c) 2017, 2024 Dirk Fauth.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -95,6 +95,7 @@ public void shouldUpdateDataInDataLayer() {
assertTrue(this.dataChangeLayer.isColumnDirty(1), "Column 1 is not dirty");
assertTrue(this.dataChangeLayer.isRowDirty(1), "Row 1 is not dirty");
assertTrue(this.dataChangeLayer.isCellDirty(1, 1), "Cell is not dirty");
assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");
}

@Test
Expand All @@ -114,6 +115,7 @@ public void shouldClearWithoutReset() {
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(1), "Row 1 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 1), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");

assertTrue(this.handler.changedColumns.isEmpty(), "changed columns are not empty");
assertTrue(this.handler.changedRows.isEmpty(), "changed rows are not empty");
Expand All @@ -137,6 +139,7 @@ public void shouldDiscardChanges() {
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(1), "Row 1 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 1), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");

assertTrue(this.handler.changedColumns.isEmpty(), "changed columns are not empty");
assertTrue(this.handler.changedRows.isEmpty(), "changed rows are not empty");
Expand All @@ -160,6 +163,7 @@ public void shouldSaveChanges() {
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(1), "Row 1 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 1), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");

assertTrue(this.handler.changedColumns.isEmpty(), "changed columns are not empty");
assertTrue(this.handler.changedRows.isEmpty(), "changed rows are not empty");
Expand All @@ -184,6 +188,7 @@ public void shouldClearOnStructuralChange() {
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(1), "Row 1 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 1), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");

assertTrue(this.handler.changedColumns.isEmpty(), "changed columns are not empty");
assertTrue(this.handler.changedRows.isEmpty(), "changed rows are not empty");
Expand Down Expand Up @@ -212,6 +217,7 @@ public void shouldRemoveChangeOnRowDelete() {
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(2), "Row 1 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 2), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");

assertTrue(this.handler.changedColumns.isEmpty(), "changed columns are not empty");
assertTrue(this.handler.changedRows.isEmpty(), "changed rows are not empty");
Expand Down Expand Up @@ -242,6 +248,7 @@ public void shouldUpdateChangeOnRowDelete() {
assertTrue(this.dataChangeLayer.isColumnDirty(1), "Column 1 is not dirty");
assertTrue(this.dataChangeLayer.isRowDirty(2), "Row 1 is not dirty");
assertTrue(this.dataChangeLayer.isCellDirty(1, 2), "Cell is not dirty");
assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");

assertFalse(this.handler.changedColumns.isEmpty(), "changed columns are empty");
assertFalse(this.handler.changedRows.isEmpty(), "changed rows are empty");
Expand Down Expand Up @@ -310,6 +317,8 @@ public void shouldUpdateOnMultiRowDelete() {
assertFalse(this.dataChangeLayer.getConfigLabelsByPosition(1, 11).hasLabel(DataChangeLayer.DIRTY), "Dirty label set");
assertFalse(this.dataChangeLayer.getConfigLabelsByPosition(1, 12).hasLabel(DataChangeLayer.DIRTY), "Dirty label set");

assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");

assertTrue(this.dataChangeLayer.isColumnDirty(1), "Column 1 is not dirty");

assertTrue(this.dataChangeLayer.isRowDirty(0), "Row 0 is not dirty");
Expand Down Expand Up @@ -365,6 +374,7 @@ public void shouldUpdateChangeOnRowInsert() {
assertTrue(this.dataChangeLayer.isColumnDirty(1), "Column 1 is not dirty");
assertTrue(this.dataChangeLayer.isRowDirty(3), "Row 1 is not dirty");
assertTrue(this.dataChangeLayer.isCellDirty(1, 3), "Cell is not dirty");
assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");

assertFalse(this.handler.changedColumns.isEmpty(), "changed columns are empty");
assertFalse(this.handler.changedRows.isEmpty(), "changed rows are empty");
Expand Down Expand Up @@ -454,6 +464,8 @@ public void shouldUpdateOnMultiRowInsert() {
assertTrue(this.dataChangeLayer.getConfigLabelsByPosition(1, 14).hasLabel(DataChangeLayer.DIRTY), "Dirty label not set");
assertFalse(this.dataChangeLayer.getConfigLabelsByPosition(1, 15).hasLabel(DataChangeLayer.DIRTY), "Dirty label set");

assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");

assertTrue(this.dataChangeLayer.isColumnDirty(1), "Column 1 is not dirty");

assertFalse(this.dataChangeLayer.isRowDirty(0), "Row 0 is not dirty");
Expand Down Expand Up @@ -507,6 +519,7 @@ public void shouldRemoveChangeOnColumnDelete() {
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(2), "Row 2 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 2), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");

assertTrue(this.handler.changedColumns.isEmpty(), "changed columns are not empty");
assertTrue(this.handler.changedRows.isEmpty(), "changed rows are not empty");
Expand All @@ -531,6 +544,7 @@ public void shouldUpdateChangeOnColumnDelete() {
assertTrue(this.dataChangeLayer.isColumnDirty(0), "Column 0 is not dirty");
assertTrue(this.dataChangeLayer.isRowDirty(2), "Row 2 is not dirty");
assertTrue(this.dataChangeLayer.isCellDirty(0, 2), "Cell is not dirty");
assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");

assertFalse(this.handler.changedColumns.isEmpty(), "changed columns are empty");
assertFalse(this.handler.changedRows.isEmpty(), "changed rows are empty");
Expand All @@ -555,6 +569,7 @@ public void shouldUpdateChangeOnColumnInsert() {
assertTrue(this.dataChangeLayer.isColumnDirty(2), "Column 2 is not dirty");
assertTrue(this.dataChangeLayer.isRowDirty(2), "Row 2 is not dirty");
assertTrue(this.dataChangeLayer.isCellDirty(2, 2), "Cell is not dirty");
assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");

assertFalse(this.handler.changedColumns.isEmpty(), "changed columns are empty");
assertFalse(this.handler.changedRows.isEmpty(), "changed rows are empty");
Expand Down Expand Up @@ -585,6 +600,7 @@ public void shouldUpdateChangeOnSortAndDiscard() {
assertFalse(this.dataChangeLayer.isRowDirty(2), "Row 2 is dirty");
assertTrue(this.dataChangeLayer.isRowDirty(17), "Row 17 is not dirty");
assertTrue(this.dataChangeLayer.isCellDirty(1, 17), "Cell is not dirty");
assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");

assertFalse(this.handler.changedColumns.isEmpty(), "changed columns are empty");
assertFalse(this.handler.changedRows.isEmpty(), "changed rows are empty");
Expand All @@ -602,6 +618,7 @@ public void shouldUpdateChangeOnSortAndDiscard() {
assertFalse(this.dataChangeLayer.isRowDirty(2), "Row 2 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(17), "Row 17 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 17), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");

assertTrue(this.handler.changedColumns.isEmpty(), "changed columns are not empty");
assertTrue(this.handler.changedRows.isEmpty(), "changed rows are not empty");
Expand Down Expand Up @@ -658,6 +675,7 @@ public Serializable getRowId(Person rowObject) {
assertFalse(this.dataChangeLayer.isRowDirty(2), "Row 2 is dirty");
assertTrue(this.dataChangeLayer.isRowDirty(17), "Row 17 is not dirty");
assertTrue(this.dataChangeLayer.isCellDirty(1, 17), "Cell is not dirty");
assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");

assertFalse(tempHandler.changedColumns.isEmpty(), "changed columns are empty");
assertFalse(tempHandler.changedRows.isEmpty(), "changed rows are empty");
Expand All @@ -675,6 +693,7 @@ public Serializable getRowId(Person rowObject) {
assertFalse(this.dataChangeLayer.isRowDirty(2), "Row 2 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(17), "Row 17 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 17), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");

assertTrue(tempHandler.changedColumns.isEmpty(), "changed columns are not empty");
assertTrue(tempHandler.changedRows.isEmpty(), "changed rows are not empty");
Expand All @@ -694,6 +713,7 @@ public void shouldNotBeDirtyForSameValue() {
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(1), "Row 1 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 1), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");
assertEquals(0, this.dataChangeLayer.dataChanges.size());
}

Expand All @@ -709,6 +729,7 @@ public void shouldNotBeDirtyOnSettingSameValue() {
assertTrue(this.dataChangeLayer.isColumnDirty(1), "Column 1 is not dirty");
assertTrue(this.dataChangeLayer.isRowDirty(1), "Row 1 is not dirty");
assertTrue(this.dataChangeLayer.isCellDirty(1, 1), "Cell is not dirty");
assertTrue(this.dataChangeLayer.isDirty(), "State is not dirty");
assertEquals(1, this.dataChangeLayer.dataChanges.size());

this.dataChangeLayer.doCommand(new UpdateDataCommand(this.dataChangeLayer, 1, 1, "Simpson"));
Expand All @@ -719,6 +740,7 @@ public void shouldNotBeDirtyOnSettingSameValue() {
assertFalse(this.dataChangeLayer.isColumnDirty(1), "Column 1 is dirty");
assertFalse(this.dataChangeLayer.isRowDirty(1), "Row 1 is dirty");
assertFalse(this.dataChangeLayer.isCellDirty(1, 1), "Cell is dirty");
assertFalse(this.dataChangeLayer.isDirty(), "State is dirty");
assertEquals(2, this.dataChangeLayer.dataChanges.size());
}

Expand Down
Loading

0 comments on commit 4179d9c

Please sign in to comment.