Bug 551660 - Validation error after Undo still present
In order for validation icons to update correctly we must never directly
modify the list of diagnostics. By changing the list directly we cannot
identify changes of diagnostics. Thus the update of the validation icon
might not work.
Change-Id: Id4d358247fd453d0f367b799292740f4eb269115
Signed-off-by: Eugen Neufeld <eneufeld@eclipsesource.com>
diff --git a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/internal/validation/ValidationServiceImpl.java b/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/internal/validation/ValidationServiceImpl.java
index 2075c87..45d3e9c 100644
--- a/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/internal/validation/ValidationServiceImpl.java
+++ b/bundles/org.eclipse.emf.ecp.view.validation/src/org/eclipse/emf/ecp/view/internal/validation/ValidationServiceImpl.java
@@ -42,7 +42,9 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
@@ -459,7 +461,11 @@
diagnosticsToRemove.add(diagnostic);
}
}
- vControl.getDiagnostic().getDiagnostics().removeAll(diagnosticsToRemove);
+ final EList<Object> diagnostics = new BasicEList<Object>(vControl.getDiagnostic().getDiagnostics());
+ diagnostics.removeAll(diagnosticsToRemove);
+ final VDiagnostic vDiagnostic = VViewFactory.eINSTANCE.createDiagnostic();
+ vDiagnostic.getDiagnostics().addAll(diagnostics);
+ vControl.setDiagnostic(vDiagnostic);
}
}
diff --git a/bundles/org.eclipse.emfforms.core.services/src/org/eclipse/emfforms/internal/core/services/controlmapper/ViewModelListener.java b/bundles/org.eclipse.emfforms.core.services/src/org/eclipse/emfforms/internal/core/services/controlmapper/ViewModelListener.java
index 47326b6..26be9fb 100644
--- a/bundles/org.eclipse.emfforms.core.services/src/org/eclipse/emfforms/internal/core/services/controlmapper/ViewModelListener.java
+++ b/bundles/org.eclipse.emfforms.core.services/src/org/eclipse/emfforms/internal/core/services/controlmapper/ViewModelListener.java
@@ -18,13 +18,17 @@
import java.util.Set;
import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecp.view.spi.model.ModelChangeListener;
import org.eclipse.emf.ecp.view.spi.model.ModelChangeNotification;
import org.eclipse.emf.ecp.view.spi.model.VControl;
+import org.eclipse.emf.ecp.view.spi.model.VDiagnostic;
import org.eclipse.emf.ecp.view.spi.model.VDomainModelReference;
+import org.eclipse.emf.ecp.view.spi.model.VViewFactory;
import org.eclipse.emfforms.spi.core.services.controlmapper.EMFFormsSettingToControlMapper;
import org.eclipse.emfforms.spi.core.services.structuralchange.EMFFormsStructuralChangeTester;
import org.eclipse.emfforms.spi.core.services.view.EMFFormsViewContext;
@@ -122,7 +126,13 @@
} else if (control.getDiagnostic() != null) {
final List<Diagnostic> diagnostics = control.getDiagnostic()
.getDiagnostic(notification.getNotifier(), notification.getStructuralFeature());
- control.getDiagnostic().getDiagnostics().removeAll(diagnostics);
+
+ final EList<Object> newDiagnostics = new BasicEList<Object>(
+ control.getDiagnostic().getDiagnostics());
+ newDiagnostics.removeAll(diagnostics);
+ final VDiagnostic vDiagnostic = VViewFactory.eINSTANCE.createDiagnostic();
+ vDiagnostic.getDiagnostics().addAll(newDiagnostics);
+ control.setDiagnostic(vDiagnostic);
}
// re-resolve DMR