diff options
9 files changed, 156 insertions, 379 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ObjectFlowEditHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ObjectFlowEditHelperAdvice.java new file mode 100644 index 00000000000..fdc5dee05ff --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/advices/ObjectFlowEditHelperAdvice.java @@ -0,0 +1,112 @@ +/***************************************************************************** + * 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: + * Pauline DEVILLE (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.activity.edit.advices; + +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.CommandResult; +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.commands.ConfigureElementCommand; +import org.eclipse.gmf.runtime.emf.type.core.commands.CreateElementCommand; +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.CreateElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.papyrus.uml.tools.utils.ObjectFlowUtil; +import org.eclipse.uml2.uml.Action; +import org.eclipse.uml2.uml.ActivityNode; +import org.eclipse.uml2.uml.InputPin; +import org.eclipse.uml2.uml.ObjectFlow; +import org.eclipse.uml2.uml.OutputPin; + +/** + * This Advice Helper is user to create pin between an ObjectFlow and an action (if it is authorized) + */ +public class ObjectFlowEditHelperAdvice extends AbstractEditHelperAdvice { + + protected ICommand getAfterConfigureCommand(final ConfigureRequest req) { + ICommand configureCommand = new ConfigureElementCommand(req) { + + protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { + ObjectFlow element = (ObjectFlow) req.getElementToConfigure(); + ActivityNode source = getSourceObject(req); + ActivityNode target = getTargetObject(req); + // add pin if the source or the target is an action (see Bug 460022) + if (source instanceof Action) { + if (ObjectFlowUtil.insertPinForStartingNewObjectFlow(source)) { + CreateElementRequest req = new CreateElementRequest(source, UMLElementTypes.OUTPUT_PIN); + CreateElementCommand cmd = new CreateElementCommand(req); + cmd.execute(null, null); + CommandResult commandResult = cmd.getCommandResult(); + if (commandResult != null) { + if (!commandResult.getStatus().isOK()) { + return commandResult; + } + } + OutputPin pin = (OutputPin) commandResult.getReturnValue(); + ObjectFlowUtil.insertOutputPin((Action) source, pin); + source = pin; + } + } + if (target instanceof Action) { + if (ObjectFlowUtil.insertPinForStartingNewObjectFlow(target)) { + CreateElementRequest req = new CreateElementRequest(target, UMLElementTypes.INPUT_PIN); + CreateElementCommand cmd = new CreateElementCommand(req); + cmd.execute(null, null); + CommandResult commandResult = cmd.getCommandResult(); + if (commandResult != null) { + if (!commandResult.getStatus().isOK()) { + return commandResult; + } + } + InputPin pin = (InputPin) commandResult.getReturnValue(); + ObjectFlowUtil.insertInputPin((Action) target, pin); + target = pin; + } + } + if (source != null) { + element.setSource(source); + } + if (target != null) { + element.setTarget(target); + } + return CommandResult.newOKCommandResult(element); + } + }; + return CompositeCommand.compose(configureCommand, super.getAfterConfigureCommand(req)); + } + + /** + * This method provides the object to be use as source. + * + * @return the source value + */ + protected ActivityNode getSourceObject(ConfigureRequest req) { + Object result = req.getParameter(CreateRelationshipRequest.SOURCE); + return (result instanceof ActivityNode) ? (ActivityNode) result : null; + } + + /** + * This method provides the object to be used as target. + * + * @return the target value + */ + protected ActivityNode getTargetObject(ConfigureRequest req) { + Object result = req.getParameter(CreateRelationshipRequest.TARGET); + return (result instanceof ActivityNode) ? (ActivityNode) result : null; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ObjectFlowWithPinsCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ObjectFlowWithPinsCreationEditPolicy.java deleted file mode 100644 index 44222f1647a..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ObjectFlowWithPinsCreationEditPolicy.java +++ /dev/null @@ -1,256 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 Atos Origin. - * - * - * 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: - * Atos Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.activity.edit.policies; - -import java.util.Iterator; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.requests.CreateConnectionRequest; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.common.core.util.StringStatics; -import org.eclipse.gmf.runtime.diagram.core.commands.SetConnectionAnchorsCommand; -import org.eclipse.gmf.runtime.diagram.core.commands.SetConnectionEndsCommand; -import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand; -import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.internal.commands.SetConnectionBendpointsCommand; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; -import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; -import org.eclipse.gmf.runtime.emf.type.core.IHintedType; -import org.eclipse.gmf.runtime.notation.Connector; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.gmf.runtime.notation.impl.ShapeImpl; -import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes; -import org.eclipse.uml2.uml.ActivityNode; -import org.eclipse.uml2.uml.ObjectFlow; - -public class ObjectFlowWithPinsCreationEditPolicy extends GraphicalNodeEditPolicy { - - /** - * Returns a command that will initialize connection creation. - * - * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy#getConnectionCreateCommand(org.eclipse.gef.requests.CreateConnectionRequest) - * @param request - * the request for creating the connection - * @return the command - */ - @Override - protected Command getConnectionCreateCommand(CreateConnectionRequest request) { - if (!(request instanceof CreateConnectionViewRequest)) { - return null; - } - CreateConnectionViewRequest req = (CreateConnectionViewRequest) request; - CompositeCommand cc = new CompositeCommand(DiagramUIMessages.Commands_CreateCommand_Connection_Label); - Diagram diagramView = ((View) getHost().getModel()).getDiagram(); - TransactionalEditingDomain editingDomain = getEditingDomain(); - CreateCommand createCommand = new CreateCommand(editingDomain, req.getConnectionViewDescriptor(), diagramView.getDiagram()); - setViewAdapter((IAdaptable) createCommand.getCommandResult().getReturnValue()); - SetConnectionEndsCommand sceCommand = new SetConnectionEndsCommand(editingDomain, StringStatics.BLANK); - sceCommand.setEdgeAdaptor(getViewAdapter()); - if (getObjectFlowHint().equals(req.getConnectionViewDescriptor().getSemanticHint())) { - // handle redirection of Object flow on created child pin - sceCommand.setNewSourceAdaptor(getObjectFlowSourceViewAdapter(request)); - } else { - sceCommand.setNewSourceAdaptor(new EObjectAdapter(getView())); - } - ConnectionAnchor sourceAnchor = getConnectableEditPart().getSourceConnectionAnchor(request); - SetConnectionAnchorsCommand scaCommand = new SetConnectionAnchorsCommand(editingDomain, StringStatics.BLANK); - scaCommand.setEdgeAdaptor(getViewAdapter()); - scaCommand.setNewSourceTerminal(getConnectableEditPart().mapConnectionAnchorToTerminal(sourceAnchor)); - SetConnectionBendpointsCommand sbbCommand = new SetConnectionBendpointsCommand(editingDomain); - sbbCommand.setEdgeAdapter(getViewAdapter()); - cc.compose(createCommand); - cc.compose(sceCommand); - cc.compose(scaCommand); - cc.compose(sbbCommand); - Command c = new ICommandProxy(cc); - request.setStartCommand(c); - return c; - } - - /** - * Get the semantic hint for an object flow edge - * - * @return semantic hint - */ - private static String getObjectFlowHint() { - IHintedType objectFlowType = (IHintedType) UMLElementTypes.ObjectFlow_Edge; - return objectFlowType.getSemanticHint(); - } - - /** - * Returns a command that will create the connection. - * - * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getConnectionCompleteCommand(org.eclipse.gef.requests.CreateConnectionRequest) - * @param request - * the request for creating the connection - * @return the command - */ - @Override - protected Command getConnectionCompleteCommand(CreateConnectionRequest request) { - ICommandProxy proxy = (ICommandProxy) request.getStartCommand(); - if (proxy == null) { - return null; - } - // reset the target edit-part for the request - INodeEditPart targetEP = getConnectionCompleteEditPart(request); - if (targetEP == null) { - return null; - } - CompositeCommand cc = (CompositeCommand) proxy.getICommand(); - ConnectionAnchor targetAnchor = targetEP.getTargetConnectionAnchor(request); - Iterator commandItr = cc.iterator(); - commandItr.next(); // 0 - SetConnectionEndsCommand sceCommand = (SetConnectionEndsCommand) commandItr.next(); // 1 - if (request instanceof CreateConnectionViewRequest && getObjectFlowHint().equals(((CreateConnectionViewRequest) request).getConnectionViewDescriptor().getSemanticHint())) { - // handle redirection of Object flow on created child pin - sceCommand.setNewTargetAdaptor(getObjectFlowTargetViewAdapter(request)); - } else { - sceCommand.setNewTargetAdaptor(new EObjectAdapter(((IGraphicalEditPart) targetEP).getNotationView())); - } - SetConnectionAnchorsCommand scaCommand = (SetConnectionAnchorsCommand) commandItr.next(); // 2 - scaCommand.setNewTargetTerminal(targetEP.mapConnectionAnchorToTerminal(targetAnchor)); - setViewAdapter(sceCommand.getEdgeAdaptor()); - INodeEditPart sourceEditPart = (INodeEditPart) request.getSourceEditPart(); - ConnectionAnchor sourceAnchor = sourceEditPart.mapTerminalToConnectionAnchor(scaCommand.getNewSourceTerminal()); - PointList pointList = new PointList(); - if (request.getLocation() == null) { - pointList.addPoint(sourceAnchor.getLocation(targetAnchor.getReferencePoint())); - pointList.addPoint(targetAnchor.getLocation(sourceAnchor.getReferencePoint())); - } else { - pointList.addPoint(sourceAnchor.getLocation(request.getLocation())); - pointList.addPoint(targetAnchor.getLocation(request.getLocation())); - } - SetConnectionBendpointsCommand sbbCommand = (SetConnectionBendpointsCommand) commandItr.next(); // 3 - sbbCommand.setNewPointList(pointList, sourceAnchor.getReferencePoint(), targetAnchor.getReferencePoint()); - return request.getStartCommand(); - } - - /** - * Get the adapter to recover the object flow source view - * - * @param request - * connection creation request - * @return adapter - */ - private IAdaptable getObjectFlowSourceViewAdapter(final CreateConnectionRequest request) { - return new IAdaptable() { - - @Override - public Object getAdapter(Class adapter) { - if (adapter != null && adapter.isAssignableFrom(ShapeImpl.class)) { - return getObjectFlowExtremityView(true); - } - return null; - } - }; - } - - /** - * Get the adapter to recover the object flow target view - * - * @param request - * connection creation request - * @return adapter - */ - private IAdaptable getObjectFlowTargetViewAdapter(final CreateConnectionRequest request) { - return new IAdaptable() { - - @Override - public Object getAdapter(Class adapter) { - if (adapter != null && adapter.isAssignableFrom(ShapeImpl.class)) { - return getObjectFlowExtremityView(false); - } - return null; - } - }; - } - - /** - * Try and get an extremity view of the object flow contained in this host. - * - * @param isStartEnd - * true if view is the object flow start end, false for the - * target end - * @return the view or null - */ - protected View getObjectFlowExtremityView(boolean isStartEnd) { - Object objectFlowView = getViewAdapter().getAdapter(Connector.class); - if (objectFlowView instanceof Connector) { - EObject objectFlow = ((Connector) objectFlowView).getElement(); - if (objectFlow instanceof ObjectFlow) { - ActivityNode actNode = null; - if (isStartEnd) { - actNode = ((ObjectFlow) objectFlow).getSource(); - } else { - actNode = ((ObjectFlow) objectFlow).getTarget(); - } - if (actNode != null) { - if (getHost().getModel() instanceof View) { - View view = (View) getHost().getModel(); - if (actNode.equals(view.getElement())) { - return view; - } - } - // refresh view children which have not been created yet. - EditPolicy policy = getHost().getEditPolicy(EditPolicyRoles.CANONICAL_ROLE); - if (policy instanceof CanonicalEditPolicy) { - CanonicalEditPolicy canonical = (CanonicalEditPolicy) policy; - if (!canonical.isEnabled()) { - canonical.setEnable(true); - canonical.refresh(); - canonical.setEnable(false); - } else { - canonical.refresh(); - } - } - // recover the appropriate child view - for (Object childPart : getHost().getChildren()) { - if (childPart instanceof EditPart) { - Object containedView = ((EditPart) childPart).getModel(); - if (containedView instanceof View) { - if (actNode.equals(((View) containedView).getElement())) { - return (View) containedView; - } - } - } - } - } - } - } - return null; - } - - /** - * Get the editing domain - * - * @return editing domain - */ - private TransactionalEditingDomain getEditingDomain() { - return ((IGraphicalEditPart) getHost()).getEditingDomain(); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/OpaqueActionObjectFlowWithPinsCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/OpaqueActionObjectFlowWithPinsCreationEditPolicy.java deleted file mode 100644 index 30364809022..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/OpaqueActionObjectFlowWithPinsCreationEditPolicy.java +++ /dev/null @@ -1,74 +0,0 @@ -/*****************************************************************************
- * Copyright (c) 2011 Atos.
- *
- *
- * 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:
- * Atos - Initial API and implementation
- * Arthur Daussy - Bug 367894 - [activity diagram] pins can not be deleted or hidden directly from selection in diagram
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.activity.edit.policies;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.gef.Request;
-import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
-import org.eclipse.gmf.runtime.notation.Connector;
-import org.eclipse.gmf.runtime.notation.Node;
-import org.eclipse.gmf.runtime.notation.View;
-import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin;
-import org.eclipse.papyrus.uml.diagram.activity.part.UMLVisualIDRegistry;
-import org.eclipse.uml2.uml.ActivityNode;
-import org.eclipse.uml2.uml.ObjectFlow;
-
-/**
- * Used to create pin when creating Object Flow
- *
- * @author arthur daussy
- *
- */
-public class OpaqueActionObjectFlowWithPinsCreationEditPolicy extends ObjectFlowWithPinsCreationEditPolicy {
-
- @Override
- protected View getObjectFlowExtremityView(boolean isStartEnd) {
- Object objectFlowView = getViewAdapter().getAdapter(Connector.class);
- if (objectFlowView instanceof Connector) {
- EObject objectFlow = ((Connector) objectFlowView).getElement();
- if (objectFlow instanceof ObjectFlow) {
- ActivityNode actNode = null;
- if (isStartEnd) {
- actNode = ((ObjectFlow) objectFlow).getSource();
- } else {
- actNode = ((ObjectFlow) objectFlow).getTarget();
- }
- if (actNode != null) {
- if (getHost().getModel() instanceof View) {
- View view = (View) getHost().getModel();
- if (actNode.equals(view.getElement())) {
- return view;
- }
- // if there is no existing view we create it
- Node node = ViewService.createNode(view, actNode, UMLVisualIDRegistry.getType(UMLVisualIDRegistry.getNodeVisualID(view, actNode)), UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
- if (node != null) {
- return node;
- }
- }
- }
- }
- }
- return null;
- }
-
- @Override
- public void eraseSourceFeedback(Request request) {
- if (connectionFeedback != null) {
- removeFeedback(connectionFeedback);
- feedbackHelper = null;
- connectionFeedback = null;
- }
- }
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations index 9a9805231b5..37ff5cbab86 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.elementtypesconfigurations @@ -87,4 +87,7 @@ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_oJutwOI1EeaaNdBqN0EQ0A" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.BehaviorEditHelperAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.BehaviorEditHelperAdvice">
<target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.Behavior"/>
</adviceBindingsConfigurations>
+ <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_qpSuUDYlEeeGB7-cMZyxlQ" description="Create pin between an ObjectFlow and an action (if it is authorized)" identifier="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ObjectFlowEditHelperAdvice" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.activity.edit.advices.ObjectFlowEditHelperAdvice">
+ <target xsi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="../../../plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.ObjectFlow"/>
+ </adviceBindingsConfigurations>
</elementtypesconfigurations:ElementTypeSetConfiguration>
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.gmfgen b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.gmfgen index 57a9659e286..c4c63b761f2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.gmfgen +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/model/activityDiagram.gmfgen @@ -18025,10 +18025,6 @@ editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.activity.edit.policies.CreateActionLocalConditionEditPolicy"/> <behaviour xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.activity.edit.policies.ObjectFlowWithPinsCreationEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.gef.RequestConstants.REQ_DELETE" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.activity.edit.policies.DeleteActionViewEditPolicy"/> <behaviour diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src-gen/org/eclipse/papyrus/uml/diagram/activity/edit/parts/CreateLinkObjectActionEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src-gen/org/eclipse/papyrus/uml/diagram/activity/edit/parts/CreateLinkObjectActionEditPart.java index 56d206ae20e..7552562a81a 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src-gen/org/eclipse/papyrus/uml/diagram/activity/edit/parts/CreateLinkObjectActionEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/src-gen/org/eclipse/papyrus/uml/diagram/activity/edit/parts/CreateLinkObjectActionEditPart.java @@ -40,7 +40,6 @@ import org.eclipse.papyrus.uml.diagram.activity.edit.policies.ActivityDiagramCha import org.eclipse.papyrus.uml.diagram.activity.edit.policies.CreateActionLocalConditionEditPolicy;
import org.eclipse.papyrus.uml.diagram.activity.edit.policies.CustomDiagramDragDropEditPolicy;
import org.eclipse.papyrus.uml.diagram.activity.edit.policies.DeleteActionViewEditPolicy;
-import org.eclipse.papyrus.uml.diagram.activity.edit.policies.ObjectFlowWithPinsCreationEditPolicy;
import org.eclipse.papyrus.uml.diagram.activity.edit.policies.OpenDiagramEditPolicy;
import org.eclipse.papyrus.uml.diagram.activity.locator.PinPositionLocator;
import org.eclipse.papyrus.uml.diagram.activity.part.UMLVisualIDRegistry;
@@ -96,7 +95,6 @@ public class CreateLinkObjectActionEditPart extends RoundedCompartmentEditPart { installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy());
installEditPolicy(EditPolicyRoles.OPEN_ROLE, new OpenDiagramEditPolicy());
installEditPolicy(RequestConstants.REQ_CREATE, new CreateActionLocalConditionEditPolicy());
- installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ObjectFlowWithPinsCreationEditPolicy());
installEditPolicy(RequestConstants.REQ_DELETE, new DeleteActionViewEditPolicy());
installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY,
new AppliedStereotypeNodeLabelDisplayEditPolicy());
@@ -158,6 +156,7 @@ public class CreateLinkObjectActionEditPart extends RoundedCompartmentEditPart { /**
*Papyrus codeGen
+ * *@generated
**/
protected void handleNotificationEvent(Notification event) {
@@ -187,6 +186,7 @@ public class CreateLinkObjectActionEditPart extends RoundedCompartmentEditPart { /**
* org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure
+ * * @generated
*/
public RoundedCompartmentFigure getPrimaryShape() {
@@ -334,7 +334,9 @@ public class CreateLinkObjectActionEditPart extends RoundedCompartmentEditPart { /**
* Default implementation treats passed figure as content pane.
* Respects layout one may have set for generated figure.
- * @param nodeShape instance of generated figure class
+ * + * @param nodeShape + * instance of generated figure class * @generated
*/
protected IFigure setupContentPane(IFigure nodeShape) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.linklf/src/org/eclipse/papyrus/uml/diagram/linklf/policy/graphicalnode/LinksLFObjectFlowWithPinsCreationEditPolicies.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.linklf/src/org/eclipse/papyrus/uml/diagram/linklf/policy/graphicalnode/LinksLFObjectFlowWithPinsCreationEditPolicies.java index eeea5a4254e..c014d2852df 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.linklf/src/org/eclipse/papyrus/uml/diagram/linklf/policy/graphicalnode/LinksLFObjectFlowWithPinsCreationEditPolicies.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.linklf/src/org/eclipse/papyrus/uml/diagram/linklf/policy/graphicalnode/LinksLFObjectFlowWithPinsCreationEditPolicies.java @@ -20,20 +20,18 @@ import org.eclipse.draw2d.ConnectionAnchor; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; import org.eclipse.gef.commands.Command; import org.eclipse.gef.requests.CreateConnectionRequest; import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; import org.eclipse.gmf.runtime.common.core.util.StringStatics; import org.eclipse.gmf.runtime.diagram.core.commands.SetConnectionAnchorsCommand; import org.eclipse.gmf.runtime.diagram.core.commands.SetConnectionEndsCommand; +import org.eclipse.gmf.runtime.diagram.core.services.ViewService; import org.eclipse.gmf.runtime.diagram.ui.commands.CreateCommand; import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; import org.eclipse.gmf.runtime.diagram.ui.internal.commands.SetConnectionBendpointsCommand; import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; @@ -41,9 +39,12 @@ import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; import org.eclipse.gmf.runtime.emf.type.core.IHintedType; import org.eclipse.gmf.runtime.notation.Connector; import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.gmf.runtime.notation.Node; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.gmf.runtime.notation.impl.ShapeImpl; import org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.linklf.policies.LinksLFGraphicalNodeEditPolicy; +import org.eclipse.papyrus.uml.diagram.activity.part.UMLDiagramEditorPlugin; +import org.eclipse.papyrus.uml.diagram.activity.part.UMLVisualIDRegistry; import org.eclipse.papyrus.uml.diagram.activity.providers.UMLElementTypes; import org.eclipse.uml2.uml.ActivityNode; import org.eclipse.uml2.uml.ObjectFlow; @@ -214,28 +215,10 @@ public class LinksLFObjectFlowWithPinsCreationEditPolicies extends LinksLFGraphi if (actNode.equals(view.getElement())) { return view; } - } - // refresh view children which have not been created yet. - EditPolicy policy = getHost().getEditPolicy(EditPolicyRoles.CANONICAL_ROLE); - if (policy instanceof CanonicalEditPolicy) { - CanonicalEditPolicy canonical = (CanonicalEditPolicy) policy; - if (!canonical.isEnabled()) { - canonical.setEnable(true); - canonical.refresh(); - canonical.setEnable(false); - } else { - canonical.refresh(); - } - } - // recover the appropriate child view - for (Object childPart : getHost().getChildren()) { - if (childPart instanceof EditPart) { - Object containedView = ((EditPart) childPart).getModel(); - if (containedView instanceof View) { - if (actNode.equals(((View) containedView).getElement())) { - return (View) containedView; - } - } + // if there is no existing view we create it + Node node = ViewService.createNode(view, actNode, UMLVisualIDRegistry.getType(UMLVisualIDRegistry.getNodeVisualID(view, actNode)), UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT); + if (node != null) { + return node; } } } @@ -243,4 +226,13 @@ public class LinksLFObjectFlowWithPinsCreationEditPolicies extends LinksLFGraphi } return null; } + + @Override + public void eraseSourceFeedback(Request request) { + if (connectionFeedback != null) { + removeFeedback(connectionFeedback); + feedbackHelper = null; + connectionFeedback = null; + } + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.linklf/src/org/eclipse/papyrus/uml/diagram/linklf/providers/ActivityLinkLFEditPoliciyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.linklf/src/org/eclipse/papyrus/uml/diagram/linklf/providers/ActivityLinkLFEditPoliciyProvider.java index 72c96ac8249..bbcec593dd0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.linklf/src/org/eclipse/papyrus/uml/diagram/linklf/providers/ActivityLinkLFEditPoliciyProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.linklf/src/org/eclipse/papyrus/uml/diagram/linklf/providers/ActivityLinkLFEditPoliciyProvider.java @@ -15,16 +15,15 @@ package org.eclipse.papyrus.uml.diagram.linklf.providers; import org.eclipse.gef.EditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart; -import org.eclipse.papyrus.uml.diagram.activity.edit.parts.CreateLinkObjectActionEditPart; +import org.eclipse.papyrus.uml.diagram.activity.edit.parts.OpaqueActionEditPart; import org.eclipse.papyrus.uml.diagram.linklf.policy.graphicalnode.LinksLFObjectFlowWithPinsCreationEditPolicies; public class ActivityLinkLFEditPoliciyProvider extends LinksLFEditPolicyProvider { @Override protected void installGraphicalNodeEditPolicy(INodeEditPart nodeEP) { - if (nodeEP instanceof CreateLinkObjectActionEditPart) { - nodeEP.installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, - new LinksLFObjectFlowWithPinsCreationEditPolicies()); + if (nodeEP instanceof OpaqueActionEditPart) { + nodeEP.installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new LinksLFObjectFlowWithPinsCreationEditPolicies()); } else { super.installGraphicalNodeEditPolicy(nodeEP); } diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ObjectFlowUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ObjectFlowUtil.java index 427862d086b..8fa7a47e418 100644 --- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ObjectFlowUtil.java +++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/ObjectFlowUtil.java @@ -13,7 +13,6 @@ package org.eclipse.papyrus.uml.tools.utils;
import org.eclipse.emf.common.util.EList;
-import org.eclipse.uml2.uml.AcceptEventAction;
import org.eclipse.uml2.uml.Action;
import org.eclipse.uml2.uml.Activity;
import org.eclipse.uml2.uml.ActivityEdge;
@@ -45,11 +44,11 @@ public class ObjectFlowUtil { * the action to start from
* @return whether action accept new output pin
*/
- public static boolean canStartNewObjectFlow(Action action) {
+ public static boolean canStartNewObjectFlowByAddingPin(Action action) {
// CallOperationAction and CallBehaviorAction have pre-defined pins which are all represented.
// SendObjectAction have only two input pins which are all represented.
// SendSignalAction has only pre-defined input pins which are all represented.
- return (action instanceof OpaqueAction) || (action instanceof AcceptEventAction);
+ return action instanceof OpaqueAction;
}
/**
@@ -59,7 +58,7 @@ public class ObjectFlowUtil { * the action to end to
* @return whether action accept new input pin
*/
- public static boolean canEndNewObjectFlow(Action action) {
+ public static boolean canEndNewObjectFlowByAddingPin(Action action) {
// CallOperationAction and CallBehaviorAction have pre-defined pins which are all represented.
// SendObjectAction have only two input pins which are all represented.
// SendSignalAction has only pre-defined input pins which are all represented.
@@ -81,8 +80,11 @@ public class ObjectFlowUtil { public static boolean canExistObjectFlow(Activity container, ObjectFlow linkInstance, ActivityNode source, ActivityNode target) {
try {
if (source instanceof Action) {
- // UMl2.5 - 15.7.22.6 constraint: no_executable_nodes
- return false;
+ // rule validateObjectFlow_validateNoActions
+ // rule workaround by addition of pins in case of Action
+ if (!ObjectFlowUtil.canStartNewObjectFlowByAddingPin((Action) source)) {
+ return false;
+ }
}
if (source instanceof InputPin) {
// rule validateInputPin_validateOutgoingEdgesStructuredOnly
@@ -152,8 +154,11 @@ public class ObjectFlowUtil { }
}
if (target instanceof Action) {
- // UMl2.5 - 15.7.22.6 constraint: no_executable_nodes
- return false;
+ // rule validateObjectFlow_validateNoActions
+ // rule workaround by addition of pins in case of Action
+ if (!ObjectFlowUtil.canEndNewObjectFlowByAddingPin((Action) target)) {
+ return false;
+ }
}
if (target instanceof OutputPin) {
// rule validateOutputPin_validateIncomingEdgesStructuredOnly
@@ -245,7 +250,7 @@ public class ObjectFlowUtil { */
public static boolean insertPinForStartingNewObjectFlow(ActivityNode node) {
if (node instanceof Action) {
- return canStartNewObjectFlow((Action) node);
+ return canStartNewObjectFlowByAddingPin((Action) node);
}
return false;
}
@@ -259,7 +264,7 @@ public class ObjectFlowUtil { */
public static boolean insertPinForEndingNewObjectFlow(ActivityNode node) {
if (node instanceof Action) {
- return canEndNewObjectFlow((Action) node);
+ return canEndNewObjectFlowByAddingPin((Action) node);
}
return false;
}
@@ -275,8 +280,6 @@ public class ObjectFlowUtil { public static void insertOutputPin(Action parentAction, OutputPin outputPin) {
if (parentAction instanceof OpaqueAction) {
((OpaqueAction) parentAction).getOutputValues().add(outputPin);
- } else if (parentAction instanceof AcceptEventAction) {
- ((AcceptEventAction) parentAction).getResults().add(outputPin);
}
}
|