Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauline DEVILLE2017-01-10 08:00:45 +0000
committerFlorian Noyrit2017-04-19 09:25:13 +0000
commitdbe83a2853b5c197d24447dd215146ec0a31a256 (patch)
treec71380d3edab68eb62792ab8d3e762b922c0b55c /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus
parentbfc914f11e72c5091f0ff5d3d410bdf2af3520c7 (diff)
downloadorg.eclipse.papyrus-dbe83a2853b5c197d24447dd215146ec0a31a256.tar.gz
org.eclipse.papyrus-dbe83a2853b5c197d24447dd215146ec0a31a256.tar.xz
org.eclipse.papyrus-dbe83a2853b5c197d24447dd215146ec0a31a256.zip
Bug 510196 - [ActivityDiagram] Pins of StartObjectBehaviorAction should
be create and update automatically Change-Id: If5c972b9a4968ca9a780067e38028d4c00d7817f Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/BehaviorEditHelperAdvice.java81
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InputPinStartObjectBehaviorActionEditHelperAdvice.java66
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ParameterEditHelperAdvice.java90
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/StartObjectBehaviorActionEditHelperAdvice.java82
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractCallActionPinUpdater.java10
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/StartObjectBehaviorActionPinUpdater.java139
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java1
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java2
10 files changed, 471 insertions, 6 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
new file mode 100644
index 00000000000..00b92348647
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/BehaviorEditHelperAdvice.java
@@ -0,0 +1,81 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+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;
+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.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.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.Package;
+import org.eclipse.uml2.uml.StartObjectBehaviorAction;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ *
+ * Pins of StartObjectBehaviorAction should be create and update automatically
+ *
+ */
+public class BehaviorEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ public ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is ownedParameter
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getBehavior_OwnedParameter())) {
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePin = false;
+ CompositeCommand command = new CompositeCommand("Update pins on modification of a behavior"); //$NON-NLS-1$
+ // 2] get the preference for StartObjectBehaviorAction
+ synchronizePin = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.START_OBJECT_BEHAVIOR_ACTION).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ // 3] check preference
+ if (synchronizePin) {
+ 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$
+ }
+ }
+ }
+ 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/InputPinStartObjectBehaviorActionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InputPinStartObjectBehaviorActionEditHelperAdvice.java
new file mode 100644
index 00000000000..e2aeeac09a5
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/InputPinStartObjectBehaviorActionEditHelperAdvice.java
@@ -0,0 +1,66 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.activity.edit.advices;
+
+/**
+ *
+ * Pins of StartObjectBehaviorAction should be create and update automatically
+ *
+ */
+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;
+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.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.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.StartObjectBehaviorAction;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ * Edit helper advice for {@link StartObjectBehaviorAction}
+ */
+public class InputPinStartObjectBehaviorActionEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is type
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getTypedElement_Type())) {
+ // 2] get the preference for StartObjectBehaviorAction
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePin = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.START_OBJECT_BEHAVIOR_ACTION).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ // 3] check preference
+ if (synchronizePin) {
+ if (request.getElementToEdit() instanceof InputPin) {
+ InputPin inputPin = (InputPin) request.getElementToEdit();
+ if (inputPin.getOwner() instanceof StartObjectBehaviorAction) {
+ // 4] call the command for the StartObjectBehaviorAction which owned the current input pin
+ IPinUpdater<StartObjectBehaviorAction> updater = new StartObjectBehaviorActionPinUpdater();
+ return new PinUpdateCommand<StartObjectBehaviorAction>("Update start object behavior action pins", updater, (StartObjectBehaviorAction) inputPin.getOwner());
+ }
+ }
+ }
+ }
+ 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/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 eb44fa4c3b2..2a833b8e4f4 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
@@ -23,6 +23,7 @@ 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;
@@ -31,8 +32,13 @@ 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.CallEvent;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.OutputPin;
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;
@@ -53,7 +59,7 @@ public class ParameterEditHelperAdvice extends AbstractEditHelperAdvice {
*/
@Override
public ICommand getAfterSetCommand(SetRequest request) {
- // 1] check if the setFeature is Name, Type or Multiplicity
+ // 1] check if the setFeature is Name, Type, Direction or Multiplicity
if (request.getFeature().equals(UMLPackage.eINSTANCE.getTypedElement_Type()) ||
request.getFeature().equals(UMLPackage.eINSTANCE.getMultiplicityElement_Lower()) ||
request.getFeature().equals(UMLPackage.eINSTANCE.getMultiplicityElement_Upper()) ||
@@ -87,11 +93,89 @@ public class ParameterEditHelperAdvice extends AbstractEditHelperAdvice {
}
}
}
- if (!command.isEmpty()) {
- return command;
+ // Pins of StartObjectBehaviorAction should be create and update automatically
+ // 1] get the preference for StartObjectBehaviorAction
+ 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$
+ }
+ }
}
}
+ if (!command.isEmpty()) {
+ return command;
+ }
}
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/StartObjectBehaviorActionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/StartObjectBehaviorActionEditHelperAdvice.java
new file mode 100644
index 00000000000..3858f5aeec1
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/StartObjectBehaviorActionEditHelperAdvice.java
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+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.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.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.uml2.uml.StartObjectBehaviorAction;
+import org.eclipse.uml2.uml.UMLPackage;
+
+/**
+ *
+ * Pins of StartObjectBehaviorAction should be create and update automatically
+ *
+ */
+public class StartObjectBehaviorActionEditHelperAdvice extends AbstractEditHelperAdvice {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected ICommand getAfterConfigureCommand(ConfigureRequest request) {
+ // 1] get the preference for StartObjectBehaviorAction
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePin = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.START_OBJECT_BEHAVIOR_ACTION).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ // 2] check preference
+ if (synchronizePin) {
+ StartObjectBehaviorAction editedModelElement = (StartObjectBehaviorAction) request.getElementToConfigure();
+ if (editedModelElement != null) {
+ // 3] call the command for the StartObjectBehaviorAction
+ IPinUpdater<StartObjectBehaviorAction> updater = PinUpdaterFactory.getInstance().instantiate(editedModelElement);
+ return new PinUpdateCommand<StartObjectBehaviorAction>("Update start object behavior action pins", updater, editedModelElement); //$NON-NLS-1$
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getAfterSetCommand(SetRequest request) {
+ // 1] check if the setFeature is object
+ if (request.getFeature().equals(UMLPackage.eINSTANCE.getStartObjectBehaviorAction_Object()) ||
+ request.getFeature().equals(UMLPackage.eINSTANCE.getCallAction_IsSynchronous())) {
+ // 2] get the preference for StartObjectBehaviorAction
+ final IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ boolean synchronizePin = (prefStore.getString(IAutomatedModelCompletionPreferencesConstants.START_OBJECT_BEHAVIOR_ACTION).equals(AutomatedModelCompletionPreferencesInitializer.PIN_SYNCHRONIZATION));
+ // 3] check preference
+ if (synchronizePin) {
+ StartObjectBehaviorAction editedModelElement = (StartObjectBehaviorAction) request.getElementToEdit();
+ if (editedModelElement != null) {
+ // 4] call the command for the StartObjectBehaviorAction
+ IPinUpdater<StartObjectBehaviorAction> updater = PinUpdaterFactory.getInstance().instantiate(editedModelElement);
+ return new PinUpdateCommand<StartObjectBehaviorAction>("Update start object behavior action pins", updater, editedModelElement); //$NON-NLS-1$
+ }
+ }
+ }
+ return null;
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractCallActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractCallActionPinUpdater.java
index 54cc3252da9..747441c0cc8 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractCallActionPinUpdater.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractCallActionPinUpdater.java
@@ -7,8 +7,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
- * Sébastien REVOL (CEA LIST) - Initial API and implementation
+ * J�r�mie TATIBOUET (CEA LIST) - Initial API and implementation
+ * S�bastien REVOL (CEA LIST) - Initial API and implementation
*
*****************************************************************************/
@@ -29,7 +29,11 @@ public abstract class AbstractCallActionPinUpdater<NodeType extends CallAction>
@Override
public void updatePins(NodeType node) {
super.updatePins(node);
- this.update(node.getResults(), this.deriveResults(node));
+ if (node.isSynchronous()) {
+ this.update(node.getResults(), this.deriveResults(node));
+ } else {
+ node.getResults().clear();
+ }
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java
index f921020acbe..ce74266e604 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java
@@ -27,6 +27,7 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediatea
import org.eclipse.uml2.uml.AcceptCallAction;
import org.eclipse.uml2.uml.AcceptEventAction;
import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions.StartClassifierBehaviorActionPinUpdater;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions.StartObjectBehaviorActionPinUpdater;
import org.eclipse.uml2.uml.ActivityNode;
import org.eclipse.uml2.uml.AddStructuralFeatureValueAction;
import org.eclipse.uml2.uml.CallBehaviorAction;
@@ -40,6 +41,7 @@ import org.eclipse.uml2.uml.SendSignalAction;
import org.eclipse.uml2.uml.TestIdentityAction;
import org.eclipse.uml2.uml.ValueSpecificationAction;
import org.eclipse.uml2.uml.StartClassifierBehaviorAction;
+import org.eclipse.uml2.uml.StartObjectBehaviorAction;
public class PinUpdaterFactory {
@@ -107,6 +109,8 @@ public class PinUpdaterFactory {
updater = (IPinUpdater<T>) new ReadLinkActionPinUpdater();
} else if (node instanceof StartClassifierBehaviorAction) {
updater = (IPinUpdater<T>) new StartClassifierBehaviorActionPinUpdater();
+ } else if (node instanceof StartObjectBehaviorAction) {
+ updater = (IPinUpdater<T>) new StartObjectBehaviorActionPinUpdater();
}
return updater;
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/StartObjectBehaviorActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/StartObjectBehaviorActionPinUpdater.java
new file mode 100644
index 00000000000..6436d0b08f2
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/intermediateactions/StartObjectBehaviorActionPinUpdater.java
@@ -0,0 +1,139 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.intermediateactions;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.internationalization.common.utils.InternationalizationPreferencesUtils;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater;
+import org.eclipse.papyrus.uml.internationalization.utils.utils.UMLLabelInternationalization;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.OutputPin;
+import org.eclipse.uml2.uml.Parameter;
+import org.eclipse.uml2.uml.ParameterDirectionKind;
+import org.eclipse.uml2.uml.StartObjectBehaviorAction;
+import org.eclipse.uml2.uml.UMLFactory;
+
+/**
+ *
+ * Pins of StartObjectBehaviorAction should be create and update automatically
+ *
+ */
+public class StartObjectBehaviorActionPinUpdater extends AbstractCallActionPinUpdater<StartObjectBehaviorAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#updatePins(org.eclipse.uml2.uml.CallAction)
+ *
+ * @param node
+ */
+ @Override
+ public void updatePins(StartObjectBehaviorAction node) {
+ if (node != null) {
+ // 1] create the object pin if it is not created yet
+ // the object pin stay untyped because we can not deduce its type
+ InputPin object = node.getObject();
+ if (object == null) {
+ object = UMLFactory.eINSTANCE.createInputPin();
+ object.setName("object");
+ object.setLower(1);
+ object.setUpper(1);
+ node.setObject(object);
+ }
+ // 2] Update both arguments and results pins
+ super.updatePins(node);
+ }
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveArguments(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ * @return
+ */
+ @Override
+ public List<InputPin> deriveArguments(StartObjectBehaviorAction node) {
+ List<InputPin> derivedInputPins = new ArrayList<InputPin>();
+ if (node.behavior() != null) {
+ // 1] loop into parameters of the behavior
+ for (Parameter parameter : node.behavior().getOwnedParameters()) {
+ // 2] if the direction is IN or INOUT we create a new input pin
+ // type and multiplicity is align on the parameter
+ // if the direction is INOUT the name has the prefix : "[in]"
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
+ InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
+ derivedInputPins.add(derivedPin);
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[in] " + parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, "[in] " + UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ } else {
+ derivedPin.setName(parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ }
+ }
+ }
+ }
+ return derivedInputPins;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#deriveResults(org.eclipse.uml2.uml.CallAction)
+ *
+ * @param node
+ * @return
+ */
+ @Override
+ public List<OutputPin> deriveResults(StartObjectBehaviorAction node) {
+ List<OutputPin> derivedOutputPins = new ArrayList<OutputPin>();
+ if (node.behavior() != null) {
+ // 1] loop into parameters of the behavior
+ for (Parameter parameter : node.behavior().getOwnedParameters()) {
+ // 2] if the direction is OUT, RETURN or INOUT we create a new output pin
+ // type and multiplicity is align on the parameter
+ // if the direction is INOUt the name has the prefix : "[out]"
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) {
+ OutputPin derivedPin = UMLFactory.eINSTANCE.createOutputPin();
+ derivedOutputPins.add(derivedPin);
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[out] " + parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, "[out] " + UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ } else {
+ derivedPin.setName(parameter.getName());
+ if (InternationalizationPreferencesUtils.getInternationalizationPreference(parameter) && null != UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter)) {
+ UMLLabelInternationalization.getInstance().setLabel(derivedPin, UMLLabelInternationalization.getInstance().getLabelWithoutUML(parameter), null);
+ }
+ }
+ }
+ }
+ }
+ return derivedOutputPins;
+ }
+
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java
index c9c3fb1b053..c5c0ff85011 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/ActivityAutomatedModelCompletionPreferencePage.java
@@ -28,6 +28,7 @@ import org.eclipse.uml2.uml.DestroyLinkAction;
import org.eclipse.uml2.uml.ReadLinkAction;
import org.eclipse.uml2.uml.ReadStructuralFeatureAction;
import org.eclipse.uml2.uml.StartClassifierBehaviorAction;
+import org.eclipse.uml2.uml.StartObjectBehaviorAction;
import org.eclipse.uml2.uml.TestIdentityAction;
import org.eclipse.uml2.uml.ValueSpecificationAction;
@@ -86,6 +87,7 @@ public class ActivityAutomatedModelCompletionPreferencePage extends AbstractAuto
actionList.add(ReadLinkAction.class);
actionList.add(ReadStructuralFeatureAction.class);
actionList.add(StartClassifierBehaviorAction.class);
+ actionList.add(StartObjectBehaviorAction.class);
actionList.add(TestIdentityAction.class);
actionList.add(ValueSpecificationAction.class);
return actionList;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java
index 27bc3b0f7c6..a3e2d8ac9e0 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/AutomatedModelCompletionPreferencesInitializer.java
@@ -53,6 +53,7 @@ public class AutomatedModelCompletionPreferencesInitializer extends AbstractPref
store.setDefault(IAutomatedModelCompletionPreferencesConstants.READ_LINK_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION);
store.setDefault(IAutomatedModelCompletionPreferencesConstants.READ_STRUCTURAL_FEATURE_ACTION_ACCELERATOR, PIN_SYNCHRONIZATION);
store.setDefault(IAutomatedModelCompletionPreferencesConstants.START_CLASSIFIER_BEHAVIOR_ACTION, PIN_SYNCHRONIZATION);
+ store.setDefault(IAutomatedModelCompletionPreferencesConstants.START_OBJECT_BEHAVIOR_ACTION, PIN_SYNCHRONIZATION);
store.setDefault(IAutomatedModelCompletionPreferencesConstants.TEST_IDENTITY_ACTION, PIN_SYNCHRONIZATION);
store.setDefault(IAutomatedModelCompletionPreferencesConstants.VALUE_SPECIFICATION_ACTION, PIN_SYNCHRONIZATION);
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java
index 82a009cb250..28fc2e81482 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/preferences/IAutomatedModelCompletionPreferencesConstants.java
@@ -38,6 +38,8 @@ public interface IAutomatedModelCompletionPreferencesConstants {
final public String START_CLASSIFIER_BEHAVIOR_ACTION = "org.eclipse.papyrus.uml.diagram.activity.preferences.startClassifierBehaviorAction";
+ final public String START_OBJECT_BEHAVIOR_ACTION = "org.eclipse.papyrus.uml.diagram.activity.preferences.startObjectBehaviorAction";
+
final public String TEST_IDENTITY_ACTION = "org.eclipse.papyrus.uml.diagram.activity.preferences.testIdentityAction";
final public String VALUE_SPECIFICATION_ACTION = "org.eclipse.papyrus.uml.diagram.activity.preferences.valueSpecificationAction";

Back to the top