summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorskovalsky2012-03-18 18:51:12 (EDT)
committer mgolubev2012-03-18 18:51:12 (EDT)
commitf2c55e528865272e7b1d0b3d70beb56275e27e5d (patch)
treed324cd4d7944bafd825d0f21fa7616244947568e
parent10c1162368c285cd3d7ae8d83a8ebccf517763e5 (diff)
downloadorg.eclipse.gmf-tooling-f2c55e528865272e7b1d0b3d70beb56275e27e5d.zip
org.eclipse.gmf-tooling-f2c55e528865272e7b1d0b3d70beb56275e27e5d.tar.gz
org.eclipse.gmf-tooling-f2c55e528865272e7b1d0b3d70beb56275e27e5d.tar.bz2
[161545] - component to listen for notifications that affects the
result of OCL expression. GMFT-specific implementation to be replaced with ImpactAnalyzer when it will be available.
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclDependencyCollector.java9
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclEvaluator.java11
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclListener.java6
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclResult.java18
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclDependencyCollectorBase.java39
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclEvaluatorImpl.java20
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclResultImpl.java78
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclTracker.java100
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclTrackerFactory.java17
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ContextData.java31
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ContextDataWithAdapter.java35
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/DependencyEvaluator.java29
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/EcoreEnvironmentFactoryEx.java50
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/EvaluationVisitorImplEx.java50
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ListeningDependencyCollector.java25
-rw-r--r--plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/SimpleDependencyCollector.java11
16 files changed, 529 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclDependencyCollector.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclDependencyCollector.java
new file mode 100644
index 0000000..ae4066b
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclDependencyCollector.java
@@ -0,0 +1,9 @@
+package org.eclipse.gmf.tooling.runtime.ocl.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+public interface ActiveOclDependencyCollector {
+
+ public void registerDependency(EObject context, EStructuralFeature feature);
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclEvaluator.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclEvaluator.java
new file mode 100644
index 0000000..d9ea1aa
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclEvaluator.java
@@ -0,0 +1,11 @@
+package org.eclipse.gmf.tooling.runtime.ocl.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.ocl.ParserException;
+
+public interface ActiveOclEvaluator {
+
+ ActiveOclResult evaluate(EObject context, String oclExp) throws ParserException;
+
+ Object evaluate(EObject context, String oclExp, ActiveOclDependencyCollector dependencyCollector) throws ParserException;
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclListener.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclListener.java
new file mode 100644
index 0000000..df2dede
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclListener.java
@@ -0,0 +1,6 @@
+package org.eclipse.gmf.tooling.runtime.ocl.activeocl;
+
+public interface ActiveOclListener {
+
+ void onResultChanged();
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclResult.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclResult.java
new file mode 100644
index 0000000..6c2ea32
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/activeocl/ActiveOclResult.java
@@ -0,0 +1,18 @@
+package org.eclipse.gmf.tooling.runtime.ocl.activeocl;
+
+import org.eclipse.emf.common.notify.Notifier;
+
+public interface ActiveOclResult {
+
+ Object getResult();
+
+ boolean canListenForChanges();
+
+ void addListener(ActiveOclListener listener);
+
+ void removeListener(ActiveOclListener listener);
+
+ Notifier adaptToEMFNotifier();
+
+ void dispose();
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclDependencyCollectorBase.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclDependencyCollectorBase.java
new file mode 100644
index 0000000..8b2c3f1
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclDependencyCollectorBase.java
@@ -0,0 +1,39 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclDependencyCollector;
+
+abstract class ActiveOclDependencyCollectorBase<T extends ContextData> implements ActiveOclDependencyCollector {
+
+ private final Map<EObject, T> myContext2Data;
+
+ public ActiveOclDependencyCollectorBase() {
+ myContext2Data = new HashMap<EObject, T>();
+ }
+
+ @Override
+ public void registerDependency(EObject context, EStructuralFeature feature) {
+ T contextData = myContext2Data.get(context);
+
+ if (contextData == null) {
+ contextData = createContextData(context);
+ myContext2Data.put(context, contextData);
+ }
+
+ contextData.addFeature(feature);
+ }
+
+ public void clear() {
+ myContext2Data.clear();
+ }
+
+ public Map<EObject, T> getContext2Data() {
+ return myContext2Data;
+ }
+
+ protected abstract T createContextData(EObject context);
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclEvaluatorImpl.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclEvaluatorImpl.java
new file mode 100644
index 0000000..70010c9
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclEvaluatorImpl.java
@@ -0,0 +1,20 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclDependencyCollector;
+import org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclEvaluator;
+import org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclResult;
+import org.eclipse.ocl.ParserException;
+
+class ActiveOclEvaluatorImpl implements ActiveOclEvaluator {
+
+ @Override
+ public ActiveOclResult evaluate(EObject context, String oclExp) throws ParserException {
+ return new ActiveOclResultImpl(context, oclExp);
+ }
+
+ @Override
+ public Object evaluate(EObject context, String oclExp, ActiveOclDependencyCollector dependencyCollector) throws ParserException {
+ return new DependencyEvaluator(context, oclExp, dependencyCollector).evaluate();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclResultImpl.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclResultImpl.java
new file mode 100644
index 0000000..f5fbada
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclResultImpl.java
@@ -0,0 +1,78 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclListener;
+import org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclResult;
+import org.eclipse.ocl.ParserException;
+
+class ActiveOclResultImpl implements ActiveOclResult, ActiveOclListener {
+
+ private final List<ActiveOclListener> myListeners;
+
+ private Object myResult;
+
+ private final ListeningDependencyCollector myDependencyCollector;
+
+ private final DependencyEvaluator myDependencyEvaluator;
+
+ public ActiveOclResultImpl(EObject context, String oclExp) throws ParserException {
+ myListeners = new ArrayList<ActiveOclListener>();
+
+ myDependencyCollector = new ListeningDependencyCollector(this);
+
+ myDependencyEvaluator = new DependencyEvaluator(context, oclExp, myDependencyCollector);
+
+ myResult = myDependencyEvaluator.evaluate();
+ }
+
+ @Override
+ public void onResultChanged() {
+ myDependencyCollector.clear();
+
+ Object newResult = myDependencyEvaluator.evaluate();
+ if (myResult == null && newResult == null //
+ || myResult != null && myResult.equals(newResult)) {
+ return;
+ }
+ myResult = newResult;
+
+ for (ActiveOclListener listener : myListeners) {
+ listener.onResultChanged();
+ }
+ }
+
+ @Override
+ public void removeListener(ActiveOclListener listener) {
+ myListeners.remove(listener);
+ }
+
+ @Override
+ public Object getResult() {
+ return myResult;
+ }
+
+ @Override
+ public void dispose() {
+ myDependencyCollector.clear();
+ }
+
+ @Override
+ public boolean canListenForChanges() {
+ return true;
+ }
+
+ @Override
+ public void addListener(ActiveOclListener listener) {
+ myListeners.add(listener);
+ }
+
+ @Override
+ public Notifier adaptToEMFNotifier() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclTracker.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclTracker.java
new file mode 100644
index 0000000..320e8a4
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclTracker.java
@@ -0,0 +1,100 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerBase;
+import org.eclipse.ocl.ParserException;
+
+class ActiveOclTracker extends OclTrackerBase {
+
+ private NotificationListener myListener;
+
+ private SimpleDependencyCollector myDependecyCollector;
+
+ private List<EObject> myParserElements;
+
+ private Registrator myRegistrator;
+
+ private Object myValue;
+
+ private boolean myValueInitialized = false;
+
+ private final boolean myCached;
+
+ public ActiveOclTracker(String expressionBody, boolean cached) {
+ super(expressionBody);
+ myCached = cached;
+ myDependecyCollector = new SimpleDependencyCollector();
+ }
+
+ @Override
+ public void installListeners(TransactionalEditingDomain domain, NotificationListener listener, Registrator registrator) {
+ myListener = listener;
+ myRegistrator = registrator;
+
+ registerListeners();
+ }
+
+ @Override
+ public void uninstallListeners() {
+ unregisterListeners();
+ }
+
+ private void registerListeners() {
+ if (myRegistrator == null) {
+ return;
+ }
+ myParserElements = new ArrayList<EObject>(myDependecyCollector.getContext2Data().keySet());
+ for (int i = 0; i < myParserElements.size(); i++) {
+ myRegistrator.registerListener("ActiveOclTracker#SemanticModel" + i, myListener, myParserElements.get(i)); //$NON-NLS-1$
+ }
+ }
+
+ private void unregisterListeners() {
+ if (myParserElements == null) {
+ return;
+ }
+ for (int i = 0; i < myParserElements.size(); i++) {
+ myRegistrator.unregisterListener("ActiveOclTracker#SemanticModel" + i); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public Object getValue() {
+ if (!myValueInitialized || !isCached()) {
+ doInitialize();
+ }
+ return myValue;
+ }
+
+ @Override
+ public boolean handleNotification(Notification notification) {
+ ContextData contextData = myDependecyCollector.getContext2Data().get(notification.getNotifier());
+ boolean affected = contextData != null && contextData.getFeatures().contains(notification.getFeature());
+ if (affected) {
+ doInitialize();
+ }
+ return affected;
+ }
+
+ @Override
+ protected void doInitialize() {
+ unregisterListeners();
+ myDependecyCollector.clear();
+ try {
+ myValue = new ActiveOclEvaluatorImpl().evaluate(getContext(), getExpressionBody(), myDependecyCollector);
+ } catch (ParserException e) {
+ throw new RuntimeException(e);
+ }
+ registerListeners();
+ }
+
+ private boolean isCached() {
+ return myCached;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclTrackerFactory.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclTrackerFactory.java
new file mode 100644
index 0000000..674f7f9
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ActiveOclTrackerFactory.java
@@ -0,0 +1,17 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTracker;
+import org.eclipse.gmf.tooling.runtime.ocl.tracker.OclTrackerFactory;
+
+public class ActiveOclTrackerFactory implements OclTrackerFactory {
+
+ @Override
+ public OclTracker createOclTracker(String expressionBody, boolean cached) {
+ return new ActiveOclTracker(expressionBody, cached);
+ }
+
+ @Override
+ public Type getImplementationType() {
+ return Type.DEFAULT_GMFT;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ContextData.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ContextData.java
new file mode 100644
index 0000000..10edb1c
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ContextData.java
@@ -0,0 +1,31 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+class ContextData {
+
+ private final EObject myContext;
+
+ private final Set<EStructuralFeature> myFeatures;
+
+ public ContextData(EObject context) {
+ myContext = context;
+ myFeatures = new HashSet<EStructuralFeature>();
+ }
+
+ public void addFeature(EStructuralFeature feature) {
+ myFeatures.add(feature);
+ }
+
+ public Set<EStructuralFeature> getFeatures() {
+ return myFeatures;
+ }
+
+ public EObject getContext() {
+ return myContext;
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ContextDataWithAdapter.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ContextDataWithAdapter.java
new file mode 100644
index 0000000..a08b1c6
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ContextDataWithAdapter.java
@@ -0,0 +1,35 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+import org.eclipse.emf.ecore.EObject;
+
+class ContextDataWithAdapter extends org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl.ContextData {
+
+ private final Adapter myAdapter;
+
+ public ContextDataWithAdapter(EObject context, final org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclListener listener) {
+ super(context);
+ myAdapter = new AdapterImpl() {
+
+ @Override
+ public void notifyChanged(Notification notification) {
+ if (getFeatures().contains(notification.getFeature())) {
+ listener.onResultChanged();
+ }
+ }
+
+ @Override
+ public boolean isAdapterForType(Object type) {
+ return true;
+ }
+ };
+
+ getContext().eAdapters().add(myAdapter);
+ }
+
+ public void dispose() {
+ getContext().eAdapters().remove(myAdapter);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/DependencyEvaluator.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/DependencyEvaluator.java
new file mode 100644
index 0000000..3669618
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/DependencyEvaluator.java
@@ -0,0 +1,29 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.ocl.ParserException;
+import org.eclipse.ocl.ecore.OCL.Helper;
+import org.eclipse.ocl.ecore.OCLExpression;
+
+class DependencyEvaluator {
+
+ private final EObject myContext;
+
+ private final org.eclipse.ocl.ecore.OCL myOcl;
+
+ private final OCLExpression myExpression;
+
+ public DependencyEvaluator(EObject context, String oclExp, org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclDependencyCollector dependencyCollector) throws ParserException {
+ myContext = context;
+
+ myOcl = org.eclipse.ocl.ecore.OCL.newInstance(new org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl.EcoreEnvironmentFactoryEx(dependencyCollector));
+
+ Helper helper = myOcl.createOCLHelper();
+ helper.setContext(context.eClass());
+ myExpression = helper.createQuery(oclExp);
+ }
+
+ public Object evaluate() {
+ return myOcl.evaluate(myContext, myExpression);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/EcoreEnvironmentFactoryEx.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/EcoreEnvironmentFactoryEx.java
new file mode 100644
index 0000000..72b2918
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/EcoreEnvironmentFactoryEx.java
@@ -0,0 +1,50 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclDependencyCollector;
+import org.eclipse.ocl.Environment;
+import org.eclipse.ocl.EvaluationEnvironment;
+import org.eclipse.ocl.EvaluationVisitor;
+import org.eclipse.ocl.ecore.CallOperationAction;
+import org.eclipse.ocl.ecore.Constraint;
+import org.eclipse.ocl.ecore.EcoreEnvironmentFactory;
+import org.eclipse.ocl.ecore.SendSignalAction;
+import org.eclipse.ocl.internal.evaluation.TracingEvaluationVisitor;
+
+class EcoreEnvironmentFactoryEx extends EcoreEnvironmentFactory {
+
+ private final ActiveOclDependencyCollector myDependencyCollector;
+
+ public EcoreEnvironmentFactoryEx(org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclDependencyCollector dependencyCollector) {
+ myDependencyCollector = dependencyCollector;
+ }
+
+ @Override
+ public EvaluationVisitor<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> createEvaluationVisitor(
+ Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> env,
+ EvaluationEnvironment<EClassifier, EOperation, EStructuralFeature, EClass, EObject> evalEnv, Map<? extends EClass, ? extends Set<? extends EObject>> extentMap) {
+
+ EvaluationVisitorImplEx evaluationVisitorImplEx = new EvaluationVisitorImplEx(env, evalEnv, extentMap, myDependencyCollector);
+ EvaluationVisitor<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> result = evaluationVisitorImplEx;
+
+ if (isEvaluationTracingEnabled()) {
+ result = decorateWithTracingSupport(result);
+ }
+ return result;
+ }
+
+ private static <PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> //
+ EvaluationVisitor<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> decorateWithTracingSupport(EvaluationVisitor<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E> base) {
+ return new TracingEvaluationVisitor<PK, C, O, P, EL, PM, S, COA, SSA, CT, CLS, E>(base);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/EvaluationVisitorImplEx.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/EvaluationVisitorImplEx.java
new file mode 100644
index 0000000..8f20c61
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/EvaluationVisitorImplEx.java
@@ -0,0 +1,50 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EParameter;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.ocl.Environment;
+import org.eclipse.ocl.EvaluationEnvironment;
+import org.eclipse.ocl.ecore.CallOperationAction;
+import org.eclipse.ocl.ecore.Constraint;
+import org.eclipse.ocl.ecore.EvaluationVisitorImpl;
+import org.eclipse.ocl.ecore.SendSignalAction;
+import org.eclipse.ocl.ecore.impl.PropertyCallExpImpl;
+import org.eclipse.ocl.expressions.OCLExpression;
+import org.eclipse.ocl.expressions.PropertyCallExp;
+
+public class EvaluationVisitorImplEx extends EvaluationVisitorImpl {
+
+ private final org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclDependencyCollector myDependencyCollector;
+
+ public EvaluationVisitorImplEx(
+ Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> env, //
+ EvaluationEnvironment<EClassifier, EOperation, EStructuralFeature, EClass, EObject> evalEnv, Map<? extends EClass, ? extends Set<? extends EObject>> extentMap, //
+ org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclDependencyCollector dependencyCollector) {
+ super(env, evalEnv, extentMap);
+ myDependencyCollector = dependencyCollector;
+ }
+
+ @Override
+ public Object visitPropertyCallExp(PropertyCallExp<EClassifier, EStructuralFeature> pc) {
+ PropertyCallExpImpl pcImpl = (PropertyCallExpImpl) pc;
+
+ final EStructuralFeature feature = pcImpl.getReferredProperty();
+
+ OCLExpression<EClassifier> source = pc.getSource();
+
+ EObject context = (EObject) source.accept(getVisitor());
+
+ myDependencyCollector.registerDependency(context, feature);
+
+ return super.visitPropertyCallExp(pc);
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ListeningDependencyCollector.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ListeningDependencyCollector.java
new file mode 100644
index 0000000..5941928
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/ListeningDependencyCollector.java
@@ -0,0 +1,25 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.tooling.runtime.ocl.activeocl.ActiveOclListener;
+
+class ListeningDependencyCollector extends ActiveOclDependencyCollectorBase<ContextDataWithAdapter> {
+
+ private final ActiveOclListener myListener;
+
+ public ListeningDependencyCollector(ActiveOclListener listener) {
+ myListener = listener;
+ }
+
+ @Override
+ protected ContextDataWithAdapter createContextData(EObject context) {
+ return new ContextDataWithAdapter(context, myListener);
+ }
+
+ public void clear() {
+ for (ContextDataWithAdapter contextData : getContext2Data().values()) {
+ contextData.dispose();
+ }
+ super.clear();
+ }
+}
diff --git a/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/SimpleDependencyCollector.java b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/SimpleDependencyCollector.java
new file mode 100644
index 0000000..53ef483
--- /dev/null
+++ b/plugins/org.eclipse.gmf.tooling.runtime/src/org/eclipse/gmf/tooling/runtime/ocl/impl/activeocl/SimpleDependencyCollector.java
@@ -0,0 +1,11 @@
+package org.eclipse.gmf.tooling.runtime.ocl.impl.activeocl;
+
+import org.eclipse.emf.ecore.EObject;
+
+class SimpleDependencyCollector extends ActiveOclDependencyCollectorBase<ContextData> {
+
+ @Override
+ protected ContextData createContextData(EObject context) {
+ return new ContextData(context);
+ }
+}