Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2014-05-05 13:56:58 +0000
committerCamille Letavernier2014-05-05 14:15:09 +0000
commit14e558d60d79f5b1f4d3ec2dcdc0cf81694d8cd5 (patch)
treee0b0d15848ce33ea1568098be65dd6b8ee09ce51
parent6084ac6002982b58650190bc6f677b7d8239d531 (diff)
parent6b613cfb8fbc158278be1d6d7d087a98b2758fd8 (diff)
downloadorg.eclipse.papyrus-14e558d60d79f5b1f4d3ec2dcdc0cf81694d8cd5.tar.gz
org.eclipse.papyrus-14e558d60d79f5b1f4d3ec2dcdc0cf81694d8cd5.tar.xz
org.eclipse.papyrus-14e558d60d79f5b1f4d3ec2dcdc0cf81694d8cd5.zip
Synchronize with master
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/OCLEValidatorAdapter.java33
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/UMLDiagnostician.java20
2 files changed, 53 insertions, 0 deletions
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/OCLEValidatorAdapter.java b/plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/OCLEValidatorAdapter.java
index b12c5dd3b15..937f24cf6be 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/OCLEValidatorAdapter.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/OCLEValidatorAdapter.java
@@ -18,7 +18,10 @@ import java.util.Map;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.validation.model.IConstraintStatus;
+import org.eclipse.ocl.examples.pivot.delegate.OCLDelegateValidator;
import org.eclipse.ocl.examples.pivot.uml.UMLOCLEValidator;
import org.eclipse.papyrus.infra.services.validation.EValidatorAdapter;
import org.eclipse.uml2.uml.InstanceSpecification;
@@ -44,6 +47,36 @@ import org.eclipse.uml2.uml.OpaqueExpression;
*/
public class OCLEValidatorAdapter
extends EValidatorAdapter {
+
+ // Overridden to invoke OCLDelegateValidator
+ public boolean validate(EClass eClass, EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
+ if (eObject.eIsProxy()) {
+ if (context != null && context.get(ROOT_OBJECT) != null) {
+ if (diagnostics != null) {
+ diagnostics.add(createDiagnostic(Diagnostic.ERROR, DIAGNOSTIC_SOURCE,
+ EOBJECT__EVERY_PROXY_RESOLVES, "_UI_UnresolvedProxy_diagnostic",
+ new Object[] {
+ getFeatureLabel(eObject.eContainmentFeature(), context),
+ getObjectLabel(eObject.eContainer(), context),
+ getObjectLabel(eObject, context) },
+ new Object[] {
+ eObject.eContainer(),
+ eObject.eContainmentFeature(),
+ eObject },
+ context));
+ }
+ return false;
+ } else {
+ return true;
+ }
+ } else if (eClass.eContainer() == getEPackage()) {
+ return validate(eClass.getClassifierID(), eObject, diagnostics, context);
+ } else {
+ return new OCLDelegateValidator(this) {
+ // Ensure that the class loader for this class will be used downstream.
+ }.validate(eClass, eObject, diagnostics, context);
+ }
+ }
@Override
public boolean validateInstanceSpecification(InstanceSpecification instanceSpecification,
diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/UMLDiagnostician.java b/plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/UMLDiagnostician.java
index 407a2cdbc3d..57028117fae 100644
--- a/plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/UMLDiagnostician.java
+++ b/plugins/uml/org.eclipse.papyrus.uml.service.validation/src/org/eclipse/papyrus/uml/service/validation/UMLDiagnostician.java
@@ -22,6 +22,8 @@ import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.ocl.examples.pivot.delegate.OCLDelegateDomain;
import org.eclipse.papyrus.infra.services.validation.EcoreDiagnostician;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.util.UMLUtil;
@@ -37,6 +39,24 @@ public class UMLDiagnostician extends EcoreDiagnostician {
validateStereotype = false;
}
+ @Override
+ public Map<Object, Object> createDefaultContext() {
+ Map<Object, Object> context = super.createDefaultContext();
+ if (context != null) {
+ OCLDelegateDomain.initializePivotOnlyDiagnosticianContext(context);
+ }
+ return context;
+ }
+
+ @Override
+ public BasicDiagnostic createDefaultDiagnostic(EObject eObject) {
+ ResourceSet resourceSet = eObject.eResource().getResourceSet();
+ if (resourceSet != null) {
+ OCLDelegateDomain.initializePivotOnlyDiagnosticianResourceSet(resourceSet);
+ }
+ return super.createDefaultDiagnostic(eObject);
+ }
+
protected boolean doValidateStereotypeApplications(EObject eObject, DiagnosticChain diagnostics, Map<Object, Object> context) {
if (validateStereotype) {
// this function is called recursively. Avoid trying to obtain stereotype applications, if we are

Back to the top