Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/BehaviorEditHelperAdvice.java27
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallEventEditHelperAdvice.java26
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceSpecificationEditHelperAdvice.java28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceValueEditHelperAdvice.java21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/OperationEditHelperAdvice.java27
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java125
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java111
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEditHelperAdvice.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEventEditHelperAdvice.java28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TestIdentityActionEditHelperAdvice.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TriggerEditHelperAdvice.java45
11 files changed, 214 insertions, 255 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/BehaviorEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/BehaviorEditHelperAdvice.java
index 9e342cf30ff..7e7975ec2e6 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/BehaviorEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/BehaviorEditHelperAdvice.java
@@ -13,8 +13,10 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
+import java.util.Collection;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
@@ -26,9 +28,9 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFac
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.InputPin;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.StartObjectBehaviorAction;
import org.eclipse.uml2.uml.UMLPackage;
@@ -36,6 +38,7 @@ import org.eclipse.uml2.uml.UMLPackage;
/**
*
* Pins of StartObjectBehaviorAction should be create and update automatically
+ *
* @since 3.0
*
*/
@@ -61,14 +64,18 @@ public class BehaviorEditHelperAdvice extends AbstractEditHelperAdvice {
Behavior behavior = (Behavior) request.getElementToEdit();
Package root = PackageUtil.getRootPackage(behavior);
if (root != null) {
- // 4] get all StartObjectBehaviorAction
- List<StartObjectBehaviorAction> allStartObjectBehaviorAction = ElementUtil.getInstancesFilteredByType(root, StartObjectBehaviorAction.class, null);
- // 5] loop into the list of StartObjectBehaviorAction
- for (StartObjectBehaviorAction startObjectBehaviorAction : allStartObjectBehaviorAction) {
- if (startObjectBehaviorAction.behavior() == behavior) {
- // 6] call the command for the StartObjectBehaviorAction which has as behavior the current one
- IPinUpdater<StartObjectBehaviorAction> updater = PinUpdaterFactory.getInstance().instantiate(startObjectBehaviorAction);
- command.add(new PinUpdateCommand<StartObjectBehaviorAction>("Update start object behavior action pins", updater, startObjectBehaviorAction)); //$NON-NLS-1$
+ // 4] get all StartObjectBehaviorAction referencing the behavior
+ // Behavior -> InputPin (type reference) -> StartObjectBehaviorAction (owned by)
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(behavior);
+ Collection<Setting> allReferences = adapter.getNonNavigableInverseReferences(behavior);
+ for (Setting reference : allReferences) {
+ if (reference.getEObject() instanceof InputPin) {
+ if (((InputPin) reference.getEObject()).getOwner() instanceof StartObjectBehaviorAction) {
+ StartObjectBehaviorAction startObjectBehaviorAction = (StartObjectBehaviorAction) ((InputPin) reference.getEObject()).getOwner();
+ // 5] call the command for the StartObjectBehaviorAction which has as behavior the current one
+ IPinUpdater<StartObjectBehaviorAction> updater = PinUpdaterFactory.getInstance().instantiate(startObjectBehaviorAction);
+ command.add(new PinUpdateCommand<StartObjectBehaviorAction>("Update start object behavior action pins", updater, startObjectBehaviorAction)); //$NON-NLS-1$
+ }
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallEventEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallEventEditHelperAdvice.java
index e49a08cfbb4..a110bd2a474 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallEventEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallEventEditHelperAdvice.java
@@ -13,8 +13,10 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
+import java.util.Collection;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
@@ -26,7 +28,6 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFac
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.CallEvent;
@@ -63,16 +64,17 @@ public class CallEventEditHelperAdvice extends AbstractEditHelperAdvice {
// 2] check the preference for AcceptCallEvent
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
if (synchronizePinPreference) {
- // 3] get allAcceptCallAction
- List<AcceptCallAction> allAcceptCallAction = ElementUtil.getInstancesFilteredByType(root, AcceptCallAction.class, null);
- for (AcceptCallAction acceptCallAction : allAcceptCallAction) {
- if (acceptCallAction instanceof AcceptCallAction) {
- for (Trigger t : acceptCallAction.getTriggers()) {
- if (t.getEvent() instanceof CallEvent && t.getEvent() == callEvent) {
- // 4] call the command for the acceptCallAction whose trigger reference the callEvent
- IPinUpdater<AcceptCallAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptCallAction);
- command.add(new PinUpdateCommand<AcceptCallAction>("Update accept event action pins", updater, acceptCallAction)); //$NON-NLS-1$
- }
+ // 3] get all AcceptCallAction referencing the CallEvent
+ // CallEvent -> Trigger (Reference) -> AcceptEventAction (owned by)
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(callEvent);
+ Collection<Setting> allReferences = adapter.getNonNavigableInverseReferences(callEvent);
+ for (Setting reference : allReferences) {
+ if(reference.getEObject() instanceof Trigger) {
+ if(((Trigger)reference.getEObject()).getOwner() instanceof AcceptCallAction) {
+ AcceptCallAction acceptCallAction = (AcceptCallAction) ((Trigger)reference.getEObject()).getOwner();
+ // 4] call the command for the acceptCallAction whose trigger reference the callEvent
+ IPinUpdater<AcceptCallAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptCallAction);
+ command.add(new PinUpdateCommand<AcceptCallAction>("Update accept event action pins", updater, acceptCallAction)); //$NON-NLS-1$
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceSpecificationEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceSpecificationEditHelperAdvice.java
index 3478e7bb3e5..74657abd803 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceSpecificationEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceSpecificationEditHelperAdvice.java
@@ -13,8 +13,11 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
+import java.util.Collection;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
@@ -25,7 +28,6 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFac
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.InstanceSpecification;
import org.eclipse.uml2.uml.InstanceValue;
@@ -53,6 +55,7 @@ public class InstanceSpecificationEditHelperAdvice extends AbstractEditHelperAdv
if (request.getFeature().equals(UMLPackage.eINSTANCE.getInstanceSpecification_Classifier())) {
final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
boolean synchronizePin = false;
+ CompositeCommand command = new CompositeCommand("Update inctanceSpecification"); //$NON-NLS-1$
InstanceSpecification instanceSpecification = (InstanceSpecification) request.getElementToEdit();
// 1] get the preference for ValueSpecificationAction
synchronizePin = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.VALUE_SPECIFICATION_ACTION).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
@@ -60,19 +63,24 @@ public class InstanceSpecificationEditHelperAdvice extends AbstractEditHelperAdv
if (synchronizePin) {
Package root = PackageUtil.getRootPackage(instanceSpecification);
if (root != null) {
- // 3] get all ValueSpecificationAction
- List<ValueSpecificationAction> allValueSpecificationAction = ElementUtil.getInstancesFilteredByType(root, ValueSpecificationAction.class, null);
- // 4] loop into the list of ValueSpecificationAction
- for (ValueSpecificationAction valueSpecificationAction : allValueSpecificationAction) {
- if (valueSpecificationAction.getValue() instanceof InstanceValue) {
- if (((InstanceValue) valueSpecificationAction.getValue()).getInstance() == instanceSpecification) {
- // 5] call the command for the ValueSpecificationAction whose value is an instanceValue which referenced the instance specification
+ // 3] get all ValueSpecificationAction referencing the instance specification
+ // instanceSpecification -> instanceValue (Reference) -> ValueSpecificationAction (owned by)
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(instanceSpecification);
+ Collection<Setting> allReferences = adapter.getNonNavigableInverseReferences(instanceSpecification);
+ for (Setting reference : allReferences) {
+ if(reference.getEObject() instanceof InstanceValue) {
+ if(((InstanceValue) reference.getEObject()).getOwner() instanceof ValueSpecificationAction) {
+ ValueSpecificationAction valueSpecificationAction = (ValueSpecificationAction) ((InstanceValue) reference.getEObject()).getOwner();
+ // 4] call the command for the ValueSpecificationAction whose value is an instanceValue which referenced the instance specification
IPinUpdater<ValueSpecificationAction> updater = PinUpdaterFactory.getInstance().instantiate(valueSpecificationAction);
- return new PinUpdateCommand<ValueSpecificationAction>("Update value specification action pins", updater, valueSpecificationAction); //$NON-NLS-1$
+ command.add(new PinUpdateCommand<ValueSpecificationAction>("Update value specification action pins", updater, valueSpecificationAction)); //$NON-NLS-1$
}
}
}
}
+ if (!command.isEmpty()) {
+ return command;
+ }
}
}
return super.getAfterSetCommand(request);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceValueEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceValueEditHelperAdvice.java
index 0a4c6a81424..4398c97fdf9 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceValueEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InstanceValueEditHelperAdvice.java
@@ -13,8 +13,6 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
-
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
@@ -25,7 +23,6 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFac
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.InstanceValue;
import org.eclipse.uml2.uml.Package;
@@ -59,17 +56,13 @@ public class InstanceValueEditHelperAdvice extends AbstractEditHelperAdvice {
InstanceValue instanceValue = (InstanceValue) request.getElementToEdit();
Package root = PackageUtil.getRootPackage(instanceValue);
if (root != null) {
- // 4] get all ValueSpecificationAction
- List<ValueSpecificationAction> allValueSpecificationAction = ElementUtil.getInstancesFilteredByType(root, ValueSpecificationAction.class, null);
- // 5] loop into the list of ValueSpecificationAction
- for (ValueSpecificationAction valueSpecificationAction : allValueSpecificationAction) {
- if (valueSpecificationAction.getValue() instanceof InstanceValue) {
- if (valueSpecificationAction.getValue() == instanceValue) {
- // 6] call the command for the ValueSpecificationAction whose value is the instanceValue
- IPinUpdater<ValueSpecificationAction> updater = PinUpdaterFactory.getInstance().instantiate(valueSpecificationAction);
- return new PinUpdateCommand<ValueSpecificationAction>("Update value specification action pins", updater, valueSpecificationAction); //$NON-NLS-1$
- }
- }
+ // 4] get all ValueSpecificationAction referencing the instance value
+ // ValueSpecification (CrossReference) -> ValueSpecificationAction (owned by)
+ if(instanceValue.getOwner() instanceof ValueSpecificationAction) {
+ // 5] call the command for the ValueSpecificationAction whose value is the instanceValue
+ ValueSpecificationAction valueSpecificationAction = (ValueSpecificationAction) instanceValue.getOwner();
+ IPinUpdater<ValueSpecificationAction> updater = PinUpdaterFactory.getInstance().instantiate(valueSpecificationAction);
+ return new PinUpdateCommand<ValueSpecificationAction>("Update value specification action pins", updater, valueSpecificationAction); //$NON-NLS-1$
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/OperationEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/OperationEditHelperAdvice.java
index 703a7762ac0..af3b7b9a789 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/OperationEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/OperationEditHelperAdvice.java
@@ -13,8 +13,10 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
+import java.util.Collection;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
@@ -26,7 +28,6 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFac
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.CallEvent;
@@ -64,16 +65,22 @@ public class OperationEditHelperAdvice extends AbstractEditHelperAdvice {
// 2] check the preference for AcceptCallEvent
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
if (synchronizePinPreference) {
- // 3] get allAcceptCallAction
- List<AcceptCallAction> allAcceptCallAction = ElementUtil.getInstancesFilteredByType(root, AcceptCallAction.class, null);
- for (AcceptCallAction acceptCallAction : allAcceptCallAction) {
- if (acceptCallAction instanceof AcceptCallAction) {
- for (Trigger t : acceptCallAction.getTriggers()) {
- if (t.getEvent() instanceof CallEvent) {
- if (((CallEvent) t.getEvent()).getOperation() == operation) {
- // 6] call the command for the acceptCallAction whose trigger reference a callEvent which reference the operation
+ // 3] get all AcceptCallAction referencing the operation
+ // Operation -> CallEvent (Reference) -> Trigger (Reference) -> AcceptEventAction (owned by)
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(operation);
+ Collection<Setting> allReferences = adapter.getNonNavigableInverseReferences(operation);
+ for (Setting reference : allReferences) {
+ if(reference.getEObject() instanceof CallEvent) {
+ ECrossReferenceAdapter adapterCallEvent = ECrossReferenceAdapter.getCrossReferenceAdapter(reference.getEObject());
+ Collection<Setting> allReferencesCallEvent = adapterCallEvent.getNonNavigableInverseReferences(reference.getEObject());
+ for(Setting referenceCallEvent : allReferencesCallEvent) {
+ if(referenceCallEvent.getEObject() instanceof Trigger) {
+ if(((Trigger)referenceCallEvent.getEObject()).getOwner() instanceof AcceptCallAction) {
+ // 4] call the command for the acceptCallAction whose trigger reference a callEvent which reference the operation
+ AcceptCallAction acceptCallAction = (AcceptCallAction) ((Trigger)referenceCallEvent.getEObject()).getOwner();
IPinUpdater<AcceptCallAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptCallAction);
return new PinUpdateCommand<AcceptCallAction>("Update accept event action pins", updater, acceptCallAction); //$NON-NLS-1$
+
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java
index f6d52f292ab..154ae2b3e72 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java
@@ -13,8 +13,10 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
+import java.util.Collection;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
@@ -23,21 +25,17 @@ import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.uml.diagram.activity.edit.commands.util.PinUpdateCommand;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.IPinUpdater;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFactory;
-import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions.StartObjectBehaviorActionPinUpdater;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.AcceptCallAction;
-import org.eclipse.uml2.uml.AcceptEventAction;
+import org.eclipse.uml2.uml.Behavior;
import org.eclipse.uml2.uml.CallEvent;
import org.eclipse.uml2.uml.InputPin;
-import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Operation;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Parameter;
-import org.eclipse.uml2.uml.ParameterDirectionKind;
-import org.eclipse.uml2.uml.Pin;
import org.eclipse.uml2.uml.StartObjectBehaviorAction;
import org.eclipse.uml2.uml.Trigger;
import org.eclipse.uml2.uml.UMLPackage;
@@ -46,6 +44,7 @@ import org.eclipse.uml2.uml.UMLPackage;
* Automated pin derivation for AcceptEventAction and AcceptCallAction
*
* Call pin derivation command on modification of a parameter
+ *
* @since 3.0
*/
public class ParameterEditHelperAdvice extends AbstractEditHelperAdvice {
@@ -75,18 +74,23 @@ public class ParameterEditHelperAdvice extends AbstractEditHelperAdvice {
// 2] check the preference for AcceptCallEvent
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
if (synchronizePinPreference) {
- // 3] get allAcceptCallAction
- List<AcceptCallAction> allAcceptCallAction = ElementUtil.getInstancesFilteredByType(root, AcceptCallAction.class, null);
- for (AcceptCallAction acceptCallAction : allAcceptCallAction) {
- if (acceptCallAction instanceof AcceptCallAction) {
- for (Trigger t : acceptCallAction.getTriggers()) {
- if (t.getEvent() instanceof CallEvent) {
- for (Parameter p : ((CallEvent) t.getEvent()).getOperation().getOwnedParameters()) {
- if (p == parameter) {
- // 4] call the command for the acceptEventAction whose trigger reference a callEvent
- // which reference an operation which owned the parameter
- IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptCallAction);
- command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptCallAction)); //$NON-NLS-1$
+ // 3] get all AcceptCallAction referencing the parameter
+ // Parameter -> Operation (owned by) -> CallEvent (Reference) -> Trigger (Reference) -> AcceptEventAction (owned by)
+ if (parameter.getOwner() instanceof Operation) {
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(parameter.getOwner());
+ Collection<Setting> allReferences = adapter.getNonNavigableInverseReferences(parameter.getOwner());
+ for (Setting reference : allReferences) {
+ if (reference.getEObject() instanceof CallEvent) {
+ ECrossReferenceAdapter adapterCallEvent = ECrossReferenceAdapter.getCrossReferenceAdapter(reference.getEObject());
+ Collection<Setting> allReferencesCallEvent = adapterCallEvent.getNonNavigableInverseReferences(reference.getEObject());
+ for (Setting referenceCallEvent : allReferencesCallEvent) {
+ if (referenceCallEvent.getEObject() instanceof Trigger) {
+ if (((Trigger) referenceCallEvent.getEObject()).getOwner() instanceof AcceptCallAction) {
+ // 4] call the command for the acceptCallAction whose trigger reference a callEvent which reference the operation
+ AcceptCallAction acceptCallAction = (AcceptCallAction) ((Trigger) referenceCallEvent.getEObject()).getOwner();
+ IPinUpdater<AcceptCallAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptCallAction);
+ return new PinUpdateCommand<AcceptCallAction>("Update accept event action pins", updater, acceptCallAction); //$NON-NLS-1$
+
}
}
}
@@ -99,19 +103,20 @@ public class ParameterEditHelperAdvice extends AbstractEditHelperAdvice {
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.START_OBJECT_BEHAVIOR_ACTION).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
// 2] check preference
if (synchronizePinPreference) {
- // 3] get all StartObjectBehaviorAction
- List<StartObjectBehaviorAction> allStartObjectBahaviorAction = ElementUtil.getInstancesFilteredByType(root, StartObjectBehaviorAction.class, null);
- // 4] loop into the list of StartObjectBehaviorAction
- for (StartObjectBehaviorAction startObjectBehaviorAction : allStartObjectBahaviorAction) {
- if (isParameterReferenceAPin(parameter, startObjectBehaviorAction.getArguments())) {
- // 5] call the command for the StartObjectBehaviorAction if the action has an argument pin referencing the current parameter
- IPinUpdater<StartObjectBehaviorAction> updater = new StartObjectBehaviorActionPinUpdater();
- command.add(new PinUpdateCommand<StartObjectBehaviorAction>("Update start object behavior action pins", updater, startObjectBehaviorAction)); //$NON-NLS-1$
- }
- if (isParameterReferenceAPin(parameter, startObjectBehaviorAction.getResults())) {
- // 6] call the command for the StartObjectBehaviorAction if the action has an result pin referencing the current parameter
- IPinUpdater<StartObjectBehaviorAction> updater = new StartObjectBehaviorActionPinUpdater();
- command.add(new PinUpdateCommand<StartObjectBehaviorAction>("Update start object behavior action pins", updater, startObjectBehaviorAction)); //$NON-NLS-1$
+ // 3] get all StartObjectBehaviorAction referencing the parameter
+ // parameter -> Behavior (owned by) -> StartObjectBehaviorAction (Reference)
+ if (parameter.getOwner() instanceof Behavior) {
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(parameter.getOwner());
+ Collection<Setting> allReferences = adapter.getNonNavigableInverseReferences(parameter.getOwner());
+ for (Setting reference : allReferences) {
+ if (reference.getEObject() instanceof InputPin) {
+ if (((InputPin) reference.getEObject()).getOwner() instanceof StartObjectBehaviorAction) {
+ // 4] call the command for the StartObjectBehaviorAction which has as behavior the current one
+ StartObjectBehaviorAction startObjectBehaviorAction = (StartObjectBehaviorAction) ((InputPin) reference.getEObject()).getOwner();
+ IPinUpdater<StartObjectBehaviorAction> updater = PinUpdaterFactory.getInstance().instantiate(startObjectBehaviorAction);
+ command.add(new PinUpdateCommand<StartObjectBehaviorAction>("Update start object behavior action pins", updater, startObjectBehaviorAction)); //$NON-NLS-1$
+ }
+ }
}
}
}
@@ -123,60 +128,4 @@ public class ParameterEditHelperAdvice extends AbstractEditHelperAdvice {
return super.getAfterSetCommand(request);
}
- /**
- * This method checks if a pin of the pins list is matching for the parameter
- *
- * @param parameter
- * @param pins
- * @return true if at least one pin of the list is matching
- */
- private static boolean isParameterReferenceAPin(Parameter parameter, List<? extends Pin> pins) {
- for (Pin pin : pins) {
- if (pinParameterMatch(pin, parameter)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * This method check if the pin and the parameter are matching
- * Matching condition:
- * -output pin if the direction of parameter is out or return
- * -input pin if the direction of parameter is in
- * -name of the pin corresponding to the parameter name with optional string before it
- * (example: "[in] foo" where foo is the name parameter)
- * -multiplicity are matching
- *
- * @param pin
- * @param parameter
- * @return true if pin and parameter are matching
- */
- private static <P extends Pin> boolean pinParameterMatch(P pin, Parameter parameter) {
- boolean match = true;
- match = pin.getType() == parameter.getType();
- // 1] check if the direction is correct
- if (parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL |
- parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL) {
- match = pin instanceof OutputPin;
- } else if (parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
- match = pin instanceof InputPin;
- }
- // 2] check if the name of the pin match with the name of the parameter (with or without [in/out])
- if (match && parameter.getName() != null) {
- if (pin.getName().matches("\\[[a-z]+\\]\\s.*")) {
- match = pin.getName().replaceFirst("\\[[a-z]+\\]\\s", "").equals(parameter.getName());
- } else {
- match = pin.getName().equals(parameter.getName());
- }
- }
- // 3] check if the multiplicity is correct
- if (match) {
- match = pin.getLower() == parameter.getLower();
- if (match) {
- match = pin.getUpper() == parameter.getUpper();
- }
- }
- return match;
- }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java
index d22809b3524..ade98a06e4c 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/PropertyEditHelperAdvice.java
@@ -13,8 +13,10 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
+import java.util.Collection;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
@@ -31,9 +33,7 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediatea
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.AcceptEventAction;
import org.eclipse.uml2.uml.AddStructuralFeatureValueAction;
import org.eclipse.uml2.uml.LinkEndCreationData;
@@ -42,6 +42,7 @@ import org.eclipse.uml2.uml.LinkEndDestructionData;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Property;
import org.eclipse.uml2.uml.ReadStructuralFeatureAction;
+import org.eclipse.uml2.uml.Signal;
import org.eclipse.uml2.uml.SignalEvent;
import org.eclipse.uml2.uml.Trigger;
import org.eclipse.uml2.uml.UMLPackage;
@@ -50,6 +51,7 @@ import org.eclipse.uml2.uml.UMLPackage;
* Automated pin derivation for AcceptEventAction and AcceptCallAction
*
* Call pin derivation command on modification of a property
+ *
* @since 3.0
*/
public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
@@ -73,20 +75,23 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
Property property = (Property) request.getElementToEdit();
Package root = PackageUtil.getRootPackage(property);
if (root != null) {
- List<AcceptEventAction> allAcceptEventAction = null;
+ Collection<Setting> allReferences = null;
// 2] check the preference for AcceptEventAction
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
if (synchronizePinPreference) {
- // 3] get all AcceptEventAction
- allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
- for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
- if (!(acceptEventAction instanceof AcceptCallAction)) { // instance of AcceptEventAction and not AcceptCallEvent
- for (Trigger t : acceptEventAction.getTriggers()) {
- if (t.getEvent() instanceof SignalEvent) {
- for (Property p : ((SignalEvent) t.getEvent()).getSignal().getAllAttributes()) { // get all properties including those inherited from its parents
- if (p == property) {
- // 4] call the command for the acceptEventAction whose trigger reference a signalEvent
- // which reference an signal which owned the property
+ // 3] get all AcceptEventAction which reference the property
+ // Property -> Signal (owned by) -> SignalEvent (Reference) -> Trigger (Reference) -> AcceptEventAction (owned by)
+ if (property.getOwner() instanceof Signal) {
+ ECrossReferenceAdapter adapterSignal = ECrossReferenceAdapter.getCrossReferenceAdapter(property.getOwner());
+ Collection<Setting> allReferencesOfSignal = adapterSignal.getNonNavigableInverseReferences(property.getOwner());
+ for (Setting settingSignal : allReferencesOfSignal) {
+ if (settingSignal.getEObject() instanceof SignalEvent) {
+ ECrossReferenceAdapter adapterSignalEvent = ECrossReferenceAdapter.getCrossReferenceAdapter(settingSignal.getEObject());
+ Collection<Setting> allReferencesOfSignalEvent = adapterSignalEvent.getNonNavigableInverseReferences(settingSignal.getEObject());
+ for (Setting settingSignalEvent : allReferencesOfSignalEvent) {
+ if (settingSignalEvent.getEObject() instanceof Trigger) {
+ if (((Trigger) settingSignalEvent.getEObject()).getOwner() instanceof AcceptEventAction) {
+ AcceptEventAction acceptEventAction = (AcceptEventAction) ((Trigger) settingSignalEvent.getEObject()).getOwner();
IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
}
@@ -97,19 +102,21 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
}
}
// Pins of CreateLinkAction should be create and update automatically
- List<LinkEndData> allLinkEndData = null;
// 1] get the preference for CreateLinkAction
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.CREATE_LINK_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
// 2] check preference
if (synchronizePinPreference) {
- // 3] get all LinkEndData
- allLinkEndData = ElementUtil.getInstancesFilteredByType(root, LinkEndData.class, null);
- // 4] loop into the list of LinkEndCreationData
- for (LinkEndData linkEndCreationData : allLinkEndData) {
- if (linkEndCreationData instanceof LinkEndCreationData && linkEndCreationData.getEnd() == property) {
- // 5] call the command for the CreateLinkAction owning the LinkEndCreationData
+ if (allReferences == null) {
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(property);
+ allReferences = adapter.getNonNavigableInverseReferences(property);
+ }
+ // 3] get all LinkEndData which reference the property
+ for (Setting setting : allReferences) {
+ if (setting.getEObject() instanceof LinkEndCreationData) {
+ LinkEndCreationData linkEndCreationData = (LinkEndCreationData) setting.getEObject();
IPinUpdaterLinkEndData updater = new LinkEndCreationDataPinUpdater();
command.add(new PinUpdateLinkEndDataCommand("Update link end data pins", updater, linkEndCreationData)); //$NON-NLS-1$
+
}
}
}
@@ -118,14 +125,14 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.DESTROY_LINK_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
// 2] check preference
if (synchronizePinPreference) {
- // 3] get all LinkEndDestructionData if not get yet
- if (allLinkEndData == null) {
- allLinkEndData = ElementUtil.getInstancesFilteredByType(root, LinkEndData.class, null);
+ if (allReferences == null) {
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(property);
+ allReferences = adapter.getNonNavigableInverseReferences(property);
}
- // 4] loop into the list of LinkEndDestructionData
- for (LinkEndData linkEndDestructionData : allLinkEndData) {
- if (linkEndDestructionData instanceof LinkEndDestructionData && linkEndDestructionData.getEnd() == property) {
- // 5] call the command for the DestroyLinkAction owning the LinkEndDestructionData
+ // 3] get all LinkEndData which reference the property
+ for (Setting setting : allReferences) {
+ if (setting.getEObject() instanceof LinkEndDestructionData) {
+ LinkEndDestructionData linkEndDestructionData = (LinkEndDestructionData) setting.getEObject();
IPinUpdaterLinkEndData updater = new LinkEndDestructionDataPinUpdater();
command.add(new PinUpdateLinkEndDataCommand("Update link end data pins", updater, linkEndDestructionData)); //$NON-NLS-1$
}
@@ -136,18 +143,16 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.READ_LINK_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
// 2] check preference
if (synchronizePinPreference) {
- // 3] get all LinkEndData if not get yet
- if (allLinkEndData == null) {
- allLinkEndData = ElementUtil.getInstancesFilteredByType(root, LinkEndData.class, null);
+ if (allReferences == null) {
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(property);
+ allReferences = adapter.getNonNavigableInverseReferences(property);
}
- // 4] loop into the list of LinkEndDestructionData
- for (LinkEndData linkEndData : allLinkEndData) {
- if (!(linkEndData instanceof LinkEndCreationData || linkEndData instanceof LinkEndDestructionData)) {
- if (linkEndData.getEnd() == property) {
- // 5] call the command for the DestroyLinkAction owning the LinkEndDestructionData
- IPinUpdaterLinkEndData updater = new LinkEndDataPinUpdater();
- command.add(new PinUpdateLinkEndDataCommand("Update link end data pins", updater, linkEndData)); //$NON-NLS-1$
- }
+ // 3] get all LinkEndData which reference the property
+ for (Setting setting : allReferences) {
+ if (setting.getEObject() instanceof LinkEndData) {
+ LinkEndData linkEndData = (LinkEndData) setting.getEObject();
+ IPinUpdaterLinkEndData updater = new LinkEndDataPinUpdater();
+ command.add(new PinUpdateLinkEndDataCommand("Update link end data pins", updater, linkEndData)); //$NON-NLS-1$
}
}
}
@@ -158,12 +163,14 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
synchronizePinPreference = prefStore.getString(IAutomatedModelCompletionPreferencesConstants.READ_STRUCTURAL_FEATURE_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION);
// 2] check preference
if (synchronizePinPreference) {
- // 3] get all ReadStructuralFeatureAction
- List<ReadStructuralFeatureAction> allReadStructuralFeatureAction = ElementUtil.getInstancesFilteredByType(root, ReadStructuralFeatureAction.class, null);
- // 4] loop into the list of ReadStructuralFeatureAction
- for (ReadStructuralFeatureAction readStructuralFeatureAction : allReadStructuralFeatureAction) {
- if (readStructuralFeatureAction.getStructuralFeature() == property) {
- // 5] call the command for the ReadStructuralFeatureAction whose the structuralFeature reference the property
+ if (allReferences == null) {
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(property);
+ allReferences = adapter.getNonNavigableInverseReferences(property);
+ }
+ // 3] get all ReadStructuralFeatureAction which reference the property
+ for (Setting setting : allReferences) {
+ if (setting.getEObject() instanceof ReadStructuralFeatureAction) {
+ ReadStructuralFeatureAction readStructuralFeatureAction = (ReadStructuralFeatureAction) setting.getEObject();
IPinUpdater<ReadStructuralFeatureAction> updater = PinUpdaterFactory.getInstance().instantiate(readStructuralFeatureAction);
command.add(new PinUpdateCommand<ReadStructuralFeatureAction>("Update read structural feature action pins", updater, readStructuralFeatureAction)); //$NON-NLS-1$
}
@@ -174,12 +181,14 @@ public class PropertyEditHelperAdvice extends AbstractEditHelperAdvice {
synchronizePinPreference = prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ADD_STRUCTURAL_FEATURE_VALUE_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION);
// 2] check preference
if (synchronizePinPreference) {
- // 3] get all AddStructuralFeatureValueAction
- List<AddStructuralFeatureValueAction> allAddStructuralFeatureValueAction = ElementUtil.getInstancesFilteredByType(root, AddStructuralFeatureValueAction.class, null);
- // 4] loop into the list of AddStructuralFeatureValueAction
- for (AddStructuralFeatureValueAction addStructuralFeatureValueAction : allAddStructuralFeatureValueAction) {
- if (addStructuralFeatureValueAction.getStructuralFeature() == request.getElementToEdit()) {
- // 5] call the command for the AddStructuralFeatureValueAction whose the structuralFeature is the property
+ if (allReferences == null) {
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(property);
+ allReferences = adapter.getNonNavigableInverseReferences(property);
+ }
+ // 3] get all AddStructuralFeatureValueAction which reference the property
+ for (Setting setting : allReferences) {
+ if (setting.getEObject() instanceof AddStructuralFeatureValueAction) {
+ AddStructuralFeatureValueAction addStructuralFeatureValueAction = (AddStructuralFeatureValueAction) setting.getEObject();
IPinUpdater<AddStructuralFeatureValueAction> updater = PinUpdaterFactory.getInstance().instantiate(addStructuralFeatureValueAction);
command.add(new PinUpdateCommand<AddStructuralFeatureValueAction>("Update add structural feature value action pins", updater, addStructuralFeatureValueAction)); //$NON-NLS-1$
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEditHelperAdvice.java
index 7f938ea771b..9abe267f398 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEditHelperAdvice.java
@@ -13,8 +13,10 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
+import java.util.Collection;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
@@ -26,10 +28,7 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFac
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.diagram.common.util.Util;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.AcceptEventAction;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.Signal;
@@ -41,6 +40,7 @@ import org.eclipse.uml2.uml.UMLPackage;
* Automated pin derivation for AcceptEventAction and AcceptCallAction
*
* Call pin derivation command on modification of a signal
+ *
* @since 3.0
*/
public class SignalEditHelperAdvice extends AbstractEditHelperAdvice {
@@ -63,19 +63,21 @@ public class SignalEditHelperAdvice extends AbstractEditHelperAdvice {
Signal signal = (Signal) request.getElementToEdit();
Package root = PackageUtil.getRootPackage(signal);
if (root != null) {
- List<AcceptEventAction> allAcceptEventAction = null;
// 2] check the preference for AcceptEventAction
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
if (synchronizePinPreference) {
- // 3] get all AcceptEventAction
- allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
- for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
- if (!(acceptEventAction instanceof AcceptCallAction)) { // instance of AcceptEventAction and not AcceptCallEvent
- for (Trigger t : acceptEventAction.getTriggers()) {
- if (t.getEvent() instanceof SignalEvent) {
- SignalEvent signalEvent = (SignalEvent) t.getEvent();
- if (signalEvent.getSignal() == signal || Util.getAllSuperClasses(null, signalEvent.getSignal()).contains(signal)) {
- // 4] call the command for the acceptEventAction whose trigger reference a signalEvent which reference the signal
+ // 3] get all AcceptEventAction which reference the signal
+ // Signal -> SignalEvent (Reference) -> Trigger (Reference) -> AcceptEventAction (owned by)
+ ECrossReferenceAdapter adapterSignal = ECrossReferenceAdapter.getCrossReferenceAdapter(signal);
+ Collection<Setting> allReferencesOfSignal = adapterSignal.getInverseReferences(signal);
+ for (Setting settingSignal : allReferencesOfSignal) {
+ if (settingSignal.getEObject() instanceof SignalEvent) {
+ ECrossReferenceAdapter adapterSignalEvent = ECrossReferenceAdapter.getCrossReferenceAdapter(settingSignal.getEObject());
+ Collection<Setting> allReferencesOfSignalEvent = adapterSignalEvent.getInverseReferences(settingSignal.getEObject());
+ for (Setting settingSignalEvent : allReferencesOfSignalEvent) {
+ if (settingSignalEvent.getEObject() instanceof Trigger) {
+ if (((Trigger) settingSignalEvent.getEObject()).getOwner() instanceof AcceptEventAction) {
+ AcceptEventAction acceptEventAction = (AcceptEventAction) ((Trigger) settingSignalEvent.getEObject()).getOwner();
IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEventEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEventEditHelperAdvice.java
index 9cb3517fccd..b0d52967f75 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEventEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SignalEventEditHelperAdvice.java
@@ -13,8 +13,10 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
+import java.util.Collection;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.ECrossReferenceAdapter;
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
@@ -26,9 +28,7 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFac
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
-import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.AcceptEventAction;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.SignalEvent;
@@ -39,6 +39,7 @@ import org.eclipse.uml2.uml.UMLPackage;
* Automated pin derivation for AcceptEventAction and AcceptCallAction
*
* Call pin derivation command on modification of a signalEvent
+ *
* @since 3.0
*/
public class SignalEventEditHelperAdvice extends AbstractEditHelperAdvice {
@@ -61,20 +62,19 @@ public class SignalEventEditHelperAdvice extends AbstractEditHelperAdvice {
SignalEvent signalEvent = (SignalEvent) request.getElementToEdit();
Package root = PackageUtil.getRootPackage(signalEvent);
if (root != null) {
- List<AcceptEventAction> allAcceptEventAction = null;
// 2] check the preference for AcceptEventAction
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
if (synchronizePinPreference) {
- // 3] get all AcceptEventAction
- allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
- for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
- if (!(acceptEventAction instanceof AcceptCallAction)) { // instance of AcceptEventAction and not AcceptCallEvent
- for (Trigger t : acceptEventAction.getTriggers()) {
- if (t.getEvent() instanceof SignalEvent && t.getEvent() == signalEvent) {
- // 4] call the command for the acceptEventAction whose trigger reference the signalEvent
- IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
- command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
- }
+ // 3] get all AcceptEventAction which reference the signalEvent
+ // SignalEvent -> Trigger (Reference) -> AcceptEventAction (owned by)
+ ECrossReferenceAdapter adapter = ECrossReferenceAdapter.getCrossReferenceAdapter(signalEvent);
+ Collection<Setting> allReferences = adapter.getInverseReferences(signalEvent);
+ for (Setting setting : allReferences) {
+ if (setting.getEObject() instanceof Trigger) {
+ if (((Trigger) setting.getEObject()).getOwner() instanceof AcceptEventAction) {
+ AcceptEventAction acceptEventAction = (AcceptEventAction) ((Trigger) setting.getEObject()).getOwner();
+ IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
+ command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TestIdentityActionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TestIdentityActionEditHelperAdvice.java
index 6b2bf66627b..3e001542bb1 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TestIdentityActionEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TestIdentityActionEditHelperAdvice.java
@@ -15,7 +15,6 @@ package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
-import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.papyrus.uml.diagram.activity.edit.commands.util.ImportUMLPrimitiveTypePackageCommand;
import org.eclipse.papyrus.uml.diagram.activity.edit.commands.util.PinUpdateCommand;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TriggerEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TriggerEditHelperAdvice.java
index 0e557a82ae0..650d95f43c3 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TriggerEditHelperAdvice.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/TriggerEditHelperAdvice.java
@@ -13,8 +13,6 @@
package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
-import java.util.List;
-
import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice;
@@ -26,7 +24,6 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.PinUpdaterFac
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.AutomatedModelCompletionPreferencesInitializer;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.preferences.IAutomatedModelCompletionPreferencesConstants;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
import org.eclipse.papyrus.uml.tools.utils.PackageUtil;
import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.AcceptEventAction;
@@ -38,6 +35,7 @@ import org.eclipse.uml2.uml.UMLPackage;
* Automated pin derivation for AcceptEventAction and AcceptCallAction
*
* Call pin derivation command on modification of a trigger
+ *
* @since 3.0
*/
public class TriggerEditHelperAdvice extends AbstractEditHelperAdvice {
@@ -58,41 +56,26 @@ public class TriggerEditHelperAdvice extends AbstractEditHelperAdvice {
Trigger trigger = (Trigger) request.getElementToEdit();
Package root = PackageUtil.getRootPackage(trigger);
if (root != null) {
- List<AcceptEventAction> allAcceptEventAction = null;
// 2] check the preference for AcceptEventAction
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPTE_EVENT_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
if (synchronizePinPreference) {
- // 3] get all AcceptEventAction
- allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
- for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
- if (!(acceptEventAction instanceof AcceptCallAction)) {
- for (Trigger t : acceptEventAction.getTriggers()) {
- if (t == trigger) {
- // 4] call the command for the acceptEventAction whose trigger is equal to the current one
- IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
- command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
- }
- }
- }
+ // 3] get all AcceptEventAction which reference the trigger
+ // Trigger -> AcceptEventAction (owned by)
+ if (trigger.getOwner() instanceof AcceptEventAction) {
+ AcceptEventAction acceptEventAction = (AcceptEventAction) trigger.getOwner();
+ IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
+ command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
}
}
- // 5] check the preference for AcceptCallEvent
+ // 4] check the preference for AcceptCallEvent
synchronizePinPreference = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.ACCEPT_CALL_ACTION_ACCELERATOR).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
if (synchronizePinPreference) {
- // 6] get allAcceptEventAction if we don't get it before
- if (allAcceptEventAction == null) {
- allAcceptEventAction = ElementUtil.getInstancesFilteredByType(root, AcceptEventAction.class, null);
- }
- for (AcceptEventAction acceptEventAction : allAcceptEventAction) {
- if (acceptEventAction instanceof AcceptCallAction) {
- for (Trigger t : acceptEventAction.getTriggers()) {
- if (t == trigger) {
- // 7] call the command for the acceptEventAction whose trigger is equal to the current one
- IPinUpdater<AcceptEventAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptEventAction);
- command.add(new PinUpdateCommand<AcceptEventAction>("Update accept event action pins", updater, acceptEventAction)); //$NON-NLS-1$
- }
- }
- }
+ // 5] get all AcceptCallAction referencing the trigger
+ // Trigger -> AcceptEventAction (owned by)
+ if (trigger.getOwner() instanceof AcceptCallAction) {
+ AcceptCallAction acceptCallAction = (AcceptCallAction) trigger.getOwner();
+ IPinUpdater<AcceptCallAction> updater = PinUpdaterFactory.getInstance().instantiate(acceptCallAction);
+ command.add(new PinUpdateCommand<AcceptCallAction>("Update accept event action pins", updater, acceptCallAction)); //$NON-NLS-1$
}
}
if (!command.isEmpty()) {

Back to the top