diff options
author | jeremie.tatibouet | 2016-05-11 13:16:19 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-05-26 13:18:13 +0000 |
commit | 9fd88d49b49089b1fd9f943dd6e453610c7bef63 (patch) | |
tree | 3137a203a534e742b0325587d3c6b7b977b9fbfa /plugins | |
parent | 31a1769b68d790fbef50d8adc8e28a9fd89b3cab (diff) | |
download | org.eclipse.papyrus-9fd88d49b49089b1fd9f943dd6e453610c7bef63.tar.gz org.eclipse.papyrus-9fd88d49b49089b1fd9f943dd6e453610c7bef63.tar.xz org.eclipse.papyrus-9fd88d49b49089b1fd9f943dd6e453610c7bef63.zip |
[Bug 406329] - This patch is a first step in removing the manual action
of synchronizing pins of activity nodes. The patch provides the
following contributions:
[1] - An extensible API to define pin derivation rules
[2] - Derivation rules for CallBehaviorAction, CallOperationAction and
SendSignalAction.
[3] - Tests to demonstrate correctness of derivation rules for each of
the type of the aforementioned actions.
Change-Id: I9055a546f0052f3021948914f00dd449ccc2d0ce
Signed-off-by: jeremie.tatibouet <jeremie.tatibouet@cea.fr>
Diffstat (limited to 'plugins')
16 files changed, 874 insertions, 8 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF index eee92929ef6..08ba9080c47 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/META-INF/MANIFEST.MF @@ -32,25 +32,27 @@ Bundle-ClassPath: . Bundle-Name: %pluginName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Require-Bundle: org.eclipse.ui.navigator;visibility:=reexport;bundle-version="[3.6.0,4.0.0)",
+Require-Bundle: org.eclipse.ui.navigator;bundle-version="[3.6.0,4.0.0)";visibility:=reexport,
org.eclipse.ui.navigator.resources;bundle-version="[3.5.0,4.0.0)",
org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide;bundle-version="[1.7.0,2.0.0)",
- org.eclipse.papyrus.infra.gmfdiag.preferences;visibility:=reexport;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.papyrus.infra.gmfdiag.preferences;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
org.eclipse.ocl.ecore;bundle-version="[3.5.0,4.0.0)",
org.eclipse.gmf.runtime.diagram.ui.providers.ide;bundle-version="[1.7.0,2.0.0)",
org.eclipse.gmf.runtime.diagram.ui.render;bundle-version="[1.7.0,2.0.0)",
org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.uml.appearance;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.uml.service.types;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.infra.widgets.toolbox;visibility:=reexport;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
org.eclipse.papyrus.editor;bundle-version="[1.2.0,2.0.0)",
org.eclipse.papyrus.infra.gmfdiag.navigation;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.emf.validation.ocl;visibility:=reexport;bundle-version="[1.4.0,2.0.0)",
+ org.eclipse.emf.validation.ocl;bundle-version="[1.4.0,2.0.0)";visibility:=reexport,
org.eclipse.e4.ui.css.core;bundle-version="[0.11.0,1.0.0)",
org.eclipse.papyrus.infra.hyperlink;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.uml.diagram.common;visibility:=reexport;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.uml.diagram.common;visibility:=reexport;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.uml2.uml.edit;visibility:=reexport;bundle-version="[5.1.0,6.0.0)"
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.uml.diagram.common;bundle-version="[2.0.0,3.0.0)";visibility:=reexport,
+ org.eclipse.uml2.uml.edit;bundle-version="[5.1.0,6.0.0)";visibility:=reexport,
+ org.eclipse.papyrus.infra.gmfdiag.css;bundle-version="[1.2.0,2.0.0)",
+ org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)"
Bundle-Vendor: %providerName
Eclipse-LazyStart: true
Bundle-Version: 2.0.0.qualifier
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/build.properties b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/build.properties index 4d10ea5deca..2e3d8ccd1c8 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/build.properties +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/build.properties @@ -11,7 +11,8 @@ bin.includes = .,\ about.html,\ custom-messages.properties,\ model/activityDiagram.elementtypesconfigurations,\ - model/activityDiagram.configuration + model/activityDiagram.configuration,\ + css/ jars.compile.order=. src.includes = about.html source.. = src-gen/,\ diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css new file mode 100644 index 00000000000..97e4068b76a --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/css/default-theme-contribution-activity-diagram.css @@ -0,0 +1,3 @@ +CallBehaviorAction, CallOperationAction, SendSignalAction{
+ canonical: true;
+}
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallBehaviorActionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallBehaviorActionEditHelperAdvice.java index 41bb7e59c56..a7f8258a8ec 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallBehaviorActionEditHelperAdvice.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallBehaviorActionEditHelperAdvice.java @@ -22,10 +22,14 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.activity.edit.commands.util.PinUpdateCommand;
import org.eclipse.papyrus.uml.diagram.activity.edit.dialogs.CreateCallBehaviorActionDialog;
+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.swt.widgets.Display;
import org.eclipse.uml2.uml.Activity;
import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.CallBehaviorAction;
import org.eclipse.uml2.uml.InvocationAction;
import org.eclipse.uml2.uml.UMLPackage;
@@ -71,8 +75,26 @@ public class CallBehaviorActionEditHelperAdvice extends AbstractEditHelperAdvice return null;
}
+ @SuppressWarnings("unchecked")
@Override
public void configureRequest(IEditCommandRequest request) {
request.getParameters().put(POPUP_TYPE, CALL_BEHAVIOR_ACTION);
}
+
+ /**
+ * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeSetCommand(org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest)
+ *
+ * @param request
+ * @return
+ */
+ @Override
+ protected ICommand getAfterSetCommand(SetRequest request) {
+ CallBehaviorAction editedModelElement = (CallBehaviorAction)request.getElementToEdit();
+ if(request.getFeature()==UMLPackage.eINSTANCE.getCallBehaviorAction_Behavior()){
+ IPinUpdater<CallBehaviorAction> updater = PinUpdaterFactory.getInstance().instantiate(editedModelElement);
+ return new PinUpdateCommand<CallBehaviorAction>("Update call behavior action pins", updater, editedModelElement);
+ }else{
+ return null;
+ }
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallOperationActionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallOperationActionEditHelperAdvice.java index 986f3b0468c..dac247e8b07 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallOperationActionEditHelperAdvice.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/CallOperationActionEditHelperAdvice.java @@ -21,7 +21,10 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.activity.edit.commands.util.PinUpdateCommand;
import org.eclipse.papyrus.uml.diagram.activity.edit.dialogs.CreateCallOperationActionDialog;
+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.swt.widgets.Display;
import org.eclipse.uml2.uml.Activity;
import org.eclipse.uml2.uml.CallOperationAction;
@@ -65,4 +68,21 @@ public class CallOperationActionEditHelperAdvice extends AbstractEditHelperAdvic }
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) {
+ CallOperationAction editedModelElement = (CallOperationAction) request.getElementToEdit();
+ if(request.getFeature()==UMLPackage.eINSTANCE.getCallOperationAction_Operation()){
+ IPinUpdater<CallOperationAction> updater =PinUpdaterFactory.getInstance().instantiate(editedModelElement);
+ return new PinUpdateCommand<CallOperationAction>("Update call operation action pins", updater, editedModelElement);
+ }else{
+ return null;
+ }
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SendSignalActionEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SendSignalActionEditHelperAdvice.java index 76b76a50afc..1cb94f12d1e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SendSignalActionEditHelperAdvice.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/SendSignalActionEditHelperAdvice.java @@ -21,7 +21,10 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.uml.diagram.activity.edit.commands.util.PinUpdateCommand;
import org.eclipse.papyrus.uml.diagram.activity.edit.dialogs.CreateSendSignalActionDialog;
+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.swt.widgets.Display;
import org.eclipse.uml2.uml.Activity;
import org.eclipse.uml2.uml.InvocationAction;
@@ -65,4 +68,21 @@ public class SendSignalActionEditHelperAdvice extends AbstractEditHelperAdvice { }
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) {
+ SendSignalAction editedModelElement = (SendSignalAction) request.getElementToEdit();
+ if(request.getFeature()==UMLPackage.eINSTANCE.getSendSignalAction_Signal()){
+ IPinUpdater<SendSignalAction > updater = PinUpdaterFactory.getInstance().instantiate(editedModelElement);
+ return new PinUpdateCommand<SendSignalAction>("Update send signal action pins", updater, editedModelElement);
+ }else{
+ return null;
+ }
+ }
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/util/PinUpdateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/util/PinUpdateCommand.java new file mode 100644 index 00000000000..a9904b8aa83 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/commands/util/PinUpdateCommand.java @@ -0,0 +1,92 @@ +/*****************************************************************************
+ * 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.commands.util;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.gmf.runtime.common.core.command.AbstractCommand;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.IPinUpdater;
+import org.eclipse.uml2.uml.ActivityNode;
+
+public class PinUpdateCommand<NodeType extends ActivityNode> extends AbstractCommand {
+
+ /**
+ *
+ */
+ protected IPinUpdater<NodeType> updater;
+
+ /**
+ *
+ */
+ protected NodeType node;
+
+ /**
+ * Constructor.
+ *
+ * @param label
+ */
+ public PinUpdateCommand(String label, IPinUpdater<NodeType> updater, NodeType node) {
+ super(label);
+ this.updater = updater;
+ this.node = node;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param arg0
+ * @param arg1
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doExecuteWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException {
+ CommandResult result = CommandResult.newOKCommandResult();
+ try{
+ this.updater.updatePins(this.node);
+ }catch(Exception e){
+ result = CommandResult.newErrorCommandResult(e);
+ }
+ return result;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doRedoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param arg0
+ * @param arg1
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doRedoWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException {
+ return null;
+ }
+
+ /**
+ * @see org.eclipse.gmf.runtime.common.core.command.AbstractCommand#doUndoWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
+ *
+ * @param arg0
+ * @param arg1
+ * @return
+ * @throws ExecutionException
+ */
+ @Override
+ protected CommandResult doUndoWithResult(IProgressMonitor arg0, IAdaptable arg1) throws ExecutionException {
+ return null;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomCallBehaviorActionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomCallBehaviorActionEditPart.java index 2ac34349a57..324026b95ac 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomCallBehaviorActionEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/part/CustomCallBehaviorActionEditPart.java @@ -5,6 +5,7 @@ import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.gef.EditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; import org.eclipse.gmf.runtime.notation.View; 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 new file mode 100644 index 00000000000..54cc3252da9 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractCallActionPinUpdater.java @@ -0,0 +1,44 @@ +/*****************************************************************************
+ * 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:
+ * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
+ * Sébastien REVOL (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import java.util.List;
+
+import org.eclipse.uml2.uml.CallAction;
+import org.eclipse.uml2.uml.OutputPin;
+
+public abstract class AbstractCallActionPinUpdater<NodeType extends CallAction> extends AbstractInvocationActionPinUpdater<NodeType> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#updatePin(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ */
+ @Override
+ public void updatePins(NodeType node) {
+ super.updatePins(node);
+ this.update(node.getResults(), this.deriveResults(node));
+ }
+
+ /**
+ * Derive the list of result pins for the CallAction
+ *
+ * @param node
+ * the call action for which result pins are derived
+ *
+ * @return the list of derived result pins
+ */
+ public abstract List<OutputPin> deriveResults(NodeType node);
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractInvocationActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractInvocationActionPinUpdater.java new file mode 100644 index 00000000000..ce0664ce2bc --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/AbstractInvocationActionPinUpdater.java @@ -0,0 +1,175 @@ +/*****************************************************************************
+ * 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:
+ * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
+ * Sébastien REVOL (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.uml2.uml.Activity;
+import org.eclipse.uml2.uml.ActivityEdge;
+import org.eclipse.uml2.uml.ActivityPartition;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.InvocationAction;
+import org.eclipse.uml2.uml.Pin;
+import org.eclipse.uml2.uml.StructuredActivityNode;
+
+public abstract class AbstractInvocationActionPinUpdater<NodeType extends InvocationAction> implements IPinUpdater<NodeType> {
+
+ /**
+ * The derived target is always named 'target'.
+ */
+ protected static final String TARGET_NAME = "target";
+
+ /**
+ * Update the original pins with newly derived pins. If it is possible to preserve
+ * existing pins then this action is preferred to replacement.
+ *
+ * @param originPins
+ * the list of pins already existing for the node
+ * @param newPins
+ * the list of pins newly computed for the node
+ */
+ protected <P extends Pin> void update(List<P> originPins, List<P> newPins) {
+ List<P> orderedPinsList = new ArrayList<P>();
+ Iterator<P> newPinsIterator = newPins.iterator();
+ while (newPinsIterator.hasNext()) {
+ P newPin = newPinsIterator.next();
+ Iterator<P> originPinsIterator = originPins.iterator();
+ P preservedPin = null;
+ while (originPinsIterator.hasNext() && preservedPin == null) {
+ // Search an existing pin in the 'originPins' which can be
+ // preserved and updated with the data of the new pin under
+ // consideration
+ P originPin = originPinsIterator.next();
+ if (!orderedPinsList.contains(originPin) && isReusable(newPin, originPin)) {
+ preservedPin = originPin;
+ update(preservedPin, newPin);
+ orderedPinsList.add(preservedPin);
+ }
+ }
+ if (preservedPin == null) {
+ // No original pin could be preserved.
+ orderedPinsList.add(newPin);
+ }
+ }
+ // 2 - Propagate deletion of unpreserved pins to edges
+ // that may use them either as source or target
+ for (P pin : originPins) {
+ if (!orderedPinsList.contains(pin)) {
+ delete(pin);
+ }
+ }
+ // 3 - Update the originPins list with the content of the orderedPinList
+ originPins.clear();
+ originPins.addAll(orderedPinsList);
+ }
+
+ /**
+ * An existing pin can only be reused under the following conditions:
+ * 1] Original type conforms to the new type (i.e. the new type is a super type of the original type or the original type itself)
+ * 2] The multiplicity of the new pin is wider than, or the same as, self
+ *
+ * @param new_
+ * the new pin
+ * @param origin
+ * the original pin
+ * @return true of it can be reused, false otherwise
+ */
+ private static boolean isReusable(Pin new_, Pin origin) {
+ boolean reuse = true;
+ if (new_.getType() != null && origin.getType() != null) {
+ reuse = origin.getType().conformsTo(new_.getType());
+ }
+ if (reuse) {
+ reuse = origin.compatibleWith(new_);
+ }
+ return reuse;
+ }
+
+ /**
+ * Update multiplicity, type and name of origin pin with the new pin
+ *
+ * @param origin
+ * the original pin
+ * @param new_
+ * the new pin
+ */
+ protected static void update(Pin origin, Pin new_) {
+ origin.setLower(new_.getLower());
+ origin.setUpper(new_.getUpper());
+ origin.setType(new_.getType());
+ origin.setName(new_.getName());
+ }
+
+ /**
+ * The deletion of a pin has an impact on edges that are using as a source or a target.
+ * To ensure model consistency, the deletion of a pin implies deletion of edges referencing
+ * this pin either as a source or a target.
+ *
+ * @param pin
+ */
+ protected static void delete(Pin pin) {
+ List<ActivityEdge> edgeToDelete = new ArrayList<ActivityEdge>(pin.getIncomings());
+ edgeToDelete.addAll(pin.getOutgoings());
+ Iterator<ActivityEdge> edgeToDeleteIterator = edgeToDelete.iterator();
+ while (edgeToDeleteIterator.hasNext()) {
+ ActivityEdge edge = edgeToDeleteIterator.next();
+ Element owner = edge.getOwner();
+ if (owner != null) {
+ if (owner instanceof StructuredActivityNode) {
+ ((StructuredActivityNode) owner).getEdges().remove(edge);
+ } else if (owner instanceof Activity) {
+ ((Activity) owner).getEdges().remove(edge);
+ } else if (owner instanceof ActivityPartition) {
+ ((ActivityPartition) owner).getEdges().remove(edge);
+ }
+ }
+ }
+ }
+
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.IPinUpdater#updatePin(org.eclipse.uml2.uml.ActivityNode)
+ *
+ * @param node
+ */
+ @Override
+ public void updatePins(NodeType node) {
+ this.update(node.getArguments(), this.deriveArguments(node));
+ }
+
+ /**
+ * Derive the argument pins of the invocation action
+ *
+ * @param node
+ * the invocation action for which the arguments pin are derived
+ * @return the list of derived arguments pin
+ */
+ public abstract List<InputPin> deriveArguments(NodeType node);
+
+ /**
+ * Derive the target used for the invocation action
+ *
+ * @param node
+ * the invocation action for which the target is derived
+ * @return the input pin corresponding to the derived target
+ */
+ public InputPin deriveTarget(NodeType node) {
+ return null; // By default do nothing
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallBehaviorActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallBehaviorActionPinUpdater.java new file mode 100644 index 00000000000..616d142be1c --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallBehaviorActionPinUpdater.java @@ -0,0 +1,86 @@ +/*****************************************************************************
+ * 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:
+ * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
+ * Sébastien REVOL (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.uml2.uml.CallBehaviorAction;
+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.UMLFactory;
+
+public class CallBehaviorActionPinUpdater extends AbstractCallActionPinUpdater<CallBehaviorAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#deriveResults()
+ *
+ * @return
+ */
+ @Override
+ public List<OutputPin> deriveResults(CallBehaviorAction node) {
+ List<OutputPin> derivedOutputPins = new ArrayList<OutputPin>();
+ if (node.getBehavior() != null) {
+ for (Parameter parameter : node.getBehavior().getOwnedParameters()) {
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) {
+ OutputPin derivedPin = UMLFactory.eINSTANCE.createOutputPin();
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[out] " + parameter.getName());
+ } else {
+ derivedPin.setName(parameter.getName());
+ }
+ derivedOutputPins.add(derivedPin);
+ }
+ }
+ }
+ return derivedOutputPins;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveArguments()
+ *
+ * @return
+ */
+ @Override
+ public List<InputPin> deriveArguments(CallBehaviorAction node) {
+ List<InputPin> derivedInputPins = new ArrayList<InputPin>();
+ if (node.getBehavior() != null) {
+ for (Parameter parameter : node.getBehavior().getOwnedParameters()) {
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
+ InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[in] " + parameter.getName());
+ } else {
+ derivedPin.setName(parameter.getName());
+ }
+ derivedInputPins.add(derivedPin);
+ }
+ }
+ }
+ return derivedInputPins;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallOperationActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallOperationActionPinUpdater.java new file mode 100644 index 00000000000..740970dd592 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/CallOperationActionPinUpdater.java @@ -0,0 +1,126 @@ +/*****************************************************************************
+ * 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:
+ * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
+ * Sébastien REVOL (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.uml2.uml.CallOperationAction;
+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.UMLFactory;
+
+public class CallOperationActionPinUpdater extends AbstractCallActionPinUpdater<CallOperationAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractCallActionPinUpdater#updatePins(org.eclipse.uml2.uml.CallAction)
+ *
+ * @param node
+ */
+ @Override
+ public void updatePins(CallOperationAction node) {
+ // Update both arguments and results
+ super.updatePins(node);
+ // Ensure a target is set for this operation call
+ InputPin targetPin = this.deriveTarget(node);
+ if (node.getTarget() == null) {
+ node.setTarget(targetPin);
+ } else {
+ update(node.getTarget(), targetPin);
+ }
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveTarget(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ * @return
+ */
+ @Override
+ public InputPin deriveTarget(CallOperationAction node) {
+ InputPin pinTarget = UMLFactory.eINSTANCE.createInputPin();
+ pinTarget.setLower(1);
+ pinTarget.setUpper(1);
+ pinTarget.setName(TARGET_NAME);
+ if (node.getOperation() != null) {
+ pinTarget.setType(node.getOperation().getClass_());
+ }
+ return pinTarget;
+ }
+
+ /**
+ * @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(CallOperationAction node) {
+ List<InputPin> derivedInputPins = new ArrayList<InputPin>();
+ if (node.getOperation() != null) {
+ for (Parameter parameter : node.getOperation().getOwnedParameters()) {
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.IN_LITERAL) {
+ InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[in] " + parameter.getName());
+ } else {
+ derivedPin.setName(parameter.getName());
+ }
+ derivedInputPins.add(derivedPin);
+ }
+ }
+ }
+ 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(CallOperationAction node) {
+ List<OutputPin> derivedOutputPins = new ArrayList<OutputPin>();
+ if (node.getOperation() != null) {
+ for (Parameter parameter : node.getOperation().getOwnedParameters()) {
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.RETURN_LITERAL
+ || parameter.getDirection() == ParameterDirectionKind.OUT_LITERAL) {
+ OutputPin derivedPin = UMLFactory.eINSTANCE.createOutputPin();
+ derivedPin.setType(parameter.getType());
+ derivedPin.setLower(parameter.getLower());
+ derivedPin.setUpper(parameter.getUpper());
+ if (parameter.getDirection() == ParameterDirectionKind.INOUT_LITERAL) {
+ derivedPin.setName("[out] " + parameter.getName());
+ } else {
+ derivedPin.setName(parameter.getName());
+ }
+ derivedOutputPins.add(derivedPin);
+ }
+ }
+ }
+ 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/IPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/IPinUpdater.java new file mode 100644 index 00000000000..bd257b36d8d --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/IPinUpdater.java @@ -0,0 +1,31 @@ +/*****************************************************************************
+ * 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:
+ * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
+ * Sébastien REVOL (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import org.eclipse.uml2.uml.ActivityNode;
+
+public interface IPinUpdater<NodeType extends ActivityNode> {
+
+ /**
+ * The role of a 'pin updater' is to enable update of any pin of a particular activity node.
+ * This operation is intended to implement the the general algorithm to update pins.
+ *
+ * @param node
+ * the activity node for which the pins need to be updated
+ *
+ */
+ public void updatePins(NodeType node);
+
+}
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 new file mode 100644 index 00000000000..d34fb4ccece --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/PinUpdaterFactory.java @@ -0,0 +1,69 @@ +/*****************************************************************************
+ * 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:
+ * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
+ * Sébastien REVOL (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import org.eclipse.uml2.uml.ActivityNode;
+import org.eclipse.uml2.uml.CallBehaviorAction;
+import org.eclipse.uml2.uml.CallOperationAction;
+import org.eclipse.uml2.uml.SendSignalAction;
+
+public class PinUpdaterFactory {
+
+ /**
+ * Singleton reference
+ */
+ private static PinUpdaterFactory INSTANCE;
+
+ /**
+ * Constructor.
+ */
+ private PinUpdaterFactory() {
+ }
+
+ /**
+ * Provide access to the singleton instance
+ *
+ * @return INSTANCE
+ * the singleton
+ */
+ public static PinUpdaterFactory getInstance() {
+ if (INSTANCE == null) {
+ INSTANCE = new PinUpdaterFactory();
+ }
+ return INSTANCE;
+ }
+
+ /**
+ * Provide a pin updater for the given activity node. This update encapsulates
+ * logic to derive activity node pins.
+ *
+ * @param node
+ * the activity node
+ * @return updater
+ * the pin updater for the given activity node
+ */
+ @SuppressWarnings("unchecked")
+ public <T extends ActivityNode> IPinUpdater<T> instantiate(ActivityNode node) {
+ IPinUpdater<T> updater = null;
+ if (node instanceof CallBehaviorAction) {
+ updater = (IPinUpdater<T>) new CallBehaviorActionPinUpdater();
+ } else if (node instanceof CallOperationAction) {
+ updater = (IPinUpdater<T>) new CallOperationActionPinUpdater();
+ } else if (node instanceof SendSignalAction) {
+ updater = (IPinUpdater<T>) new SendSignalActionPinUpdater();
+ }
+ 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/SendSignalActionPinUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/SendSignalActionPinUpdater.java new file mode 100644 index 00000000000..890f4b7933a --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/utils/updater/SendSignalActionPinUpdater.java @@ -0,0 +1,166 @@ +/*****************************************************************************
+ * 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:
+ * Jérémie TATIBOUET (CEA LIST) - Initial API and implementation
+ * Sébastien REVOL (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.window.Window;
+import org.eclipse.papyrus.infra.widgets.editors.TreeSelectorDialog;
+import org.eclipse.papyrus.uml.tools.providers.UMLContentProvider;
+import org.eclipse.papyrus.uml.tools.providers.UMLLabelProvider;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.uml2.uml.InputPin;
+import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.Reception;
+import org.eclipse.uml2.uml.SendSignalAction;
+import org.eclipse.uml2.uml.Signal;
+import org.eclipse.uml2.uml.Type;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.UMLFactory;
+import org.eclipse.uml2.uml.UMLPackage;
+
+public class SendSignalActionPinUpdater extends AbstractInvocationActionPinUpdater<SendSignalAction> {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#updatePins(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ */
+ @Override
+ public void updatePins(SendSignalAction node) {
+ // Update arguments
+ super.updatePins(node);
+ // Update target
+ InputPin targetPin = this.deriveTarget(node);
+ if (node.getTarget() == null) {
+ node.setTarget(targetPin);
+ } else {
+ update(node.getTarget(), targetPin);
+ }
+ }
+
+ private static boolean canReceive(Class clazz, Signal signal) {
+ Reception matchingReception = null;
+ Iterator<Reception> receptionsIterator = clazz.getOwnedReceptions().iterator();
+ while (matchingReception == null && receptionsIterator.hasNext()) {
+ Reception currentReception = receptionsIterator.next();
+ if (currentReception.getSignal() != null) {
+ matchingReception = currentReception.getSignal().conformsTo(signal) ? currentReception : null;
+ }
+ }
+ return matchingReception != null;
+ }
+
+ /**
+ * Derive the type of the target in the context of a SendSignalAction. Three cases are supported:
+ *
+ * 1] A port is specified to send the signal. In the theory, this port must be owned the class realizing the sending. Hence
+ * the type chosen for the target is the class owning the port.
+ *
+ * 2] The node already has a typed target pin. Make sure this type is still correct. This is evaluated by checking if
+ * the type has a reception for chosen signal. If it is the case the type is reused, otherwise the only remaining solution
+ * is to propose to the user all classes having a reception on the signal referenced by the action.
+ *
+ * @param node
+ * the send signal action for which the target type is derived
+ *
+ * @return the derived type or null
+ */
+ private Type deriveTargetType(SendSignalAction node) {
+ Type targetPinType = null;
+ if (node.getOnPort() != null) {
+ // If a port is specified it is possible to propose a type for the target pin. The type
+ // is the type of class owning the port. This proposal might not be always right however it
+ // if the signal is sent through a port it reasonable to think that the target used for the
+ // send is of the type of the port owner.
+ targetPinType = node.getOnPort().getClass_();
+ } else {
+ if (node.getTarget() != null) {
+ Type currentTargetPinType = node.getTarget().getType();
+ if (currentTargetPinType instanceof Class && canReceive((Class) currentTargetPinType, node.getSignal())) {
+ targetPinType = currentTargetPinType;
+ }
+ }
+ if (targetPinType == null && Display.getCurrent() !=null) {
+ // In this case there is no automated derivation possible. Indeed at most we can only propose
+ // to the user to choose among a list of type being able to accept the arrival of the signal
+ // specified for the given action.
+ //
+ // Note: This can only be realized if this code is called from UI thread
+ InputPin currentTargetPin = node.getTarget();
+ if (currentTargetPin == null) {
+ node.setTarget(UMLFactory.eINSTANCE.createInputPin());
+ }
+ UMLContentProvider provider = new UMLContentProvider(node.getTarget(), UMLPackage.eINSTANCE.getTypedElement_Type());
+ TreeSelectorDialog dialog = new TreeSelectorDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
+ dialog.setTitle("Select type");
+ dialog.setDescription("Select type for target input pin");
+ dialog.setContentProvider(provider);
+ dialog.setLabelProvider(new UMLLabelProvider());
+ int userResponse = dialog.open();
+ if (userResponse == Window.OK) {
+ Object[] result = dialog.getResult();
+ if (result != null && result.length > 0 && result[0] instanceof Type) {
+ targetPinType = (Type) result[0];
+ }
+ }
+ node.setTarget(currentTargetPin);
+ }
+ }
+ return targetPinType;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.activity.edit.utils.updater.AbstractInvocationActionPinUpdater#deriveTarget(org.eclipse.uml2.uml.InvocationAction)
+ *
+ * @param node
+ * @return
+ */
+ @Override
+ public InputPin deriveTarget(SendSignalAction node) {
+ InputPin targetPin = UMLFactory.eINSTANCE.createInputPin();
+ targetPin.setLower(1);
+ targetPin.setUpper(1);
+ targetPin.setName(TARGET_NAME);
+ targetPin.setType(this.deriveTargetType(node));
+ return targetPin;
+ }
+
+ /**
+ * @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(SendSignalAction node) {
+ List<InputPin> derivedInputPins = new ArrayList<InputPin>();
+ if (node.getSignal() != null) {
+ for (Property property : node.getSignal().getAllAttributes()) {
+ InputPin derivedPin = UMLFactory.eINSTANCE.createInputPin();
+ derivedPin.setLower(property.getLower());
+ derivedPin.setUpper(property.getUpper());
+ derivedPin.setType(property.getType());
+ derivedPin.setName(property.getName());
+ derivedInputPins.add(derivedPin);
+ }
+ }
+ return derivedInputPins;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml index 3a2f932086d..5ce95b5f349 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/plugin.xml @@ -3337,5 +3337,13 @@ self.structuralFeature.oclAsType(Property).opposite.type = self.object.type]]> label="Owned activity hyperlinks"> </contributor> </extension> +<extension + id="org.eclipse.papyrus.uml.diagram.activity.css" + name="CSS extension for activity models" + point="org.eclipse.papyrus.infra.gmfdiag.css.userAgentStyleSheet"> + <stylesheet + stylesheetPath="css/default-theme-contribution-activity-diagram.css"> + </stylesheet> +</extension> </plugin> |