diff options
author | Nicolas FAUVERGUE | 2018-09-18 11:53:00 +0000 |
---|---|---|
committer | Patrick Tessier | 2018-10-19 07:39:40 +0000 |
commit | 94e017428e887c22c9a3ff100cbb5dbc61cd50ad (patch) | |
tree | 9ba25ff100522f587f81f9dba15f53a8a213b259 /plugins/uml | |
parent | 353489b4cc8f511882f97c38f98772ddd710df53 (diff) | |
download | org.eclipse.papyrus-94e017428e887c22c9a3ff100cbb5dbc61cd50ad.tar.gz org.eclipse.papyrus-94e017428e887c22c9a3ff100cbb5dbc61cd50ad.tar.xz org.eclipse.papyrus-94e017428e887c22c9a3ff100cbb5dbc61cd50ad.zip |
Bug 536486 - [Sequence Diagram] Duration/time constraint & Duration/time
observation and general ordering
https://bugs.eclipse.org/bugs/show_bug.cgi?id=536486
- Manage Duration/Time constraint, Duration/Time observation and
GeneralOrdering
Change-Id: Ice6a31e9b4bb1e757378494a62a2714d775f47dd
Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@cea.fr>
Diffstat (limited to 'plugins/uml')
173 files changed, 8548 insertions, 11171 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java index 985c770fafd..9e0681d441c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java @@ -43,6 +43,14 @@ import org.eclipse.gmf.runtime.notation.View; */ public class BorderItemResizableEditPolicy extends ResizableShapeEditPolicy { + /** + * Constructor. + * + */ + public BorderItemResizableEditPolicy() { + super(); + } + @Override public void eraseSourceFeedback(Request request) { if ((REQ_MOVE.equals(request.getType()) && isDragAllowed()) || REQ_CLONE.equals(request.getType()) || REQ_ADD.equals(request.getType()) || RequestConstants.REQ_DROP.equals(request.getType()) || REQ_RESIZE.equals(request.getType())) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/ObservationParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/ObservationParser.java new file mode 100644 index 00000000000..52afd9a8003 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/ObservationParser.java @@ -0,0 +1,27 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.parser; + +import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; +import org.eclipse.uml2.uml.Observation; + +/** + * <p> + * An {@link IParser} for {@link Observation} + * </p> + */ +public class ObservationParser extends NamedElementLabelParser { + + // Placeholder + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/theme/uml.css b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/theme/uml.css index 53d369b4f35..142fb709a1a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/theme/uml.css +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/theme/uml.css @@ -1 +1,19 @@ -/* Reserved */ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource + *****************************************************************************/ + +/* + * UML-specific rules for Papyrus Theme and B&W Theme + */ + +DurationObservation > Label { + elementIcon: true; +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.restrictions/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.restrictions/META-INF/MANIFEST.MF index 2c9c9d70ad4..09b190d3c00 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.restrictions/META-INF/MANIFEST.MF +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.restrictions/META-INF/MANIFEST.MF @@ -7,9 +7,9 @@ Bundle-Vendor: Eclipse Modeling Project Automatic-Module-Name: org.eclipse.papyrus.uml.diagram.sequence.restrictions Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy -Service-Component: OSGI-INF/org.eclipse.papyrus.uml.diagram.sequence.restrictions.SequenceEditPolicyProviderTester.xml, - OSGI-INF/org.eclipse.papyrus.uml.diagram.sequence.restrictions.SequenceViewProviderTester.xml Require-Bundle: org.eclipse.papyrus.uml.diagram.sequence;bundle-version="5.0.0", org.eclipse.papyrus.infra.gmfdiag.common, org.eclipse.papyrus.uml.diagram.symbols;bundle-version="1.2.0" Import-Package: org.osgi.service.component.annotations;version="1.3.0";resolution:=optional +Service-Component: OSGI-INF/org.eclipse.papyrus.uml.diagram.sequence.restrictions.SequenceEditPolicyProviderTester.xml, + OSGI-INF/org.eclipse.papyrus.uml.diagram.sequence.restrictions.SequenceViewProviderTester.xml diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options index df059bd75ab..6b00f7152df 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options @@ -5,6 +5,3 @@ org.eclipse.papyrus.uml.diagram.sequence/debug=false # Visual IDs org.eclipse.papyrus.uml.diagram.sequence/debug/visualID=false -org.eclipse.papyrus.uml.diagram.sequence/debug/SequenceDebug=false -org.eclipse.papyrus.uml.diagram.sequence/debug/SequenceDebugGrid=false -org.eclipse.papyrus.uml.diagram.sequence/debug/SequenceDebugUtil=false diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.settings/.api_filters b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.settings/.api_filters index 3d7cee1853b..6c30062304d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.settings/.api_filters +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.settings/.api_filters @@ -1,11 +1,6 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <component id="org.eclipse.papyrus.uml.diagram.sequence" version="2"> <resource path="custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/InteractionOperandDragDropEditPolicy.java" type="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionOperandDragDropEditPolicy"> - <filter comment="API moved to InteractionOperandResizePolicy" id="337682486"> - <message_arguments> - <message_argument value="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionOperandDragDropEditPolicy"/> - </message_arguments> - </filter> <filter comment="API moved to InteractionOperandResizePolicy" id="338755678"> <message_arguments> <message_argument value="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionOperandDragDropEditPolicy"/> @@ -24,10 +19,5 @@ <message_argument value="getResizeCommand(ChangeBoundsRequest)"/> </message_arguments> </filter> - <filter comment="API moved to InteractionOperandResizePolicy" id="338849923"> - <message_arguments> - <message_argument value="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionOperandDragDropEditPolicy"/> - </message_arguments> - </filter> </resource> </component> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/META-INF/MANIFEST.MF b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/META-INF/MANIFEST.MF index 4294ef024c9..7ed919715fb 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/META-INF/MANIFEST.MF +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/META-INF/MANIFEST.MF @@ -1,5 +1,6 @@ Manifest-Version: 1.0 Export-Package: org.eclipse.papyrus.uml.diagram.sequence, + org.eclipse.papyrus.uml.diagram.sequence.anchors, org.eclipse.papyrus.uml.diagram.sequence.edit.parts, org.eclipse.papyrus.uml.diagram.sequence.edit.policies, org.eclipse.papyrus.uml.diagram.sequence.figures, @@ -15,7 +16,7 @@ Bundle-ClassPath: . Bundle-Name: %pluginName Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Require-Bundle: org.eclipse.ui.navigator;bundle-version="[3.6.0,4.0.0)";visibility:=reexport, +Require-Bundle: org.eclipse.ui.navigator;visibility:=reexport;bundle-version="[3.6.0,4.0.0)", org.eclipse.ui.navigator.resources;bundle-version="[3.5.0,4.0.0)", org.eclipse.gmf.runtime.diagram.ui.render;bundle-version="[1.7.0,2.0.0)", org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide;bundle-version="[1.7.0,2.0.0)", @@ -25,10 +26,10 @@ Require-Bundle: org.eclipse.ui.navigator;bundle-version="[3.6.0,4.0.0)";visibili org.eclipse.gmf.runtime.diagram.ui.providers.ide;bundle-version="[1.7.0,2.0.0)", org.eclipse.papyrus.uml.service.types;bundle-version="[4.0.0,5.0.0)", org.eclipse.papyrus.uml.appearance;bundle-version="[2.0.0,3.0.0)", - org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility:=reexport, - org.eclipse.emf.ecore;bundle-version="[2.12.0,3.0.0)";visibility:=reexport, - org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)";visibility:=reexport, - org.eclipse.emf.validation;bundle-version="[1.8.0,2.0.0)";visibility:=reexport, + org.eclipse.emf.ecore;visibility:=reexport;bundle-version="[2.12.0,3.0.0)", + org.eclipse.emf.ecore;visibility:=reexport;bundle-version="[2.12.0,3.0.0)", + org.eclipse.emf.ecore.edit;visibility:=reexport;bundle-version="[2.9.0,3.0.0)", + org.eclipse.emf.validation;visibility:=reexport;bundle-version="[1.8.0,2.0.0)", org.eclipse.papyrus.infra.gmfdiag.hyperlink;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.uml.internationalization.utils;bundle-version="[1.0.0,2.0.0)", org.eclipse.papyrus.infra.internationalization.utils;bundle-version="[1.0.0,2.0.0)", @@ -53,8 +54,8 @@ Require-Bundle: org.eclipse.ui.navigator;bundle-version="[3.6.0,4.0.0)";visibili org.eclipse.gmf.runtime.diagram.ui.properties, org.eclipse.gmf.runtime.diagram.ui.providers, org.eclipse.gmf.runtime.diagram.ui.resources.editor, - org.eclipse.uml2.uml;bundle-version="[5.3.0,6.0.0)";visibility:=reexport, - org.eclipse.uml2.uml.edit;bundle-version="[5.3.0,6.0.0)";visibility:=reexport, + org.eclipse.uml2.uml;visibility:=reexport;bundle-version="[5.3.0,6.0.0)", + org.eclipse.uml2.uml.edit;visibility:=reexport;bundle-version="[5.3.0,6.0.0)", org.eclipse.gmf.runtime.draw2d.ui;visibility:=reexport, org.eclipse.gef, org.eclipse.papyrus.extensionpoints.editors;bundle-version="[3.0.0,4.0.0)", diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java index 90dfbebb96d..a97e8898b64 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. + * Copyright (c) 2016, 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,12 +11,15 @@ * Contributors: * CEA LIST - Initial API and implementation * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 531596 + * Christian W. Damus - bug 539373 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence; import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.TreeSearch; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; @@ -54,12 +57,13 @@ public class LifelineNodePlate extends LinkLFSVGNodePlateFigure { } - /** - * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#getPolygonPoints() - */ @Override public PointList getPolygonPoints() { - return ((NodeFigure) this.getChildren().get(0)).getPolygonPoints(); + return getLifelineFigure().getPolygonPoints(); + } + + NodeFigure getLifelineFigure() { + return (NodeFigure) this.getChildren().get(0); } @Override @@ -88,9 +92,6 @@ public class LifelineNodePlate extends LinkLFSVGNodePlateFigure { } } - /** - * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#isDefaultAnchorArea(org.eclipse.draw2d.geometry.PrecisionPoint) - */ @Override protected boolean isDefaultAnchorArea(PrecisionPoint p) { return false; @@ -98,10 +99,13 @@ public class LifelineNodePlate extends LinkLFSVGNodePlateFigure { @Override public boolean containsPoint(int x, int y) { - if (Math.abs(this.getBounds().x + this.getBounds().width / 2 - x) < 20) { - return super.containsPoint(x, y); - } - return false; + return getLifelineFigure().containsPoint(x, y); + } + + @Override + public final IFigure findFigureAt(int x, int y, TreeSearch search) { + NodeFigure lifeline = getLifelineFigure(); + return lifeline.findFigureAt(x, y, search); } -}
\ No newline at end of file +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/AnchorConstants.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/AnchorConstants.java new file mode 100644 index 00000000000..fe9339c31b0 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/AnchorConstants.java @@ -0,0 +1,72 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.anchors; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.uml2.uml.DestructionOccurrenceSpecification; +import org.eclipse.uml2.uml.ExecutionSpecification; +import org.eclipse.uml2.uml.Message; + +/** + * Constants class for Anchors + */ +public final class AnchorConstants { + private AnchorConstants() { + // Constants class; no instance + } + + /** + * <p> + * The Anchor Terminal for an Anchor at the start/beginning of an element. + * </p> + * + * <p> + * This anchor represents a single point (Which depends on the anchorage {@link IFigure}), without any parameter. + * </p> + * + * <p> + * This anchor may represent, for example, the start of an {@link ExecutionSpecification}, or the source Send Event of a {@link Message} + * </p> + */ + public static final String START_TERMINAL = "start"; + + /** + * <p> + * The Anchor Terminal for an Anchor at the finish/end of an element. + * </p> + * + * <p> + * This anchor represents a single point (Which depends on the anchorage {@link IFigure}), without any parameter. + * </p> + * + * <p> + * This anchor may represent, for example, the finish of an {@link ExecutionSpecification}, or the target Receive Event of a {@link Message} + * </p> + */ + public static final String END_TERMINAL = "end"; + + /** + * <p> + * The Anchor Terminal for an Anchor at the center of an element. + * </p> + * + * <p> + * This anchor represents a single point (Which depends on the anchorage {@link IFigure}), without any parameter. + * </p> + * + * <p> + * This anchor typically represents the center of the X in a {@link DestructionOccurrenceSpecification} + * </p> + */ + public static final String CENTER_TERMINAL = "center"; +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/CenterAnchor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/CenterAnchor.java new file mode 100644 index 00000000000..be94663a889 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/CenterAnchor.java @@ -0,0 +1,36 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.anchors; + +import org.eclipse.draw2d.AbstractConnectionAnchor; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.uml2.uml.DestructionOccurrenceSpecification; + +/** + * An anchor to the center of an element (Typically a {@link DestructionOccurrenceSpecification}) + */ +public class CenterAnchor extends AbstractConnectionAnchor { + + public CenterAnchor(IFigure anchorage) { + super(anchorage); + } + + @Override + public Point getLocation(Point reference) { + Point center = getOwner().getBounds().getCenter().getCopy(); + getOwner().translateToAbsolute(center); + return center; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/ConnectionSourceAnchor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/ConnectionSourceAnchor.java new file mode 100644 index 00000000000..6da15ce29b3 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/ConnectionSourceAnchor.java @@ -0,0 +1,38 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.anchors; + +import org.eclipse.draw2d.AbstractConnectionAnchor; +import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.draw2d.geometry.Point; + +/** + * Anchors a Connection to the source of a {@link PolylineConnection} (Typically the sendEvent of a Message) + */ +public class ConnectionSourceAnchor extends AbstractConnectionAnchor { + + private final PolylineConnection anchorage; + + public ConnectionSourceAnchor(PolylineConnection anchorage) { + super(anchorage); + this.anchorage = anchorage; + } + + @Override + public Point getLocation(Point reference) { + Point source = anchorage.getStart().getCopy(); + anchorage.translateToAbsolute(source); + return source; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/ConnectionTargetAnchor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/ConnectionTargetAnchor.java new file mode 100644 index 00000000000..eeea63e49b6 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/ConnectionTargetAnchor.java @@ -0,0 +1,39 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.anchors; + +import org.eclipse.draw2d.AbstractConnectionAnchor; +import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.draw2d.geometry.Point; + + +/** + * Anchors a Connection to the target of a {@link PolylineConnection} (Typically the receiveEvent of a Message) + */ +public class ConnectionTargetAnchor extends AbstractConnectionAnchor { + + private final PolylineConnection anchorage; + + public ConnectionTargetAnchor(PolylineConnection anchorage) { + super(anchorage); + this.anchorage = anchorage; + } + + @Override + public Point getLocation(Point reference) { + Point target = anchorage.getEnd().getCopy(); + anchorage.translateToAbsolute(target); + return target; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/NodeBottomAnchor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/NodeBottomAnchor.java new file mode 100644 index 00000000000..efd72365047 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/NodeBottomAnchor.java @@ -0,0 +1,36 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.anchors; + +import org.eclipse.draw2d.AbstractConnectionAnchor; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Point; + +/** + * Anchors a Connection to the Bottom-Center point of a Node (Typically the finish of an Execution Specification) + */ +public class NodeBottomAnchor extends AbstractConnectionAnchor { + + public NodeBottomAnchor(IFigure anchorage) { + super(anchorage); + } + + @Override + public Point getLocation(Point reference) { + IFigure owner = getOwner(); + Point bottom = owner.getBounds().getBottom().getCopy(); + owner.translateToAbsolute(bottom); + return bottom; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/NodeTopAnchor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/NodeTopAnchor.java new file mode 100644 index 00000000000..f11b1fdc436 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/NodeTopAnchor.java @@ -0,0 +1,36 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.anchors; + +import org.eclipse.draw2d.AbstractConnectionAnchor; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Point; + +/** + * Anchors a Connection to the Top-Center point of a Node (Typically the start of an Execution Specification) + */ +public class NodeTopAnchor extends AbstractConnectionAnchor { + + public NodeTopAnchor(IFigure anchorage) { + super(anchorage); + } + + @Override + public Point getLocation(Point reference) { + IFigure owner = getOwner(); + Point top = owner.getBounds().getTop().getCopy(); + owner.translateToAbsolute(top); + return top; + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomTimeObservationCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomTimeObservationCreateCommand.java deleted file mode 100644 index 13b8aed13c2..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomTimeObservationCreateCommand.java +++ /dev/null @@ -1,105 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Atos Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.command; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; -import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand; -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.notation.View; -import org.eclipse.papyrus.uml.diagram.sequence.providers.ElementInitializers; -import org.eclipse.uml2.uml.Package; -import org.eclipse.uml2.uml.TimeObservation; -import org.eclipse.uml2.uml.UMLFactory; - -/** - * Command for creating time observation element - * - */ -public class CustomTimeObservationCreateCommand extends EditElementCommand { - - private EClass eClass = null; - - private EObject eObject = null; - - public CustomTimeObservationCreateCommand(CreateElementRequest req, EObject eObject) { - super(req.getLabel(), null, req); - this.eObject = eObject; - this.eClass = eObject != null ? eObject.eClass() : null; - } - - public static CustomTimeObservationCreateCommand create(CreateElementRequest req, EObject eObject) { - return new CustomTimeObservationCreateCommand(req, eObject); - } - - public CustomTimeObservationCreateCommand(CreateElementRequest req) { - super(req.getLabel(), null, req); - } - - @Override - protected EObject getElementToEdit() { - EObject container = ((CreateElementRequest) getRequest()).getContainer(); - if (container instanceof View) { - container = ((View) container).getElement(); - } - if (container != null) { - return container; - } - return eObject; - } - - @Override - public boolean canExecute() { - return true; - } - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - TimeObservation newElement = UMLFactory.eINSTANCE.createTimeObservation(); - // get the parent package as owner - EObject container = getElementToEdit(); - while (container != null && !(container instanceof Package)) { - container = container.eContainer(); - } - if (container == null) { - return CommandResult.newCancelledCommandResult(); - } - Package owner = (Package) container; - owner.getPackagedElements().add(newElement); - ElementInitializers.getInstance().init_TimeObservation_Shape(newElement); - doConfigure(newElement, monitor, info); - ((CreateElementRequest) getRequest()).setNewElement(newElement); - return CommandResult.newOKCommandResult(newElement); - } - - protected void doConfigure(TimeObservation newElement, IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - IElementType elementType = ((CreateElementRequest) getRequest()).getElementType(); - ConfigureRequest configureRequest = new ConfigureRequest(getEditingDomain(), newElement, elementType); - configureRequest.setClientContext(((CreateElementRequest) getRequest()).getClientContext()); - configureRequest.addParameters(getRequest().getParameters()); - ICommand configureCommand = elementType.getEditCommand(configureRequest); - if (configureCommand != null && configureCommand.canExecute()) { - configureCommand.execute(monitor, info); - } - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/RestoreDurationConstraintLinkCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/RestoreDurationConstraintLinkCommand.java deleted file mode 100644 index a9f8992914c..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/RestoreDurationConstraintLinkCommand.java +++ /dev/null @@ -1,144 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2013 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.command; - -import java.util.Collections; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequestFactory; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AnnotatedLinkEndEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AnnotatedLinkStartEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class RestoreDurationConstraintLinkCommand extends AbstractTransactionalCommand { - - private IAdaptable dcViewAdapter; - - private EditPartViewer viewer; - - private Boolean isOnTop; - - private Point targetLocation; - - private PreferencesHint diagramPreferenceHint; - - /** - * Constructor. - * - * @param domain - * @param label - * @param affectedFiles - */ - public RestoreDurationConstraintLinkCommand(TransactionalEditingDomain domain, IAdaptable dcViewAdapter, EditPartViewer viewer, Boolean isOnTop, Point targetLocation, PreferencesHint diagramPreferenceHint) { - super(domain, "Resotore Annotated Link", null); - this.dcViewAdapter = dcViewAdapter; - this.viewer = viewer; - this.isOnTop = isOnTop; - this.targetLocation = targetLocation; - this.diagramPreferenceHint = diagramPreferenceHint; - } - - /** - * @see org.eclipse.core.commands.operations.AbstractOperation#canExecute() - * - * @return - */ - @Override - public boolean canExecute() { - if (dcViewAdapter == null || viewer == null || targetLocation == null) { - return false; - } - return super.canExecute(); - } - - /** - * @see org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - * - * @param monitor - * @param info - * @return - * @throws ExecutionException - */ - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - if (!canExecute()) { - return CommandResult.newCancelledCommandResult(); - } - View view = dcViewAdapter.getAdapter(View.class); - if (view == null) { - return CommandResult.newErrorCommandResult("No view found"); - } - EditPart sourceEditPart = (EditPart) viewer.getEditPartRegistry().get(view); - if (sourceEditPart == null) { - return CommandResult.newCancelledCommandResult(); - } - Rectangle bounds = SequenceUtil.getAbsoluteBounds((IGraphicalEditPart) sourceEditPart); - Point sourceLocation = null; - if (isOnTop != null) { - sourceLocation = isOnTop.booleanValue() ? bounds.getTop() : bounds.getBottom(); - } else if (targetLocation.y >= bounds.getCenter().y) { - sourceLocation = bounds.getBottom(); - } else { - sourceLocation = bounds.getTop(); - } - EditPart targetEditPart = null; - CreateConnectionViewRequest request = CreateViewRequestFactory.getCreateConnectionRequest(UMLElementTypes.Comment_AnnotatedElementEdge, diagramPreferenceHint); - request.setLocation(sourceLocation); - request.setType(AnnotatedLinkStartEditPolicy.REQ_ANNOTATED_LINK_START); - request.setSourceEditPart(sourceEditPart); - request.setTargetEditPart(sourceEditPart); - Command command = sourceEditPart.getCommand(request); - // connect... - request.setLocation(targetLocation); - request.setType(AnnotatedLinkEndEditPolicy.REQ_ANNOTATED_LINK_END); - targetEditPart = sourceEditPart.getViewer().findObjectAtExcluding(targetLocation, Collections.emptySet(), getTargetingConditional(request)); - request.setTargetEditPart(targetEditPart); - command = targetEditPart.getCommand(request); - if (command != null && command.canExecute()) { - command.execute(); - } - return CommandResult.newOKCommandResult(); - } - - protected EditPartViewer.Conditional getTargetingConditional(final Request req) { - return new EditPartViewer.Conditional() { - - @Override - public boolean evaluate(EditPart editpart) { - return editpart.getTargetEditPart(req) != null; - } - }; - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/DurationConstraintAutomaticRouter.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/DurationConstraintAutomaticRouter.java deleted file mode 100644 index 78461e21347..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/DurationConstraintAutomaticRouter.java +++ /dev/null @@ -1,90 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.draw2d.routers; - -import org.eclipse.draw2d.Connection; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.PrecisionPoint; -import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ObliqueRouter; -import org.eclipse.gmf.runtime.notation.View; - -public class DurationConstraintAutomaticRouter extends ObliqueRouter { - - public DurationConstraintAutomaticRouter(View notationView) { - super(); - } - - @Override - protected void resetEndPointsToEdge(Connection conn, PointList newLine) { - if (newLine.size() < 2) { - /* - * Connection must have at least 2 points in the list: the source - * and target anchor points. Otherwise it's invalid connection. - * Invalid connection case: add a dumb point at the start of the - * list and at the end of the list. The first and the last point in - * the list are replaced by the new source and target anchor points - * in this method - */ - newLine.addPoint(0, 0); - newLine.insertPoint(new Point(), 0); - } - - PrecisionPoint sourceAnchorPoint = null, targetAnchorPoint = null; - while (newLine.size() != 2) { - newLine.removePoint(1); - } - PrecisionPoint sourceReference = getAnchorReference(conn.getTargetAnchor()); - sourceAnchorPoint = getAnchorLocation(conn.getSourceAnchor(), sourceReference); - targetAnchorPoint = getAnchorLocation(conn.getTargetAnchor(), sourceAnchorPoint); - Point midpoint = recomputeBenpointLocation(conn); - newLine.addPoint(midpoint); - newLine.setPoint(midpoint, 1); - - conn.translateToRelative(sourceAnchorPoint); - conn.translateToRelative(targetAnchorPoint); - - newLine.setPoint(new PrecisionPoint(sourceAnchorPoint.preciseX(), sourceAnchorPoint.preciseY()), 0); - newLine.setPoint(targetAnchorPoint, newLine.size() - 1); - } - - public Point recomputeBenpointLocation(Connection conn) { - PrecisionPoint a1 = new PrecisionPoint(conn.getSourceAnchor().getReferencePoint()); - PrecisionPoint a2 = new PrecisionPoint(conn.getTargetAnchor().getReferencePoint()); - PrecisionPoint a3 = new PrecisionPoint(conn.getSourceAnchor().getLocation(a1)); - PrecisionPoint a4 = new PrecisionPoint(conn.getTargetAnchor().getLocation(a2)); - conn.translateToRelative(a3); - conn.translateToRelative(a4); - return new PrecisionPoint(a4.preciseX() + computeOffset(a3.preciseX(), a4.preciseX()), a3.preciseY()); - } - - private double computeOffset(double x, double x2) { - if (Math.abs(x - x2) > 20) { - return 20 * Math.signum(x - x2); - } else { - return (x - x2) * 0.5; - } - } - - private PrecisionPoint getAnchorLocation(ConnectionAnchor anchor, Point reference) { - return new PrecisionPoint(anchor.getLocation(reference)); - } - - private PrecisionPoint getAnchorReference(ConnectionAnchor anchor) { - return new PrecisionPoint(anchor.getReferencePoint()); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/AbstractDurationLinkAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/AbstractDurationLinkAdvice.java new file mode 100644 index 00000000000..4d70849c3a2 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/AbstractDurationLinkAdvice.java @@ -0,0 +1,87 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature.Setting; +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.DestroyElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.gmf.runtime.notation.Connector; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; +import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.SequenceDiagramEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; + +/** + * <p> + * Abstract sequence diagram advice to clear DurationLinks when the corresponding + * semantic Duration element becomes inconsistent (typically, the source/target changes + * or is removed). + * </p> + */ +public abstract class AbstractDurationLinkAdvice extends AbstractEditHelperAdvice { + + private EClass durationElementType; + private EReference eventsReference; + private String durationLinkType; + + protected AbstractDurationLinkAdvice(EClass durationElementType, EReference eventsReference, String durationLinkType) { + this.durationElementType = durationElementType; + this.eventsReference = eventsReference; + this.durationLinkType = durationLinkType; + } + + @Override + protected ICommand getAfterSetCommand(SetRequest request) { + if (request.getFeature() == eventsReference && durationElementType.isInstance(request.getElementToEdit())) { + Collection<Setting> usages = EMFHelper.getUsages(request.getElementToEdit()); + + // We need to delegate to the command provider; otherwise the view is not correctly destroyed, + // and the diagram may still display a ghost connection (referencing a view that is no longer + // attached to the notation model) + IElementEditService provider = ElementEditServiceUtils.getCommandProvider(request.getElementToEdit()); + if (provider == null) { + return null; + } + + CompositeCommand deletions = new CompositeCommand("Delete inconsistent DurationLink views"); + for (Setting usage : usages) { + if (usage.getEObject() instanceof Connector && usage.getEStructuralFeature() == NotationPackage.Literals.VIEW__ELEMENT) { + Connector connector = (Connector) usage.getEObject(); + if (durationLinkType.equals(connector.getType()) // + && connector.getDiagram() != null // + && SequenceDiagramEditPart.MODEL_ID.equals(connector.getDiagram().getType())) { + if (!DurationLinkUtil.isConsistent(connector, request)) { + // Retrieve delete command from the Element Edit service + DestroyElementRequest destroyRequest = new DestroyElementRequest(request.getEditingDomain(), connector, false); + ICommand deleteCommand = provider.getEditCommand(destroyRequest); + deletions.add(deleteCommand); + } + } + } + } + return deletions.isEmpty() ? null : deletions.reduce(); + } + return super.getAfterSetCommand(request); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DurationConstraintLinkAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DurationConstraintLinkAdvice.java new file mode 100644 index 00000000000..7bd4d30d6b9 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DurationConstraintLinkAdvice.java @@ -0,0 +1,31 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice; + +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * <p> + * A sequence diagram advice to clear {@link DurationConstraintLinkEditPart DurationConstraint links} when the + * constraint's constrained elements are changed. + * </p> + */ +public class DurationConstraintLinkAdvice extends AbstractDurationLinkAdvice { + + public DurationConstraintLinkAdvice() { + super(UMLPackage.Literals.DURATION_CONSTRAINT, UMLPackage.Literals.CONSTRAINT__CONSTRAINED_ELEMENT, DurationConstraintLinkEditPart.VISUAL_ID); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DurationObservationLinkAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DurationObservationLinkAdvice.java new file mode 100644 index 00000000000..6a3c92258c8 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DurationObservationLinkAdvice.java @@ -0,0 +1,31 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice; + +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkEditPart; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * <p> + * A sequence diagram advice to clear {@link DurationObservationLinkEditPart DurationObservation links} when the + * observation's events are changed. + * </p> + */ +public class DurationObservationLinkAdvice extends AbstractDurationLinkAdvice { + + public DurationObservationLinkAdvice() { + super(UMLPackage.Literals.DURATION_OBSERVATION, UMLPackage.Literals.DURATION_OBSERVATION__EVENT, DurationObservationLinkEditPart.VISUAL_ID); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/GeneralOrderingLinkHelperAdvice.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/GeneralOrderingLinkHelperAdvice.java new file mode 100644 index 00000000000..2715aa7715a --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/GeneralOrderingLinkHelperAdvice.java @@ -0,0 +1,79 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Bug 537562 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice; + + +import java.util.Collection; + +import org.eclipse.emf.ecore.EStructuralFeature.Setting; +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.DestroyElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.gmf.runtime.notation.Connector; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; +import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.SequenceDiagramEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil; +import org.eclipse.uml2.uml.GeneralOrdering; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * <p> + * A sequence diagram advice to clear {@link GeneralOrderingEditPart GeneralOrdering links} when the + * orderings's before or after events are changed. + * </p> + */ +public class GeneralOrderingLinkHelperAdvice extends AbstractEditHelperAdvice { + + @Override + protected ICommand getAfterSetCommand(SetRequest request) { + if ((request.getFeature() == UMLPackage.Literals.GENERAL_ORDERING__AFTER + || request.getFeature() == UMLPackage.Literals.GENERAL_ORDERING__BEFORE) + && request.getElementToEdit() instanceof GeneralOrdering) { + Collection<Setting> usages = EMFHelper.getUsages(request.getElementToEdit()); + + // We need to delegate to the command provider; otherwise the view is not correctly destroyed, + // and the diagram may still display a ghost connection (referencing a view that is no longer + // attached to the notation model) + IElementEditService provider = ElementEditServiceUtils.getCommandProvider(request.getElementToEdit()); + if (provider == null) { + return null; + } + + CompositeCommand deletions = new CompositeCommand("Delete inconsistent GeneralOrdering views"); + for (Setting usage : usages) { + if (usage.getEObject() instanceof Connector && usage.getEStructuralFeature() == NotationPackage.Literals.VIEW__ELEMENT) { + Connector connector = (Connector) usage.getEObject(); + if (GeneralOrderingEditPart.VISUAL_ID.equals(connector.getType()) // + && connector.getDiagram() != null // + && SequenceDiagramEditPart.MODEL_ID.equals(connector.getDiagram().getType())) { + if (!GeneralOrderingUtil.isConsistent(connector, request)) { + // Retrieve delete command from the Element Edit service + DestroyElementRequest destroyRequest = new DestroyElementRequest(request.getEditingDomain(), connector, false); + ICommand deleteCommand = provider.getEditCommand(destroyRequest); + deletions.add(deleteCommand); + } + } + } + } + return deletions.isEmpty() ? null : deletions.reduce(); + } + return super.getAfterSetCommand(request); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java index 04f2ae1d362..0889585edc7 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST and others. + * Copyright (c) 2017, 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,10 +11,12 @@ * Contributors: * CEA LIST - Initial API and implementation * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 526079 + * Christian W. Damus - bug 536486 *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; import java.util.List; +import java.util.Optional; import org.eclipse.draw2d.ConnectionAnchor; import org.eclipse.draw2d.DelegatingLayout; @@ -32,10 +34,13 @@ import org.eclipse.gef.EditPolicy; import org.eclipse.gef.GraphicalViewer; import org.eclipse.gef.Request; import org.eclipse.gef.requests.ChangeBoundsRequest; +import org.eclipse.gef.requests.CreateRequest; import org.eclipse.gef.requests.ReconnectRequest; import org.eclipse.gmf.runtime.common.core.util.Log; import org.eclipse.gmf.runtime.common.core.util.Trace; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions; import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin; import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes; @@ -57,28 +62,42 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.gmf.runtime.notation.datatype.GradientData; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; import org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AffixedNodeAlignmentEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.NodeBottomAnchor; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.NodeTopAnchor; import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeCommentCreationEditPolicyEx; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationAffixedChildAlignmentPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceReferenceEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateConnectionReferenceEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateWeakReferenceForExecSpecEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.ExecutionSpecificationNodePlate; +import org.eclipse.papyrus.uml.diagram.sequence.locator.CenterLocator; +import org.eclipse.papyrus.uml.diagram.sequence.locator.TimeElementLocator; import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.BoundForEditPart; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectExecutionToGridEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectYCoordinateToGrillingEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.util.CoordinateReferentialUtils; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil; import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCommentEditPolicy; import org.eclipse.swt.graphics.Color; +import org.eclipse.uml2.uml.MessageEnd; /** * Add implementing IPapyrusEditPart to displaying Stereotypes. * * @author Jin Liu (jin.liu@soyatec.com) */ +@SuppressWarnings("restriction") public abstract class AbstractExecutionSpecificationEditPart extends RoundedCompartmentEditPart { - public static final String EXECUTION_FIX_ANCHOR_POSITION = "Execution Fix Anchor Position"; + /** + * @deprecated since 5.1 this constant is not used anymore. + */ + @Deprecated public static int DEFAUT_HEIGHT = 100; public static int DEFAUT_WIDTH = 20; @@ -148,7 +167,61 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp feedback.setBounds(rect); } }); + installEditPolicy(AffixedNodeAlignmentEditPolicy.AFFIXED_CHILD_ALIGNMENT_ROLE, new ExecutionSpecificationAffixedChildAlignmentPolicy()); + } + + @Override + protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { + if (borderItemEditPart instanceof TimeConstraintBorderNodeEditPart || + borderItemEditPart instanceof TimeObservationBorderNodeEditPart) { + Optional<MessageEnd> messageEnd = Optional.of(borderItemEditPart) + .filter(ITimeElementBorderNodeEditPart.class::isInstance) + .map(ITimeElementBorderNodeEditPart.class::cast) + .flatMap(ITimeElementBorderNodeEditPart::getMessageEnd); + + IBorderItemLocator locator = messageEnd + // It needs to remain anchored to the message end + .map(__ -> new CenterLocator(getMainFigure(), PositionConstants.NONE)) + .map(IBorderItemLocator.class::cast) + .orElseGet(() -> new TimeElementLocator(getMainFigure(), + constraint -> findNearestSide(getMainFigure(), constraint))); + borderItemContainer.add(borderItemEditPart.getFigure(), locator); + } else { + super.addBorderItem(borderItemContainer, borderItemEditPart); + } + } + + /** + * Given a {@code constraint} proposed for a border item (usually a time element) + * on an execution figure, compute the side to which it should be attached. + * + * @param execFig + * an execution specification figure + * @param constraint + * a proposed time element border item bounds + * + * @return a {@link PositionConstants} side + */ + public static int findNearestSide(IFigure execFig, Rectangle constraint) { + Rectangle figBounds = execFig.getBounds().getCopy(); + Point where = constraint.getTopLeft(); + where.setX((figBounds.width() - constraint.width()) / 2); + + if (DurationLinkUtil.isStart(execFig, where)) { + // Pin it to the top of the execution + return PositionConstants.NORTH; + } else { + // Pin it to the bottome + return PositionConstants.SOUTH; + } + } + @Override + public EditPart getTargetEditPart(Request request) { + if (request instanceof CreateRequest) { + return super.getTargetEditPart(request); + } + return super.getTargetEditPart(request); } @Override @@ -234,15 +307,15 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp protected void moveExecutionSpecificationFeedback(ChangeBoundsRequest request, AbstractExecutionSpecificationEditPart movedPart, PrecisionRectangle rect, Rectangle originalBounds) { // If this is a move to the top, the execution specification cannot be moved upper than the life line y position - if(request.getMoveDelta().y < 0) { + if (request.getMoveDelta().y < 0) { EditPart parent = getParent(); - if(parent instanceof CLifeLineEditPart) { - + if (parent instanceof CLifeLineEditPart) { + Point locationOnDiagram = CoordinateReferentialUtils.transformPointFromScreenToDiagramReferential(originalBounds.getCopy().getLocation(), (GraphicalViewer) movedPart.getViewer()); - Bounds parentBounds = BoundForEditPart.getBounds((Node)((CLifeLineEditPart)parent).getModel()); - + Bounds parentBounds = BoundForEditPart.getBounds((Node) ((CLifeLineEditPart) parent).getModel()); + // This magic delta is needed to be at the bottom of the life line name - if((locationOnDiagram.y + request.getMoveDelta().y) < (parentBounds.getY() + 50)) { + if ((locationOnDiagram.y + request.getMoveDelta().y) < (parentBounds.getY() + 50)) { Point loc = locationOnDiagram.getCopy(); loc.y = parentBounds.getY() + 50; rect.setLocation(loc); @@ -306,20 +379,18 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp */ @Override public ConnectionAnchor getTargetConnectionAnchor(Request request) { - Object fixPos = request.getExtendedData().get(EXECUTION_FIX_ANCHOR_POSITION); - if (fixPos != null && (fixPos.equals(PositionConstants.TOP) || fixPos.equals(PositionConstants.BOTTOM))) { - return new AnchorHelper.FixedAnchorEx(getFigure(), (Integer) fixPos); - } if (request instanceof CreateUnspecifiedTypeConnectionRequest) { CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request; List<?> relationshipTypes = createRequest.getElementTypes(); - for (Object obj : relationshipTypes) { - if (UMLElementTypes.Message_SynchEdge.equals(obj)) { + for (Object type : relationshipTypes) { + if (UMLElementTypes.Message_SynchEdge.equals(type)) { // Sync Message if (!createRequest.getTargetEditPart().equals(createRequest.getSourceEditPart())) { return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.TOP); } // otherwise, this is a recursive call, let destination free + } else if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) { + return OccurrenceSpecificationUtil.isStart(getFigure(), createRequest.getLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure()); } } } else if (request instanceof ReconnectRequest) { @@ -328,6 +399,8 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp if (connectionEditPart instanceof MessageSyncEditPart) { // Sync Message return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.TOP); + } else if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) { + return OccurrenceSpecificationUtil.isStart(getFigure(), reconnectRequest.getLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure()); } } // Fixed bug about computing target anchor when creating message sync. @@ -340,6 +413,9 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.TOP); } } + if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) { + return OccurrenceSpecificationUtil.isStart(getFigure(), createRequest.getLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure()); + } } return super.getTargetConnectionAnchor(request); } @@ -360,7 +436,7 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) connEditPart; String t = null; try { - t = (String) getEditingDomain().runExclusive(new RunnableWithResult.Impl() { + t = (String) getEditingDomain().runExclusive(new RunnableWithResult.Impl<String>() { @Override public void run() { @@ -394,17 +470,15 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp */ @Override public ConnectionAnchor getSourceConnectionAnchor(Request request) { - Object fixPos = request.getExtendedData().get(EXECUTION_FIX_ANCHOR_POSITION); - if (fixPos != null && (fixPos.equals(PositionConstants.TOP) || fixPos.equals(PositionConstants.BOTTOM))) { - return new AnchorHelper.FixedAnchorEx(getFigure(), (Integer) fixPos); - } if (request instanceof CreateUnspecifiedTypeConnectionRequest) { CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request; List<?> relationshipTypes = createRequest.getElementTypes(); - for (Object obj : relationshipTypes) { - if (UMLElementTypes.Message_ReplyEdge.equals(obj)) { + for (Object type : relationshipTypes) { + if (UMLElementTypes.Message_ReplyEdge.equals(type)) { // Reply Message return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.BOTTOM); + } else if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) { + return OccurrenceSpecificationUtil.isStart(getFigure(), createRequest.getLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure()); } } } else if (request instanceof ReconnectRequest) { @@ -413,6 +487,13 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp if (connectionEditPart instanceof MessageReplyEditPart) { // Reply Message return new AnchorHelper.FixedAnchorEx(getFigure(), PositionConstants.BOTTOM); + } else if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) { + return OccurrenceSpecificationUtil.isStart(getFigure(), reconnectRequest.getLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure()); + } + } else if (request instanceof CreateConnectionViewRequest) { + CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request; + if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) { + return OccurrenceSpecificationUtil.isStart(getFigure(), createRequest.getLocation()) ? new NodeTopAnchor(getFigure()) : new NodeBottomAnchor(getFigure()); } } return super.getSourceConnectionAnchor(request); @@ -434,7 +515,7 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) connEditPart; String t = null; try { - t = (String) getEditingDomain().runExclusive(new RunnableWithResult.Impl() { + t = (String) getEditingDomain().runExclusive(new RunnableWithResult.Impl<String>() { @Override public void run() { @@ -520,4 +601,5 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp } super.showTargetFeedback(request); } + } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java index ab6208ae860..1765a1f7fdf 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST and others. + * Copyright (c) 2017, 2018 CEA LIST, EclipseSource and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,13 +11,20 @@ * Contributors: * CEA LIST - Initial API and implementation * Celine Janssens (ALL4TEC) - Bug 507348 + * EclipseSource - Bug 536631 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Set; +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.ConnectionAnchor; import org.eclipse.draw2d.Cursors; +import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; import org.eclipse.emf.common.notify.Notification; @@ -25,10 +32,12 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.gef.ConnectionEditPart; import org.eclipse.gef.DragTracker; import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; import org.eclipse.gef.Request; import org.eclipse.gef.requests.ReconnectRequest; import org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart; import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; import org.eclipse.gmf.runtime.draw2d.ui.geometry.LineSeg; @@ -39,6 +48,10 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart; import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure; +import org.eclipse.papyrus.uml.diagram.common.service.ApplyStereotypeRequest; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.ConnectionSourceAnchor; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.ConnectionTargetAnchor; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageGraphicalNodeEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageLabelEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceReferenceEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageDelete; @@ -49,6 +62,9 @@ import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectMessageToGridEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectRectangleToGridEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.LifeLineGraphicalNodeEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil; import org.eclipse.papyrus.uml.diagram.sequence.util.SelectMessagesEditPartTracker; import org.eclipse.papyrus.uml.diagram.sequence.util.SelfMessageHelper; import org.eclipse.swt.SWT; @@ -58,8 +74,6 @@ import org.eclipse.ui.PlatformUI; public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart implements IKeyPressState { - private List messageEventParts; - private boolean reorderMessages = false; /** @@ -191,7 +205,7 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart if (points.size() <= 1) { return; } - List lineSegments = PointListUtilities.getLineSegments(points); + List<?> lineSegments = PointListUtilities.getLineSegments(points); LineSeg nearestSegment = PointListUtilities.getNearestSegment(lineSegments, p.x, p.y); if (points.size() > 3 && (p.getDistance(points.getPoint(1)) < 5 || p.getDistance(points.getPoint(2)) < 5)) { myCursor = Cursors.SIZEALL; @@ -250,7 +264,7 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart } public View findChildByModel(EObject model) { - List list = getModelChildren(); + List<?> list = getModelChildren(); if (list != null && list.size() > 0) { for (Object o : list) { if (!(o instanceof View)) { @@ -273,12 +287,13 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart // Ordering Message Occurrence Specification. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=403233 installEditPolicy(ConnectRectangleToGridEditPolicy.CONNECT_TO_GRILLING_MANAGEMENT, new ConnectMessageToGridEditPolicy()); installEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE, new SequenceReferenceEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new MessageGraphicalNodeEditPolicy()); } @Override public EditPart getTargetEditPart(Request request) { if (request instanceof CreateUnspecifiedTypeConnectionRequest) { - List types = ((CreateUnspecifiedTypeConnectionRequest) request).getElementTypes(); + List<?> types = ((CreateUnspecifiedTypeConnectionRequest) request).getElementTypes(); if (types.contains(UMLElementTypes.Message_FoundEdge) || types.contains(UMLElementTypes.Message_LostEdge)) { return null; } @@ -287,10 +302,135 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart if (con instanceof MessageLostEditPart || con instanceof MessageFoundEditPart) { return null; } + // Workaround for Bug 537724: GMF does not support reconnection of links if link.source == link.target and + // the source/target is a link. + // We need to copy all inherited implementations, except the problematic GMF one... To be safe, only do + // that for DurationLinks and GeneralOrderings, since that's the case we want to support + ReconnectRequest reconnectRequest = (ReconnectRequest) request; + if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) { + return doGetTargetEditPart(reconnectRequest); + } } return super.getTargetEditPart(request); } + /** + * Workaround for Bug 537724: GMF's implementation of cyclic dependency is incorrect, + * and we need to bypass it. Unfortunately, that means we need to copy all inherited + * implementations. + * + * @param reconnectRequest + * @return + */ + protected EditPart doGetTargetEditPart(ReconnectRequest reconnectRequest) { + // From UMLConnectionNodeEditPart + if (ApplyStereotypeRequest.APPLY_STEREOTYPE_REQUEST.equals(reconnectRequest.getType())) { + return this; + } + + // From GEF's AbstractEditPart + EditPolicyIterator i = getEditPolicyIterator(); + EditPart targetEditPart = null; + while (i.hasNext()) { + targetEditPart = i.next().getTargetEditPart(reconnectRequest); + if (targetEditPart != null) { + break; + } + } + + // From GMF's ConnectionNodeEditPart (The buggy part) + + if (reconnectRequest.isMovingStartAnchor()) { + if (reconnectRequest.getConnectionEditPart().getSource() == targetEditPart) { + return targetEditPart; + } + } else if (reconnectRequest.getConnectionEditPart().getTarget() == targetEditPart) { + return targetEditPart; + } + + // If source anchor is moved, the connection's source edit part + // should not be taken into account for a cyclic dependency + // check so as to avoid false checks. Same goes for the target + // anchor. See bugzilla# 155243 -- we do not want to target a + // connection that is already connected to us so that we do not + // introduce a cyclic connection + if (isCyclicConnectionRequest((org.eclipse.gef.ConnectionEditPart) targetEditPart, + reconnectRequest.getConnectionEditPart(), false, reconnectRequest.isMovingStartAnchor())) { + return null; + } + + return targetEditPart; + } + + // Custom implementation of the parent method, which is buggy + // This is a workaround for Bug 537724 + // TODO This implementation should be properly tested... It allows more cases than + // the parent one, and may potentially allow cycles + private boolean isCyclicConnectionRequest(org.eclipse.gef.ConnectionEditPart targetCEP, + org.eclipse.gef.ConnectionEditPart sourceCEP, + boolean checkSourceAndTargetEditParts, boolean doNotCheckSourceEditPart) { + if (targetCEP == null || sourceCEP == null) { + return false; + } + + // first, do a cyclic check on source and target connections + // of the source connection itself. + // (as every connection is also a node). + + Set<IFigure> set = new HashSet<>(); + getSourceAndTargetConnections(set, sourceCEP); + if (set.contains(targetCEP.getFigure())) { + return true; + } + + // now do the cyclic check on the source and target of the source connection... + EditPart sourceEP = sourceCEP.getSource(), + targetEP = sourceCEP.getTarget(); + + if (!checkSourceAndTargetEditParts && doNotCheckSourceEditPart) { + // . + } else if (sourceEP instanceof org.eclipse.gef.ConnectionEditPart && + isCyclicConnectionRequest(targetCEP, + (org.eclipse.gef.ConnectionEditPart) sourceEP, + true, doNotCheckSourceEditPart)) { + return true; + } + + if (!checkSourceAndTargetEditParts && !doNotCheckSourceEditPart) { + // . + } else if (targetEP instanceof org.eclipse.gef.ConnectionEditPart && + isCyclicConnectionRequest(targetCEP, + (org.eclipse.gef.ConnectionEditPart) targetEP, + true, doNotCheckSourceEditPart)) { + return true; + } + + return false; + } + + private void getSourceAndTargetConnections(Set<IFigure> set, + org.eclipse.gef.ConnectionEditPart connectionEditPart) { + + if (connectionEditPart == null || set == null) { + return; + } + + for (Iterator<?> i = connectionEditPart.getSourceConnections().iterator(); i.hasNext();) { + org.eclipse.gef.ConnectionEditPart next = (org.eclipse.gef.ConnectionEditPart) i.next(); + Connection sourceConnection = (Connection) next.getFigure(); + set.add(sourceConnection); + getSourceAndTargetConnections(set, next); + } + + for (Iterator<?> i = connectionEditPart.getTargetConnections().iterator(); i.hasNext();) { + org.eclipse.gef.ConnectionEditPart next = (org.eclipse.gef.ConnectionEditPart) i.next(); + Connection targetConnection = (Connection) next.getFigure(); + set.add(targetConnection); + getSourceAndTargetConnections(set, next); + } + } + + @Override protected void handleNotificationEvent(Notification notification) { super.handleNotificationEvent(notification); @@ -394,4 +534,54 @@ public abstract class AbstractMessageEditPart extends UMLConnectionNodeEditPart super.refreshFont(); } } + + @Override + public ConnectionAnchor getSourceConnectionAnchor(Request request) { + if (request instanceof CreateUnspecifiedTypeConnectionRequest) { + CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request; + List<?> relationshipTypes = createRequest.getElementTypes(); + for (Object type : relationshipTypes) { + if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) { + return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest.getLocation()) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape()); + } + } + } else if (request instanceof CreateConnectionViewRequest) { + CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request; + if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) { + return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest.getLocation()) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape()); + } + } else if (request instanceof ReconnectRequest) { + ReconnectRequest reconnectRequest = (ReconnectRequest) request; + if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) { + return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), reconnectRequest.getLocation()) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape()); + } + } + return super.getSourceConnectionAnchor(request); + } + + @Override + public ConnectionAnchor getTargetConnectionAnchor(Request request) { + if (request instanceof CreateUnspecifiedTypeConnectionRequest) { + CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request; + List<?> relationshipTypes = createRequest.getElementTypes(); + for (Object type : relationshipTypes) { + if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) { + return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest.getLocation()) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape()); + } + } + } else if (request instanceof CreateConnectionViewRequest) { + CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request; + if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) { + return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), createRequest.getLocation()) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape()); + } + } else if (request instanceof ReconnectRequest) { + ReconnectRequest reconnectRequest = (ReconnectRequest) request; + if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) { + return OccurrenceSpecificationUtil.isSource(getConnectionFigure(), reconnectRequest.getLocation()) ? new ConnectionSourceAnchor(getPrimaryShape()) : new ConnectionTargetAnchor(getPrimaryShape()); + } + } + return super.getTargetConnectionAnchor(request); + } + + } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java new file mode 100644 index 00000000000..71e368b5ea2 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java @@ -0,0 +1,110 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource, Christian W. Damus, 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: + * EclipseSource - Initial API and implementation + * Christian W. Damus - bug 536486 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; + +import java.util.List; + +import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.Request; +import org.eclipse.gef.requests.ReconnectRequest; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest; +import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.CenterAnchor; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DestructionOccurrenceGraphicalNodeEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DestructionEventNodePlate; +import org.eclipse.papyrus.uml.diagram.sequence.locator.TimeElementLocator; +import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil; + +public class CDestructionOccurrenceSpecificationEditPart extends DestructionOccurrenceSpecificationEditPart { + + public CDestructionOccurrenceSpecificationEditPart(View view) { + super(view); + } + + @Override + protected void createDefaultEditPolicies() { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DestructionOccurrenceGraphicalNodeEditPolicy()); + } + + @Override + public ConnectionAnchor getTargetConnectionAnchor(Request request) { + if (request instanceof CreateUnspecifiedTypeConnectionRequest) { + CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request; + List<?> relationshipTypes = createRequest.getElementTypes(); + for (Object type : relationshipTypes) { + if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) { + return new CenterAnchor(getFigure()); + } + } + } else if (request instanceof CreateConnectionViewRequest) { + CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request; + if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) { + return new CenterAnchor(getFigure()); + } + } else if (request instanceof ReconnectRequest) { + ReconnectRequest reconnectRequest = (ReconnectRequest) request; + if (DurationLinkUtil.isDurationLink(reconnectRequest) || GeneralOrderingUtil.isGeneralOrderingLink(reconnectRequest)) { + return new CenterAnchor(getFigure()); + } + } + return super.getTargetConnectionAnchor(request); + } + + @Override + public ConnectionAnchor getSourceConnectionAnchor(Request request) { + if (request instanceof CreateUnspecifiedTypeConnectionRequest) { + CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest) request; + List<?> relationshipTypes = createRequest.getElementTypes(); + for (Object type : relationshipTypes) { + if (UMLElementTypes.DurationConstraint_Edge.equals(type) || UMLElementTypes.DurationObservation_Edge.equals(type) || UMLElementTypes.GeneralOrdering_Edge.equals(type)) { + return new CenterAnchor(getFigure()); + } + } + } else if (request instanceof CreateConnectionViewRequest) { + CreateConnectionViewRequest createRequest = (CreateConnectionViewRequest) request; + if (DurationLinkUtil.isDurationLink(createRequest) || GeneralOrderingUtil.isGeneralOrderingLink(createRequest)) { + return new CenterAnchor(getFigure()); + } + } + return super.getSourceConnectionAnchor(request); + } + + @Override + protected NodeFigure createNodePlate() { + // Use a custom NodePlate to support the Destruction's CenterAnchor + DestructionEventNodePlate nodePlate = new DestructionEventNodePlate(40, 40); + return nodePlate; + } + + @Override + protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { + if (borderItemEditPart instanceof TimeConstraintBorderNodeEditPart + || borderItemEditPart instanceof TimeObservationBorderNodeEditPart) { + borderItemContainer.add(borderItemEditPart.getFigure(), new TimeElementLocator(getMainFigure(), + __ -> PositionConstants.CENTER)); + } else { + super.addBorderItem(borderItemContainer, borderItemEditPart); + } + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java index 19df9b50215..abdb45d7f30 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java @@ -25,13 +25,8 @@ import org.eclipse.gef.commands.UnexecutableCommand; import org.eclipse.gef.requests.ChangeBoundsRequest; import org.eclipse.gef.requests.ReconnectRequest; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest.ViewAndElementDescriptor; -import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionFragmentContainerCreationEditPolicy; -import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes; -import org.eclipse.papyrus.uml.service.types.utils.ElementUtil; /** * @author Celine JANSSENS @@ -63,15 +58,6 @@ public class CInteractionInteractionCompartmentEditPart extends InteractionInter */ @Override public Command getCommand(Request request) { - if (request instanceof CreateViewAndElementRequest && request.getType().equals(REQ_CREATE)) { - CreateViewAndElementRequest createrequest = (CreateViewAndElementRequest) request; - ViewAndElementDescriptor descriptor = createrequest.getViewAndElementDescriptor(); - IElementType elementType = descriptor.getElementAdapter().getAdapter(IElementType.class); - if (ElementUtil.isTypeOf(elementType, UMLDIElementTypes.DURATION_CONSTRAINT_SHAPE)) { - return null; - } - } - // ExecutionSpecification can't be drop into Interaction if (request instanceof ChangeBoundsRequest) { List<?> editParts = ((ChangeBoundsRequest) request).getEditParts(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java index ac063d5a830..d53628f7baf 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java @@ -12,21 +12,29 @@ * CEA LIST - Initial API and implementation * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519621, 526803 * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 531520 - * Christian W. Damus - bug 533672 + * Christian W. Damus - bugs 533672, 536486 *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import java.util.OptionalInt; +import org.eclipse.draw2d.Connection; import org.eclipse.draw2d.ConnectionAnchor; import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.emf.ecore.EObject; import org.eclipse.gef.ConnectionEditPart; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPolicy; import org.eclipse.gef.Request; import org.eclipse.gef.requests.CreateRequest; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; import org.eclipse.gmf.runtime.emf.type.core.IElementType; @@ -44,8 +52,13 @@ import org.eclipse.papyrus.uml.diagram.sequence.figures.LifeLineLayoutManager; import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineFigure; import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineNodeFigure; import org.eclipse.papyrus.uml.diagram.sequence.locator.MessageCreateLifelineAnchor; +import org.eclipse.papyrus.uml.diagram.sequence.locator.TimeElementLocator; import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; +import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.DisplayEvent; import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil; +import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.MessageEnd; +import org.eclipse.uml2.uml.MessageSort; /** * @author Patrick Tessier @@ -274,4 +287,72 @@ public class CLifeLineEditPart extends LifelineEditPart { } super.eraseTargetFeedback(request); } + + @Override + protected boolean addFixedChild(EditPart childEditPart) { + Optional<MessageEnd> createEnd = TimeElementLocator.getTimedElement(childEditPart, MessageEnd.class) + .filter(MessageEnd::isReceive) + .filter(end -> end.getMessage().getMessageSort() == MessageSort.CREATE_MESSAGE_LITERAL); + + return createEnd.map(__ -> { + getBorderedFigure().getBorderItemContainer() + .add(((IGraphicalEditPart) childEditPart).getFigure(), + new TimeElementLocator(getMainFigure(), this::getTimeElementSide)); + + return true; + }).orElseGet(() -> super.addFixedChild(childEditPart)); + } + + public OptionalInt getCreateMessageIncomingSide(Point where) { + // The proposed location is in relative coordinates, but the DisplayEvent API is + // in absolute terms (dealing with the mouse pointer) + Point search = where.getCopy(); + getMainFigure().translateToAbsolute(search); + + DisplayEvent displayEvent = new DisplayEvent(this); + MessageEnd end = displayEvent.getMessageEvent(getMainFigure(), search); + if ((end != null) && end.isReceive() && (end.getMessage().getMessageSort() == MessageSort.CREATE_MESSAGE_LITERAL)) { + return getCreateMessageIncomingSide(end); + } + + return OptionalInt.empty(); + } + + private OptionalInt getCreateMessageIncomingSide(MessageEnd end) { + LifelineFigure lifelineFigure = (LifelineFigure) svgNodePlate.getChildren().get(0); + IFigure headerFigure = lifelineFigure.getHeaderFigure(); + + OptionalInt result = OptionalInt.empty(); + + for (Object next : getTargetConnections()) { + ConnectionEditPart incoming = (ConnectionEditPart) next; + EObject semantic = incoming.getAdapter(EObject.class); + if (semantic instanceof Message) { + Message message = (Message) semantic; + if (message.getMessageSort() == MessageSort.CREATE_MESSAGE_LITERAL) { + Point headCenter = headerFigure.getBounds().getCenter(); + lifelineFigure.translateToAbsolute(headCenter); + Connection conn = (Connection) incoming.getFigure(); + Point target = conn.getPoints().getLastPoint(); + if (target.x() > headCenter.x()) { + // The create message is incoming from the right + result = OptionalInt.of(PositionConstants.EAST); + } else { + result = OptionalInt.of(PositionConstants.WEST); + } + } + } + } + + return result; + } + + int getTimeElementSide(Rectangle proposedBounds) { + OptionalInt incoming = getCreateMessageIncomingSide(proposedBounds.getTopLeft()); + return incoming.isPresent() + // Put the time element on the side opposite to the incoming create message + ? PositionConstants.EAST_WEST ^ incoming.getAsInt() + // Center it on the lifeline + : PositionConstants.CENTER; + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomCommentAnnotatedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomCommentAnnotatedElementEditPart.java deleted file mode 100644 index a3973aae58a..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomCommentAnnotatedElementEditPart.java +++ /dev/null @@ -1,113 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.ConnectionLayer; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.gef.DragTracker; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.LayerConstants; -import org.eclipse.gef.Request; -import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; -import org.eclipse.gmf.runtime.draw2d.ui.internal.figures.ConnectionLayerEx; -import org.eclipse.gmf.runtime.draw2d.ui.internal.routers.FanRouter; -import org.eclipse.gmf.runtime.gef.ui.internal.tools.SelectConnectionEditPartTracker; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.RoutingStyle; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.uml.diagram.sequence.draw2d.routers.DurationConstraintAutomaticRouter; -import org.eclipse.papyrus.uml.diagram.sequence.util.LinkRouteModelElementFactory; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomCommentAnnotatedElementEditPart extends CommentAnnotatedElementEditPart implements ITreeBranchEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomCommentAnnotatedElementEditPart(View view) { - super(view); - } - - - @Override - protected void handleNotificationEvent(Notification event) { - super.handleNotificationEvent(event); - if (LinkRouteModelElementFactory.isRoutingNotification(event)) { - installRouter(); - } - } - - private FanRouter customRouter; - - @Override - protected void installRouter() { - if (this.getSource() instanceof CustomDurationConstraintEditPart) { - ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER); - RoutingStyle style = (RoutingStyle) ((View) getModel()).getStyle(NotationPackage.Literals.ROUTING_STYLE); - if (style != null && cLayer instanceof ConnectionLayerEx) { - ConnectionLayerEx cLayerEx = (ConnectionLayerEx) cLayer; - if (LinkRouteModelElementFactory.isAutomaticRouting(this.getNotationView())) { - CustomDurationConstraintEditPart customDurationConstraintEditPart = (CustomDurationConstraintEditPart) this.getSource(); - if (customRouter == null) { - FanRouter router = new FanRouter(); - router.setNextRouter(new DurationConstraintAutomaticRouter(this.getNotationView())); - customRouter = router; - } - getConnectionFigure().setConnectionRouter(customRouter); - } else { - getConnectionFigure().setConnectionRouter(cLayerEx.getObliqueRouter()); - } - } - refreshRouterChange(); - } else { - super.installRouter(); - } - } - - @Override - public void setSource(EditPart editPart) { - super.setSource(editPart); - // Fixed bug about duration constraint links' automatic router. - if (editPart instanceof CustomDurationConstraintEditPart) { - installRouter(); - } - } - - @Override - public DragTracker getDragTracker(final Request req) { - return new SelectConnectionEditPartTrackerEx(this); - } - - class SelectConnectionEditPartTrackerEx extends SelectConnectionEditPartTracker { - - public SelectConnectionEditPartTrackerEx(CommentAnnotatedElementEditPart owner) { - super(owner); - } - - @Override - protected boolean handleDragInProgress() { - if (isInState(STATE_DRAG_IN_PROGRESS) && shouldAllowDrag()) { - LinkRouteModelElementFactory.switchToManualRouting(getEdge()); - super.handleDragInProgress(); - } - return true; - } - }; -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDestructionOccurrenceSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDestructionOccurrenceSpecificationEditPart.java deleted file mode 100644 index d33fb72202a..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDestructionOccurrenceSpecificationEditPart.java +++ /dev/null @@ -1,97 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeCommentCreationEditPolicyEx; -import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCommentEditPolicy; - -/** - * Add implementing interface IPapyrusEditPart to displaying Stereotypes. - * - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomDestructionOccurrenceSpecificationEditPart extends DestructionOccurrenceSpecificationEditPart implements IPapyrusEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomDestructionOccurrenceSpecificationEditPart(View view) { - super(view); - } - - @Override - protected NodeFigure createNodePlate() { - NodeFigure result = super.createNodePlate(); - // FIXME: workaround for #154536 - result.getBounds().setSize(result.getPreferredSize()); - return result; - } - - /** - * @Override - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - // install a editpolicy to display stereotypes - installEditPolicy(AppliedStereotypeCommentEditPolicy.APPLIED_STEREOTYPE_COMMENT, new AppliedStereotypeCommentCreationEditPolicyEx()); - } - - @Override - protected void refreshBounds() { - if (getBorderItemLocator() != null) { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - Point loc = new Point(x, y); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); - Dimension size = new Dimension(width, height); - if (width != -1 && height != -1) { - getFigure().setBounds(new Rectangle(loc, size)); - } - getBorderItemLocator().setConstraint(new Rectangle(loc, size)); - } else { - super.refreshBounds(); - } - } - - @Override - protected void handleNotificationEvent(Notification notification) { - super.handleNotificationEvent(notification); - Object feature = notification.getFeature(); - if ((getModel() != null) && (getModel() == notification.getNotifier())) { - if (NotationPackage.eINSTANCE.getLineStyle_LineWidth().equals(feature)) { - refreshLineWidth(); - } - } - } - - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshLineWidth(); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintAppliedStereotypeEditPart.java deleted file mode 100644 index 470824f5114..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintAppliedStereotypeEditPart.java +++ /dev/null @@ -1,73 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeExternalNodeLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.AppliedStereotypeLabelFigure; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomDurationConstraintAppliedStereotypeEditPart extends DurationConstraintAppliedStereotypeEditPart implements IPapyrusEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomDurationConstraintAppliedStereotypeEditPart(View view) { - super(view); - } - - /** - * @Override - */ - @Override - public IFigure getPrimaryShape() { - return getFigure(); - } - - @Override - protected void refreshLabel() { - // We do NOT want to update label with the Parser. - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - removeEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeLabelEditPolicy()); - } - - @Override - protected IFigure createFigurePrim() { - return new AppliedStereotypeLabelFigure(); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintEditPart.java deleted file mode 100644 index 581db81737b..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintEditPart.java +++ /dev/null @@ -1,926 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import java.util.List; - -import org.eclipse.draw2d.Border; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.Figure; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PolylineShape; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Insets; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.PrecisionPoint; -import org.eclipse.draw2d.geometry.PrecisionRectangle; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EAnnotation; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.ConnectionEditPart; -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.editpolicies.LayoutEditPolicy; -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; -import org.eclipse.gef.handles.HandleBounds; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gef.requests.ReconnectRequest; -import org.eclipse.gmf.runtime.common.core.util.StringStatics; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.diagram.ui.render.editparts.RenderedDiagramRootEditPart; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; -import org.eclipse.gmf.runtime.draw2d.ui.geometry.PointListUtilities; -import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode; -import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil; -import org.eclipse.gmf.runtime.emf.type.core.IHintedType; -import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.preferences.PreferencesConstantsHelper; -import org.eclipse.papyrus.uml.diagram.common.draw2d.LinesBorder; -import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; -import org.eclipse.papyrus.uml.diagram.common.locator.ExternalLabelPositionLocator; -import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper; -import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper.FixedAnchorEx; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeCommentCreationEditPolicyEx; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExternalLabelPrimaryDragRoleEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationConstraintFigure; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; -import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil; -import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCommentEditPolicy; -import org.eclipse.uml2.uml.DurationConstraint; -import org.eclipse.uml2.uml.InteractionFragment; -import org.eclipse.uml2.uml.MessageOccurrenceSpecification; - -/** - * Add implementing IPapyrusEditPart to displaying Stereotypes. - * - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomDurationConstraintEditPart extends DurationConstraintEditPart implements IPapyrusEditPart { - - private static final String ARROW = "Arrow"; - - private static final String DIRECTION = "Direction"; - - private static final String VERTICAL = "vertical"; - - private static final String HORIZONTAL = "horizontal"; - - /** - * Constructor. - * - * @param view - */ - public CustomDurationConstraintEditPart(View view) { - super(view); - } - - /** - * @Override - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - // install a editpolicy to display stereotypes, there's a bug on super class. - installEditPolicy(AppliedStereotypeCommentEditPolicy.APPLIED_STEREOTYPE_COMMENT, new AppliedStereotypeCommentCreationEditPolicyEx()); - } - - /** - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request) - * - * @param request - * The request - * @return The anchor - */ - @Override - public ConnectionAnchor getSourceConnectionAnchor(Request request) { - IHintedType type = (IHintedType) UMLElementTypes.Comment_AnnotatedElementEdge; - if (request instanceof CreateConnectionViewRequest) { - String hint = ((CreateConnectionViewRequest) request).getConnectionViewDescriptor().getSemanticHint(); - if (hint.equals(type.getSemanticHint())) { - return new RotateAnchor(getFigure(), computeAnchorLocation(((CreateConnectionViewRequest) request).getLocation())); - } - } else if (request instanceof ReconnectRequest) { - ConnectionEditPart linkPart = ((ReconnectRequest) request).getConnectionEditPart(); - if (linkPart instanceof CommentAnnotatedElementEditPart) { - return new RotateAnchor(getFigure(), computeAnchorLocation(((ReconnectRequest) request).getLocation())); - } - } - return super.getSourceConnectionAnchor(request); - } - - protected int computeAnchorLocation(Point location) { - Rectangle box = getBox(); - if (isArrowVertical()) { - if (location.getDistance2(box.getTop()) > location.getDistance2(box.getBottom())) { - return PositionConstants.BOTTOM; - } - return PositionConstants.TOP; - } else { - if (location.getDistance2(box.getLeft()) > location.getDistance2(box.getRight())) { - return PositionConstants.RIGHT; - } - return PositionConstants.LEFT; - } - } - - protected Rectangle getBox() { - Rectangle rBox = getFigure() instanceof HandleBounds ? new PrecisionRectangle(((HandleBounds) getFigure()).getHandleBounds()) : new PrecisionRectangle(getFigure().getBounds()); - getFigure().translateToAbsolute(rBox); - return rBox; - } - - public boolean canCreateLink(Point point) { - DurationConstraint dc = (DurationConstraint) this.resolveSemanticElement(); - - int count = 0; // link counts - List list = this.getSourceConnections(); - for (Object o : list) { - if (o instanceof CustomCommentAnnotatedElementEditPart) { - count++; - } - } - if (count >= 2) { - return false; - } - - if (count < 1) { - return true; - } - - int targetPosition = computeAnchorLocation(point); - if (findLinkAtPosition(targetPosition)) { - return false; - } - return true; - } - - // protected void refreshSourceConnections() { - // super.refreshSourceConnections(); - // Display.getDefault().asyncExec(new Runnable(){ - // public void run() { - // refreshBorder(); - // } - // }); - // } - // - // public void refresh(){ - // super.refresh(); - // refreshBorder(); - // } - // - // private void refreshBorder() { - // if(getPrimaryShape() instanceof CustomDurationConstraintFigure){ - // CustomDurationConstraintFigure fig = (CustomDurationConstraintFigure)getPrimaryShape(); - // fig.setBorderVisible(hasTopLink(), hasBottomLink()); - // } - // } - - public boolean hasTopLink() { - return findLinkAtPosition(PositionConstants.TOP); - } - - public boolean hasBottomLink() { - return findLinkAtPosition(PositionConstants.BOTTOM); - } - - protected boolean findLinkAtPosition(int targetPos) { - List list = this.getSourceConnections(); - for (Object o : list) { - if (o instanceof CustomCommentAnnotatedElementEditPart) { - CustomCommentAnnotatedElementEditPart connPart = (CustomCommentAnnotatedElementEditPart) o; - if ((targetPos & getSourceAnchorPosition(connPart)) > 0) { - return true; - } - - } - } - return false; - } - - /** - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart) - * - * @param connEditPart - * The connection edit part. - * @return The anchor. - */ - @Override - public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connEditPart) { - ConnectionAnchor anchor = null; - if (connEditPart instanceof CommentAnnotatedElementEditPart) { - anchor = new RotateAnchor(getFigure(), getSourceAnchorPosition((CommentAnnotatedElementEditPart) connEditPart)); - } else { - anchor = super.getSourceConnectionAnchor(connEditPart); - } - - return anchor; - } - - private int getSourceAnchorPosition(CommentAnnotatedElementEditPart connEditPart) { - String terminal = AnchorHelper.getAnchorId(getEditingDomain(), connEditPart, true); - if (terminal.length() > 0) { - return parseLocation(terminal); - } - return PositionConstants.TOP; - } - - @Override - protected void refreshBounds() { - super.refreshBounds(); - - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); - // restore to default size - if (width == -1) { - width = getFigure().getPreferredSize().width; - } - if (height == -1) { - height = getFigure().getPreferredSize().height; - } - - if (width != -1 && height != -1) { - Dimension size = primaryShape.getBounds().getSize(); - // if(size.width != width || size.height != height) { // if resize bounds - primaryShape.setBounds(new Rectangle(primaryShape.getBounds().getLocation(), new Dimension(width, height))); - // } - } - - // fix combined fragment move - this.getFigure().getParent().getLayoutManager().layout(this.getFigure().getParent()); - relocateLabelEditPart(); - } - - @Override - protected IFigure createNodeShape() { - return primaryShape = new CustomDurationConstraintFigure(); - } - - @Override - protected IFigure setupContentPane(IFigure nodeShape) { - nodeShape = super.setupContentPane(nodeShape); - DefaultSizeNodeFigure parent = (DefaultSizeNodeFigure) nodeShape.getParent(); - nodeShape.setPreferredSize(parent.getDefaultSize()); - return nodeShape; // use nodeShape itself as contentPane - } - - /** - * This method creates a specific edit policy for time realted elements - * - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart#getPrimaryDragEditPolicy() - * - * @return <code>EditPolicy</code> - * @Override - */ - @Override - public EditPolicy getPrimaryDragEditPolicy() { - EditPolicy policy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - return policy != null ? policy : new ResizableShapeEditPolicy() { - - @Override - protected Command getResizeCommand(ChangeBoundsRequest request) { - ChangeBoundsRequest req = new ChangeBoundsRequest(REQ_RESIZE_CHILDREN); - req.setEditParts(getHost()); - req.setMoveDelta(request.getMoveDelta()); - req.setSizeDelta(request.getSizeDelta()); - req.setLocation(request.getLocation()); - req.setExtendedData(request.getExtendedData()); - req.setResizeDirection(request.getResizeDirection()); - return getHost().getParent().getCommand(req); - } - - @Override - protected void showChangeBoundsFeedback(ChangeBoundsRequest request) { - IFigure feedback = getDragSourceFeedbackFigure(); - - PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy()); - getHostFigure().translateToAbsolute(rect); - rect.translate(request.getMoveDelta()); - rect.resize(request.getSizeDelta()); - - IFigure f = getHostFigure(); - Dimension max = f.getMaximumSize().getCopy(); - IMapMode mmode = MapModeUtil.getMapMode(f); - max.height = mmode.LPtoDP(max.height); - max.width = mmode.LPtoDP(max.width); - - // no minimal size - if (max.width < rect.width) { - rect.width = max.width; - } - - if (max.height < rect.height) { - rect.height = max.height; - } - - feedback.translateToRelative(rect); - feedback.setBounds(rect); - } - }; - } - - /** - * @Override use ExternalLabelPrimaryDragRoleEditPolicy - */ - @Override - protected LayoutEditPolicy createLayoutEditPolicy() { - org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { - - @Override - protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); - switch (UMLVisualIDRegistry.getVisualID(childView)) { - case DurationConstraintLabelEditPart.VISUAL_ID: - case DurationConstraintAppliedStereotypeEditPart.VISUAL_ID: - // use ExternalLabelPrimaryDragRoleEditPolicy - return new ExternalLabelPrimaryDragRoleEditPolicy(); - } - EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { - result = new NonResizableEditPolicy(); - } - return result; - } - - @Override - protected Command getMoveChildrenCommand(Request request) { - return null; - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - }; - return lep; - } - - /** - * @Override use ExternalLabelPositionLocator - */ - @Override - protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof DurationConstraintLabelEditPart) { - DurationConstraintLabelLocator locator = new DurationConstraintLabelLocator(getMainFigure()); - locator.setParentEditPart(this); - borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else if (borderItemEditPart instanceof DurationConstraintAppliedStereotypeEditPart) { - // use ExternalLabelPositionLocator - IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); - borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else { - super.addBorderItem(borderItemContainer, borderItemEditPart); - } - } - - /** - * @Override Override for redirecting creation request to the lifeline - */ - @Override - public Command getCommand(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - return getParent().getCommand(request); - } - return super.getCommand(request); - } - - /** - * @Override Override for redirecting creation request to the lifeline - */ - @Override - public void showSourceFeedback(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - getParent().showSourceFeedback(request); - } - super.showSourceFeedback(request); - } - - /** - * @Override Override for redirecting creation request to the lifeline - */ - @Override - public void eraseSourceFeedback(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - getParent().eraseSourceFeedback(request); - } - super.eraseSourceFeedback(request); - } - - @Override - protected void handleNotificationEvent(Notification notification) { - super.handleNotificationEvent(notification); - Object feature = notification.getFeature(); - if ((getModel() != null) && (getModel() == notification.getNotifier())) { - if (NotationPackage.eINSTANCE.getLineStyle_LineWidth().equals(feature)) { - refreshLineWidth(); - } - } - - if (notification.getNewValue() instanceof EAnnotation && ARROW.equals(((EAnnotation) notification.getNewValue()).getSource())) { - refreshArrowDirection((EAnnotation) notification.getNewValue()); - } else if (notification.getNotifier() instanceof EAnnotation && ARROW.equals(((EAnnotation) notification.getNotifier()).getSource())) { - refreshArrowDirection((EAnnotation) notification.getNotifier()); // notification.getEventType() == - } - } - - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshArrowDirection(null); - refreshLineWidth(); - } - - private void relocateLabelEditPart() { - List list = this.getChildren(); - for (Object o : list) { - if (o instanceof DurationConstraintLabelEditPart) { - DurationConstraintLabelEditPart label = (DurationConstraintLabelEditPart) o; - if (label.getBorderItemLocator() != null) { - IBorderItemLocator loc = label.getBorderItemLocator(); - loc.relocate(label.getFigure()); - } - } - } - } - - public Rectangle updateMoveBounds(Rectangle newBounds) { - if (getCurrentSideOfParent() == PositionConstants.WEST) { - Rectangle bounds = this.getFigure().getBounds(); - return newBounds.translate(-bounds.width, 0); // keep bounds in left side - } - return newBounds; - } - - public int getCurrentSideOfParent() { - IBorderItemLocator locator = this.getBorderItemLocator(); - if (locator != null) { - return locator.getCurrentSideOfParent(); - } - return PositionConstants.EAST; - } - - public class CustomDurationConstraintFigure extends DurationConstraintFigure { - - /** - * Height of the arrow end - * - */ - private static final int ARROW_HEIGHT = 8; - - /** - * Width of the half of the arrow end - * - */ - private static final int ARROW_SEMI_WIDTH = 7; - - boolean vertical = true; - - public CustomDurationConstraintFigure() { - setBorder(createBorder0()); - setDashBorder(); - } - - private Border createBorder0() { - LinesBorder result = new LinesBorder() { - - @Override - public void paint(IFigure figure, Graphics graphics, Insets insets) { - tempRect.setBounds(getPaintRectangle(figure, insets)); - - int one = MapModeUtil.getMapMode(figure).DPtoLP(1); - int widthInDP = getWidth() / one; - - int halfWidthInLP = MapModeUtil.getMapMode(figure).DPtoLP(widthInDP / 2); - - graphics.setLineWidth(getWidth()); - graphics.setLineStyle(getStyle()); - // adapt tempRect so that borders do not overflow the initial bounds - tempRect.x += halfWidthInLP; - tempRect.width -= getWidth(); - tempRect.y += halfWidthInLP; - tempRect.height -= getWidth(); - - if ((getPositions() & PositionConstants.TOP) > 0) { - // graphics.drawLine(tempRect.getTopLeft(), tempRect.getTopRight()); - graphics.drawLine(new Point(tempRect.getTopLeft().x(), tempRect.getTopLeft().y() + 1), new Point(tempRect.getTopRight().x(), tempRect.getTopRight().y() + 1)); - } - if ((getPositions() & PositionConstants.LEFT) > 0) { - // graphics.drawLine(tempRect.getTopLeft(), tempRect.getBottomLeft()); - graphics.drawLine(new Point(tempRect.getTopLeft().x() + 1, tempRect.getTopLeft().y()), new Point(tempRect.getBottomLeft().x() + 1, tempRect.getBottomLeft().y())); - } - if ((getPositions() & PositionConstants.BOTTOM) > 0) { - graphics.drawLine(tempRect.getBottomLeft(), tempRect.getBottomRight()); - } - if ((getPositions() & PositionConstants.RIGHT) > 0) { - graphics.drawLine(tempRect.getTopRight(), tempRect.getBottomRight()); - } - } - }; - result.setSides(PositionConstants.TOP | PositionConstants.BOTTOM); - return result; - } - - protected void setDashBorder() { - if (this.getBorder() instanceof LinesBorder) { - LinesBorder lb = (LinesBorder) this.getBorder(); - lb.setStyle(Graphics.LINE_DASH); - if (vertical) { - lb.setSides(PositionConstants.TOP | PositionConstants.BOTTOM); - } else { - lb.setSides(PositionConstants.LEFT | PositionConstants.RIGHT); - } - } - } - - @Override - public Insets getInsets() { - if (getBorder() != null) { - return getBorder().getInsets(this); - } - return NO_INSETS; - } - - public void setVertical(boolean val) { - if (val != vertical) { - vertical = val; - setDashBorder(); - revalidate(); - } - } - - // public void setBorderVisible(boolean top, boolean bottom){ - // if(this.getBorder() instanceof LinesBorder){ - // LinesBorder lb = (LinesBorder) this.getBorder(); - // if(top){ - // int value = bottom ? PositionConstants.TOP | PositionConstants.BOTTOM : PositionConstants.TOP; - // lb.setSides(value); - // }else{ - // int value = bottom ? PositionConstants.BOTTOM : PositionConstants.NONE; - // lb.setSides(value); - // } - // this.repaint(); - // } - // } - - /** - * Sets the bounds of this Figure to the Rectangle <i>rect</i>. - * This also updates sub-figures. - * - * @see Figure#setBounds(Rectangle) - * @param rect - * The new bounds - */ - @Override - public void setBounds(Rectangle rect) { - updateArrow(rect.width, rect.height); - - Rectangle c = rect.getCopy(); - this.getParent().translateToAbsolute(c); - - super.setBounds(rect); - } - - /** - * Update the arrow polyline taking in account new figure's size - * - * @param figureWidth - * the new figure width - * @param figureHeight - * the new figure height - */ - public void updateArrow(int figureWidth, int figureHeight) { - // handle insets to avoid figure growing indefinitely - figureWidth -= getInsets().left + getInsets().right; - figureHeight -= getInsets().top + getInsets().bottom; - if (getDurationArrow() != null) { - int halfLineWidth = getLineWidth() / 2; - if (vertical) { - PointList points = new PointList(8); - int centerX = figureWidth / 2; - points.addPoint(centerX - ARROW_SEMI_WIDTH, halfLineWidth + ARROW_HEIGHT); - points.addPoint(centerX, halfLineWidth); - points.addPoint(centerX + ARROW_SEMI_WIDTH, halfLineWidth + ARROW_HEIGHT); - points.addPoint(centerX, halfLineWidth); - points.addPoint(centerX, figureHeight - halfLineWidth); - points.addPoint(centerX - ARROW_SEMI_WIDTH, figureHeight - halfLineWidth - ARROW_HEIGHT); - points.addPoint(centerX, figureHeight - halfLineWidth); - points.addPoint(centerX + ARROW_SEMI_WIDTH, figureHeight - halfLineWidth - ARROW_HEIGHT); - getDurationArrow().setPoints(points); - Point topLeft = getLocation().getTranslated(getInsets().left, getInsets().top); - getDurationArrow().setBounds(new Rectangle(topLeft, new Dimension(figureWidth, figureHeight))); - } else { - PointList points = new PointList(8); - int centerY = figureHeight / 2; - points.addPoint(halfLineWidth + ARROW_HEIGHT, centerY - ARROW_SEMI_WIDTH); - points.addPoint(halfLineWidth, centerY); - points.addPoint(halfLineWidth + ARROW_HEIGHT, centerY + ARROW_SEMI_WIDTH); - points.addPoint(halfLineWidth, centerY); - points.addPoint(figureWidth - halfLineWidth, centerY); - - points.addPoint(figureWidth - halfLineWidth - ARROW_HEIGHT, centerY - ARROW_SEMI_WIDTH); - points.addPoint(figureWidth - halfLineWidth, centerY); - points.addPoint(figureWidth - halfLineWidth - ARROW_HEIGHT, centerY + ARROW_SEMI_WIDTH); - - getDurationArrow().setPoints(points); - Point topLeft = getLocation().getTranslated(getInsets().left, getInsets().top); - getDurationArrow().setBounds(new Rectangle(topLeft, new Dimension(figureWidth, figureHeight))); - } - } - } - - @Override - public boolean containsPoint(int x, int y) { - boolean containsPoint = super.containsPoint(x, y); - if (!containsPoint) { - return false; - } - PolylineShape durationArrow = getDurationArrow(); - if (durationArrow != null) { - return PointListUtilities.containsPoint(durationArrow.getPoints(), new Point(x, y)); - // return fDurationArrow.containsPoint(x, y); - } - return containsPoint; - } - - @Override - public void paintFigure(Graphics graphics) { - graphics.setLineWidth(lineWidth); - super.paintFigure(graphics); - } - - @Override - public void setLineWidth(int w) { - LinesBorder lb = (LinesBorder) getBorder(); - lb.setWidth(w); - getDurationArrow().setLineWidth(w); - super.setLineWidth(w); - } - } - - public static Rectangle fixMessageBounds(Rectangle newBounds, Request cvr, LifelineEditPart host) { - Object oc1 = getFirstElement(cvr.getExtendedData().get(org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION)); - Object oc2 = getFirstElement(cvr.getExtendedData().get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2)); - if (oc1 != null && oc2 != null && (oc1 instanceof MessageOccurrenceSpecification || oc2 instanceof MessageOccurrenceSpecification)) { - Point start = null, end = null; - Rectangle bounds = null; - if (oc1 instanceof InteractionFragment) { - start = SequenceUtil.findLocationOfEvent(host, (InteractionFragment) oc1, true); - } - if (oc2 instanceof InteractionFragment) { - end = SequenceUtil.findLocationOfEvent(host, (InteractionFragment) oc2, true); - } - if (start != null && end != null) { - bounds = (start.y < end.y) ? new Rectangle(start, end) : new Rectangle(end, start); - } - if (bounds != null) { - IFigure parentFigure = host.getFigure(); - Point parentFigDelta = parentFigure.getBounds().getLocation().getCopy().negate(); - parentFigure.translateToRelative(bounds); - bounds.translate(parentFigDelta); - if (bounds.y != newBounds.y || newBounds.height != bounds.height) { - newBounds.y = bounds.y; - newBounds.height = bounds.height; - } - } - } - return newBounds; - } - - static class DurationConstraintLabelLocator extends ExternalLabelPositionLocator { - - private CustomDurationConstraintEditPart durationConstraintEditPart; - - public DurationConstraintLabelLocator(IFigure mainFigure) { - super(mainFigure); - } - - public void setParentEditPart(CustomDurationConstraintEditPart durationConstraintEditPart) { - this.durationConstraintEditPart = durationConstraintEditPart; - } - - @Override - public void relocate(IFigure target) { - if (constraint.y == 0) { - if (durationConstraintEditPart.getCurrentSideOfParent() == PositionConstants.WEST) { - Point r = parentFigure.getBounds().getLeft().translate(-20, -5); - target.setBounds(new Rectangle(r, target.getPreferredSize())); - } else { - Point r = parentFigure.getBounds().getRight().translate(5, -5); - target.setBounds(new Rectangle(r, target.getPreferredSize())); - } - } else { - super.relocate(target); - } - } - } - - static Object getFirstElement(Object obj) { - if (obj != null && obj instanceof List) { - List list = (List) obj; - if (list.size() > 0) { - return list.get(0); - } - } - return null; - } - - - protected void refreshArrowDirection(EAnnotation newValue) { - CustomDurationConstraintFigure dc = (CustomDurationConstraintFigure) getPrimaryShape(); - dc.setVertical(isArrowVertical()); - refreshBounds(); - } - - public void setArrowDirection(String dir) { - View view = this.getNotationView(); - if (view == null) { - return; - } - - EAnnotation ea = view.getEAnnotation(ARROW); - if (ea == null) { - ea = EcoreFactory.eINSTANCE.createEAnnotation(); - ea.setSource(ARROW); - ea.getDetails().put(DIRECTION, dir); - view.getEAnnotations().add(ea); - } else { - ea.getDetails().clear(); - ea.getDetails().put(DIRECTION, dir); - } - } - - public String getArrowDirection() { - View view = this.getNotationView(); - if (view == null) { - return ""; - } - EAnnotation ea = view.getEAnnotation(ARROW); - if (ea != null) { - String pos = ea.getDetails().get(DIRECTION); - if (pos != null) { - return pos; - } - } - return VERTICAL; - } - - public boolean isArrowVertical() { - return VERTICAL.equals(getArrowDirection()); - } - - public void rotateArrow() { - if (isArrowVertical()) { - setArrowDirection(HORIZONTAL); - } else { - setArrowDirection(VERTICAL); - } - } - - private Object getStructuralFeatureValue(View view, EStructuralFeature feature) { - return ViewUtil.getPropertyValue(view, feature, feature.getEContainingClass()); - } - - public Rectangle getBounds() { - View view = this.getNotationView(); - int width = ((Integer) getStructuralFeatureValue(view, NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(view, NotationPackage.eINSTANCE.getSize_Height())).intValue(); - int x = ((Integer) getStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - String prefElementId = ViewUtil.resolveSemanticElement(view).eClass().getName(); - IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore(); - String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(view, prefElementId, PreferencesConstantsHelper.WIDTH); - String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(view, prefElementId, PreferencesConstantsHelper.HEIGHT); - if (width <= 0) { - width = store.getInt(preferenceConstantWitdh); - } - if (height <= 0) { - height = store.getInt(preferenceConstantHeight); - } - return new Rectangle(x, y, width, height); - } - - public static class RotateArrowCommand extends org.eclipse.emf.transaction.RecordingCommand { - - private CustomDurationConstraintEditPart part; - - public RotateArrowCommand(TransactionalEditingDomain domain, CustomDurationConstraintEditPart part) { - super(domain); - this.part = part; - } - - @Override - protected void doExecute() { - List list = part.getSourceConnections(); - if (part.isArrowVertical()) { - part.setArrowDirection(HORIZONTAL); - } else { - part.setArrowDirection(VERTICAL); - } - } - } - - class RotateAnchor extends FixedAnchorEx { - - public RotateAnchor(IFigure f, int location) { - super(f, location); - } - - @Override - public Point getLocation(Point reference) { - double zoom = 0; - if (CustomDurationConstraintEditPart.this.getRoot() instanceof RenderedDiagramRootEditPart) { - RenderedDiagramRootEditPart render = (RenderedDiagramRootEditPart) CustomDurationConstraintEditPart.this.getRoot(); - zoom = render.getZoomManager().getZoom(); - } - if (position == PositionConstants.TOP) { - return new PrecisionPoint(getBox().getTop().preciseX(), getBox().getTop().preciseY() + 1 * zoom); - } else if (position == PositionConstants.BOTTOM) { - if (zoom > 1) { - zoom = zoom - 1; - } - return new PrecisionPoint(getBox().getBottom().preciseX(), getBox().getBottom().preciseY() - 1 * zoom); - } else if (position == PositionConstants.LEFT) { - if (zoom > 1) { - zoom = zoom - 1; - } - return new PrecisionPoint(getBox().getLeft().preciseX(), getBox().getLeft().preciseY() + 1 * zoom); - } else if (position == PositionConstants.RIGHT) { - if (zoom > 1) { - zoom = zoom - 1; - } - return new PrecisionPoint(getBox().getRight().preciseX(), getBox().getRight().preciseY() + 1 * zoom); - } - return super.getLocation(reference); - } - - @Override - public String getTerminal() { - if (isDefaultAnchor()) { - return StringStatics.BLANK; - } - if (position == PositionConstants.TOP) { - return "(0.5,0){T}"; - } else if (position == PositionConstants.BOTTOM) { - return "(0.5,1){D}"; - } else if (position == PositionConstants.LEFT) { - return "(0,0.5){L}"; - } else if (position == PositionConstants.RIGHT) { - return "(1,0.5){R}"; - } - return "(0.5,0){T}"; - } - - } - - private int parseLocation(String terminal) { - if (terminal.length() > 0) { - int start = terminal.indexOf("{") + 1; - if (start > 0) { - char ch = Character.toUpperCase(terminal.charAt(start)); - switch (ch) { - case 'L': - return PositionConstants.LEFT; - case 'R': - return PositionConstants.RIGHT; - case 'D': - return PositionConstants.BOTTOM; - default: - return PositionConstants.TOP; - } - } - } - return PositionConstants.TOP; - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintInMessageAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintInMessageAppliedStereotypeEditPart.java deleted file mode 100644 index 3f5391b6cbb..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintInMessageAppliedStereotypeEditPart.java +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomDurationConstraintInMessageAppliedStereotypeEditPart extends DurationConstraintInMessageAppliedStereotypeEditPart implements IPapyrusEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomDurationConstraintInMessageAppliedStereotypeEditPart(View view) { - super(view); - } - - /** - * @Override - */ - @Override - public IFigure getPrimaryShape() { - return getFigure(); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintInMessageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintInMessageEditPart.java deleted file mode 100644 index df29a5de062..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintInMessageEditPart.java +++ /dev/null @@ -1,130 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.ConnectionLocator; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; -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.editparts.AbstractConnectionEditPart; -import org.eclipse.gef.editparts.AbstractGraphicalEditPart; -import org.eclipse.gef.editpolicies.LayoutEditPolicy; -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.diagram.ui.figures.LabelLocator; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.uml.diagram.common.locator.ExternalLabelPositionLocator; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExternalLabelPrimaryDragRoleEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomDurationConstraintInMessageEditPart extends DurationConstraintInMessageEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomDurationConstraintInMessageEditPart(View view) { - super(view); - } - - /** - * Make sure bounds are also refreshed. - * - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#refresh() - * @Override - */ - @Override - public void refresh() { - super.refresh(); - refreshBounds(); - } - - /** - * Handles refresh bounds the same way as for a non resizable label - * - * @Override - */ - @Override - protected void refreshBounds() { - int dx = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int dy = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - Point offset = new Point(dx, dy); - if (getParent() instanceof AbstractConnectionEditPart) { - ((AbstractGraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), new LabelLocator(((AbstractConnectionEditPart) getParent()).getConnectionFigure(), offset, ConnectionLocator.MIDDLE)); - } else { - getFigure().getParent().setConstraint(getFigure(), new LabelLocator(getFigure().getParent(), offset, ConnectionLocator.MIDDLE)); - } - } - - /** - * @Override use ExternalLabelPrimaryDragRoleEditPolicy - */ - @Override - protected LayoutEditPolicy createLayoutEditPolicy() { - org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { - - @Override - protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); - switch (UMLVisualIDRegistry.getVisualID(childView)) { - case DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID: - // use ExternalLabelPrimaryDragRoleEditPolicy - return new ExternalLabelPrimaryDragRoleEditPolicy(); - } - EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { - result = new NonResizableEditPolicy(); - } - return result; - } - - @Override - protected Command getMoveChildrenCommand(Request request) { - return null; - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - }; - return lep; - } - - /** - * @Override use ExternalLabelPositionLocator - */ - @Override - protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof DurationConstraintInMessageAppliedStereotypeEditPart) { - // use ExternalLabelPositionLocator - IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); - borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else { - super.addBorderItem(borderItemContainer, borderItemEditPart); - } - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintLinkEditPart.java new file mode 100644 index 00000000000..4673b8acbbf --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintLinkEditPart.java @@ -0,0 +1,77 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gmf.runtime.notation.Connector; +import org.eclipse.gmf.runtime.notation.IntValueStyle; +import org.eclipse.gmf.runtime.notation.NamedStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DurationLinkSelectionHandlesEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure; + +public class CustomDurationConstraintLinkEditPart extends DurationConstraintLinkEditPart { + + /** + * Constructor. + * + * @param view + */ + public CustomDurationConstraintLinkEditPart(View view) { + super(view); + } + + @Override + protected void createDefaultEditPolicies() { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new DurationLinkSelectionHandlesEditPolicy(this, getEditingDomain())); + } + + @Override + protected void refreshVisuals() { + refreshArrowDelta(); + super.refreshVisuals(); + } + + protected void refreshArrowDelta() { + Connector connector = (Connector) getNotationView(); + NamedStyle namedStyle = connector.getNamedStyle(NotationPackage.Literals.INT_VALUE_STYLE, DurationLinkFigure.DELTA_VIEW_STYLE); + if (namedStyle instanceof IntValueStyle) { + int delta = ((IntValueStyle) namedStyle).getIntValue(); + getPrimaryShape().setArrowPositionDelta(delta); + } else { + // no style - reset value + getPrimaryShape().setArrowPositionDelta(0); + } + } + + @Override + protected void handleNotificationEvent(Notification event) { + if (isDeltaIntValueStyle(event.getNotifier()) || + (event.getNotifier() == getNotationView() + && event.getFeature() == NotationPackage.Literals.VIEW__STYLES && + (isDeltaIntValueStyle(event.getNewValue()) || + (event.getNewValue() == null && isDeltaIntValueStyle(event.getOldValue()))))) { + refreshArrowDelta(); + } + super.handleNotificationEvent(event); + } + + private boolean isDeltaIntValueStyle(Object object) { + return object instanceof IntValueStyle && DurationLinkFigure.DELTA_VIEW_STYLE.equals(((IntValueStyle) object).getName()); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationAppliedStereotypeEditPart.java deleted file mode 100644 index e8a5ce3fa9f..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationAppliedStereotypeEditPart.java +++ /dev/null @@ -1,78 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeExternalNodeLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.AppliedStereotypeLabelFigure; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomDurationObservationAppliedStereotypeEditPart extends DurationObservationAppliedStereotypeEditPart implements IPapyrusEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomDurationObservationAppliedStereotypeEditPart(View view) { - super(view); - } - - /** - * @Override - */ - @Override - public IFigure getPrimaryShape() { - return getFigure(); - } - - @Override - protected void refreshLabel() { - // We do NOT want to update label with the Parser. - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - removeEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY); - View view = getPrimaryView(); - View stereotypeChangedView = view; - if (view != null) { - // stereotypeChangedView = ViewUtil.getChildBySemanticHint(view, UMLVisualIDRegistry.getType(DurationObservationLabelEditPart.VISUAL_ID)); - } - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeLabelEditPolicy(stereotypeChangedView)); - } - - @Override - protected IFigure createFigurePrim() { - return new AppliedStereotypeLabelFigure(); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationEditPart.java deleted file mode 100644 index 99ac21598fa..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationEditPart.java +++ /dev/null @@ -1,147 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.Border; -import org.eclipse.draw2d.IFigure; -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.editpolicies.LayoutEditPolicy; -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; -import org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure; -import org.eclipse.papyrus.uml.diagram.common.locator.ExternalLabelPositionLocator; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomConnectionHandleEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomExternalLabelPrimaryDragRoleEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomDurationObservationEditPart extends DurationObservationEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomDurationObservationEditPart(View view) { - super(view); - } - - /** - * @Override - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE, new CustomConnectionHandleEditPolicy()); - removeEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - removeEditPolicy(DeleteTimeElementWithoutEventPolicy.KEY); - } - - /** - * Make sure bounds are also refreshed. - * - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#refresh() - * @Override - */ - @Override - public void refresh() { - super.refresh(); - refreshBounds(); - } - - /** - * @Override use ExternalLabelPrimaryDragRoleEditPolicy - */ - @Override - protected LayoutEditPolicy createLayoutEditPolicy() { - org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { - - @Override - protected org.eclipse.gef.EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); - switch (UMLVisualIDRegistry.getVisualID(childView)) { - case DurationObservationAppliedStereotypeEditPart.VISUAL_ID: - // use ExternalLabelPrimaryDragRoleEditPolicy - return new CustomExternalLabelPrimaryDragRoleEditPolicy(); - } - org.eclipse.gef.EditPolicy result = child.getEditPolicy(org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { - result = new NonResizableEditPolicy(); - } - return result; - } - - @Override - protected Command getMoveChildrenCommand(Request request) { - return null; - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - }; - return lep; - } - - /** - * @Override use ExternalLabelPositionLocator - */ - @Override - protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof DurationObservationAppliedStereotypeEditPart) { - // use ExternalLabelPositionLocator - IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); - borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else { - super.addBorderItem(borderItemContainer, borderItemEditPart); - } - } - - @Override - protected NodeFigure createNodePlate() { - return new RoundedRectangleNodePlateFigure(20, 20); - } - - @Override - protected IFigure createNodeShape() { - primaryShape = new RoundedCompartmentFigure() { - - @Override - public Border getBorder() { - return null; - } - - @Override - public boolean isUsingGradient() { - return false; - } - }; - return primaryShape; - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java new file mode 100644 index 00000000000..a87bf7d3439 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java @@ -0,0 +1,78 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gmf.runtime.notation.Connector; +import org.eclipse.gmf.runtime.notation.IntValueStyle; +import org.eclipse.gmf.runtime.notation.NamedStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DurationLinkSelectionHandlesEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure; + +public class CustomDurationObservationLinkEditPart extends DurationObservationLinkEditPart { + + /** + * Constructor. + * + * @param view + */ + public CustomDurationObservationLinkEditPart(View view) { + super(view); + } + + @Override + protected void createDefaultEditPolicies() { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new DurationLinkSelectionHandlesEditPolicy(this, getEditingDomain())); + } + + @Override + protected void refreshVisuals() { + refreshArrowDelta(); + super.refreshVisuals(); + } + + protected void refreshArrowDelta() { + Connector connector = (Connector) getNotationView(); + NamedStyle namedStyle = connector.getNamedStyle(NotationPackage.Literals.INT_VALUE_STYLE, DurationLinkFigure.DELTA_VIEW_STYLE); + if (namedStyle instanceof IntValueStyle) { + int delta = ((IntValueStyle) namedStyle).getIntValue(); + getPrimaryShape().setArrowPositionDelta(delta); + } else { + // no style - reset value + getPrimaryShape().setArrowPositionDelta(0); + } + } + + @Override + protected void handleNotificationEvent(Notification event) { + if (isDeltaIntValueStyle(event.getNotifier()) || + (event.getNotifier() == getNotationView() + && event.getFeature() == NotationPackage.Literals.VIEW__STYLES && + (isDeltaIntValueStyle(event.getNewValue()) || + (event.getNewValue() == null && isDeltaIntValueStyle(event.getOldValue()))))) { + refreshArrowDelta(); + } + super.handleNotificationEvent(event); + } + + private boolean isDeltaIntValueStyle(Object object) { + return object instanceof IntValueStyle && DurationLinkFigure.DELTA_VIEW_STYLE.equals(((IntValueStyle) object).getName()); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java index 164cb9de86e..cb9f741681a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2010 CEA + * Copyright (c) 2010, 2018 CEA List, EclipseSource and others * * * All rights reserved. This program and the accompanying materials @@ -11,16 +11,13 @@ * * Contributors: * Soyatec - Initial API and implementation + * EclipseSource - Bug 537561 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; import org.eclipse.draw2d.Connection; import org.eclipse.emf.common.notify.Notification; -import org.eclipse.gef.ConnectionEditPart; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.ReconnectRequest; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; @@ -65,51 +62,7 @@ public class CustomGeneralOrderingEditPart extends GeneralOrderingEditPart imple @Override protected void setLineWidth(int width) { - getPrimaryShape().setLineWidth(width < 0 ? 1 : 0); - } - - @Override - public EditPart getTargetEditPart(Request request) { - EditPart ep = super.getTargetEditPart(request); - if (ep != null && ep instanceof org.eclipse.gef.ConnectionEditPart) { - if (request instanceof ReconnectRequest) { - ReconnectRequest rRequest = (ReconnectRequest) request; - - // If source anchor is moved, the connection's source edit part - // should not be taken into account for a cyclic dependency - // check so as to avoid false checks. Same goes for the target - // anchor. See bugzilla# 417373 -- we do not want to target a - // connection that is already connected to us so that we do not - // introduce a cyclic connection - if (isCyclicConnectionRequest((org.eclipse.gef.ConnectionEditPart) ep, rRequest.getConnectionEditPart())) { - return null; - } - } - } - - return ep; - } - - /** - * Fixed bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=417373 - * - * The ends of GeneralOrderingEditPart are MessageEndEditParts which parent are Message*EditParts, once we move the ends of the messages, we - * should IGNORE to move current GeneralOrdering, otherwise cyclic dependency occur. - * - */ - private boolean isCyclicConnectionRequest(ConnectionEditPart currentConn, ConnectionEditPart reqConn) { - if (currentConn == null || reqConn == null) { - return false; - } - EditPart source = currentConn.getSource(); - EditPart target = currentConn.getTarget(); - if (reqConn == source || reqConn == target) { - return true; - } - if (reqConn == source.getParent() || reqConn == target.getParent()) { - return true; - } - return false; + getPrimaryShape().setLineWidth(width < 0 ? 1 : width); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintAppliedStereotypeEditPart.java deleted file mode 100644 index 1b7c1ddef90..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintAppliedStereotypeEditPart.java +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeExternalNodeLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.AppliedStereotypeLabelFigure; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomTimeConstraintAppliedStereotypeEditPart extends TimeConstraintAppliedStereotypeEditPart implements IPapyrusEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomTimeConstraintAppliedStereotypeEditPart(View view) { - super(view); - } - - /** - * @Override - */ - @Override - public IFigure getPrimaryShape() { - return getFigure(); - } - - @Override - protected void refreshLabel() { - // We do NOT want to update label with the Parser. - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - removeEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY); - View stereotypeChangedView = null; - View view = getPrimaryView(); - if (view != null) { - stereotypeChangedView = ViewUtil.getChildBySemanticHint(view, UMLVisualIDRegistry.getType(TimeConstraintLabelEditPart.VISUAL_ID)); - } - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeLabelEditPolicy(stereotypeChangedView)); - } - - @Override - protected IFigure createFigurePrim() { - return new AppliedStereotypeLabelFigure(); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintBorderNodeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintBorderNodeEditPart.java new file mode 100644 index 00000000000..a352eaad2e2 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintBorderNodeEditPart.java @@ -0,0 +1,61 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; + +import java.util.Optional; + +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.uml2.uml.MessageEnd; +import org.eclipse.uml2.uml.TimeConstraint; + +/** + * Custom edit-part for {@code TimeConstraint} as a border node. + */ +public class CustomTimeConstraintBorderNodeEditPart extends TimeConstraintBorderNodeEditPart implements ITimeElementBorderNodeEditPart { + + private final TimeElementEditPartHelper helper; + + /** + * Initializes me with my view model. + * + * @param view + * my view model + */ + public CustomTimeConstraintBorderNodeEditPart(View view) { + super(view); + + helper = new TimeElementEditPartHelper(this, this::getMessageEnd); + } + + @Override + protected void refreshBounds() { + if (!helper.refreshBounds(getBorderItemLocator())) { + super.refreshBounds(); + } + } + + @Override + public Optional<MessageEnd> getMessageEnd() { + return Optional.of(resolveSemanticElement()) + .filter(TimeConstraint.class::isInstance) + .map(TimeConstraint.class::cast) + .flatMap(tc -> tc.getConstrainedElements().stream() + .filter(MessageEnd.class::isInstance) + .map(MessageEnd.class::cast) + .findFirst()); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintEditPart.java deleted file mode 100644 index 82c4c8307e3..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintEditPart.java +++ /dev/null @@ -1,168 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.IFigure; -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.editpolicies.LayoutEditPolicy; -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; -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; -import org.eclipse.papyrus.uml.diagram.common.locator.ExternalLabelPositionLocator; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExternalLabelPrimaryDragRoleEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.TimeRelatedSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.TimeMarkElementFigure; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomTimeConstraintEditPart extends TimeConstraintEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomTimeConstraintEditPart(View view) { - super(view); - } - - /** - * @Override use ExternalLabelPrimaryDragRoleEditPolicy - */ - @Override - protected LayoutEditPolicy createLayoutEditPolicy() { - org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { - - @Override - protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); - switch (UMLVisualIDRegistry.getVisualID(childView)) { - case TimeConstraintLabelEditPart.VISUAL_ID: - case TimeConstraintAppliedStereotypeEditPart.VISUAL_ID: - // use ExternalLabelPrimaryDragRoleEditPolicy - return new ExternalLabelPrimaryDragRoleEditPolicy(); - } - EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { - result = new NonResizableEditPolicy(); - } - return result; - } - - @Override - protected Command getMoveChildrenCommand(Request request) { - return null; - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - }; - return lep; - } - - /** - * This method creates a specific edit policy for time realted elements - * - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart#getPrimaryDragEditPolicy() - * - * @return <code>EditPolicy</code> - * @Override - */ - @Override - public EditPolicy getPrimaryDragEditPolicy() { - return new TimeRelatedSelectionEditPolicy(); - } - - /** - * @Override use ExternalLabelPositionLocator - */ - @Override - protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof TimeConstraintLabelEditPart || borderItemEditPart instanceof TimeConstraintAppliedStereotypeEditPart) { - // use ExternalLabelPositionLocator - IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); - borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else { - super.addBorderItem(borderItemContainer, borderItemEditPart); - } - } - - /** - * @Override use correct dimensions - */ - @Override - protected NodeFigure createNodePlate() { - // use correct dimensions - /* - * Bypass the preference mechanism which finally returns an incoherent constant hard written in NodePreferencePage.xpt templates. - * Instead, we shall use the correct default size. - */ - DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(TimeMarkElementFigure.TIME_MARK_LENGTH, 1); - // String prefElementId = "TimeConstraint"; - // IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore(); - // String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferencesConstantsHelper.WIDTH); - // String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferencesConstantsHelper.HEIGHT); - // DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)); - // FIXME: workaround for #154536 - result.getBounds().setSize(result.getPreferredSize()); - return result; - } - - /** - * @Override Override for redirecting creation request to the lifeline - */ - @Override - public Command getCommand(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - return getParent().getCommand(request); - } - return super.getCommand(request); - } - - /** - * @Override Override for redirecting creation request to the lifeline - */ - @Override - public void showSourceFeedback(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - getParent().showSourceFeedback(request); - } - super.showSourceFeedback(request); - } - - /** - * @Override Override for redirecting creation request to the lifeline - */ - @Override - public void eraseSourceFeedback(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - getParent().eraseSourceFeedback(request); - } - super.eraseSourceFeedback(request); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintLabelEditPart.java deleted file mode 100644 index 906147b3a31..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintLabelEditPart.java +++ /dev/null @@ -1,62 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2013 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeCommentCreationEditPolicyEx; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomConnectionHandleEditPolicy; -import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCommentEditPolicy; - - -/** - * Support displaying Stereotype as a Comment Node for TimeConstraint. - * - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomTimeConstraintLabelEditPart extends TimeConstraintLabelEditPart implements IPapyrusEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomTimeConstraintLabelEditPart(View view) { - super(view); - } - - /** - * @see org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart#getPrimaryShape() - * - * @return - */ - - @Override - public IFigure getPrimaryShape() { - return getFigure(); - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE, new CustomConnectionHandleEditPolicy()); - // install a editpolicy to display stereotypes - installEditPolicy(AppliedStereotypeCommentEditPolicy.APPLIED_STEREOTYPE_COMMENT, new AppliedStereotypeCommentCreationEditPolicyEx()); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationAppliedStereotypeEditPart.java deleted file mode 100644 index 3de9462da2d..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationAppliedStereotypeEditPart.java +++ /dev/null @@ -1,86 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeExternalNodeLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.AppliedStereotypeLabelFigure; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; -import org.eclipse.swt.graphics.Image; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomTimeObservationAppliedStereotypeEditPart extends TimeObservationAppliedStereotypeEditPart implements IPapyrusEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomTimeObservationAppliedStereotypeEditPart(View view) { - super(view); - } - - /** - * @Override - */ - @Override - public IFigure getPrimaryShape() { - return getFigure(); - } - - @Override - protected Image getLabelIcon() { - return null; - } - - @Override - protected void refreshLabel() { - // We do NOT want to update label with the Parser. - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - removeEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY); - View stereotypeChangedView = null; - View view = getPrimaryView(); - if (view != null) { - stereotypeChangedView = ViewUtil.getChildBySemanticHint(view, UMLVisualIDRegistry.getType(TimeObservationLabelEditPart.VISUAL_ID)); - } - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeExternalNodeLabelEditPolicy(stereotypeChangedView)); - } - - @Override - protected IFigure createFigurePrim() { - return new AppliedStereotypeLabelFigure(); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationBorderNodeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationBorderNodeEditPart.java new file mode 100644 index 00000000000..ef42cec14d7 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationBorderNodeEditPart.java @@ -0,0 +1,60 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; + +import java.util.Optional; + +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.uml2.uml.MessageEnd; +import org.eclipse.uml2.uml.TimeObservation; + +/** + * Custom edit-part for {@code TimeObservation} as a border node. + */ +public class CustomTimeObservationBorderNodeEditPart extends TimeObservationBorderNodeEditPart implements ITimeElementBorderNodeEditPart { + + private final TimeElementEditPartHelper helper; + + /** + * Initializes me with my view model. + * + * @param view + * my view model + */ + public CustomTimeObservationBorderNodeEditPart(View view) { + super(view); + + helper = new TimeElementEditPartHelper(this, this::getMessageEnd); + } + + @Override + protected void refreshBounds() { + if (!helper.refreshBounds(getBorderItemLocator())) { + super.refreshBounds(); + } + } + + @Override + public Optional<MessageEnd> getMessageEnd() { + return Optional.of(resolveSemanticElement()) + .filter(TimeObservation.class::isInstance) + .map(TimeObservation.class::cast) + .map(TimeObservation::getEvent) + .filter(MessageEnd.class::isInstance) + .map(MessageEnd.class::cast); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationEditPart.java deleted file mode 100644 index da23674c605..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationEditPart.java +++ /dev/null @@ -1,199 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.draw2d.IFigure; -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.editpolicies.LayoutEditPolicy; -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; -import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.uml.diagram.common.locator.ExternalLabelPositionLocator; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomExternalLabelPrimaryDragRoleEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.TimeRelatedSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.TimeObservationFigure; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; - -/** - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomTimeObservationEditPart extends TimeObservationEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomTimeObservationEditPart(View view) { - super(view); - } - - /** - * @Override - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - removeEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - removeEditPolicy(DeleteTimeElementWithoutEventPolicy.KEY); - } - - /** - * This method creates a specific edit policy for time realted elements - * - * @see org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart#getPrimaryDragEditPolicy() - * - * @return <code>EditPolicy</code> - * @Override - */ - @Override - public EditPolicy getPrimaryDragEditPolicy() { - return new TimeRelatedSelectionEditPolicy(); - } - - /** - * @Override use ExternalLabelPrimaryDragRoleEditPolicy - */ - @Override - protected LayoutEditPolicy createLayoutEditPolicy() { - org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { - - @Override - protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); - switch (UMLVisualIDRegistry.getVisualID(childView)) { - case TimeObservationLabelEditPart.VISUAL_ID: - case TimeObservationAppliedStereotypeEditPart.VISUAL_ID: - // use ExternalLabelPrimaryDragRoleEditPolicy - return new CustomExternalLabelPrimaryDragRoleEditPolicy(); - } - EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { - result = new NonResizableEditPolicy(); - } - return result; - } - - @Override - protected Command getMoveChildrenCommand(Request request) { - return null; - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - }; - return lep; - } - - /** - * @Override use ExternalLabelPositionLocator - */ - @Override - protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof TimeObservationLabelEditPart || borderItemEditPart instanceof TimeObservationAppliedStereotypeEditPart) { - // use ExternalLabelPositionLocator - IBorderItemLocator locator = new ExternalLabelPositionLocator(getMainFigure()); - borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else { - super.addBorderItem(borderItemContainer, borderItemEditPart); - } - } - - /** - * @Override use correct dimensions - */ - @Override - protected NodeFigure createNodePlate() { - // use correct dimensions - /* - * Bypass the preference mechanism which finally returns an incoherent constant hard written in NodePreferencePage.xpt templates. - * Instead, we shall use the correct default size. - */ - // DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(TimeMarkElementFigure.TIME_MARK_LENGTH, 1); - // String prefElementId = "TimeObservation"; - // IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore(); - // String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferencesConstantsHelper.WIDTH); - // String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferencesConstantsHelper.HEIGHT); - // DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)); - // FIXME: workaround for #154536 - // result.getBounds().setSize(result.getPreferredSize()); - NodeFigure result = new NodeFigure(); - return result; - } - - /** - * @Override Override for redirecting creation request to the lifeline - */ - @Override - public Command getCommand(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - return getParent().getCommand(request); - } - return super.getCommand(request); - } - - /** - * @Override Override for redirecting creation request to the lifeline - */ - @Override - public void showSourceFeedback(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - getParent().showSourceFeedback(request); - } - super.showSourceFeedback(request); - } - - /** - * @Override Override for redirecting creation request to the lifeline - */ - @Override - public void eraseSourceFeedback(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - getParent().eraseSourceFeedback(request); - } - super.eraseSourceFeedback(request); - } - - /** - * @see org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart#createNodeShape() - * - * @return - */ - @Override - protected IFigure createNodeShape() { - return primaryShape = new TimeObservationFigure(); - } - - /** - * @see org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart#getPrimaryShape() - * - * @return - */ - @Override - public TimeObservationFigure getPrimaryShape() { - return (TimeObservationFigure) primaryShape; - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationLabelEditPart.java deleted file mode 100644 index f51f2d93052..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationLabelEditPart.java +++ /dev/null @@ -1,298 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import java.util.List; - -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.StackLayout; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.transaction.RunnableWithResult; -import org.eclipse.gef.ConnectionEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.DropRequest; -import org.eclipse.gef.requests.ReconnectRequest; -import org.eclipse.gmf.runtime.common.core.util.Log; -import org.eclipse.gmf.runtime.common.core.util.Trace; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.diagram.ui.editparts.INodeEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions; -import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin; -import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes; -import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; -import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; -import org.eclipse.gmf.runtime.notation.Anchor; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.IdentityAnchor; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeCommentCreationEditPolicyEx; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomConnectionHandleEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; -import org.eclipse.papyrus.uml.diagram.sequence.util.ElementIconUtil; -import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCommentEditPolicy; -import org.eclipse.swt.graphics.Image; - -/** - * Add implementing IPapyrusEditPart to support displaying Stereotype as a Comment, because the label is always selected when a TimeObservation is - * selected. - * - * @author Jin Liu (jin.liu@soyatec.com) - */ -public class CustomTimeObservationLabelEditPart extends TimeObservationLabelEditPart implements INodeEditPart, IPapyrusEditPart { - - /** - * Constructor. - * - * @param view - */ - public CustomTimeObservationLabelEditPart(View view) { - super(view); - } - - /** - * @Override - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE, new CustomConnectionHandleEditPolicy()); - // install a editpolicy to display stereotypes - installEditPolicy(AppliedStereotypeCommentEditPolicy.APPLIED_STEREOTYPE_COMMENT, new AppliedStereotypeCommentCreationEditPolicyEx()); - } - - /** - * @Override - */ - @Override - protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof NodeFigure && getWrappingLabel(figure) != null) { - return getWrappingLabel(figure).getText(); - } - return super.getLabelTextHelper(figure); - } - - /** - * @Override - */ - @Override - protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof NodeFigure && getWrappingLabel(figure) != null) { - getWrappingLabel(figure).setText(text); - } else { - super.setLabelTextHelper(figure, text); - } - } - - /** - * @Override - */ - @Override - protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof NodeFigure && getWrappingLabel(figure) != null) { - return getWrappingLabel(figure).getIcon(); - } else { - return super.getLabelIconHelper(figure); - } - } - - /** - * @Override - */ - @Override - protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof NodeFigure && getWrappingLabel(figure) != null) { - getWrappingLabel(figure).setIcon(icon); - } else { - super.setLabelIconHelper(figure, icon); - } - } - - /** - * @Override - */ - @Override - protected void handleNotificationEvent(Notification event) { - Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getView_SourceEdges().equals(feature)) { - refreshSourceConnections(); - } else if (NotationPackage.eINSTANCE.getView_TargetEdges().equals(feature)) { - refreshTargetConnections(); - } - if (ElementIconUtil.isIconNotification(event)) { - refreshLabel(); - } - super.handleNotificationEvent(event); - } - - @Override - protected NodeFigure createFigure() { - NodeFigure figure = createNodePlate(); - figure.setLayoutManager(new StackLayout()); - IFigure shape = createNodeShape(); - figure.add(shape); - return figure; - } - - protected NodeFigure createNodePlate() { - NodeFigure result = new NodeFigure(); - return result; - } - - protected IFigure createNodeShape() { - IFigure label = createFigurePrim(); - return label; - } - - protected WrappingLabel getWrappingLabel(IFigure nodeFigure) { - if (nodeFigure instanceof NodeFigure) { - return ((WrappingLabel) (nodeFigure.getChildren().get(0))); - } - return null; - } - - // Fix https://bugs.eclipse.org/bugs/show_bug.cgi?id=364826 - @Override - protected List getModelSourceConnections() { - return ViewUtil.getSourceConnectionsConnectingVisibleViews((View) getModel()); - } - - @Override - protected List getModelTargetConnections() { - List list = ViewUtil.getTargetConnectionsConnectingVisibleViews((View) getModel()); - return list; - } - - @Override - public ConnectionAnchor getSourceConnectionAnchor(Request request) { - if (request instanceof ReconnectRequest) { - if (((DropRequest) request).getLocation() == null) { - return ((NodeFigure) getFigure()).getSourceConnectionAnchorAt(null); - } - Point pt = ((DropRequest) request).getLocation().getCopy(); - return ((NodeFigure) getFigure()).getSourceConnectionAnchorAt(pt); - } else if (request instanceof DropRequest) { - return ((NodeFigure) getFigure()).getSourceConnectionAnchorAt(((DropRequest) request).getLocation()); - } - return ((NodeFigure) getFigure()).getSourceConnectionAnchorAt(null); - } - - @Override - public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connEditPart) { - final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) connEditPart; - String t = ""; //$NON-NLS-1$ - try { - t = (String) getEditingDomain().runExclusive(new RunnableWithResult.Impl() { - - @Override - public void run() { - Anchor a = ((Edge) connection.getModel()).getSourceAnchor(); - if (a instanceof IdentityAnchor) { - setResult(((IdentityAnchor) a).getId()); - } else { - setResult(""); //$NON-NLS-1$ - } - } - }); - } catch (InterruptedException e) { - Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getSourceConnectionAnchor", e); //$NON-NLS-1$ - Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getSourceConnectionAnchor", e); //$NON-NLS-1$ - } - return ((NodeFigure) getFigure()).getConnectionAnchor(t); - } - - @Override - public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connEditPart) { - final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection = (org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart) connEditPart; - String t = ""; //$NON-NLS-1$ - try { - t = (String) getEditingDomain().runExclusive(new RunnableWithResult.Impl() { - - @Override - public void run() { - Anchor a = ((Edge) connection.getModel()).getTargetAnchor(); - if (a instanceof IdentityAnchor) { - setResult(((IdentityAnchor) a).getId()); - } else { - setResult(""); //$NON-NLS-1$ - } - } - }); - } catch (InterruptedException e) { - Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), "getTargetConnectionAnchor", e); //$NON-NLS-1$ - Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getTargetConnectionAnchor", e); //$NON-NLS-1$ - } - return ((NodeFigure) getFigure()).getConnectionAnchor(t); - } - - @Override - public ConnectionAnchor getTargetConnectionAnchor(Request request) { - if (request instanceof ReconnectRequest) { - if (((DropRequest) request).getLocation() == null) { - return ((NodeFigure) getFigure()).getTargetConnectionAnchorAt(null); - } - Point pt = ((DropRequest) request).getLocation().getCopy(); - return ((NodeFigure) getFigure()).getTargetConnectionAnchorAt(pt); - } else if (request instanceof DropRequest) { - return ((NodeFigure) getFigure()).getTargetConnectionAnchorAt(((DropRequest) request).getLocation()); - } - return ((NodeFigure) getFigure()).getTargetConnectionAnchorAt(null); - } - - @Override - public String mapConnectionAnchorToTerminal(ConnectionAnchor c) { - return ((NodeFigure) getFigure()).getConnectionAnchorTerminal(c); - } - - @Override - public ConnectionAnchor mapTerminalToConnectionAnchor(String terminal) { - return ((NodeFigure) getFigure()).getConnectionAnchor(terminal); - } - - @Override - public boolean canAttachNote() { - return true; - } - - @Override - protected Image getLabelIcon() { - if (AppearanceHelper.showElementIcon(getNotationView())) { - return UMLElementTypes.getImage(resolveSemanticElement().eClass()); - } - return null; - } - - @Override - public void refreshBounds() { - super.refreshBounds(); - // Update location manually. - IBorderItemLocator locator = getBorderItemLocator(); - if (locator != null) { - locator.relocate(getFigure()); - } - } - - @Override - public IFigure getPrimaryShape() { - return getFigure(); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ITimeElementBorderNodeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ITimeElementBorderNodeEditPart.java new file mode 100644 index 00000000000..3d7a2327c0e --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ITimeElementBorderNodeEditPart.java @@ -0,0 +1,37 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; + +import java.util.Optional; + +import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; +import org.eclipse.uml2.uml.MessageEnd; +import org.eclipse.uml2.uml.TimeConstraint; +import org.eclipse.uml2.uml.TimeObservation; + +/** + * Protocol for the border-item edit parts controlling the presentation of + * {@link TimeObservation}s and {@link TimeConstraint}s. + */ +public interface ITimeElementBorderNodeEditPart extends IBorderItemEditPart { + + /** + * Obtain the message end that is my time event, if any. + * + * @return my message end, or {@code null} if I do not observe or constrain a message end + */ + Optional<MessageEnd> getMessageEnd(); +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ObservationLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ObservationLinkEditPart.java deleted file mode 100644 index 90d5ee3692c..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ObservationLinkEditPart.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.commands.Command; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.uml2.uml.DurationObservation; -import org.eclipse.uml2.uml.TimeObservation; - -/** - * Observation link editpart used by time observation and duration observation - * - */ -public class ObservationLinkEditPart extends AnnotatedLinkEditPart { - - public ObservationLinkEditPart(View view) { - super(view); - } - - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomComponentEditPolicy()); - // installEditPolicy(EditPolicy.COMPONENT_ROLE, new CustomComponentEditPolicy()); - // SequenceUtil.OBSERVATION_LINK_TYPE - // installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE,new CustomConnectionEndpointEditPolicy()); - } - - private final class CustomComponentEditPolicy extends SemanticEditPolicy { - - @Override - protected Command getSemanticCommand(IEditCommandRequest request) { - Command semanticCommand = super.getSemanticCommand(request); - if (semanticCommand != null) { - if (semanticCommand instanceof ICommandProxy) { - ICommandProxy proxy = (ICommandProxy) semanticCommand; - if (proxy.getICommand() instanceof CompositeTransactionalCommand) { - CompositeTransactionalCommand compositeCommand = (CompositeTransactionalCommand) proxy.getICommand(); - // update TimeObservation or DurationObservation model - final ObservationLinkEditPart link = (ObservationLinkEditPart) getHost(); - AbstractTransactionalCommand updateLinkSourceModelCmd = new AbstractTransactionalCommand(link.getEditingDomain(), "", null) { - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - EditPart source = link.getSource(); - if (source instanceof TimeObservationLabelEditPart) { - TimeObservation timeObservation = (TimeObservation) ((TimeObservationLabelEditPart) source).resolveSemanticElement(); - timeObservation.setEvent(null); - } else if (source instanceof DurationObservationEditPart) { - DurationObservation durationObservation = (DurationObservation) ((DurationObservationEditPart) source).resolveSemanticElement(); - durationObservation.getEvents().clear(); - } - return CommandResult.newOKCommandResult(); - } - }; - compositeCommand.add(updateLinkSourceModelCmd); - } - } - } - return semanticCommand; - } - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeElementEditPartHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeElementEditPartHelper.java new file mode 100644 index 00000000000..c427bbf30c0 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeElementEditPartHelper.java @@ -0,0 +1,216 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Optional; +import java.util.concurrent.Executor; +import java.util.function.Supplier; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.ConnectionEditPart; +import org.eclipse.gef.Disposable; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.papyrus.infra.core.utils.OneShotExecutor; +import org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramHelper; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; +import org.eclipse.papyrus.infra.ui.util.TransactionUIHelper; +import org.eclipse.uml2.uml.MessageEnd; + +/** + * Common behaviour that time-element edit-parts can delegate. + */ +class TimeElementEditPartHelper { + private static final MessageTracker NONE = new MessageTracker(); + + private final IGraphicalEditPart owner; + private final Supplier<? extends Optional<MessageEnd>> messageEndSupplier; + private final Executor executor; + private MessageTracker messageTracker = NONE; + + /** + * Initializes me with the edit-part that I help. + * + * @param owner + * my owner + * @param messageEndSupplier + * extracts the message-end from my {@code owner}'s semantic element + */ + public TimeElementEditPartHelper(IGraphicalEditPart owner, + Supplier<? extends Optional<MessageEnd>> messageEndSupplier) { + + super(); + + this.owner = owner; + this.messageEndSupplier = messageEndSupplier; + + // Don't post redundant refreshes + this.executor = new OneShotExecutor(TransactionUIHelper.getExecutor(owner.getEditingDomain())); + } + + boolean refreshBounds(IBorderItemLocator locator) { + boolean result = false; + + if (locator != null) { + Optional<Point> messageEndLoc = Optional.ofNullable(getLocation()); + if (messageEndLoc.isPresent()) { + // We are fixed by a message end, then + Dimension size = new Dimension( + ((Integer) owner.getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(), + ((Integer) owner.getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue()); + + locator.setConstraint(new Rectangle(messageEndLoc.get(), size)); + result = true; + } + } + + return result; + } + + // Asynchronously post a refresh of my owner edit-part + private void postRefresh() { + executor.execute(() -> DiagramHelper.refresh(owner, true)); + } + + /** + * Obtain the message end that is my observedor constrained event, if any. + * + * @return my message end, or {@code null} if I do not observe or constrain a message end + */ + Optional<MessageEnd> getMessageEnd() { + return messageEndSupplier.get(); + } + + /** + * Compute the location of a message end. + * + * @param messageEnd + * a message end + * @return the location of that end relative to my parent, or {@code null} if it cannot + * be determined + */ + Point getLocation() { + return getMessage().getLocation(); + } + + private MessageTracker getMessage() { + if (!messageTracker.isValid()) { + messageTracker.dispose(); + + // Refresh our idea of what the message is + messageTracker = messageEndSupplier.get() + .map(end -> new MessageTracker(this, end)) + .filter(MessageTracker::isValid) + .orElse(NONE); + } + + return messageTracker; + } + + // + // Nested types + // + + /** + * A helper for tracking the message, if any, the end of which is linked to a time + * element to cause that time element to follow (track) the movement of the message + * end. + */ + private static final class MessageTracker implements Supplier<ConnectionEditPart>, Disposable { + private final PropertyChangeListener connectionListener = this::connectionMoved; + private final TimeElementEditPartHelper owner; + private final ConnectionEditPart connectionEP; + private final Connection connection; + private final boolean source; + private final Point anchor = new Point(); + + MessageTracker() { + super(); + + this.owner = null; + connectionEP = null; + connection = null; + source = false; + } + + MessageTracker(TimeElementEditPartHelper owner, MessageEnd end) { + super(); + + this.owner = owner; + + IGraphicalEditPart ep = DiagramEditPartsUtil.getChildByEObject(end.getMessage(), + (IGraphicalEditPart) owner.owner.getRoot().getContents(), true); + if ((ep instanceof ConnectionEditPart) && ep.isActive()) { + connectionEP = (ConnectionEditPart) ep; + connection = (Connection) connectionEP.getFigure(); + connection.addPropertyChangeListener(Connection.PROPERTY_POINTS, connectionListener); + source = end.isSend(); + anchor.setLocation(source ? connection.getPoints().getFirstPoint() : connection.getPoints().getLastPoint()); + } else { + connectionEP = null; + connection = null; + source = false; + } + } + + @Override + public void dispose() { + if (connection != null) { + connection.removePropertyChangeListener(Connection.PROPERTY_POINTS, connectionListener); + } + } + + @Override + public ConnectionEditPart get() { + return isValid() ? connectionEP : null; + } + + public Point getLocation() { + Point result = null; + + if (isValid()) { + // If we were ever valid, we have a connection + ConnectionAnchor anchor = source ? connection.getSourceAnchor() : connection.getTargetAnchor(); + result = anchor.getReferencePoint().getCopy(); + owner.owner.getFigure().getParent().translateToRelative(result); + } + + return result; + } + + boolean isValid() { + return (connectionEP != null) && connectionEP.isActive(); + } + + private void connectionMoved(PropertyChangeEvent event) { + PointList points = (PointList) event.getNewValue(); + Point newAnchor = source ? points.getFirstPoint() : points.getLastPoint(); + if (!anchor.equals(newAnchor)) { + anchor.setLocation(newAnchor); + owner.postRefresh(); + } + } + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkEndEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkEndEditPolicy.java index a61068dd600..469bd2a079b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkEndEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkEndEditPolicy.java @@ -141,63 +141,9 @@ public class AnnotatedLinkEndEditPolicy extends GraphicalNodeEditPolicy { return UnexecutableCommand.INSTANCE; } command.setTarget(getHost()); - // update bendpoints - // if((request.getSourceEditPart() instanceof CustomDurationConstraintEditPart) && !(request.getTargetEditPart() instanceof CustomDurationConstraintEditPart)) { - // updateConnectionBendpoints(request, proxy); - // } return proxy; } - // private void updateConnectionBendpoints(CreateConnectionRequest request, ICommandProxy proxy) { - // ICommand iCommand = proxy.getICommand(); - // if(!(iCommand instanceof CompositeCommand)) { - // return; - // } - // INodeEditPart targetEP = getConnectionCompleteEditPart(request); - // if(targetEP == null) { - // return; - // } - // CompositeCommand cc = (CompositeCommand)iCommand; - // SetConnectionAnchorsCommand scaCommand = null; - // SetConnectionBendpointsCommand sbbCommand = null; - // Iterator it = cc.iterator(); - // while(it.hasNext()) { - // Object next = it.next(); - // if(next instanceof SetConnectionBendpointsCommand) { - // sbbCommand = (SetConnectionBendpointsCommand)next; - // } else if(next instanceof SetConnectionAnchorsCommand) { - // scaCommand = (SetConnectionAnchorsCommand)next; - // } - // if(sbbCommand != null && scaCommand != null) { - // break; - // } - // } - // if(sbbCommand == null || scaCommand == null) { - // return; - // } - // ConnectionAnchor targetAnchor = targetEP.getTargetConnectionAnchor(request); - // INodeEditPart sourceEditPart = (INodeEditPart)request.getSourceEditPart(); - // ConnectionAnchor sourceAnchor = sourceEditPart.getSourceConnectionAnchor(request);// sourceEditPart.mapTerminalToConnectionAnchor(scaCommand.getNewSourceTerminal()); - // Point sourcePoint = sourceAnchor.getLocation(sourceAnchor.getReferencePoint()); - // Point targetPoint = targetAnchor.getLocation(targetAnchor.getReferencePoint()); - // - // if(sourcePoint.y != targetPoint.y) { - // PointList newList = new PointList(3); - // newList.addPoint(sourcePoint); - // Point p = new Point(DurationConstraintAutomaticRouter.BENDPOINT_GATE,0);//addBendpoint(sourcePoint.x, targetPoint.x, sourcePoint.y); - // newList.addPoint(p); - // newList.addPoint(targetPoint); - // sbbCommand.setNewPointList(newList, sourceAnchor.getReferencePoint(), targetAnchor.getReferencePoint()); - // } - // } - // - // private Point addBendpoint(int x, int x2, int y) { - // if(Math.abs(x - x2) > 20) { - // return new PrecisionPoint(x2 + 20 * Math.signum(x - x2), y); - // } else { - // return new PrecisionPoint(x2 + (x - x2) * 0.5, y); - // } - // } @Override public void eraseTargetFeedback(Request request) { if (REQ_ANNOTATED_LINK_END.equals(request.getType())) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkStartEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkStartEditPolicy.java index e4eefd867e9..4e16d9f178c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkStartEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkStartEditPolicy.java @@ -35,7 +35,6 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.uml.diagram.sequence.command.AnnotatedLinkEditCommand; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AnnotatedLinkEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationConstraintEditPart; import org.eclipse.uml2.uml.TimeObservation; /** @@ -137,10 +136,6 @@ public class AnnotatedLinkStartEditPolicy extends GraphicalNodeEditPolicy { return null; } if (request.getConnectionEditPart() instanceof AnnotatedLinkEditPart) { - if (getHost() instanceof CustomDurationConstraintEditPart && !((CustomDurationConstraintEditPart) getHost()).canCreateLink(request.getLocation())) { - return UnexecutableCommand.INSTANCE; // only 2 links are allowed, one for each side - } - CompositeCommand cc = (CompositeCommand) c.getICommand(); AnnotatedLinkEditCommand ac = new AnnotatedLinkEditCommand(getEditingDomain()); ac.setAnnotatedLink((AnnotatedLinkEditPart) request.getConnectionEditPart()); @@ -161,12 +156,6 @@ public class AnnotatedLinkStartEditPolicy extends GraphicalNodeEditPolicy { if (element instanceof TimeObservation && ((TimeObservation) element).getEvent() != null) { return UnexecutableCommand.INSTANCE; } - if (host instanceof CustomDurationConstraintEditPart) { - boolean can = ((CustomDurationConstraintEditPart) host).canCreateLink(request.getLocation()); - if (!can) { - return UnexecutableCommand.INSTANCE; - } - } } Command command = super.getConnectionCreateCommand(request); if (command instanceof ICommandProxy) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeCommentCreationEditPolicyEx.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeCommentCreationEditPolicyEx.java index d75ac51a896..09bc6634efc 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeCommentCreationEditPolicyEx.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeCommentCreationEditPolicyEx.java @@ -27,7 +27,6 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.emf.gmf.util.GMFUnsafe; import org.eclipse.papyrus.uml.diagram.common.Activator; import org.eclipse.papyrus.uml.diagram.sequence.command.CreateAppliedStereotypeCommentViewCommandEx; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationConstraintEditPart; import org.eclipse.papyrus.uml.diagram.stereotype.edition.editpolicies.AppliedStereotypeCommentEditPolicy; import org.eclipse.swt.widgets.Display; @@ -70,10 +69,8 @@ public class AppliedStereotypeCommentCreationEditPolicyEx extends AppliedStereot } boolean isBorderElement = false; - if (!(hostEditPart instanceof CustomDurationConstraintEditPart)) { - if (hostEditPart instanceof BorderedBorderItemEditPart) { - isBorderElement = true; - } + if (hostEditPart instanceof BorderedBorderItemEditPart) { + isBorderElement = true; } if (helper.getStereotypeComment((View) getHost().getModel()) == null) { CreateAppliedStereotypeCommentViewCommandEx command = new CreateAppliedStereotypeCommentViewCommandEx(domain, (View) hostEditPart.getModel(), x, y, semanticElement, isBorderElement); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CreationOnMessageEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CreationOnMessageEditPolicy.java deleted file mode 100644 index 73527941042..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CreationOnMessageEditPolicy.java +++ /dev/null @@ -1,150 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Atos Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; - -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPartViewer; -import org.eclipse.gef.commands.Command; -import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; -import org.eclipse.gmf.runtime.emf.type.core.IHintedType; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil; -import org.eclipse.uml2.uml.OccurrenceSpecification; - -public class CreationOnMessageEditPolicy extends CreationEditPolicy { - - /** - * TODO_MIA: CHeck if necessary - * Get the command after updating the request with appropriate occurrences - * - * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy#getCreateElementAndViewCommand(org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest) - * - * @param request - * the request - * @return command or null - */ - @Override - protected Command getCreateElementAndViewCommand(CreateViewAndElementRequest request) { - Map<String, Object> extendedData = request.getExtendedData(); - // record the nearest event if necessary - String requestHint = request.getViewAndElementDescriptor().getSemanticHint(); - if (isCreatedOnOccurrenceSpecification(requestHint)) { - EditPart hostPart = getHost(); - if (hostPart instanceof ConnectionNodeEditPart) { - LifelineEditPart sourceLifeline = SequenceUtil.getParentLifelinePart(((ConnectionNodeEditPart) hostPart).getSource()); - LifelineEditPart targetLifeline = SequenceUtil.getParentLifelinePart(((ConnectionNodeEditPart) hostPart).getTarget()); - Entry<Point, List<OccurrenceSpecification>> eventAndLocation = null; - if (sourceLifeline != null) { - eventAndLocation = SequenceUtil.findNearestEvent(request.getLocation(), sourceLifeline); - } - if (targetLifeline != null && eventAndLocation == null) { - eventAndLocation = SequenceUtil.findNearestEvent(request.getLocation(), targetLifeline); - } - // find an event near enough to create the constraint or observation - List<OccurrenceSpecification> events = Collections.emptyList(); - Point location = null; - if (eventAndLocation != null) { - location = eventAndLocation.getKey(); - events = eventAndLocation.getValue(); - } - if (extendedData.containsKey(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2)) { - extendedData.put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2, events); - } else { - extendedData.put(org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, events); - } - if (extendedData.containsKey(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION_2)) { - extendedData.put(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION_2, location); - } else { - extendedData.put(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION, location); - } - if (location != null) { - // Let the hosted lifeline to do it. - EditPart object = getHost().getViewer().findObjectAtExcluding(location, Collections.emptyList(), new EditPartViewer.Conditional() { - - @Override - public boolean evaluate(EditPart editpart) { - return editpart instanceof LifelineEditPart; - } - }); - LifelineEditPart targetEditPart = null; - if (object instanceof LifelineEditPart) { - targetEditPart = (LifelineEditPart) object; - } else { - while (object != null) { - if (object.getParent() instanceof LifelineEditPart) { - targetEditPart = (LifelineEditPart) object.getParent(); - break; - } - object = object.getParent(); - } - } - if (targetEditPart != null) { - return targetEditPart.getCommand(request); - } - } - } - } - return super.getCreateElementAndViewCommand(request); - } - - /** - * Return true if creation must be performed on an occurrence specification - * - * @param requestHint - * the hint of object to create - * @return true if creation on an occurrence specification - */ - private boolean isCreatedOnOccurrenceSpecification(String requestHint) { - return isTimeHint(requestHint) || isDurationHint(requestHint); - } - - /** - * Return true if hint is for creating a duration observation/constraint - * - * @param requestHint - * the hint of object to create - * @return true if correct hint - */ - private boolean isDurationHint(String requestHint) { - String durCstOnLifelineHint = ((IHintedType) UMLElementTypes.DurationConstraint_Shape).getSemanticHint(); - String durCstOnMessage = ((IHintedType) UMLElementTypes.DurationConstraint_Shape_CN).getSemanticHint(); - String durObsOnMessage = ((IHintedType) UMLElementTypes.DurationObservation_Shape).getSemanticHint(); - return durCstOnLifelineHint.equals(requestHint) /* || durCstOnMessage.equals(requestHint) */ || durObsOnMessage.equals(requestHint); - } - - /** - * Return true if hint is for creating a time observation/constraint - * - * @param requestHint - * the hint of object to create - * @return true if correct hint - */ - private boolean isTimeHint(String requestHint) { - String timeConstraintHint = ((IHintedType) UMLElementTypes.TimeConstraint_Shape).getSemanticHint(); - String timeObservationHint = ((IHintedType) UMLElementTypes.TimeObservation_Shape).getSemanticHint(); - return timeConstraintHint.equals(requestHint) || timeObservationHint.equals(requestHint); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDestructionOccurrenceSpecificationSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDestructionOccurrenceSpecificationSemanticEditPolicy.java new file mode 100644 index 00000000000..a053f982e5d --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDestructionOccurrenceSpecificationSemanticEditPolicy.java @@ -0,0 +1,51 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import static java.util.Arrays.asList; +import static org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION; + +import org.eclipse.gef.commands.Command; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.papyrus.uml.service.types.utils.ElementUtil; +import org.eclipse.uml2.uml.DestructionOccurrenceSpecification; +import org.eclipse.uml2.uml.TimeConstraint; +import org.eclipse.uml2.uml.TimeObservation; + +/** + * Custom semantic edit policy for configuration of the constrained or observed element in a + * {@link TimeConstraint} or {@link TimeObservation}, respectively. + */ +public class CustomDestructionOccurrenceSpecificationSemanticEditPolicy extends DefaultSemanticEditPolicy { + + @Override + protected Command getCreateCommand(CreateElementRequest req) { + if (ElementUtil.isTypeOf(req.getElementType(), UMLElementTypes.TIME_CONSTRAINT) + || ElementUtil.isTypeOf(req.getElementType(), UMLElementTypes.TIME_OBSERVATION)) { + + if (!(getHost() instanceof IGraphicalEditPart) || !(req.getContainer() instanceof DestructionOccurrenceSpecification)) { + return super.getCreateCommand(req); + } + + req.setParameter(NEAREST_OCCURRENCE_SPECIFICATION, asList(req.getContainer())); + } + return super.getCreateCommand(req); + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java index e41297e55b8..757fd27ae83 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java @@ -24,7 +24,6 @@ import java.util.Set; import org.eclipse.core.commands.operations.IUndoableOperation; import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.draw2d.ConnectionAnchor; import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; @@ -34,18 +33,14 @@ import org.eclipse.gef.GraphicalViewer; import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.commands.UnexecutableCommand; -import org.eclipse.gef.requests.CreateConnectionRequest; import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; import org.eclipse.gmf.runtime.common.core.command.ICommand; import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; import org.eclipse.gmf.runtime.diagram.ui.commands.CommandProxy; import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; -import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; 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.requests.CreateConnectionViewRequest; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; @@ -65,11 +60,8 @@ import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramUtils; import org.eclipse.papyrus.uml.diagram.common.commands.DeferredCreateCommand; import org.eclipse.papyrus.uml.diagram.common.editpolicies.CommonDiagramDragDropEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.helper.DurationConstraintHelper; -import org.eclipse.papyrus.uml.diagram.common.helper.DurationObservationHelper; import org.eclipse.papyrus.uml.diagram.sequence.command.CreateLocatedConnectionViewCommand; import org.eclipse.papyrus.uml.diagram.sequence.command.OLDCreateGateViewCommand; -import org.eclipse.papyrus.uml.diagram.sequence.command.RestoreDurationConstraintLinkCommand; import org.eclipse.papyrus.uml.diagram.sequence.command.SetResizeAndLocationCommand; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart; @@ -85,9 +77,6 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintConstrained import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart; @@ -103,8 +92,6 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageReplyEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.SequenceDiagramEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; @@ -118,22 +105,17 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.uml2.uml.CombinedFragment; import org.eclipse.uml2.uml.ConnectableElement; import org.eclipse.uml2.uml.DestructionOccurrenceSpecification; -import org.eclipse.uml2.uml.DurationConstraint; import org.eclipse.uml2.uml.DurationObservation; import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification; import org.eclipse.uml2.uml.ExecutionSpecification; import org.eclipse.uml2.uml.Gate; import org.eclipse.uml2.uml.GeneralOrdering; import org.eclipse.uml2.uml.InteractionOperand; -import org.eclipse.uml2.uml.IntervalConstraint; import org.eclipse.uml2.uml.Lifeline; import org.eclipse.uml2.uml.Message; import org.eclipse.uml2.uml.MessageEnd; -import org.eclipse.uml2.uml.MessageOccurrenceSpecification; import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.OccurrenceSpecification; -import org.eclipse.uml2.uml.PackageableElement; import org.eclipse.uml2.uml.StateInvariant; import org.eclipse.uml2.uml.TimeObservation; @@ -174,9 +156,6 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo elementsVisualId.add(ConstraintEditPart.VISUAL_ID); elementsVisualId.add(Constraint2EditPart.VISUAL_ID); elementsVisualId.add(ConstraintConstrainedElementEditPart.VISUAL_ID); - elementsVisualId.add(TimeConstraintEditPart.VISUAL_ID); - elementsVisualId.add(TimeObservationEditPart.VISUAL_ID); - elementsVisualId.add(DurationConstraintEditPart.VISUAL_ID); elementsVisualId.add(SequenceDiagramEditPart.VISUAL_ID); elementsVisualId.add(MessageSyncEditPart.VISUAL_ID); elementsVisualId.add(MessageAsyncEditPart.VISUAL_ID); @@ -190,11 +169,6 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo elementsVisualId.add(GeneralOrderingEditPart.VISUAL_ID); elementsVisualId.add(DestructionOccurrenceSpecificationEditPart.VISUAL_ID); elementsVisualId.add(StateInvariantEditPart.VISUAL_ID); - elementsVisualId.add(TimeConstraintEditPart.VISUAL_ID); - elementsVisualId.add(DurationConstraintEditPart.VISUAL_ID); - elementsVisualId.add(DurationConstraintInMessageEditPart.VISUAL_ID); - elementsVisualId.add(TimeObservationEditPart.VISUAL_ID); - elementsVisualId.add(DurationObservationEditPart.VISUAL_ID); elementsVisualId.add(LifelineEditPart.VISUAL_ID); // elementsVisualId.add(GateEditPart.VISUAL_ID); // handle nodes on messages (no visual ID detected for them) @@ -266,11 +240,6 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo if (semanticElement instanceof DurationObservation) { return new ICommandProxy(getDefaultDropNodeCommand(nodeVISUALID, location, semanticElement, dropRequest)); } - // handle specifically the case when node is on a message - Command cmd = handleNodeOnMessage(semanticElement, nodeVISUALID, linkVISUALID, location); - if (cmd != null) { - return cmd; - } if (nodeVISUALID != null) { switch (nodeVISUALID) { case ActionExecutionSpecificationEditPart.VISUAL_ID: @@ -281,16 +250,8 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo return dropDestructionOccurrence((DestructionOccurrenceSpecification) semanticElement, nodeVISUALID, location); case StateInvariantEditPart.VISUAL_ID: return dropStateInvariant((StateInvariant) semanticElement, nodeVISUALID, location); - case TimeConstraintEditPart.VISUAL_ID: - case DurationConstraintEditPart.VISUAL_ID: - return dropIntervalConstraintInLifeline((IntervalConstraint) semanticElement, nodeVISUALID); - case TimeObservationEditPart.VISUAL_ID: - return dropTimeObservationInLifeline((TimeObservation) semanticElement, nodeVISUALID, location); case CommentEditPart.VISUAL_ID: case ConstraintEditPart.VISUAL_ID: - if (semanticElement instanceof DurationConstraint) { - return dropDurationConstraint((DurationConstraint) semanticElement, location); - } case Constraint2EditPart.VISUAL_ID: case InteractionUseEditPart.VISUAL_ID: case LifelineEditPart.VISUAL_ID: @@ -324,9 +285,9 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo * Get the drop command for the Element * * @param element - * the Element + * the Element * @param nodeVISUALID - * the node visual id + * the node visual id * @return the drop command if the Element can be dropped */ private Command dropNodeElement(Element element, String nodeVISUALID, Point location) { @@ -364,9 +325,9 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo * Get the drop command for the Element * * @param element - * the Element + * the Element * @param nodeVISUALID - * the node visual id + * the node visual id * @return the drop command if the element can be dropped */ private Command dropCombinedFragment(CombinedFragment combinedFragment, String nodeVISUALID, Point location) { @@ -503,323 +464,12 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo } /** - * Get the drop command in case the element can be handled as a node on a message - * - * @param semanticElement - * the element being dropped from the model - * @param nodeVISUALID - * node visual id or -1 - * @param linkVISUALID - * link visual id or -1 - * @param location - * @return the drop command if the element can be dropped as a message label node, or null otherwise - */ - private Command handleNodeOnMessage(Element semanticElement, String nodeVISUALID, String linkVISUALID, Point location) { - if (nodeVISUALID == null && linkVISUALID == null) { - // detect duration observation on a message - if (semanticElement instanceof DurationObservation) { - List<NamedElement> events = ((DurationObservation) semanticElement).getEvents(); - if (events.size() >= 2) { - return dropMessageNodeBetweenEvents(semanticElement, events.get(0), events.get(1)); - } - } - } - if (isDurationConstraintHint(nodeVISUALID, linkVISUALID)) { - // detect duration constraint on a message - if (semanticElement instanceof DurationConstraint) { - return dropDurationConstraint((DurationConstraint) semanticElement, location); - } - } - return null; - } - - /** - * Drop DurationConstraint at given location. The constrained elements would also be restored if existed. - * - * @see dropDurationConstraint(Element durationConstraint, Element event1, Element event2, Point location) - * @param durationConstraint - * @param location - */ - protected Command dropDurationConstraint(DurationConstraint durationConstraint, Point location) { - List<Element> events = durationConstraint.getConstrainedElements(); - Element event1 = null, event2 = null; - if (events.size() >= 2) { - event1 = events.get(0); - event2 = events.get(1); - } else if (events.size() == 1) { - event1 = event2 = events.get(0); - } - return dropDurationConstraint(durationConstraint, event1, event2, location); - } - - /** - * Drop DurationConstraint at given location. The constrained elements would also be restored if existed. - * - * @param durationConstraint - * @param event1 - * @param event2 - * @param location - * @return - */ - private Command dropDurationConstraint(Element durationConstraint, Element event1, Element event2, Point location) { - List<View> existingViews = DiagramEditPartsUtil.findViews(durationConstraint, getViewer()); - // only allow one view instance of a single element by diagram - if (!existingViews.isEmpty()) { - return UnexecutableCommand.INSTANCE; - } - IAdaptable elementAdapter = new EObjectAdapter(durationConstraint); - IHintedType elementType = (IHintedType) UMLElementTypes.getElementType(DurationConstraintEditPart.VISUAL_ID); - ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, elementType.getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint()); - CreateViewRequest createViewRequest = new CreateViewRequest(descriptor); - createViewRequest.setLocation(location); - // "ask" the host for a command associated with the - // CreateViewRequest - Command command = getHost().getCommand(createViewRequest); - if (command == null || !command.canExecute()) { - return UnexecutableCommand.INSTANCE; - } - // restore links. - CompositeCommand result = new CompositeCommand(command.getLabel()); - result.add(new CommandProxyWithResult(command, descriptor)); - Point[] constraintLocations = getLocationForDurationConstraint((DurationConstraint) durationConstraint, event1, event2, location); - if (constraintLocations[0] != null && constraintLocations[1] != null) { - if (constraintLocations[0].y <= constraintLocations[1].y) { - result.add(new RestoreDurationConstraintLinkCommand(getEditingDomain(), descriptor, getViewer(), true, constraintLocations[0], getDiagramPreferencesHint())); - result.add(new RestoreDurationConstraintLinkCommand(getEditingDomain(), descriptor, getViewer(), false, constraintLocations[1], getDiagramPreferencesHint())); - } else if (constraintLocations[0].y > constraintLocations[1].y) { - result.add(new RestoreDurationConstraintLinkCommand(getEditingDomain(), descriptor, getViewer(), false, constraintLocations[0], getDiagramPreferencesHint())); - result.add(new RestoreDurationConstraintLinkCommand(getEditingDomain(), descriptor, getViewer(), true, constraintLocations[1], getDiagramPreferencesHint())); - } - } else if (constraintLocations[0] != null) { - result.add(new RestoreDurationConstraintLinkCommand(getEditingDomain(), descriptor, getViewer(), null, constraintLocations[0], getDiagramPreferencesHint())); - } else if (constraintLocations[1] != null) { - result.add(new RestoreDurationConstraintLinkCommand(getEditingDomain(), descriptor, getViewer(), null, constraintLocations[1], getDiagramPreferencesHint())); - } - // it then can be used as an adaptable to retrieve the View - return new ICommandProxy(result); - } - - /** - * Collect the locations of constrained elements. - * - * @param durationConstraint - * @param event1 - * @param event2 - * @param location - * @return - */ - private Point[] getLocationForDurationConstraint(DurationConstraint durationConstraint, Element event1, Element event2, Point location) { - Point[] constraintLocations = new Point[2]; - if (event1 instanceof OccurrenceSpecification) { - constraintLocations[0] = getLocationForDurationConstraintOnEvent((OccurrenceSpecification) event1); - } - if (event2 instanceof OccurrenceSpecification) { - constraintLocations[1] = getLocationForDurationConstraintOnEvent((OccurrenceSpecification) event2); - } - if (constraintLocations[0] == null && event1 != null) { - EditPart editPart = lookForEditPart(event1); - if (editPart instanceof INodeEditPart) { - constraintLocations[0] = getLocationForDurationConstraintOnEditPart((INodeEditPart) editPart, location); - } - } - if (constraintLocations[1] == null && event2 != null) { - EditPart editPart = lookForEditPart(event2); - if (editPart instanceof INodeEditPart) { - constraintLocations[1] = getLocationForDurationConstraintOnEditPart((INodeEditPart) editPart, location.getTranslated(0, 40)); - } - } - if (event1 != null && event1 == event2 && constraintLocations[0] != null && constraintLocations[0].equals(constraintLocations[1])) { - EditPart editPart = lookForEditPart(event1); - if (editPart instanceof IGraphicalEditPart) { - Rectangle rect = SequenceUtil.getAbsoluteBounds((IGraphicalEditPart) editPart); - if (rect.contains(constraintLocations[0].getTranslated(0, 40))) { - constraintLocations[1] = constraintLocations[0].getTranslated(0, 40); - } else if (rect.contains(constraintLocations[0].getTranslated(0, -40))) { - constraintLocations[1] = constraintLocations[0].getTranslated(0, -40); - } - } - } - return constraintLocations; - } - - /** - * Get location from a INodeEditPart. - * - * @param nodeEditPart - * @param reference - * @return - */ - private Point getLocationForDurationConstraintOnEditPart(INodeEditPart nodeEditPart, Point reference) { - Rectangle rect = SequenceUtil.getAbsoluteBounds((IGraphicalEditPart) nodeEditPart); - Point location = new Point(); - if (reference.y < rect.y) { - location.y = rect.y + 1; - } else if (reference.y > rect.bottom()) { - location.y = rect.bottom() - 1; - } else { - location.y = reference.y; - } - for (int x = rect.x; x <= rect.right(); x++) { - CreateConnectionRequest request = new CreateConnectionRequest(); - request.setType(REQ_CONNECTION_END); - request.setTargetEditPart(nodeEditPart); - location.x = x; - request.setLocation(location); - ConnectionAnchor targetAnchor = nodeEditPart.getTargetConnectionAnchor(request); - if (targetAnchor != null) { - location = targetAnchor.getLocation(reference); - break; - } - } - return location; - } - - /** - * Get location of OccurrenceSpecification. - * - * @param event - * @return - */ - private Point getLocationForDurationConstraintOnEvent(OccurrenceSpecification event) { - Point targetLocation = null; - if (event instanceof MessageOccurrenceSpecification) { - Message message = ((MessageOccurrenceSpecification) event).getMessage(); - if (message == null) { - return null; - } - ConnectionNodeEditPart MessageSyncEditPart = null; - DiagramEditPart diag = DiagramEditPartsUtil.getDiagramEditPart(getHost()); - for (Object conn : diag.getConnections()) { - if (conn instanceof ConnectionNodeEditPart) { - EObject connElt = ((ConnectionNodeEditPart) conn).resolveSemanticElement(); - if (message.equals(connElt)) { - MessageSyncEditPart = (ConnectionNodeEditPart) conn; - break; - } - } - } - if (MessageSyncEditPart == null) { - return null; - } - if (event == message.getSendEvent()) { - targetLocation = SequenceUtil.getAbsoluteEdgeExtremity(MessageSyncEditPart, true); - } else if (event == message.getReceiveEvent()) { - targetLocation = SequenceUtil.getAbsoluteEdgeExtremity(MessageSyncEditPart, false); - } - } else if (event instanceof ExecutionOccurrenceSpecification) { - ExecutionSpecification execution = ((ExecutionOccurrenceSpecification) event).getExecution(); - if (execution != null) { - List<View> existingViews = DiagramEditPartsUtil.findViews(execution, getViewer()); - for (View view : existingViews) { - if (CCombinedCompartmentEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getVisualID(view)) || BehaviorExecutionSpecificationEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getVisualID(view))) { - Object object = getViewer().getEditPartRegistry().get(view); - if (object instanceof IGraphicalEditPart) { - Rectangle bounds = SequenceUtil.getAbsoluteBounds((IGraphicalEditPart) object); - if (event == execution.getStart()) { - targetLocation = bounds.getTop(); - } else if (event == execution.getFinish()) { - targetLocation = bounds.getBottom(); - } - } - } - } - } - } - return targetLocation; - } - - /** - * Get the command to drop an element between two events in order to create a message label - * - * @param droppedElement - * the dropped element - * @param event1 - * first event (of type MessageOccurrenceSpecification) - * @param event2 - * second event (of type MessageOccurrenceSpecification) - * @param element - * @return the command or false if the elements can not be dropped as message label - */ - private Command dropMessageNodeBetweenEvents(Element droppedElement, Element event1, Element event2) { - if (event1 instanceof MessageOccurrenceSpecification && event2 instanceof MessageOccurrenceSpecification) { - if (!event1.equals(event2)) { - boolean endsOfSameMessage = false; - String visualId = null; - if (droppedElement instanceof DurationConstraint) { - visualId = DurationConstraintInMessageEditPart.VISUAL_ID; - endsOfSameMessage = DurationConstraintHelper.endsOfSameMessage((OccurrenceSpecification) event1, (OccurrenceSpecification) event2); - } else if (droppedElement instanceof DurationObservation) { - visualId = DurationObservationEditPart.VISUAL_ID; - endsOfSameMessage = DurationObservationHelper.endsOfSameMessage((OccurrenceSpecification) event1, (OccurrenceSpecification) event2); - } - if (endsOfSameMessage) { - Message message = ((MessageOccurrenceSpecification) event1).getMessage(); - // search a connection which matches the possessing message - DiagramEditPart diag = DiagramEditPartsUtil.getDiagramEditPart(getHost()); - for (Object conn : diag.getConnections()) { - if (conn instanceof ConnectionNodeEditPart) { - EObject connElt = ((ConnectionNodeEditPart) conn).resolveSemanticElement(); - if (message.equals(connElt)) { - // check that node isn't already represented, or dropping is impossible - for (Object child : ((ConnectionNodeEditPart) conn).getChildren()) { - if (child instanceof GraphicalEditPart) { - EObject childElt = ((GraphicalEditPart) child).resolveSemanticElement(); - if (droppedElement.equals(childElt)) { - return null; - } - } - } - return dropNodeOnMessage((PackageableElement) droppedElement, (ConnectionNodeEditPart) conn, visualId); - } - } - } - } - } - } - return null; - } - - /** - * Test whether visual ids are compatible with a duration constraint element - * - * @param nodeVISUALID - * the detected node visual id - * @param linkVISUALID - * the detected link visual id - * @return true if element may be a duration constraint - */ - private boolean isDurationConstraintHint(String nodeVISUALID, String linkVISUALID) { - if (linkVISUALID != null) { - return false; - } else { - return nodeVISUALID == null || ConstraintEditPart.VISUAL_ID.equals(nodeVISUALID) || DurationConstraintEditPart.VISUAL_ID.equals(nodeVISUALID) || DurationConstraintInMessageEditPart.VISUAL_ID.equals(nodeVISUALID); - } - } - - /** - * Drop a duration observation or a duration constraint on a message edit part - * - * @param durationLabelElement - * the duration observation or duration constraint to display as message label - * @param MessageSyncEditPart - * the containing message edit part - * @param nodeVISUALID - * the label node visual id - * @return the command or UnexecutableCommand - */ - private Command dropNodeOnMessage(PackageableElement durationLabelElement, ConnectionNodeEditPart MessageSyncEditPart, String nodeVISUALID) { - IAdaptable elementAdapter = new EObjectAdapter(durationLabelElement); - ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType) getUMLElementType(nodeVISUALID)).getSemanticHint(), ViewUtil.APPEND, false, getDiagramPreferencesHint()); - return MessageSyncEditPart.getCommand(new CreateViewRequest(descriptor)); - } - - /** * Drop a time observation on a lifeline. * * @param observation - * the time constraint + * the time constraint * @param nodeVISUALID - * the node visual id + * the node visual id * @param dropLocation * @return the command if the lifeline is the correct one or UnexecutableCommand */ @@ -860,76 +510,13 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo } /** - * Drop an interval constraint (duration or time) on a lifeline. - * - * @param constraint - * the interval constraint - * @param nodeVISUALID - * the node visual id - * @return the command if the lifeline is the correct one or UnexecutableCommand - */ - private Command dropIntervalConstraintInLifeline(IntervalConstraint constraint, String nodeVISUALID) { - CompoundCommand cc = new CompoundCommand("Drop"); - IAdaptable elementAdapter = new EObjectAdapter(constraint); - ViewDescriptor descriptor = new ViewDescriptor(elementAdapter, Node.class, ((IHintedType) getUMLElementType(nodeVISUALID)).getSemanticHint(), ViewUtil.APPEND, true, getDiagramPreferencesHint()); - cc.add(getHost().getCommand(new CreateViewRequest(descriptor))); - LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(getHost()); - if (lifelinePart != null && constraint.getConstrainedElements().size() >= 2) { - Element occ1 = constraint.getConstrainedElements().get(0); - Element occ2 = constraint.getConstrainedElements().get(1); - if (occ1 instanceof OccurrenceSpecification && occ2 instanceof OccurrenceSpecification) { - Point startPoint = SequenceUtil.findLocationOfEvent(lifelinePart, (OccurrenceSpecification) occ1); - Point endPoint = SequenceUtil.findLocationOfEvent(lifelinePart, (OccurrenceSpecification) occ2); - if (startPoint != null && endPoint != null) { - int height = endPoint.y - startPoint.y; - Rectangle newBounds = null; - if (height < 0) { - newBounds = new Rectangle(endPoint, new Dimension(-1, -height)); - } else { - newBounds = new Rectangle(startPoint, new Dimension(-1, height)); - } - lifelinePart.getFigure().translateToRelative(newBounds); - Point parentLoc = lifelinePart.getLocation(); - newBounds.translate(parentLoc.getNegated()); - ICommand setBoundsCommand = new SetResizeAndLocationCommand(getEditingDomain(), "move", descriptor, newBounds); - cc.add(new ICommandProxy(setBoundsCommand)); - return cc; - } - } - } else if (lifelinePart != null && constraint.getConstrainedElements().size() == 1) { - Element occ1 = constraint.getConstrainedElements().get(0); - if (occ1 instanceof OccurrenceSpecification) { - Point middlePoint = SequenceUtil.findLocationOfEvent(lifelinePart, (OccurrenceSpecification) occ1); - if (middlePoint != null) { - int height = getDefaultDropHeight(nodeVISUALID); - Point startPoint = middlePoint.getCopy(); - if (height > 0) { - startPoint.translate(0, -height / 2); - } - Rectangle newBounds = new Rectangle(startPoint, new Dimension(-1, height)); - lifelinePart.getFigure().translateToRelative(newBounds); - Point parentLoc = lifelinePart.getLocation(); - newBounds.translate(parentLoc.getNegated()); - ICommand setBoundsCommand = new SetResizeAndLocationCommand(getEditingDomain(), "move", descriptor, newBounds); - cc.add(new ICommandProxy(setBoundsCommand)); - return cc; - } - } - } - return UnexecutableCommand.INSTANCE; - } - - /** * Get the default height to set to a drop object. This method is useful for dropped objects which must be positioned relatively to their center. * * @param nodeVISUALID - * the node visual id + * the node visual id * @return arbitrary default height for the node visual id (eventually -1) */ private int getDefaultDropHeight(String nodeVISUALID) { - if (TimeConstraintEditPart.VISUAL_ID.equals(nodeVISUALID) || TimeObservationEditPart.VISUAL_ID.equals(nodeVISUALID)) { - return 2; - } return -1; } @@ -947,7 +534,7 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo * Get lifelines element which contains these existingViews * * @param existingViews - * the existing views. + * the existing views. * @return the list of lifeline. */ private List<Lifeline> getLifelines(List<View> existingViews) { @@ -998,9 +585,9 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo * Drop a destructionEvent on a lifeline * * @param destructionOccurence - * the destructionEvent to drop + * the destructionEvent to drop * @param nodeVISUALID - * the node visualID + * the node visualID * @return the command to drop the destructionEvent on a lifeline if allowed. */ private Command dropDestructionOccurrence(DestructionOccurrenceSpecification destructionOccurence, String nodeVISUALID, Point location) { @@ -1028,11 +615,11 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo * Get the command to drop an execution specification node * * @param es - * execution specification + * execution specification * @param nodeVISUALID - * the execution specification's visual id + * the execution specification's visual id * @param location - * the location of the drop request + * the location of the drop request * @return the drop command */ private Command dropExecutionSpecification(ExecutionSpecification es, String nodeVISUALID, Point location) { @@ -1081,11 +668,11 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo * Get the command to drop a message link * * @param dropRequest - * request to drop + * request to drop * @param semanticLink - * message link + * message link * @param linkVISUALID - * the message's visual id + * the message's visual id * @return the drop command */ private Command dropMessage(DropObjectsRequest dropRequest, Element semanticLink, String linkVISUALID) { @@ -1112,20 +699,20 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo * This implementation is very similar to {@link CommonDiagramDragDropEditPolicy#dropBinaryLink(CompositeCommand, Element, Element, int, Point, Element)}. * * @param dropRequest - * the drop request + * the drop request * @param cc - * the composite command that will contain the set of command to create the binary - * link + * the composite command that will contain the set of command to create the binary + * link * @param source - * the element source of the link + * the element source of the link * @param target - * the element target of the link + * the element target of the link * @param linkVISUALID - * the link VISUALID used to create the view + * the link VISUALID used to create the view * @param location - * the location the location where the view will be be created + * the location the location where the view will be be created * @param semanticLink - * the semantic link that will be attached to the view + * the semantic link that will be attached to the view * * @return the composite command */ @@ -1176,13 +763,13 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo * Get the source and target recommended points for creating the link * * @param semanticLink - * link to create + * link to create * @param sourceEditPart - * edit part source of the link + * edit part source of the link * @param targetEditPart - * edit part target of the link + * edit part target of the link * @param dropLocation - * default location if NOT found. + * default location if NOT found. * @return a point array of size 2, with eventually null values (when no point constraint). Index 0 : source location, 1 : target location */ private Point[] getLinkSourceAndTargetLocations(Element semanticLink, GraphicalEditPart sourceEditPart, GraphicalEditPart targetEditPart, Point dropLocation) { @@ -1325,11 +912,11 @@ public class CustomDiagramDragDropEditPolicy extends CommonDiagramDragDropEditPo * Get the command to drop a general ordering link * * @param dropRequest - * request to drop + * request to drop * @param semanticLink - * general ordering link + * general ordering link * @param linkVISUALID - * the link's visual id + * the link's visual id * @return the drop command */ private Command dropGeneralOrdering(DropObjectsRequest dropRequest, Element semanticLink, String linkVISUALID) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExecutionSpecificationSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExecutionSpecificationSemanticEditPolicy.java new file mode 100644 index 00000000000..95fe15a4a05 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExecutionSpecificationSemanticEditPolicy.java @@ -0,0 +1,59 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, Christian W. Damus, 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: + * EclipseSource France - Initial API and implementation + * Christian W. Damus - bug 536486 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import java.util.Arrays; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.commands.Command; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.papyrus.uml.service.types.utils.ElementUtil; +import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant; +import org.eclipse.uml2.uml.ExecutionSpecification; +import org.eclipse.uml2.uml.TimeConstraint; + +/** + * Specific policy to set the contrained element for {@link TimeConstraint}. + */ +public class CustomExecutionSpecificationSemanticEditPolicy extends OccurenceSemanticEditPolicy { + + @Override + protected Command getCreateCommand(CreateElementRequest req) { + if (ElementUtil.isTypeOf(req.getElementType(), UMLElementTypes.TIME_CONSTRAINT) + || ElementUtil.isTypeOf(req.getElementType(), UMLElementTypes.TIME_OBSERVATION)) { + + Object loc = req.getParameter("initialMouseLocationForCreation"); + // evaluate parameters + if (!Point.class.isInstance(loc) + || !IGraphicalEditPart.class.isInstance(getHost()) + || !ExecutionSpecification.class.isInstance(req.getContainer())) { + return super.getCreateCommand(req); + } + + boolean isStart = DurationLinkUtil.isStart(((IGraphicalEditPart) getHost()).getFigure(), Point.class.cast(loc)); + if (isStart) { + req.setParameter(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, Arrays.asList(((ExecutionSpecification) req.getContainer()).getStart())); + } else { + req.setParameter(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, Arrays.asList(((ExecutionSpecification) req.getContainer()).getFinish())); + } + + } + return super.getCreateCommand(req); + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomLifelineSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomLifelineSemanticEditPolicy.java new file mode 100644 index 00000000000..60b6adaf2ea --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomLifelineSemanticEditPolicy.java @@ -0,0 +1,76 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import java.util.Arrays; + +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.commands.UnexecutableCommand; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.CustomDefaultSemanticEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.DisplayEvent; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.papyrus.uml.service.types.utils.ElementUtil; +import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant; +import org.eclipse.uml2.uml.MessageOccurrenceSpecification; +import org.eclipse.uml2.uml.TimeConstraint; + +/** + * Custom semantic edit-policy for lifelines that manages configuration of + * {@#link TimeObservation} and {@link TimeConstraint} border items. + */ +public class CustomLifelineSemanticEditPolicy extends CustomDefaultSemanticEditPolicy { + + private DisplayEvent displayEvent; + + /** + * Initializes me. + */ + public CustomLifelineSemanticEditPolicy() { + super(); + } + + @Override + public void setHost(EditPart host) { + super.setHost(host); + displayEvent = new DisplayEvent(host); + } + + @Override + protected Command getCreateCommand(CreateElementRequest req) { + if (ElementUtil.isTypeOf(req.getElementType(), UMLElementTypes.TIME_CONSTRAINT) + || ElementUtil.isTypeOf(req.getElementType(), UMLElementTypes.TIME_OBSERVATION)) { + + Object loc = req.getParameter("initialMouseLocationForCreation"); + if ((loc instanceof Point) && (getHost() instanceof IGraphicalEditPart)) { + // Is a message end here? + MessageOccurrenceSpecification messageOcc = displayEvent.getMessageEvent(((IGraphicalEditPart) getHost()).getFigure(), (Point) loc); + if (messageOcc != null) { + req.setParameter(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, Arrays.asList(messageOcc)); + } else { + // Cannot create this on a lifeline without the message end to constrain + // or observe + return UnexecutableCommand.INSTANCE; + } + } + } + return super.getCreateCommand(req); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DeleteTimeElementWithoutEventPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DeleteTimeElementWithoutEventPolicy.java index 24c89b5c782..50a8e8a52ae 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DeleteTimeElementWithoutEventPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DeleteTimeElementWithoutEventPolicy.java @@ -53,15 +53,7 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.core.listenerservice.IPapyrusListener; import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil; import org.eclipse.uml2.uml.DurationObservation; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.OccurrenceSpecification; import org.eclipse.uml2.uml.TimeConstraint; import org.eclipse.uml2.uml.TimeObservation; @@ -219,13 +211,6 @@ public class DeleteTimeElementWithoutEventPolicy extends AbstractEditPolicy impl } else if (hostSemanticElement instanceof TimeConstraint) { return ((TimeConstraint) hostSemanticElement).getConstrainedElements().size() > 0; } - // else if(hostSemanticElement instanceof DurationConstraint) { - // /* - // * Note that DurationConstraint may have only one ConstrainedElement. - // * But in such a case, we suppose it has not been created as one of the concerned edit parts. - // */ - // return ((DurationConstraint)hostSemanticElement).getConstrainedElements().size() >= 2; - // } return true; } @@ -235,81 +220,11 @@ public class DeleteTimeElementWithoutEventPolicy extends AbstractEditPolicy impl * @return list of views */ protected List<View> getLinkedViews() { - if (getHost() instanceof TimeObservationEditPart && hostSemanticElement instanceof TimeObservation) { - LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost()); - NamedElement occ = ((TimeObservation) hostSemanticElement).getEvent(); - if (occ instanceof OccurrenceSpecification) { - EditPart part = SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification) occ); - if (part != null) { - return Collections.singletonList((View) part.getModel()); - } - } - return Collections.emptyList(); - } else if (getHost() instanceof TimeConstraintEditPart && hostSemanticElement instanceof TimeConstraint) { - LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost()); - List<Element> occs = ((TimeConstraint) hostSemanticElement).getConstrainedElements(); - if (occs.size() > 0 && occs.get(0) instanceof OccurrenceSpecification) { - EditPart part = SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification) occs.get(0)); - if (part != null) { - return Collections.singletonList((View) part.getModel()); - } - } - return Collections.emptyList(); - } else if (getHost() instanceof DurationConstraintEditPart && hostSemanticElement instanceof TimeConstraint) { - LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost()); - List<Element> occs = ((TimeConstraint) hostSemanticElement).getConstrainedElements(); - if (occs.size() >= 2 && occs.get(0) instanceof OccurrenceSpecification && occs.get(1) instanceof OccurrenceSpecification) { - EditPart part1 = SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification) occs.get(0)); - EditPart part2 = SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification) occs.get(1)); - List<View> list = new ArrayList<>(2); - if (part1 != null) { - list.add((View) part1.getModel()); - } - if (part2 != null) { - list.add((View) part2.getModel()); - } - return list; - } - return Collections.emptyList(); - } // a label on a message always has its parent message return Collections.emptyList(); } /** - * Check if time element has required other figures - * - * @return true if the time element figure miss one of the figure representing its ends. - */ - protected boolean timeElementMissAnEventFigure() { - if (getHost() instanceof TimeObservationEditPart && hostSemanticElement instanceof TimeObservation) { - LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost()); - NamedElement occ = ((TimeObservation) hostSemanticElement).getEvent(); - if (occ instanceof OccurrenceSpecification) { - return SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification) occ) == null; - } - return true; - } else if (getHost() instanceof TimeConstraintEditPart && hostSemanticElement instanceof TimeConstraint) { - LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost()); - List<Element> occs = ((TimeConstraint) hostSemanticElement).getConstrainedElements(); - if (occs.size() > 0 && occs.get(0) instanceof OccurrenceSpecification) { - return SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification) occs.get(0)) == null; - } - return true; - } - // else if(getHost() instanceof DurationConstraintEditPart && hostSemanticElement instanceof DurationConstraint) { - // LifelineEditPart lifeline = SequenceUtil.getParentLifelinePart(getHost()); - // List<Element> occs = ((DurationConstraint)hostSemanticElement).getConstrainedElements(); - // if(occs.size() >= 2 && occs.get(0) instanceof OccurrenceSpecification && occs.get(1) instanceof OccurrenceSpecification) { - // return SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occs.get(0)) == null || SequenceUtil.getLinkedEditPart(lifeline, (OccurrenceSpecification)occs.get(1)) == null; - // } - // return true; - // } - // a label on a message always has its parent message - return false; - } - - /** * Returns a {@link Command} to delete the host element * * @param graphOnly @@ -436,10 +351,6 @@ public class DeleteTimeElementWithoutEventPolicy extends AbstractEditPolicy impl // delete the time element deleteTimeElement(); } - if (timeElementMissAnEventFigure()) { - // delete the view - deleteTimeView(); - } } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java new file mode 100644 index 00000000000..80299d899a9 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java @@ -0,0 +1,70 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.requests.CreateConnectionRequest; +import org.eclipse.gef.requests.ReconnectRequest; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil; + +/** + * An extended {@link DefaultGraphicalNodeEditPolicy} which supports creation of DurationLinks + */ +public class DestructionOccurrenceGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPolicy { + + @Override + protected ICommand getAfterConnectionCompleteCommand(CreateConnectionViewAndElementRequest request, final TransactionalEditingDomain editingDomain) { + if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) { + return null; // Prevent the superclass from "Fixing" the anchors + } + return super.getAfterConnectionCompleteCommand(request, editingDomain); + } + + @Override + protected Command getReconnectSourceCommand(ReconnectRequest request) { + // if (DurationLinkUtil.isDurationLink(request)) { + // // Bug 536639: Forbid reconnect on Duration edit parts + // return UnexecutableCommand.INSTANCE; + // } + return super.getReconnectSourceCommand(request); + } + + @Override + protected Command getReconnectTargetCommand(ReconnectRequest request) { + // if (DurationLinkUtil.isDurationLink(request)) { + // // Bug 536639: Forbid reconnect on Duration edit parts + // return UnexecutableCommand.INSTANCE; + // } + return super.getReconnectTargetCommand(request); + } + + @Override + protected Connection createDummyConnection(Request req) { + if (req instanceof CreateConnectionRequest && DurationLinkUtil.isCreateDurationLink((CreateConnectionRequest) req)) { + return new DurationLinkFigure(); + } + return new PolylineConnection(); + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java new file mode 100644 index 00000000000..ee9aaea8f3d --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java @@ -0,0 +1,294 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Optional; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.ConnectionLocator; +import org.eclipse.draw2d.Cursors; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.DragTracker; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.Handle; +import org.eclipse.gef.Request; +import org.eclipse.gef.RequestConstants; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.handles.ConnectionHandle; +import org.eclipse.gef.handles.SquareHandle; +import org.eclipse.gef.tools.SelectEditPartTracker; +import org.eclipse.gef.tools.SimpleDragTracker; +import org.eclipse.gmf.runtime.common.core.command.CommandResult; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.gmf.runtime.notation.Connector; +import org.eclipse.gmf.runtime.notation.IntValueStyle; +import org.eclipse.gmf.runtime.notation.NotationPackage; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusConnectionEndEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure.Orientation; +import org.eclipse.papyrus.uml.diagram.sequence.locator.IntersectionPointSelectionLocator; +import org.eclipse.papyrus.uml.diagram.sequence.requests.MoveArrowRequest; +import org.eclipse.swt.graphics.Cursor; + +/** + * Edit policy for the selection handles of a {@link DurationConstraintLinkEditPart} + */ +public class DurationLinkSelectionHandlesEditPolicy extends PapyrusConnectionEndEditPolicy implements PropertyChangeListener { + private UMLConnectionNodeEditPart durationLinkEditPart; + private TransactionalEditingDomain editingDomain; + private Integer arrowPositionDelta; + + public DurationLinkSelectionHandlesEditPolicy(UMLConnectionNodeEditPart durationLinkEditPart, TransactionalEditingDomain editingDomain) { + this.durationLinkEditPart = durationLinkEditPart; + this.editingDomain = editingDomain; + } + + @Override + public void setHost(EditPart host) { + super.setHost(host); + if (getHost() != null) { + getHostFigure().addPropertyChangeListener(Connection.PROPERTY_POINTS, this); + } + } + + @SuppressWarnings("unchecked") + @Override + protected List<?> createSelectionHandles() { + List<Handle> handles = new ArrayList<>(); + handles.addAll((Collection<? extends Handle>) super.createSelectionHandles()); + addSelectionHandles(handles); + addMoveHandles(handles); + return handles; + } + + private void addMoveHandles(List<Handle> list) { + // middle of the arrow line + DurationLinkFigure figure = ((DurationLinkFigure) getHostFigure()); + Cursor cursor = getCursor(figure); + Handle moveHandle = new SquareHandle((ConnectionEditPart) getHost(), new CustomMoveHandleLocator(figure), cursor) { + @Override + protected DragTracker createDragTracker() { + return new ArrowLineMoveTracker(); + } + }; + + list.add(moveHandle); + } + + @Override + public void showSourceFeedback(Request request) { + if (MoveArrowRequest.REQ_MOVE_ARROW.equals(request.getType())) { + showArrowMoveFeedback((MoveArrowRequest) request); + } + super.showSourceFeedback(request); + } + + @Override + public void eraseSourceFeedback(Request request) { + if (MoveArrowRequest.REQ_MOVE_ARROW.equals(request.getType())) { + eraseArrowMoveFeedback((MoveArrowRequest) request); + } + super.eraseSourceFeedback(request); + } + + private void eraseArrowMoveFeedback(MoveArrowRequest request) { + arrowPositionDelta = null; + getHost().refresh(); + } + + protected void showArrowMoveFeedback(MoveArrowRequest request) { + DurationLinkFigure figure = (DurationLinkFigure) durationLinkEditPart.getFigure(); + if (arrowPositionDelta == null) { + arrowPositionDelta = figure.getArrowPositionDelta(); + } + PointList arrowLinePoints = figure.getArrowLinePoints(); + Point arrowPoint = arrowLinePoints.getMidpoint().getCopy(); + + figure.translateToAbsolute(arrowPoint); + arrowPoint.translate(request.getMoveDelta()); + figure.translateToRelative(arrowPoint); + + Dimension moveDelta = arrowPoint.getDifference(arrowLinePoints.getMidpoint()); + + Orientation arrowOrientation = request.getArrowOrientation(); + if (arrowOrientation == Orientation.VERTICAL) { + figure.setArrowPositionDelta(arrowPositionDelta + moveDelta.width); + } else { + // horizontal + figure.setArrowPositionDelta(arrowPositionDelta + moveDelta.height); + } + } + + private Cursor getCursor(DurationLinkFigure figure) { + if (figure.getArrowOrientation() == Orientation.VERTICAL) { + return Cursors.SIZEWE; + } + return Cursors.SIZENS; + } + + private void addSelectionHandles(List<Handle> list) { + DurationLinkFigure figure = ((DurationLinkFigure) getHostFigure()); + + PointList arrowLinePoints = figure.getArrowLinePoints(); + PointList startLinePoints = figure.getStartLinePoints(); + PointList endLinePoints = figure.getEndLinePoints(); + // intersection between start and arrow line + list.add(new DurationConstraintArrowSelectionHandle(true, durationLinkEditPart, figure, startLinePoints, arrowLinePoints)); + // intersection between end and arrow line + list.add(new DurationConstraintArrowSelectionHandle(true, durationLinkEditPart, figure, endLinePoints, arrowLinePoints)); + } + + protected SelectEditPartTracker getSelectTracker() { + return new SelectEditPartTracker(getHost()); + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + // refresh selection handles when the points property changes + if (getHost().getSelected() != EditPart.SELECTED_NONE) { + addSelectionHandles(); + } + } + + class CustomMoveHandleLocator extends ConnectionLocator { + + /** + * Constructor. + * + * @param connection + */ + public CustomMoveHandleLocator(Connection connection) { + super(connection); + } + + @Override + protected Point getLocation(PointList points) { + DurationLinkFigure figure = (DurationLinkFigure) getConnection(); + PointList arrowLinePoints = figure.getArrowLinePoints(); + return arrowLinePoints.getMidpoint(); + } + + } + + class DurationConstraintArrowSelectionHandle extends ConnectionHandle { + + DurationConstraintArrowSelectionHandle(boolean fixed, org.eclipse.gef.GraphicalEditPart owner, Connection connection, PointList pointList1, PointList pointList2) { + super(fixed); + setOwner(owner); + setLocator(new IntersectionPointSelectionLocator(connection, pointList1, pointList2)); + } + + @Override + protected DragTracker createDragTracker() { + return new SimpleDragTracker() { + @Override + protected String getCommandName() { + return RequestConstants.REQ_SELECTION; + } + }; + } + } + + class ArrowLineMoveTracker extends SimpleDragTracker { + + @Override + protected String getCommandName() { + return MoveArrowRequest.REQ_MOVE_ARROW; + } + + @Override + protected void updateSourceRequest() { + super.updateSourceRequest(); + MoveArrowRequest request = (MoveArrowRequest) getSourceRequest(); + DurationLinkFigure figure = (DurationLinkFigure) durationLinkEditPart.getPrimaryShape(); + request.setArrowOrientation(figure.getArrowOrientation()); + Point location = new Point(getLocation()); + request.setLocation(location); + Dimension dragMoveDelta = getDragMoveDelta(); + Point moveDelta = new Point(0, 0); + moveDelta.y += dragMoveDelta.height; + moveDelta.x += dragMoveDelta.width; + request.setMoveDelta(moveDelta); + } + + @Override + protected Request createSourceRequest() { + return new MoveArrowRequest(); + } + + @Override + protected Command getCommand() { + Request request = getSourceRequest(); + + if (request instanceof MoveArrowRequest) { + ICommand moveArrowCommand = new AbstractTransactionalCommand(editingDomain, "Move arrow", null) { + + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + Connector connector = (Connector) durationLinkEditPart.getNotationView(); + + @SuppressWarnings("unchecked") + Optional<IntValueStyle> deltaOptional = connector.getStyles().stream().filter(IntValueStyle.class::isInstance).filter(style -> DurationLinkFigure.DELTA_VIEW_STYLE.equals(((IntValueStyle) style).getName())).findFirst(); + IntValueStyle deltaStyle = deltaOptional.orElseGet(() -> { + IntValueStyle style = (IntValueStyle) connector.createStyle(NotationPackage.eINSTANCE.getIntValueStyle()); + style.setName(DurationLinkFigure.DELTA_VIEW_STYLE); + return style; + }); + + DurationLinkFigure figure = ((DurationLinkFigure) durationLinkEditPart.getFigure()); + PointList arrowLinePoints = figure.getArrowLinePoints(); + Point arrowPoint = arrowLinePoints.getMidpoint().getCopy(); + + figure.translateToAbsolute(arrowPoint); + arrowPoint.translate(((MoveArrowRequest) request).getMoveDelta()); + figure.translateToRelative(arrowPoint); + + Dimension moveDelta = arrowPoint.getDifference(arrowLinePoints.getMidpoint()); + + Orientation arrowOrientation = ((MoveArrowRequest) request).getArrowOrientation(); + if (arrowOrientation == Orientation.VERTICAL) { + deltaStyle.setIntValue(deltaStyle.getIntValue() + moveDelta.width); + } else { + // horizontal + deltaStyle.setIntValue(deltaStyle.getIntValue() + moveDelta.height); + } + return CommandResult.newOKCommandResult(); + } + }; + return new ICommandProxy(moveArrowCommand); + } + return super.getCommand(); + } + + } + +}
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationAffixedChildAlignmentPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationAffixedChildAlignmentPolicy.java new file mode 100644 index 00000000000..a428871b23b --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationAffixedChildAlignmentPolicy.java @@ -0,0 +1,169 @@ +/***************************************************************************** + * Copyright (c) 2018 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.sequence.edit.policies; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.draw2d.Cursors; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PrecisionRectangle; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.NonResizableEditPolicy; +import org.eclipse.gef.handles.ResizableHandleKit; +import org.eclipse.gef.requests.ChangeBoundsRequest; +import org.eclipse.gef.tools.ResizeTracker; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.FigureUtils; +import org.eclipse.papyrus.uml.diagram.common.editparts.IFloatingLabelEditPart; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AllowResizeAffixedNodeAlignmentEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy; +import org.eclipse.uml2.uml.TimeConstraint; +import org.eclipse.uml2.uml.TimeObservation; + +/** + * Specific execution specification policy to allow specific resize of {@link TimeConstraint} & {@link TimeObservation}. + */ +public class ExecutionSpecificationAffixedChildAlignmentPolicy extends AllowResizeAffixedNodeAlignmentEditPolicy { + + public ExecutionSpecificationAffixedChildAlignmentPolicy() { + super(); + } + + @Override + protected EditPolicy createChildEditPolicy(EditPart child) { + if ((child instanceof IBorderItemEditPart) && !(child instanceof IFloatingLabelEditPart)) { + BorderItemResizableEditPolicy policy = new BorderItemResizableEditPolicy() { + @Override + protected void createResizeHandle(List handles, int direction) { + if ((getResizeDirections() & direction) == direction) { + ResizableHandleKit.addHandle((GraphicalEditPart) getHost(), + handles, direction, getResizeTracker(direction), Cursors + .getDirectionalCursor(direction, getHostFigure() + .isMirrored())); + } + // no else, otherwise there is some overrride + } + + @Override + protected ResizeTracker getResizeTracker(int direction) { + return new TimeElementResizeTracker((GraphicalEditPart) getHost(), direction); + } + + @Override + protected Command getAutoSizeCommand(Request request) { + return null; + } + + @Override + protected void showChangeBoundsFeedback(ChangeBoundsRequest request) { + IBorderItemEditPart borderItemEP = (IBorderItemEditPart) getHost(); + IBorderItemLocator borderItemLocator = borderItemEP.getBorderItemLocator(); + + if (borderItemLocator != null) { + IFigure feedback = getDragSourceFeedbackFigure(); + PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy()); + EditPart part = borderItemEP.getParent(); + // position is relative to parent + Point p = ((IGraphicalEditPart) part).getFigure().getBounds().getLocation().getNegated(); + rect.translate(p); + // scaling not taken into account for feedback + double scale = FigureUtils.getScale(getHostFigure()); + Point moveDelta = request.getMoveDelta().getCopy(); + moveDelta.scale(1 / scale); + rect.translate(moveDelta); + Dimension sizeDelta = request.getSizeDelta().getCopy(); + sizeDelta.scale(1 / scale); + rect.resize(sizeDelta); + IFigure borderItemfigure = borderItemEP.getFigure(); + Rectangle realLocation = borderItemLocator.getValidLocation(rect.getCopy(), borderItemfigure); + getHostFigure().translateToAbsolute(realLocation); + feedback.translateToRelative(realLocation); + feedback.setBounds(realLocation); + } + } + }; + policy.setResizeDirections(PositionConstants.EAST | PositionConstants.WEST); + policy.setDragAllowed(false); + return policy; + } + EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); + if (result == null) { + result = new NonResizableEditPolicy(); + } + return result; + + } + + public class TimeElementResizeTracker extends ResizeTracker { + + public TimeElementResizeTracker(GraphicalEditPart owner, int direction) { + super(owner, direction); + } + + @Override + protected List<EditPart> createOperationSet() { + // no multi-selection + return Collections.singletonList(getOwner()); + } + + @Override + protected Request createSourceRequest() { + ChangeBoundsRequest request = new ChangeBoundsRequest(REQ_RESIZE); + request.setConstrainedResize(false); + request.setResizeDirection(getResizeDirection()); + return request; + } + + @Override + protected Command getCommand() { + return super.getCommand(); + } + + /** + * @see org.eclipse.gef.tools.ResizeTracker#updateSourceRequest() + * + */ + @Override + protected void updateSourceRequest() { + super.updateSourceRequest(); + } + + @Override + protected Dimension getMinimumSizeFor(ChangeBoundsRequest request) { + return new Dimension(20, 1); + } + + /** + * @see org.eclipse.gef.tools.SimpleDragTracker#showSourceFeedback() + * + */ + @Override + protected void showSourceFeedback() { + super.showSourceFeedback(); + } + + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java new file mode 100644 index 00000000000..d5d83eb6802 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java @@ -0,0 +1,126 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import java.util.Map; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy; +import org.eclipse.gef.requests.CreateConnectionRequest; +import org.eclipse.gef.requests.ReconnectRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil; +import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant; +import org.eclipse.uml2.uml.ExecutionSpecification; +import org.eclipse.uml2.uml.GeneralOrdering; +import org.eclipse.uml2.uml.OccurrenceSpecification; + +/** + * <p> + * A specialized {@link GraphicalNodeEditPolicy} for {@link ExecutionSpecification ExecutionSpecifications}, to handle + * connection of DurationLinks or {@link GeneralOrdering} links to the Start/Finish Occurrences of the {@link ExecutionSpecification} + * </p> + */ +public class ExecutionSpecificationGraphicalNodeEditPolicy extends ElementCreationWithMessageEditPolicy { + + // Source (First half of the request) + @Override + protected Command getConnectionCreateCommand(CreateConnectionRequest request) { + if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) { + CreateRelationshipRequest createRequest = DurationLinkUtil.getCreateRelationshipRequest(request); + if (createRequest != null) { + OccurrenceSpecification sourceOccurrence; + ExecutionSpecification execSpec = getExecutionSpecification(); + if (execSpec != null) { + if (OccurrenceSpecificationUtil.isStart(getHostFigure(), request.getLocation())) { + sourceOccurrence = execSpec.getStart(); + } else { + sourceOccurrence = execSpec.getFinish(); + } + @SuppressWarnings("unchecked") + Map<Object, Object> extendedData = request.getExtendedData(); + extendedData.put(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence); + createRequest.setParameter(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence); + } + } + } + return super.getConnectionCreateCommand(request); + } + + private ExecutionSpecification getExecutionSpecification() { + Object model = getHost().getModel(); + if (model instanceof View && ((View) model).getElement() instanceof ExecutionSpecification) { + return (ExecutionSpecification) ((View) model).getElement(); + } + return null; + } + + // Target (Second half of the request) + @Override + protected Command getConnectionAndRelationshipCompleteCommand(CreateConnectionViewAndElementRequest request) { + if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) { + CreateRelationshipRequest createRequest = OccurrenceSpecificationUtil.getCreateRelationshipRequest(request); + if (createRequest != null) { + OccurrenceSpecification targetOccurrence; + ExecutionSpecification execSpec = getExecutionSpecification(); + if (execSpec != null) { + if (OccurrenceSpecificationUtil.isStart(getHostFigure(), request.getLocation())) { + targetOccurrence = execSpec.getStart(); + } else { + targetOccurrence = execSpec.getFinish(); + } + @SuppressWarnings("unchecked") + Map<Object, Object> extendedData = request.getExtendedData(); + extendedData.put(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence); + createRequest.setParameter(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence); + } + } + } + return super.getConnectionAndRelationshipCompleteCommand(request); + } + + @Override + protected Command getReconnectSourceCommand(ReconnectRequest request) { + // if (DurationLinkUtil.isDurationLink(request)) { + // // Bug 536639: Forbid reconnect on Duration edit parts + // return UnexecutableCommand.INSTANCE; + // } + return super.getReconnectSourceCommand(request); + } + + @Override + protected Command getReconnectTargetCommand(ReconnectRequest request) { + // if (DurationLinkUtil.isDurationLink(request)) { + // // Bug 536639: Forbid reconnect on Duration edit parts + // return UnexecutableCommand.INSTANCE; + // } + return super.getReconnectTargetCommand(request); + } + + @Override + protected Connection createDummyConnection(Request req) { + if (req instanceof CreateConnectionRequest && DurationLinkUtil.isCreateDurationLink((CreateConnectionRequest) req)) { + return new DurationLinkFigure(); + } + return new PolylineConnection(); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java index 8fd591346fc..c4abca475ba 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java @@ -21,8 +21,6 @@ import java.util.List; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.draw2d.ConnectionRouter; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.Polyline; import org.eclipse.draw2d.geometry.Point; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.TransactionalEditingDomain; @@ -32,7 +30,6 @@ import org.eclipse.gef.Request; import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.requests.CreateConnectionRequest; -import org.eclipse.gef.requests.CreateRequest; import org.eclipse.gef.requests.ReconnectRequest; import org.eclipse.gmf.runtime.diagram.core.commands.SetConnectionEndsCommand; import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; @@ -42,13 +39,13 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElemen import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest.ConnectionViewDescriptor; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; import org.eclipse.gmf.runtime.emf.type.core.IHintedType; import org.eclipse.gmf.runtime.notation.Connector; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.uml.diagram.sequence.command.OLDCreateGateViewCommand; import org.eclipse.papyrus.uml.diagram.sequence.draw2d.routers.MessageRouter; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteEditPart; @@ -75,9 +72,6 @@ import org.eclipse.uml2.uml.MessageEnd; */ public class LifelineChildGraphicalNodeEditPolicy extends OLDSequenceGraphicalNodeEditPolicy { - /** the feedback for creating a duration constraint node */ - private Polyline durationCreationFeedback = null; - /** the router to use for messages */ public static ConnectionRouter messageRouter = new MessageRouter(); @@ -173,7 +167,7 @@ public class LifelineChildGraphicalNodeEditPolicy extends OLDSequenceGraphicalNo } else { // Get the start command for each individual request, this will // update each request as required. - final List commands = new ArrayList(); + final List<Command> commands = new ArrayList<>(); for (Iterator iter = request.getAllRequests().iterator(); iter.hasNext();) { Request individualRequest = (Request) iter.next(); Command cmd = null; @@ -221,7 +215,7 @@ public class LifelineChildGraphicalNodeEditPolicy extends OLDSequenceGraphicalNo } } Command command = super.getReconnectSourceCommand(request); - if (command != null) { + if (command != null && request.getConnectionEditPart() instanceof AbstractMessageEditPart) { command = OccurrenceSpecificationMoveHelper.completeReconnectConnectionCommand(command, request, getConnectableEditPart()); if (request.getConnectionEditPart() instanceof MessageCreateEditPart && request.getTarget() instanceof LifelineEditPart) { LifelineEditPart newSource = (LifelineEditPart) request.getTarget(); @@ -257,7 +251,7 @@ public class LifelineChildGraphicalNodeEditPolicy extends OLDSequenceGraphicalNo } Command command = super.getReconnectTargetCommand(request); - if (command != null) { + if (command != null && request.getConnectionEditPart() instanceof AbstractMessageEditPart) { command = OccurrenceSpecificationMoveHelper.completeReconnectConnectionCommand(command, request, getConnectableEditPart()); if (request.getConnectionEditPart() instanceof MessageCreateEditPart && request.getTarget() instanceof LifelineEditPart) { command = LifelineMessageCreateHelper.reconnectMessageCreateTarget(request, command); @@ -270,62 +264,6 @@ public class LifelineChildGraphicalNodeEditPolicy extends OLDSequenceGraphicalNo } /** - * Show the feedback for creating a duration constraint from this edit part - * - * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#showSourceFeedback(org.eclipse.gef.Request) - * @param request - * creation request - */ - @Override - public void showSourceFeedback(Request request) { - if (request instanceof CreateUnspecifiedTypeRequest) { - Object hintedType = ((CreateUnspecifiedTypeRequest) request).getElementTypes().get(0); - CreateRequest req = null; - if (UMLElementTypes.DurationConstraint_Shape.equals(hintedType)) { - req = ((CreateUnspecifiedTypeRequest) request).getRequestForType(UMLElementTypes.DurationConstraint_Shape); - } else if (UMLElementTypes.DurationObservation_Shape.equals(hintedType)) { - req = ((CreateUnspecifiedTypeRequest) request).getRequestForType(UMLElementTypes.DurationObservation_Shape); - } - if (req != null) { - Object initLocation = req.getExtendedData().get(SequenceRequestConstant.OCCURRENCE_SPECIFICATION_LOCATION); - if (initLocation instanceof Point) { - Point startPoint = ((Point) initLocation).getCopy(); - Point targetPoint = ((CreateUnspecifiedTypeRequest) request).getLocation().getCopy(); - getFeedbackLayer().translateToRelative(startPoint); - getFeedbackLayer().translateToRelative(targetPoint); - if (durationCreationFeedback == null) { - durationCreationFeedback = new Polyline(); - durationCreationFeedback.setLineWidth(1); - durationCreationFeedback.setLineStyle(Graphics.LINE_DASHDOT); - durationCreationFeedback.setForegroundColor(((IGraphicalEditPart) getHost()).getFigure().getLocalForegroundColor()); - addFeedback(durationCreationFeedback); - } - durationCreationFeedback.setStart(startPoint); - durationCreationFeedback.setEnd(targetPoint); - return; - } - } - } - super.showSourceFeedback(request); - } - - /** - * Erase the feedback for creating a duration constraint from this edit part - * - * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#eraseSourceFeedback(org.eclipse.gef.Request) - * @param request - * creation request - */ - @Override - public void eraseSourceFeedback(Request request) { - super.eraseSourceFeedback(request); - if (durationCreationFeedback != null) { - removeFeedback(durationCreationFeedback); - } - durationCreationFeedback = null; - } - - /** * Get the replacing connection router for routing messages correctly * * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getDummyConnectionRouter(org.eclipse.gef.requests.CreateConnectionRequest) @@ -372,12 +310,12 @@ public class LifelineChildGraphicalNodeEditPolicy extends OLDSequenceGraphicalNo IAdaptable gateAdapter = new IAdaptable() { @Override - public Object getAdapter(Class adapter) { + public <T> T getAdapter(Class<T> adapter) { if (Gate.class == adapter) { Message message = elementAdapter.getAdapter(Message.class); MessageEnd sendEvent = message.getSendEvent(); if (sendEvent instanceof Gate) { - return sendEvent; + return adapter.cast(sendEvent); } } return null; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java new file mode 100644 index 00000000000..5b031be65ba --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java @@ -0,0 +1,112 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import java.util.Map; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.requests.CreateConnectionRequest; +import org.eclipse.gef.requests.ReconnectRequest; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil; +import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant; +import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.MessageEnd; +import org.eclipse.uml2.uml.OccurrenceSpecification; + +public class MessageGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy { + // Source (First half of the request) + @Override + protected Command getConnectionCreateCommand(CreateConnectionRequest request) { + if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) { + CreateRelationshipRequest createRequest = OccurrenceSpecificationUtil.getCreateRelationshipRequest(request); + if (createRequest != null) { + MessageEnd sourceOccurrence; + Message message = getMessage(); + if (message != null) { + sourceOccurrence = OccurrenceSpecificationUtil.isSource(getHostFigure(), request.getLocation()) ? message.getSendEvent() : message.getReceiveEvent(); + if (sourceOccurrence instanceof OccurrenceSpecification) { + @SuppressWarnings("unchecked") + Map<Object, Object> extendedData = request.getExtendedData(); + extendedData.put(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence); + createRequest.setParameter(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence); + } + } + } + } + return super.getConnectionCreateCommand(request); + } + + // Target (Second half of the request) + @Override + protected Command getConnectionAndRelationshipCompleteCommand(CreateConnectionViewAndElementRequest request) { + if (DurationLinkUtil.isCreateDurationLink(request) || GeneralOrderingUtil.isCreateGeneralOrderingLink(request)) { + CreateRelationshipRequest createRequest = OccurrenceSpecificationUtil.getCreateRelationshipRequest(request); + if (createRequest != null) { + MessageEnd targetOccurrence; + Message message = getMessage(); + if (message != null) { + targetOccurrence = OccurrenceSpecificationUtil.isSource(getHostFigure(), request.getLocation()) ? message.getSendEvent() : message.getReceiveEvent(); + if (targetOccurrence instanceof OccurrenceSpecification) { + @SuppressWarnings("unchecked") + Map<Object, Object> extendedData = request.getExtendedData(); + extendedData.put(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence); + createRequest.setParameter(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence); + } + } + } + } + return super.getConnectionAndRelationshipCompleteCommand(request); + } + + @Override + protected Command getReconnectSourceCommand(ReconnectRequest request) { + // if (DurationLinkUtil.isDurationLink(request)) { + // // Bug 536639: Forbid reconnect on Duration edit parts + // return UnexecutableCommand.INSTANCE; + // } + return super.getReconnectSourceCommand(request); + } + + @Override + protected Command getReconnectTargetCommand(ReconnectRequest request) { + // if (DurationLinkUtil.isDurationLink(request)) { + // // Bug 536639: Forbid reconnect on Duration edit parts + // return UnexecutableCommand.INSTANCE; + // } + return super.getReconnectTargetCommand(request); + } + + private Message getMessage() { + EObject model = EMFHelper.getEObject(getHost()); + return model instanceof Message ? (Message) model : null; + } + + @Override + protected Connection createDummyConnection(Request req) { + if (req instanceof CreateConnectionRequest && DurationLinkUtil.isCreateDurationLink((CreateConnectionRequest) req)) { + return new DurationLinkFigure(); + } + return new PolylineConnection(); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDSequenceGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDSequenceGraphicalNodeEditPolicy.java index 8136e8306f5..0f4ee1de667 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDSequenceGraphicalNodeEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDSequenceGraphicalNodeEditPolicy.java @@ -56,6 +56,7 @@ import org.eclipse.gmf.runtime.emf.type.core.IHintedType; import org.eclipse.gmf.runtime.notation.Edge; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionFragmentEditPart; @@ -429,7 +430,7 @@ public class OLDSequenceGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy } Command command = super.getReconnectSourceCommand(request); // //Ordering message occurrence specifications after message reconnected, See https://bugs.eclipse.org/bugs/show_bug.cgi?id=403233 - if (command != null && command.canExecute()) { + if (command != null && command.canExecute() && request.getConnectionEditPart() instanceof AbstractMessageEditPart) { command = command.chain(FragmentsOrdererHelper.createOrderingFragmentsCommand(getHost(), request)); } return command; @@ -464,7 +465,7 @@ public class OLDSequenceGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy // } Command command = super.getReconnectTargetCommand(request); // Ordering message occurrence specifications after message reconnected, See https://bugs.eclipse.org/bugs/show_bug.cgi?id=403233 - if (command != null && command.canExecute()) { + if (command != null && command.canExecute() && request.getConnectionEditPart() instanceof AbstractMessageEditPart) { command = command.chain(FragmentsOrdererHelper.createOrderingFragmentsCommand(getHost(), request)); } return command; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ObservationLinkPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ObservationLinkPolicy.java deleted file mode 100644 index c075383ff73..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ObservationLinkPolicy.java +++ /dev/null @@ -1,638 +0,0 @@ -package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.draw2d.ConnectionAnchor; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.FeedbackHelper; -import org.eclipse.gef.requests.CreateConnectionRequest; -import org.eclipse.gef.requests.DropRequest; -import org.eclipse.gef.requests.ReconnectRequest; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; -import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; -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.GraphicalNodeEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; -import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.notation.IdentityAnchor; -import org.eclipse.gmf.runtime.notation.NotationFactory; -import org.eclipse.gmf.runtime.notation.RelativeBendpoints; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint; -import org.eclipse.gmf.runtime.notation.impl.ConnectorImpl; -import org.eclipse.papyrus.uml.diagram.sequence.ObservationLinkMetamodelType; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ObservationLinkEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineEditPartUtil; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil; -import org.eclipse.uml2.uml.DurationObservation; -import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification; -import org.eclipse.uml2.uml.Message; -import org.eclipse.uml2.uml.MessageOccurrenceSpecification; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.OccurrenceSpecification; -import org.eclipse.uml2.uml.TimeObservation; - -/** - * This policy is to process observation link creating, reconnecting - * - */ -public class ObservationLinkPolicy extends GraphicalNodeEditPolicy { - - private final EditPart editPart; - - public ObservationLinkPolicy(EditPart editPart) { - this.editPart = editPart; - } - - @Override - public Command getCommand(Request request) { - if (request instanceof CreateUnspecifiedTypeConnectionRequest) { - if (((CreateUnspecifiedTypeConnectionRequest) request).getElementTypes().contains(ObservationLinkMetamodelType.getInstance())) { - if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType())) { - return getConnectionCreateCommand((CreateConnectionRequest) request); - } - if (SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType())) { - return getConnectionCompleteCommand((CreateConnectionRequest) request); - } - } - return null; - } - if (request instanceof CreateConnectionRequest) { - CreateConnectionRequest cc = (CreateConnectionRequest) request; - if (cc.getNewObject() != null) { - if (cc.getNewObject() instanceof ObservationLink) { - if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType())) { - return getConnectionCreateCommand((CreateConnectionRequest) request); - } - if (SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType())) { - return getConnectionCompleteCommand((CreateConnectionRequest) request); - } - } - } - return null; - } - if (request instanceof ReconnectRequest) { - ReconnectRequest rr = (ReconnectRequest) request; - if (rr.getConnectionEditPart() instanceof ObservationLinkEditPart) { - if (SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_SOURCE.equals(request.getType())) { - return getReconnectSourceCommand((ReconnectRequest) request); - } - if (SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType())) { - return getReconnectTargetCommand((ReconnectRequest) request); - } - } - } - return null; - } - - @Override - public EditPart getTargetEditPart(Request request) { - if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType()) || SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType()) || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_SOURCE.equals(request.getType()) - || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType())) { - if (request instanceof CreateConnectionRequest) { - if (((CreateConnectionRequest) request).getSourceEditPart() instanceof TimeObservationLabelEditPart) { - if (getHost() instanceof AbstractMessageEditPart) { - return null; - } - } - } - if (SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType())) { - if (request instanceof ReconnectRequest) { - if (((ReconnectRequest) request).getConnectionEditPart().getSource() instanceof TimeObservationLabelEditPart) { - if (getHost() instanceof AbstractMessageEditPart) { - return null; - } - } - } - } - return getHost(); - } - return null; - } - - @Override - protected Command getConnectionCreateCommand(CreateConnectionRequest request) { - EditPart host = getHost(); - if (host instanceof TimeObservationLabelEditPart) { - TimeObservationLabelEditPart timeObservationLabelEditPart = (TimeObservationLabelEditPart) host; - if (timeObservationLabelEditPart.getSourceConnections().size() > 0) { - return null; - } - } else if (host instanceof DurationObservationEditPart) { - DurationObservationEditPart durationObservationEditPart = (DurationObservationEditPart) host; - if (durationObservationEditPart.getSourceConnections().size() > 0) { - return null; - } - } else { - return null; - } - CompositeCommand cc = new CompositeCommand(DiagramUIMessages.Commands_CreateCommand_Connection_Label); - CreateObservationLinkCommand cmd = new CreateObservationLinkCommand(((GraphicalEditPart) editPart).getEditingDomain(), "Create connection command", null); - cmd.setSourceEditPart(host); - cmd.setRequest(request); - cc.compose(cmd); - Command c = new ICommandProxy(cc); - request.setStartCommand(c); - return c; - } - - @Override - protected Command getConnectionCompleteCommand(final CreateConnectionRequest request) { - EditPart sourceEditPart = request.getSourceEditPart(); - if ((sourceEditPart instanceof TimeObservationLabelEditPart) && !(getHost() instanceof LifelineEditPart)) { - return null; - } else if (sourceEditPart instanceof DurationObservationEditPart && !(getHost() instanceof AbstractMessageEditPart)) { - return null; - } - ICommandProxy proxy = (ICommandProxy) request.getStartCommand(); - if (proxy == null) { - return null; - } - CompositeCommand result = new CompositeCommand("Add observation link command"); - if (sourceEditPart instanceof TimeObservationLabelEditPart) { - result.add(new UpdateTimeObservationLinkTargetElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request, getHost())); - } else if (sourceEditPart instanceof DurationObservationEditPart) { - result.add(new UpdateDurationObservationLinkTargetElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request, getHost())); - } - // 1: - CompositeCommand cc = (CompositeCommand) proxy.getICommand(); - Iterator commandItr = cc.iterator(); - CreateObservationLinkCommand createConnectorViewCommand = (CreateObservationLinkCommand) commandItr.next(); - createConnectorViewCommand.setSourceEditPart(request.getSourceEditPart()); - createConnectorViewCommand.setTargetEditPart(request.getTargetEditPart()); - result.add(cc); - return new ICommandProxy(result); - } - - @Override - protected Command getReconnectSourceCommand(final ReconnectRequest request) { - Command reconnectSourceCommand = super.getReconnectSourceCommand(request); - ICommandProxy proxy = (ICommandProxy) reconnectSourceCommand; - CompositeCommand cc = (CompositeCommand) proxy.getICommand(); - // update semantic model - if (request.getConnectionEditPart().getSource() instanceof TimeObservationLabelEditPart && getHost() instanceof TimeObservationLabelEditPart) { - TimeObservationLabelEditPart timeObservationLabelEditPart = (TimeObservationLabelEditPart) getHost(); - if (timeObservationLabelEditPart.getSourceConnections().size() > 0) { - return null; - } - cc.add(new UpdateTimeObservationLinkSourceElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request, getHost())); - } else if (request.getConnectionEditPart().getSource() instanceof DurationObservationEditPart && getHost() instanceof DurationObservationEditPart) { - DurationObservationEditPart durationObservationEditPart = (DurationObservationEditPart) getHost(); - if (durationObservationEditPart.getSourceConnections().size() > 0) { - return null; - } - cc.add(new UpdateDurationObservationLinkSourceElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request, getHost())); - } - return reconnectSourceCommand; - } - - @Override - protected Command getReconnectTargetCommand(final ReconnectRequest request) { - Command reconnectTargetCommand = super.getReconnectTargetCommand(request); - ICommandProxy proxy = (ICommandProxy) reconnectTargetCommand; - CompositeCommand cc = (CompositeCommand) proxy.getICommand(); - // update semantic model - if (request.getConnectionEditPart().getSource() instanceof TimeObservationLabelEditPart) { - cc.add(new UpdateTimeObservationLinkTargetElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request, getHost())); - } else if (request.getConnectionEditPart().getSource() instanceof DurationObservationEditPart) { - cc.add(new UpdateDurationObservationLinkTargetElementCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), "Update semantic model", null, request, getHost())); - } - return proxy; - } - - @Override - public void showSourceFeedback(Request request) { - if ((SequenceUtil.OBSERVATION_LINK_REQUEST_END).equals(request.getType())) { - showCreationFeedback((CreateConnectionRequest) request); - } - } - - @Override - protected FeedbackHelper getFeedbackHelper(CreateConnectionRequest request) { - if (feedbackHelper == null) { - feedbackHelper = new FeedbackHelper(); - Point p = request.getLocation(); - connectionFeedback = createDummyConnection(request); - connectionFeedback.setConnectionRouter(getDummyConnectionRouter(request)); - connectionFeedback.setSourceAnchor(getSourceConnectionAnchor(request)); - connectionFeedback.setForegroundColor(ColorConstants.black); - feedbackHelper.setConnection(connectionFeedback); - addFeedback(connectionFeedback); - feedbackHelper.update(null, p); - } - return feedbackHelper; - } - - @Override - public void showTargetFeedback(Request request) { - if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType()) || SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType()) || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_SOURCE.equals(request.getType()) - || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType())) { - showTargetConnectionFeedback((DropRequest) request); - } - } - - @Override - public void eraseSourceFeedback(Request request) { - if (SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType())) { - eraseCreationFeedback((CreateConnectionRequest) request); - } - } - - @Override - public void eraseTargetFeedback(Request request) { - if (SequenceUtil.OBSERVATION_LINK_REQUEST_START.equals(request.getType()) || SequenceUtil.OBSERVATION_LINK_REQUEST_END.equals(request.getType()) || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_SOURCE.equals(request.getType()) - || SequenceUtil.OBSERVATION_LINK_REQUEST_RECONNECT_TARGET.equals(request.getType())) { - eraseTargetConnectionFeedback((DropRequest) request); - } - } - - private class UpdateDurationObservationLinkSourceElementCommand extends AbstractTransactionalCommand { - - private final ReconnectRequest request; - - private EditPart hostPart; - - private DurationObservationEditPart sourceTolEP; - - List<OccurrenceSpecification> occList = Collections.emptyList(); - - public UpdateDurationObservationLinkSourceElementCommand(TransactionalEditingDomain domain, String label, List affectedFiles, ReconnectRequest request, EditPart hostPart) { - super(domain, label, affectedFiles); - this.request = request; - sourceTolEP = (DurationObservationEditPart) request.getConnectionEditPart().getSource(); - this.hostPart = hostPart; - } - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - if (sourceTolEP == hostPart) { - return CommandResult.newCancelledCommandResult(); - } - View sourceView = (View) sourceTolEP.getModel(); - DurationObservation sourceDurationObservation = (DurationObservation) sourceView.getElement(); - DurationObservationEditPart targetDoEP = (DurationObservationEditPart) hostPart; - View targetView = (View) targetDoEP.getModel(); - DurationObservation targetDurationObservation = (DurationObservation) targetView.getElement(); - targetDurationObservation.getEvents().addAll(sourceDurationObservation.getEvents()); - sourceDurationObservation.getEvents().clear(); - return CommandResult.newOKCommandResult(); - } - - @Override - public boolean canExecute() { - if (hostPart instanceof DurationObservationEditPart) { - return true; - } - return false; - } - } - - public class UpdateDurationObservationLinkTargetElementCommand extends AbstractTransactionalCommand { - - private final Request request; - - private EditPart hostPart; - - public UpdateDurationObservationLinkTargetElementCommand(TransactionalEditingDomain domain, String label, List affectedFiles, Request request, EditPart hostPart) { - super(domain, label, affectedFiles); - this.request = request; - this.hostPart = hostPart; - } - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - DurationObservationEditPart doEP = null; - if (request instanceof CreateConnectionRequest) { - doEP = (DurationObservationEditPart) (((CreateConnectionRequest) request).getSourceEditPart()); - } else if (request instanceof ReconnectRequest) { - doEP = (DurationObservationEditPart) (((ReconnectRequest) request).getConnectionEditPart().getSource()); - } - View view = (View) doEP.getModel(); - DurationObservation durationObservation = (DurationObservation) view.getElement(); - EList<NamedElement> events = durationObservation.getEvents(); - // if is reconnect operation, first remove orginal message event of DurationObservation - if (request instanceof ReconnectRequest) { - events.clear(); - } - Map<String, Object> extendedData = request.getExtendedData(); - // assign the occurrence specification - Object paramOcc1 = extendedData.get(org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION); - Object paramOcc2 = extendedData.get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2); - if (paramOcc1 != null && paramOcc2 != null) { - events.add((OccurrenceSpecification) paramOcc1); - events.add((OccurrenceSpecification) paramOcc2); - } - return CommandResult.newOKCommandResult(); - } - - @Override - public boolean canExecute() { - if (hostPart instanceof ConnectionNodeEditPart) { - Map<String, Object> extendedData = request.getExtendedData(); - if (hostPart instanceof AbstractMessageEditPart) { - AbstractMessageEditPart messageEP = (AbstractMessageEditPart) hostPart; - View view = (View) messageEP.getModel(); - Message message = (Message) view.getElement(); - if (message.getSendEvent() != null) { - extendedData.put(org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION, message.getSendEvent()); - } - if (message.getReceiveEvent() != null) { - extendedData.put(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2, message.getReceiveEvent()); - } - } - if (extendedData.containsKey(org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION) && extendedData.containsKey(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2)) { - return true; - } - } - return false; - } - } - - private class UpdateTimeObservationLinkSourceElementCommand extends AbstractTransactionalCommand { - - private final ReconnectRequest request; - - private EditPart hostPart; - - private TimeObservationLabelEditPart sourceTolEP; - - List<OccurrenceSpecification> occList = Collections.emptyList(); - - public UpdateTimeObservationLinkSourceElementCommand(TransactionalEditingDomain domain, String label, List affectedFiles, ReconnectRequest request, EditPart hostPart) { - super(domain, label, affectedFiles); - this.request = request; - sourceTolEP = (TimeObservationLabelEditPart) request.getConnectionEditPart().getSource(); - this.hostPart = hostPart; - } - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - if (sourceTolEP == hostPart) { - return CommandResult.newCancelledCommandResult(); - } - View sourceView = (View) sourceTolEP.getModel(); - TimeObservation sourceTimeObservation = (TimeObservation) sourceView.getElement(); - TimeObservationLabelEditPart targetTolEP = (TimeObservationLabelEditPart) hostPart; - View targetView = (View) targetTolEP.getModel(); - TimeObservation targetTimeObservation = (TimeObservation) targetView.getElement(); - targetTimeObservation.setEvent(sourceTimeObservation.getEvent()); - sourceTimeObservation.setEvent(null); - return CommandResult.newOKCommandResult(); - } - - @Override - public boolean canExecute() { - if (hostPart instanceof TimeObservationLabelEditPart) { - return true; - } - return false; - } - } - - private class UpdateTimeObservationLinkTargetElementCommand extends AbstractTransactionalCommand { - - private final Request request; - - private EditPart hostPart; - - List<OccurrenceSpecification> occList = Collections.emptyList(); - - public UpdateTimeObservationLinkTargetElementCommand(TransactionalEditingDomain domain, String label, List affectedFiles, Request request, EditPart hostPart) { - super(domain, label, affectedFiles); - this.request = request; - this.hostPart = hostPart; - } - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - TimeObservationLabelEditPart tolEP = null; - if (request instanceof CreateConnectionRequest) { - tolEP = (TimeObservationLabelEditPart) (((CreateConnectionRequest) request).getSourceEditPart()); - } else if (request instanceof ReconnectRequest) { - tolEP = (TimeObservationLabelEditPart) (((ReconnectRequest) request).getConnectionEditPart().getSource()); - } - View view = (View) tolEP.getModel(); - TimeObservation timeObservation = (TimeObservation) view.getElement(); - // assign the occurrence specification - if (!occList.isEmpty()) { - for (OccurrenceSpecification occurrence : occList) { - // Not needed since fixed bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=402975 - /* - * if(occurrence instanceof MessageOccurrenceSpecification) { - * Message mess = ((MessageOccurrenceSpecification)occurrence).getMessage(); - * if(mess.getReceiveEvent().equals(occurrence) && MessageSort.SYNCH_CALL_LITERAL.equals(mess.getMessageSort())) { - * // filter receive event, we prefer the corresponding - * // start event at the same location - * continue; - * } - * } - */ - // otherwise, first occ is just fine - timeObservation.setEvent(occurrence); - break; - } - } - // reset request vertical location - if (timeObservation.getEvent() instanceof MessageOccurrenceSpecification) { - Point messageOccurrenceLoc = SequenceUtil.findLocationOfMessageOccurrence((GraphicalEditPart) hostPart, (MessageOccurrenceSpecification) timeObservation.getEvent()); - setRequestLocation(messageOccurrenceLoc); - } else if (timeObservation.getEvent() instanceof ExecutionOccurrenceSpecification) { - Point executionOccurrenceLoc = SequenceUtil.findLocationOfExecutionOccurrence((GraphicalEditPart) hostPart, (ExecutionOccurrenceSpecification) timeObservation.getEvent()); - setRequestLocation(executionOccurrenceLoc); - } - return CommandResult.newOKCommandResult(); - } - - private void setRequestLocation(Point occurrenceLoc) { - if (occurrenceLoc == null) { - return; - } - if (request instanceof CreateConnectionRequest) { - CreateConnectionRequest req = (CreateConnectionRequest) request; - req.setLocation(new Point(req.getLocation().x, occurrenceLoc.y)); - } else if (request instanceof ReconnectRequest) { - ReconnectRequest req = (ReconnectRequest) request; - req.setLocation(new Point(req.getLocation().x, occurrenceLoc.y)); - } - } - - @Override - public boolean canExecute() { - if (hostPart instanceof LifelineEditPart) { - Point location = null; - if (request instanceof CreateConnectionRequest) { - location = ((CreateConnectionRequest) request).getLocation(); - } else if (request instanceof ReconnectRequest) { - location = ((ReconnectRequest) request).getLocation(); - } - Entry<Point, List<OccurrenceSpecification>> eventAndLocation = SequenceUtil.findNearestEvent(location, (LifelineEditPart) hostPart); - // find an event near enough to create the - // constraint or observation - occList = Collections.emptyList(); - if (eventAndLocation != null) { - occList = eventAndLocation.getValue(); - } - if (!occList.isEmpty()) { - /* - * for(OccurrenceSpecification occurrence : occList) { - * if(occurrence instanceof MessageOccurrenceSpecification) { - * Message mess = ((MessageOccurrenceSpecification)occurrence).getMessage(); - * if(mess.getReceiveEvent().equals(occurrence) && MessageSort.SYNCH_CALL_LITERAL.equals(mess.getMessageSort())) { - * // filter receive event, we prefer the - * // corresponding - * // start event at the same location - * continue; - * } - * } - * return true; - * } - */ - // Not needed since fixed bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=402975 - return true; - } - } - return false; - } - } - - private class CreateObservationLinkCommand extends AbstractTransactionalCommand { - - private EditPart sourceEditPart; - - private EditPart targetEditPart; - - private CreateConnectionRequest request; - - private ObservationLink c; - - private String newSourceTerminal; - - public CreateObservationLinkCommand(TransactionalEditingDomain domain, String label, List affectedFiles) { - super(domain, label, affectedFiles); - } - - public void setSourceEditPart(EditPart sourceEditPart) { - this.sourceEditPart = sourceEditPart; - } - - public void setTargetEditPart(EditPart targetEditPart) { - this.targetEditPart = targetEditPart; - } - - public void setRequest(CreateConnectionRequest request) { - this.request = request; - } - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - c = new ObservationLink(); - c.setType(SequenceUtil.OBSERVATION_LINK_TYPE); - c.setElement(null); - View newSourceView = (View) sourceEditPart.getModel(); - c.setSource(newSourceView); - ViewUtil.insertChildView(newSourceView.getDiagram(), c, -1, true); - INodeEditPart ce = (INodeEditPart) sourceEditPart; - ConnectionAnchor sourceAnchor = ce.getSourceConnectionAnchor(request); - newSourceTerminal = ce.mapConnectionAnchorToTerminal(sourceAnchor); - if (newSourceTerminal != null) { - if (newSourceTerminal.length() == 0) { - c.setSourceAnchor(null); - } else { - IdentityAnchor a = (IdentityAnchor) c.getSourceAnchor(); - if (a == null) { - a = NotationFactory.eINSTANCE.createIdentityAnchor(); - } - a.setId(newSourceTerminal); - c.setSourceAnchor(a); - } - } - initCompleteCommand(); - return CommandResult.newOKCommandResult(); - } - - private void initCompleteCommand() { - // reset the target edit-part for the request - if (targetEditPart != null) { - View newTargetView = ((IGraphicalEditPart) targetEditPart).getNotationView(); - c.setTarget(newTargetView); - // 3: - INodeEditPart ce = (INodeEditPart) targetEditPart; - ConnectionAnchor targetAnchor = null; - if (ce instanceof LifelineEditPart) { - LifelineEditPart lifelinePart = (LifelineEditPart) ce; - targetAnchor = LifelineEditPartUtil.getNodeFigure(lifelinePart).getTargetConnectionAnchorAt(request.getLocation()); - } else { - targetAnchor = ce.getTargetConnectionAnchor(request); - } - String newTargetTerminal = ce.mapConnectionAnchorToTerminal(targetAnchor); - if (newTargetTerminal != null) { - if (newTargetTerminal.length() == 0) { - c.setTargetAnchor(null); - } else { - IdentityAnchor a = (IdentityAnchor) c.getTargetAnchor(); - if (a == null) { - a = NotationFactory.eINSTANCE.createIdentityAnchor(); - } - a.setId(newTargetTerminal); - c.setTargetAnchor(a); - } - } - // 4: - INodeEditPart sourceEditPart = (INodeEditPart) request.getSourceEditPart(); - ConnectionAnchor sourceAnchor = sourceEditPart.mapTerminalToConnectionAnchor(newSourceTerminal); - 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())); - } - List newBendpoints = new ArrayList(); - int numOfPoints = pointList.size(); - for (short i = 0; i < numOfPoints; i++) { - Dimension s = pointList.getPoint(i).getDifference(sourceAnchor.getReferencePoint()); - Dimension t = pointList.getPoint(i).getDifference(targetAnchor.getReferencePoint()); - newBendpoints.add(new RelativeBendpoint(s.width, s.height, t.width, t.height)); - } - RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); - bendpoints.setPoints(newBendpoints); - c.setBendpoints(bendpoints); - } - } - } - - public static class ObservationLink extends ConnectorImpl { - - public ObservationLink() { - super(); - } - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OccurenceSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OccurenceSemanticEditPolicy.java new file mode 100644 index 00000000000..25d7c2faac3 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OccurenceSemanticEditPolicy.java @@ -0,0 +1,145 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.commands.Command; +import org.eclipse.gef.requests.ReconnectRequest; +import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.SemanticEditPolicy; +import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.GeneralOrderingUtil; +import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationUtil; +import org.eclipse.uml2.uml.ExecutionSpecification; +import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.OccurrenceSpecification; + +/** + * A {@link SemanticEditPolicy} that is able to target specific {@link OccurrenceSpecification}s + * from a request (Typically for {@link Message#getSendEvent()},{@link Message#getReceiveEvent()}, + * {@link ExecutionSpecification#getStart()} and {@link ExecutionSpecification#getFinish()}) + */ +public class OccurenceSemanticEditPolicy extends DefaultSemanticEditPolicy { + + /** + * {@inheritDoc} + * + * <p> + * Overridden to support {@link ReconnectRequest}, when only the anchor changes, referencing + * a different {@link OccurrenceSpecification} on the same edit part. + * </p> + * + * @param request + * @return + */ + @Override + public Command getCommand(Request request) { + if (REQ_RECONNECT_SOURCE.equals(request.getType()) + && relationshipSourceHasChanged((ReconnectRequest) request)) { + EditPart connectionEP = ((ReconnectRequest) request) + .getConnectionEditPart(); + if (ViewUtil.resolveSemanticElement((View) connectionEP.getModel()) == null) { + return getReorientRefRelationshipSourceCommand((ReconnectRequest) request); + } else { + return getReorientRelationshipSourceCommand((ReconnectRequest) request); + } + } else if (REQ_RECONNECT_TARGET.equals(request.getType()) + && relationshipTargetHasChanged((ReconnectRequest) request)) { + EditPart connectionEP = ((ReconnectRequest) request) + .getConnectionEditPart(); + if (ViewUtil.resolveSemanticElement((View) connectionEP.getModel()) == null) { + return getReorientRefRelationshipTargetCommand((ReconnectRequest) request); + } else { + return getReorientRelationshipTargetCommand((ReconnectRequest) request); + } + } + return super.getCommand(request); + } + + protected boolean relationshipSourceHasChanged(ReconnectRequest request) { + if (!request.getConnectionEditPart().getSource().equals(request.getTarget())) { + // Connecting different edit parts + return true; + } else if (request.getConnectionEditPart().getModel() instanceof Edge) { + // Connecting different occurrences on the same edit part (Source vs Target, Start vs Finish...) + Edge edge = (Edge) request.getConnectionEditPart().getModel(); + return OccurrenceSpecificationUtil.getSourceOccurrence(edge) != OccurrenceSpecificationUtil.getOccurrence(request); + } + return false; + } + + protected boolean relationshipTargetHasChanged(ReconnectRequest request) { + if (!request.getConnectionEditPart().getTarget().equals(request.getTarget())) { + // Connecting different edit parts + return true; + } else if (request.getConnectionEditPart().getModel() instanceof Edge) { + // Connecting different occurrences on the same edit part (Source vs Target, Start vs Finish...) + Edge edge = (Edge) request.getConnectionEditPart().getModel(); + return OccurrenceSpecificationUtil.getTargetOccurrence(edge) != OccurrenceSpecificationUtil.getOccurrence(request); + } + return false; + } + + @Override + protected Command getReorientRelationshipSourceCommand(ReconnectRequest request) { + if (GeneralOrderingUtil.isGeneralOrderingLink(request) || DurationLinkUtil.isDurationLink(request)) { + EObject connectionSemElement = ViewUtil.resolveSemanticElement(((View) request.getConnectionEditPart() + .getModel())); + EObject targetSemElement = OccurrenceSpecificationUtil.getOccurrence(request); + EObject oldSemElement = OccurrenceSpecificationUtil.getSourceOccurrence((Edge) request.getConnectionEditPart().getModel()); + + TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()) + .getEditingDomain(); + ReorientRelationshipRequest semRequest = new ReorientRelationshipRequest( + editingDomain, connectionSemElement, targetSemElement, + oldSemElement, ReorientRelationshipRequest.REORIENT_SOURCE); + + semRequest.addParameters(request.getExtendedData()); + + return getSemanticCommand(semRequest); + } + + return super.getReorientRefRelationshipSourceCommand(request); + } + + @Override + protected Command getReorientRelationshipTargetCommand(ReconnectRequest request) { + if (GeneralOrderingUtil.isGeneralOrderingLink(request) || DurationLinkUtil.isDurationLink(request)) { + EObject connectionSemElement = ViewUtil.resolveSemanticElement((View) request.getConnectionEditPart().getModel()); + EObject targetSemElement = OccurrenceSpecificationUtil.getOccurrence(request); + EObject oldSemElement = OccurrenceSpecificationUtil.getTargetOccurrence((Edge) request.getConnectionEditPart().getModel()); + + TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()) + .getEditingDomain(); + ReorientRelationshipRequest semRequest = new ReorientRelationshipRequest( + editingDomain, connectionSemElement, targetSemElement, + oldSemElement, ReorientRelationshipRequest.REORIENT_TARGET); + + semRequest.addParameters(request.getExtendedData()); + + return getSemanticCommand(semRequest); + } + + return super.getReorientRelationshipTargetCommand(request); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeElementCreationFeedbackEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeElementCreationFeedbackEditPolicy.java new file mode 100644 index 00000000000..ab8c9685b5e --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeElementCreationFeedbackEditPolicy.java @@ -0,0 +1,202 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; + +import java.util.Set; +import java.util.function.Function; + +import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.RectangleFigure; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.Request; +import org.eclipse.gef.editpolicies.GraphicalEditPolicy; +import org.eclipse.gef.requests.DropRequest; +import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure; +import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; +import org.eclipse.gmf.runtime.diagram.ui.requests.DropObjectsRequest; +import org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.ISpecializationType; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectUnspecifiedTypeCreationTool.CreateAspectUnspecifiedTypeRequest; +import org.eclipse.papyrus.infra.services.edit.utils.ElementTypeUtils; +import org.eclipse.papyrus.uml.diagram.sequence.locator.CenterLocator; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; + +import com.google.common.collect.ImmutableSet; + +/** + * Feed-back edit-policy for creation of time constraints and time observations + * on various elements in the sequence diagram. + */ +public class TimeElementCreationFeedbackEditPolicy extends GraphicalEditPolicy { + + public static final String ROLE = "TimeElementCreationFeedback"; //$NON-NLS-1$ + + private final Function<? super IFigure, ? extends IBorderItemLocator> locatorFunction; + private IBorderItemLocator locator; + private IFigure feedback; + + /** + * Initializes me. + */ + public TimeElementCreationFeedbackEditPolicy() { + this(fig -> new CenterLocator(fig, PositionConstants.NONE)); + } + + public TimeElementCreationFeedbackEditPolicy(Function<? super IFigure, ? extends IBorderItemLocator> locatorFunction) { + super(); + + this.locatorFunction = locatorFunction; + } + + protected IBorderItemLocator getFeedbackLocator() { + if (locator == null) { + locator = locatorFunction.apply(getFeedbackParent()); + } + return locator; + } + + IFigure getFeedbackParent() { + IFigure result = getHostFigure(); + if (result instanceof BorderedNodeFigure) { + // Unwrap to get the figure on which border items are presented + result = ((BorderedNodeFigure) result).getMainFigure(); + } + return result; + } + + @Override + public void showTargetFeedback(Request request) { + IElementType typeToShow = getCreatedElementType(request); + if (isTimeElementType(typeToShow)) { + IFigure feedback = requireFeedback(); + + // Use our locator to present the feed-back in the place where the edit-part + // would end up putting the resulting element + IBorderItemLocator locator = getFeedbackLocator(); + Point where = getRelativeLocation(request); + Rectangle proposedLocation = new Rectangle(where, feedback.getSize()); + locator.setConstraint(proposedLocation); + + // Resolve the appropriate location in the feedback layer + Rectangle resolved = locator.getValidLocation(proposedLocation, feedback); + resolved.translate(0, -resolved.height() / 2); // Center on the mouse + getFeedbackParent().translateToAbsolute(resolved); + getFeedbackLayer().translateToRelative(resolved); + feedback.setBounds(resolved); + } + } + + /** + * Determine the element type being created that is a time element for which + * we provide feed-back. + * + * @param request + * the create/drop request + * @return the element type to be created/dropped, or {@code null} if indeterminate + */ + protected IElementType getCreatedElementType(Request request) { + IElementType result = null; + + if (request instanceof CreateAspectUnspecifiedTypeRequest) { + CreateAspectUnspecifiedTypeRequest createReq = (CreateAspectUnspecifiedTypeRequest) request; + if (createReq.getElementTypes().size() == 1) { + result = (IElementType) createReq.getElementTypes().get(0); + } + } else if (request instanceof DropObjectsRequest) { + // Not creating the element, but creating the view, so infer the type from the element + DropObjectsRequest dropReq = (DropObjectsRequest) request; + if (dropReq.getObjects().size() == 1) { + EObject element = EMFHelper.getEObject(dropReq.getObjects().get(0)); + if (element != null) { + result = ElementTypeRegistry.getInstance().getElementType(element, ElementTypeUtils.getDefaultClientContext()); + } + } + } + + return result; + } + + protected boolean isTimeElementType(IElementType type) { + boolean result = false; + + if (type != null) { + final Set<IElementType> types = ImmutableSet.of(UMLElementTypes.TIME_CONSTRAINT, + UMLElementTypes.TIME_OBSERVATION); + result = types.contains(type); + if (!result && type instanceof ISpecializationType) { + // Try subtypes + ISpecializationType spec = (ISpecializationType) type; + result = types.stream().anyMatch(spec::isSpecializationOf); + } + } + + return result; + } + + protected Point getRelativeLocation(Request request) { + Point result = null; + + // There are other requests that implement distinct getLocation API but + // we aren't interested in those + if (request instanceof DropRequest) { + result = ((DropRequest) request).getLocation(); + } + if (result != null) { + // Don't destroy the request's data + result = result.getCopy(); + getFeedbackParent().translateToRelative(result); + } else { + // Assume top left for want of anything requested + result = new Point(); + } + + return result; + } + + protected IFigure getFeedback() { + if (feedback == null) { + feedback = new RectangleFigure(); + feedback.setForegroundColor(ColorConstants.gray); + feedback.setBackgroundColor(ColorConstants.gray); + feedback.setSize(60, 5); // Make it thicker so that it's obvious + } + return feedback; + } + + protected IFigure requireFeedback() { + IFigure result = getFeedback(); + if (result.getParent() == null) { + // Add it now because we need to show it + addFeedback(result); + } + return result; + } + + @Override + public void eraseTargetFeedback(Request request) { + if (feedback != null && feedback.getParent() != null) { + // Remove it from the scene + removeFeedback(feedback); + } + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeRelatedSelectionEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeRelatedSelectionEditPolicy.java deleted file mode 100644 index 4adc38ab280..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeRelatedSelectionEditPolicy.java +++ /dev/null @@ -1,152 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Atos Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PrecisionRectangle; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.common.util.EList; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.UnexecutableCommand; -import org.eclipse.gef.requests.ChangeBoundsRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.notation.Bounds; -import org.eclipse.gmf.runtime.notation.Node; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationMoveHelper; -import org.eclipse.uml2.uml.DurationConstraint; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification; -import org.eclipse.uml2.uml.ExecutionSpecification; - -/** - * Edit policy to restrict border item movement. This edit policy moves the related events when a Time/Duration Observation/Constraint is moved. - */ -public class TimeRelatedSelectionEditPolicy extends BorderItemSelectionEditPolicy { - - @Override - protected Command getMoveCommand(ChangeBoundsRequest request) { - updateRequest(request); - // Prepare request - if (getHost() instanceof IBorderItemEditPart) { - OccurrenceSpecificationMoveHelper.prepareTimeRelatedElementMoveRequest(request, (IBorderItemEditPart) getHost()); - } - // In fact, BorderItem can not be moved out of parent bounds, so the moveDelta if not correctly when move out parent. - Command command = super.getMoveCommand(request); - if (command != null) { - if (invalidMoveDurationConstraint(request.getMoveDelta())) { - return UnexecutableCommand.INSTANCE; - } - command = OccurrenceSpecificationMoveHelper.completeMoveTimeRelatedElementCommand(command, request, getHost(), getHostFigure()); - } - return command; - } - - /** - * Bug description: - * When we move down the Duration Constraint which attached to a Execution Specification, the Execution Specification can be moved out it's Parent - * Execution Specification. This would not happen when move Execution Specification directly. - * - * At present, we just avoid this kind of moving. - */ - private boolean invalidMoveDurationConstraint(Point moveDelta) { - if (!(getHost() instanceof DurationConstraintEditPart) || moveDelta == null || moveDelta.y == 0) { - return false; - } - DurationConstraintEditPart editPart = (DurationConstraintEditPart) getHost(); - DurationConstraint durationConstraint = (DurationConstraint) editPart.resolveSemanticElement(); - EList<Element> constrainedElements = durationConstraint.getConstrainedElements(); - List<ExecutionSpecification> executions = new ArrayList<>(); - for (Element element : constrainedElements) { - if (!(element instanceof ExecutionOccurrenceSpecification)) { - continue; - } - ExecutionSpecification execution = ((ExecutionOccurrenceSpecification) element).getExecution(); - if (execution != null && !executions.contains(execution)) { - executions.add(execution); - } - } - if (executions.isEmpty()) { - return false; - } - // LifelineEditPart lifelineEditPart = (LifelineEditPart)getHost().getParent(); - // for(ExecutionSpecification executionSpecification : executions) { - // Collection<Setting> settings = CacheAdapter.getInstance().getNonNavigableInverseReferences(executionSpecification); - // for(Setting ref : settings) { - // if(NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) { - // View view = (View)ref.getEObject(); - // EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, getHost()); - // if(!(part instanceof ShapeNodeEditPart)) { - // continue; - // } - // Rectangle childBounds = ((ShapeNodeEditPart)part).getFigure().getBounds().getCopy(); - // List<ShapeNodeEditPart> toCheckExecutionSpecificationList = new ArrayList<ShapeNodeEditPart>(lifelineEditPart.getChildShapeNodeEditPart()); - // toCheckExecutionSpecificationList.remove(part); - // ShapeNodeEditPart parent = LifelineXYLayoutEditPolicy.getParent(lifelineEditPart, childBounds, toCheckExecutionSpecificationList); - // if(parent != null) { - // Rectangle parentBounds = parent.getFigure().getBounds().getCopy(); - // if(childBounds.y + moveDelta.y >= parentBounds.bottom() - 1) { - // return true; - // } - // } - // } - // } - // } - return true; - } - - /** - * By default, the IBorderItemEditPart can not be moved out of the parent. - * - * @param request - */ - private void updateRequest(ChangeBoundsRequest request) { - IBorderItemEditPart borderItemEP = (IBorderItemEditPart) getHost(); - IBorderItemLocator borderItemLocator = borderItemEP.getBorderItemLocator(); - if (borderItemLocator != null) { - Rectangle initialFeedbackBounds = getInitialFeedbackBounds(); - PrecisionRectangle rect = new PrecisionRectangle(initialFeedbackBounds.getCopy()); - getHostFigure().translateToAbsolute(rect); - rect.translate(request.getMoveDelta()); - rect.resize(request.getSizeDelta()); - getHostFigure().translateToRelative(rect); - Rectangle realLocation = borderItemLocator.getValidLocation(rect.getCopy(), borderItemEP.getFigure()); - Point parentOrigin = borderItemEP.getFigure().getParent().getBounds().getTopLeft(); - Dimension d = realLocation.getTopLeft().getDifference(parentOrigin); - Point newLocation = new Point(d.width, d.height); - if (getHost().getModel() instanceof Node && ((Node) getHost().getModel()).getLayoutConstraint() instanceof Bounds) { - Bounds bounds = (Bounds) ((Node) getHost().getModel()).getLayoutConstraint(); - Point moveDelta = request.getMoveDelta(); - moveDelta.x = newLocation.x - bounds.getX(); - moveDelta.y = newLocation.y - bounds.getY(); - } - } - } - - @Override - protected void showChangeBoundsFeedback(ChangeBoundsRequest request) { - if (getHost() instanceof IBorderItemEditPart) { - OccurrenceSpecificationMoveHelper.prepareTimeRelatedElementMoveRequest(request, (IBorderItemEditPart) getHost()); - } - super.showChangeBoundsFeedback(request); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java index 26c8cc36cfc..73c501b53b0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java @@ -31,7 +31,7 @@ import org.eclipse.gef.RequestConstants; import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.requests.ReconnectRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest; import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx; import org.eclipse.gmf.runtime.notation.View; @@ -132,8 +132,8 @@ public class UpdateWeakReferenceForMessageSpecEditPolicy extends UpdateWeakRefer for (OccurrenceSpecification nextEvent : nextEventsFromPosition) { UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "\tNext Event: " + nextEvent); - GraphicalEditPart sourceLifeLineEP = (GraphicalEditPart) createRequest.getSourceEditPart(); - GraphicalEditPart targetLifeLineEP = (GraphicalEditPart) createRequest.getTargetEditPart(); + IGraphicalEditPart sourceLifeLineEP = (IGraphicalEditPart) createRequest.getSourceEditPart(); + IGraphicalEditPart targetLifeLineEP = (IGraphicalEditPart) createRequest.getTargetEditPart(); ArrayList<EditPart> senderList = SenderRequestUtils.getSenders(request); List<?> connectionsAndChildren = new ArrayList<>(); @@ -149,7 +149,7 @@ public class UpdateWeakReferenceForMessageSpecEditPolicy extends UpdateWeakRefer } for (Object editPart : connectionsAndChildren) { - if (editPart instanceof ConnectionEditPart) { + if (editPart instanceof AbstractMessageEditPart) { EObject element = ((View) ((AbstractMessageEditPart) editPart).getAdapter(View.class)).getElement(); if (element instanceof Message && null != ((Message) element).getSendEvent() && ((Message) element).getSendEvent().equals(nextEvent) || element instanceof Message && null != ((Message) element).getReceiveEvent() && ((Message) element).getReceiveEvent().equals(nextEvent)) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java index e19631c7c98..92b7a0241c8 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java @@ -91,9 +91,6 @@ public class CustomGeneralOrderingDescriptor extends GeneralOrderingDescriptor i add(fAppliedStereotypeLabel); } - /** - * @generated - */ private RotatableDecoration createTargetDecoration() { PolygonDecoration df = new PolygonDecoration(); df.setFill(true); @@ -153,7 +150,6 @@ public class CustomGeneralOrderingDescriptor extends GeneralOrderingDescriptor i * Set the middle decoration * * @see org.eclipse.draw2d.PolylineConnection#setTargetDecoration(org.eclipse.draw2d.RotatableDecoration) - * @generated NOT */ public void setMiddleDecoration(RotatableDecoration dec) { if (getMiddleDecoration() != null) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java index 6d2ca825903..cf06364d3eb 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2005 AIRBUS FRANCE. + * Copyright (c) 2005, 2018 AIRBUS FRANCE, CEA LIST, EclipseSource and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,37 +14,32 @@ * Jacques Lescot (Anyware Technologies), * Thomas Friol (Anyware Technologies), * Nicolas Lalevee (Anyware Technologies) - initial API and implementation - * + * EclipseSource - Bug 536638, Bug 536641 ****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.figures; +import org.eclipse.draw2d.ConnectionAnchor; import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.CenterAnchor; +import org.eclipse.uml2.uml.DestructionOccurrenceSpecification; /** - * <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated + * Figure for a {@link DestructionOccurrenceSpecification}. It is drawn as an X centered over a Lifeline body */ -public class DestructionEventFigure extends org.eclipse.draw2d.Figure { +public class DestructionEventFigure extends DefaultSizeNodeFigure { + + private int lineWidth = 1; /** * Constructor <!-- begin-user-doc --> <!-- end-user-doc --> - * - * @generated */ public DestructionEventFigure() { - super(); - } - /** - * @return a <code>Dimension</code> that represents the minimum or default size of - * this figure. - * @since 3.0 - */ - public Dimension getDefaultSize() { - return new Dimension(40,40); + super(40, 40); } + /** * The stop is a cross * @@ -55,11 +50,12 @@ public class DestructionEventFigure extends org.eclipse.draw2d.Figure { super.paintFigure(graphics); graphics.pushState(); graphics.setLineWidth(2); - graphics.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height); - graphics.drawLine(bounds.x, bounds.y+ bounds.height, bounds.x + bounds.width, bounds.y); + graphics.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height); + graphics.drawLine(bounds.x, bounds.y + bounds.height, bounds.x + bounds.width, bounds.y); graphics.popState(); } + @Override public void setLineWidth(int w) { if ((lineWidth == w) || (w < 0)) { return; @@ -68,5 +64,20 @@ public class DestructionEventFigure extends org.eclipse.draw2d.Figure { repaint(); } - private int lineWidth = 1; + @Override + public ConnectionAnchor getConnectionAnchor(String terminal) { + if (AnchorConstants.CENTER_TERMINAL.equals(terminal)) { + return new CenterAnchor(this); + } + return super.getConnectionAnchor(terminal); + } + + @Override + public String getConnectionAnchorTerminal(ConnectionAnchor c) { + if (c instanceof CenterAnchor) { + return AnchorConstants.CENTER_TERMINAL; + } + return super.getConnectionAnchorTerminal(c); + } + } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventNodePlate.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventNodePlate.java new file mode 100644 index 00000000000..6612cb05b58 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventNodePlate.java @@ -0,0 +1,57 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.sequence.figures; + +import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.LinkLFSVGNodePlateFigure; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.CenterAnchor; + +/** + * <p> + * Custom {@link LinkLFSVGNodePlateFigure} to support custom Anchors for the Destruction + * Figure. + * </p> + * + * @see CenterAnchor + * @see AnchorConstants#CENTER_TERMINAL + */ +public class DestructionEventNodePlate extends RoundedRectangleNodePlateFigure { + + public DestructionEventNodePlate(Dimension defSize) { + super(defSize); + } + + public DestructionEventNodePlate(int width, int height) { + super(width, height); + } + + @Override + public ConnectionAnchor getConnectionAnchor(String terminal) { + if (AnchorConstants.CENTER_TERMINAL.equals(terminal)) { + return new CenterAnchor(this); + } + return super.getConnectionAnchor(terminal); + } + + @Override + public String getConnectionAnchorTerminal(ConnectionAnchor c) { + if (c instanceof CenterAnchor) { + return AnchorConstants.CENTER_TERMINAL; + } + return super.getConnectionAnchorTerminal(c); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationConstraintFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationConstraintFigure.java deleted file mode 100644 index afc3993eb65..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationConstraintFigure.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * 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 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * CEA LIST - Initial API and implementation - */ -package org.eclipse.papyrus.uml.diagram.sequence.figures; - -import org.eclipse.draw2d.Border; -import org.eclipse.draw2d.Graphics; -import org.eclipse.draw2d.PolylineShape; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.RectangleFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PointList; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.papyrus.uml.diagram.common.draw2d.CenterLayout; -import org.eclipse.papyrus.uml.diagram.common.draw2d.LinesBorder; -import org.eclipse.swt.SWT; - -public class DurationConstraintFigure extends RectangleFigure { - - - - /** - * The delta number of pixel to paint the Arrow. - */ - private static final int ARROW_SIZE = 10; - - /** - * - * Constructor. - * - */ - public DurationConstraintFigure() { - CenterLayout layoutThis = new CenterLayout(); - this.setLayoutManager(layoutThis); - - } - - /** - * Create and display the top and bottom line of the figure. - * - * @return the created Border - */ - private Border createBorder() { - LinesBorder result = new LinesBorder(); - result.setSides(PositionConstants.TOP | PositionConstants.BOTTOM); - result.setStyle(SWT.BORDER_DASH); - return result; - } - - - /** - * @see org.eclipse.draw2d.Figure#paint(org.eclipse.draw2d.Graphics) - * - * @param graphics - */ - @Override - public void paint(Graphics graphics) { - super.paint(graphics); - Rectangle rect = this.getBounds(); - graphics.pushState(); - graphics.setForegroundColor(getForegroundColor()); - Point top = new Point(rect.getTop()); - Point bottom = new Point(rect.getBottom()); - graphics.drawLine(top, bottom); - // draw arrows - - // Top Arrow - Point left = new Point(top); - left = left.getTranslated(-ARROW_SIZE, ARROW_SIZE); - Point right = new Point(top); - right = right.getTranslated(ARROW_SIZE, ARROW_SIZE); - // Create list of point - PointList list = new PointList(); - list.addPoint(right); - list.addPoint(top); - list.addPoint(left); - graphics.drawPolyline(list); - - // Bottom Arrow - left = new Point(bottom); - left = left.getTranslated(-ARROW_SIZE, -ARROW_SIZE); - right = new Point(bottom); - right = right.getTranslated(ARROW_SIZE, -ARROW_SIZE); - // Create list of point - list = new PointList(); - list.addPoint(right); - list.addPoint(bottom); - list.addPoint(left); - graphics.drawPolyline(list); - - this.setFill(false); - this.setOutline(false); - this.setBorder(createBorder()); - graphics.popState(); - - } - - /** - * Not used anymore (present for compilation purpose of CustomDurationConstraintFigure that is no more called ) - * - * @return null - * @deprecated Use paint instead. - * - */ - @Deprecated - protected PolylineShape getDurationArrow() { - return null; - } -}
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java new file mode 100644 index 00000000000..bea6013cca1 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java @@ -0,0 +1,433 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.figures; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.draw2d.Bendpoint; +import org.eclipse.draw2d.ConnectionRouter; +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PolylineConnection; +import org.eclipse.draw2d.PolylineDecoration; +import org.eclipse.draw2d.geometry.Geometry; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; +import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure; +import org.eclipse.swt.SWT; +import org.eclipse.uml2.uml.DurationConstraint; +import org.eclipse.uml2.uml.DurationObservation; + +/** + * <p> + * A Figure for Durations ({@link DurationObservation Observation} or {@link DurationConstraint Constraint}) + * represented as an arrow between two events. The figure consists of two horizontal dashed lines, + * with a vertical arrow between them: + * </p> + * <img src="./doc-files/DurationLinkFigure.png" /> + * <p> + * The horizontal lines are <code>anchored</code> to the source/target of the link. By default, the vertical line will + * be placed in the middle of the bounds formed by these two anchors, although the figure supports a horizontal delta, + * to position the arrow closer to one or the other anchor. + * </p> + * + * <p> + * The figure can also be rotated 90° (i.e. vertical dashed lines and horizontal arrow), + * when the source and target points are on the same Y coordinate (Typically for horizontal messages) + * </p> + */ +public class DurationLinkFigure extends UMLEdgeFigure { + + /** + * The orientation of the figure changes from the default value {@link Orientation#VERTICAL} to {@link Orientation#HORIZONTAL} + * if the difference in pixels between end and start points are no more than this amount of pixels. + */ + private static final int ORIENTATION_SWITCH_DIFFERENCE = 30; + + /** + * When the arrow is in an {@link Orientation#HORIZONTAL} position, the start line is drawn as a 90° bent line, with + * an horizontal segment connected to the start point and a vertical segment. This offset determines the length of + * the horizontal segment, in pixels. + */ + private static final int HORIZOTAL_ARROW_START_LINE_OFFSET = 15; + + /** + * When the arrow is in an {@link Orientation#HORIZONTAL} position, the end line is drawn as a 90° bent line, with + * an horizontal segment connected to the end point and a vertical segment. This offset determines the length of + * the horizontal segment, in pixels. + */ + private static final int HORIZOTAL_ARROW_END_LINE_OFFSET = 15; + + /** + * The connecting end and start dashed lines will be drawn slightly further + * than the arrow, by this amount of pixels. + */ + private static final int ARROW_PADDING = 15; + private Orientation arrowOrientation = Orientation.VERTICAL; + private int arrowPositionDelta = 0; + private PapyrusWrappingLabel durationLabel; + + /** + * Thin lines may be difficult to select, so we add a tolerance area around it + * to make selection easier. + * + * @see #containsPoint(int, int) + */ + private static final int SELECTION_TOLERANCE = 3; + + public static final String DELTA_VIEW_STYLE = "delta"; //$NON-NLS-1$ + + @Override + protected void outlineShape(Graphics graphics) { + // Skip super; we're not drawing a polyline connection + arrowOrientation = computeOptimalOrientation(); + + paintStartLine(graphics); + paintEndLine(graphics); + paintArrow(graphics); + } + + /** + * Paint the line from this figure to the start point/event (Typically a horizontal line) + * + * @param graphics + */ + protected void paintStartLine(Graphics graphics) { + graphics.pushState(); + graphics.setLineStyle(SWT.LINE_DASH); + try { + PointList startLinePoints = getStartLinePoints(); + graphics.drawPolyline(startLinePoints); + } finally { + graphics.popState(); + } + } + + /** Returns the points for the start line - the line connecting the start point to the arrow. */ + public PointList getStartLinePoints() { + if (arrowOrientation == Orientation.HORIZONTAL) { + return getStartLinePointsHorizontal(); + } + // Orientation.VERTICAL and default case + return getStartLinePointsVertical(); + } + + private PointList getStartLinePointsHorizontal() { + PointList points = new PointList(3); + + points.addPoint(getStart()); + + Point startOffsetEnd = getStart().getCopy(); + startOffsetEnd.setX(startOffsetEnd.x() + HORIZOTAL_ARROW_START_LINE_OFFSET); + points.addPoint(startOffsetEnd); + + int arrowYCoordinate = getArrowLineHorizontalY(); + + // the vertical segment + Point startLineEnd = startOffsetEnd.getCopy(); + if (arrowYCoordinate > startOffsetEnd.y) { + startLineEnd.setY(arrowYCoordinate + ARROW_PADDING); + } else { + startLineEnd.setY(arrowYCoordinate - ARROW_PADDING); + } + points.addPoint(startLineEnd); + return points; + } + + private PointList getStartLinePointsVertical() { + PointList points = new PointList(2); + + // start + points.addPoint(getStart()); + + // end + int arrowLinePosition = getArrowLineVerticalX(); + Point startLineEnd = getStart().getCopy(); + if (arrowLinePosition > getStart().x()) { + startLineEnd.setX(arrowLinePosition + ARROW_PADDING); + } else { + startLineEnd.setX(arrowLinePosition - ARROW_PADDING); + } + points.addPoint(startLineEnd); + return points; + } + + private int getArrowLineVerticalX() { + if (super.getPoints().size() < 2) { + // The connection is not configured yet + return 0; + } + return (getStart().x() + getEnd().x()) / 2 + arrowPositionDelta; + } + + private int getArrowLineVerticalY() { + return getEnd().y(); + } + + /** + * Paint the line from this figure to the end point/event (Typically a horizontal line) + * + * @param graphics + */ + protected void paintEndLine(Graphics graphics) { + graphics.pushState(); + graphics.setLineStyle(SWT.LINE_DASH); + try { + PointList endLinePoints = getEndLinePoints(); + graphics.drawPolyline(endLinePoints); + } finally { + graphics.popState(); + } + } + + /** Returns the points for the end line - the line connecting the end point to the arrow. */ + public PointList getEndLinePoints() { + if (arrowOrientation == Orientation.HORIZONTAL) { + return getEndLinePointsHorizontal(); + } + // Orientation.VERTICAL and default case + return getEndLinePointsVertical(); + } + + private PointList getEndLinePointsHorizontal() { + PointList points = new PointList(2); + + points.addPoint(getEnd()); + Point endOffsetEnd = getEnd().getCopy(); + endOffsetEnd.setX(endOffsetEnd.x() - HORIZOTAL_ARROW_END_LINE_OFFSET); + points.addPoint(endOffsetEnd); + int arrowYCoordinate = getArrowLineHorizontalY(); + // paint the end line + Point endLineEnd = endOffsetEnd.getCopy(); + if (arrowYCoordinate < getEnd().y) { + endLineEnd.setY(arrowYCoordinate - HORIZOTAL_ARROW_END_LINE_OFFSET); + } else { + endLineEnd.setY(arrowYCoordinate + HORIZOTAL_ARROW_END_LINE_OFFSET); + } + points.addPoint(endLineEnd); + + return points; + } + + private PointList getEndLinePointsVertical() { + PointList points = new PointList(2); + + // start + points.addPoint(getEnd()); + + // end + int arrowLinePosition = getArrowLineVerticalX(); + Point endLineEnd = getEnd().getCopy(); + if (arrowLinePosition < getEnd().x()) { + endLineEnd.setX(arrowLinePosition - ARROW_PADDING); + } else { + endLineEnd.setX(arrowLinePosition + ARROW_PADDING); + } + points.addPoint(endLineEnd); + return points; + } + + /** + * Paint the arrow between the start line and end line (Typically a vertical arrow) + * + * @param graphics + */ + protected void paintArrow(Graphics graphics) { + PolylineConnection arrowLine = new PolylineConnection(); + arrowLine.setForegroundColor(getForegroundColor()); + arrowLine.setBackgroundColor(getBackgroundColor()); + arrowLine.setLineStyle(getLineStyle()); + arrowLine.setLineWidth(getLineWidth()); + + PointList arrowPoints = getArrowLinePoints(); + Point arrowStart = arrowPoints.getFirstPoint(); + Point arrowEnd = arrowPoints.getLastPoint(); + + arrowLine.setStart(arrowStart); + arrowLine.setEnd(arrowEnd); + + decorateArrowLine(arrowLine, arrowStart, arrowEnd); + arrowLine.paint(graphics); + } + + /** Returns the points for the arrow line drawn between the and and start lines. */ + public PointList getArrowLinePoints() { + PointList points = new PointList(2); + Point arrowStart = null, arrowEnd = null; + if (arrowOrientation == Orientation.HORIZONTAL) { + arrowStart = getStart().getCopy().setX(getStart().x() + ARROW_PADDING).setY(getArrowLineHorizontalY()); + arrowEnd = getEnd().getCopy().setX(getEnd().x() - ARROW_PADDING).setY(getArrowLineHorizontalY()); + } else { + arrowStart = getStart().getCopy().setX(getArrowLineVerticalX()); + arrowEnd = arrowStart.getCopy().setY(getArrowLineVerticalY()); + } + points.addPoint(arrowStart); + points.addPoint(arrowEnd); + return points; + } + + private int getArrowLineHorizontalY() { + if (super.getPoints().size() < 2) { + // The connection is not configured yet + return 0; + } + return (getStart().y() + getEnd().y()) / 2 + arrowPositionDelta; + } + + /** Adds decorations(e.g. arrow triangles) to the arrow line. */ + protected void decorateArrowLine(PolylineConnection arrowLine, Point arrowStart, Point arrowEnd) { + // source + PolylineDecoration source = new PolylineDecoration(); + source.setScale(7 * getLineWidth(), 3 * getLineWidth()); + source.setLineWidth(getLineWidth()); + source.setLocation(arrowStart); + source.setReferencePoint(arrowEnd); + arrowLine.setSourceDecoration(source); + + // target + PolylineDecoration target = new PolylineDecoration(); + target.setScale(7 * getLineWidth(), 3 * getLineWidth()); + target.setLineWidth(getLineWidth()); + target.setLocation(arrowEnd); + target.setReferencePoint(arrowStart); + arrowLine.setTargetDecoration(target); + } + + + private Orientation computeOptimalOrientation() { + if (Math.abs(getStart().y - getEnd().y) < ORIENTATION_SWITCH_DIFFERENCE) { + return Orientation.HORIZONTAL; + } + return Orientation.VERTICAL; + } + + + /** + * {@inheritDoc} + * <p> + * Override containsPoint to handle clicks on any of the 3 lines (start, end and arrow line) + * </p> + */ + @Override + public boolean containsPoint(int x, int y) { + // START LINE + PointList startLinePoints = getStartLinePoints(); + if (Geometry.polylineContainsPoint(startLinePoints, x, y, SELECTION_TOLERANCE)) { + return true; + } + + // END LINE + PointList endLinePoints = getEndLinePoints(); + if (Geometry.polylineContainsPoint(endLinePoints, x, y, SELECTION_TOLERANCE)) { + return true; + } + + // ARROW + PointList arrowPoints = getArrowLinePoints(); + if (Geometry.polylineContainsPoint(arrowPoints, x, y, SELECTION_TOLERANCE)) { + return true; + } + + // Child labels + @SuppressWarnings("unchecked") + List<IFigure> children = getChildren(); + return children.stream().anyMatch(child -> child.containsPoint(x, y)); + } + + + /** + * <p> + * By default, the arrow is centered between its start and end point (delta = 0). The position + * delta can be used to move it to the right (delta > 0) or to the left (delta < 0). + * </p> + * + * @param delta + */ + public void setArrowPositionDelta(int delta) { + if (delta != this.arrowPositionDelta) { + this.arrowPositionDelta = delta; + revalidate(); + } + } + + /** Returns the arrow position delta. + * <p> + * By default, the arrow is centered between its start and end point (delta = 0). The position + * delta can be used to move it to the right (delta > 0) or to the left (delta < 0). + * </p>*/ + public int getArrowPositionDelta() { + return arrowPositionDelta; + } + + @Override + public Rectangle getBounds() { + Rectangle bounds = super.getBounds(); + + // The arrow may be moved outside of the bounds defined by (start, end). + // In that case, we need to update the bounds, to make sure we can draw + // everything + if (getPoints().size() >= 2) { + PointList allPoints = new PointList(); + allPoints.addAll(getStartLinePoints()); + allPoints.addAll(getEndLinePoints()); + allPoints.addAll(getArrowLinePoints()); + bounds.union(allPoints.getBounds()); + } + return bounds; + } + + @Override + public void setConnectionRouter(ConnectionRouter cr) { + // Skip; this figure doesn't support routers/bendpoints + } + + /** + * @return the arrowOrientation + */ + public Orientation getArrowOrientation() { + return arrowOrientation; + } + + public static enum Orientation { + VERTICAL, HORIZONTAL; + } + + public WrappingLabel getDurationLabelFigure() { + return this.durationLabel; + } + + + @Override + protected void createContents() { + super.createContents(); + this.durationLabel = new PapyrusWrappingLabel(); + this.durationLabel.setText(""); //$NON-NLS-1$ + add(this.durationLabel); + } + + @Override + public Object getRoutingConstraint() { + // Bendpoints should at least contain the start and end points; otherwise the + // bendpoint policy will crash. We don't support bendpoints, so just return + // a new list everytime. + List<Bendpoint> list = new ArrayList<>(); + list.add(this::getStart); + list.add(this::getEnd); + return list; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java index eb51cb32a7d..39894b9df3d 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST and others. + * Copyright (c) 2017, 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,16 +10,23 @@ * * Contributors: * CEA LIST - Initial API and implementation + * Christian W. Damus - bug 539373 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.figures; import org.eclipse.draw2d.ConnectionAnchor; +import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.TreeSearch; import org.eclipse.draw2d.geometry.PrecisionPoint; import org.eclipse.gef.GraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.LinkLFSVGNodePlateFigure; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.NodeBottomAnchor; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.NodeTopAnchor; import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper; /** @@ -48,6 +55,12 @@ public class ExecutionSpecificationNodePlate extends LinkLFSVGNodePlateFigure im @Override public ConnectionAnchor getConnectionAnchor(String terminal) { + if (AnchorConstants.START_TERMINAL.equals(terminal)) { + return new NodeTopAnchor(this); + } else if (AnchorConstants.END_TERMINAL.equals(terminal)) { + return new NodeBottomAnchor(this); + } + // Use FixedAnchorEx for MessageSync, this will be invoked by mapConnectionAnchor(termial) operation. if (terminal != null && terminal.indexOf("{") != -1 && terminal.indexOf("}") != -1) { int position = AnchorHelper.FixedAnchorEx.parsePosition(terminal); @@ -57,4 +70,36 @@ public class ExecutionSpecificationNodePlate extends LinkLFSVGNodePlateFigure im } return super.getConnectionAnchor(terminal); } + + @Override + public String getConnectionAnchorTerminal(ConnectionAnchor c) { + if (c instanceof NodeTopAnchor) { + return AnchorConstants.START_TERMINAL; + } else if (c instanceof NodeBottomAnchor) { + return AnchorConstants.END_TERMINAL; + } + return super.getConnectionAnchorTerminal(c); + } + + @Override + public boolean containsPoint(int x, int y) { + boolean result = super.containsPoint(x, y); + if (!result) { + // Hit test my border items + BorderedNodeFigure parent = (BorderedNodeFigure) getParent(); + result = parent.getBorderItemContainer().containsPoint(x, y); + } + return result; + } + + @Override + public final IFigure findFigureAt(int x, int y, TreeSearch search) { + IFigure result = super.findFigureAt(x, y, search); + if (result == null) { + // Search my border items + BorderedNodeFigure parent = (BorderedNodeFigure) getParent(); + result = parent.getBorderItemContainer().findFigureAt(x, y, search); + } + return result; + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/FigureHitTestUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/FigureHitTestUtil.java new file mode 100644 index 00000000000..3026fcc454a --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/FigureHitTestUtil.java @@ -0,0 +1,140 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.figures; + +import java.util.List; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.TreeSearch; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; + +/** + * Hit-test utilities for {@code IFigure figure}s. + */ +public class FigureHitTestUtil { + public static final FigureHitTestUtil INSTANCE = new FigureHitTestUtil(); + + private static final int FUZZ_FACTOR = 2; + + // A slightly fuzzy point for hit-testing on a polyline + private final Rectangle fuzzyPoint = new Rectangle(0, 0, + FUZZ_FACTOR * 2 + 1, FUZZ_FACTOR * 2 + 1); + + /** + * Not instantiable by clients. + */ + private FigureHitTestUtil() { + super(); + } + + /** + * Obtain the children of a figure as a typed list. + * + * @param figure + * a figure + * @return its children + */ + @SuppressWarnings("unchecked") + public final List<? extends IFigure> getChildren(IFigure figure) { + return figure.getChildren(); + } + + /** + * Fuzzily test whether a {@code polygon} contains some point. Effectively, + * test whether the {@code polygon} overlaps a tiny square around the point. + * + * @param polygon + * a polygon + * @param x + * the X coördinate at which to search + * @param y + * the Y coördinate at which to search + * @return whether the point fuzzily is in the {@code polygon} + */ + public boolean fuzzyHitTest(PointList polygon, int x, int y) { + boolean result = polygon.polygonContainsPoint(x, y); + if (!result) { + // If the center of our rectangle isn't in the polygon but + // any of it does overlap the polygon, then it must intersect + // the polygon boundary + fuzzyPoint.setLocation(x - FUZZ_FACTOR, y - FUZZ_FACTOR); + result = polygon.intersects(fuzzyPoint); + } + return result; + } + + /** + * Query whether any child of a {@code figure} contains a point. + * + * @param figure + * a figure + * @param x + * the X coördinate at which to search + * @param y + * the Y coördinate at which to search + * @return whether any child of the {@code figure} contains the point + */ + public boolean anyChildContainsPoint(IFigure figure, int x, int y) { + boolean result = false; + + final List<? extends IFigure> children = getChildren(figure); + + for (int i = children.size() - 1; i >= 0; i--) { + IFigure next = children.get(i); + if (next.isVisible() && next.containsPoint(x, y)) { + result = true; + break; + } + } + + return result; + } + + /** + * Find a child figure (recursively) at the given location, excluding + * the {@code figure}, itself. + * + * @param figure + * a figure in which to search for some child + * @param x + * the X coördinate at which to search + * @param y + * the Y coördinate at which to search + * @param search + * a tree search filter + * + * @return the child, or {@code null} if there is no child at this location + */ + public IFigure findChildAt(IFigure figure, int x, int y, TreeSearch search) { + IFigure result = null; + + final List<? extends IFigure> children = getChildren(figure); + + for (int i = children.size() - 1; i >= 0; i--) { + IFigure next = children.get(i); + if (next.isVisible()) { + next = next.findFigureAt(x, y, search); + if (next != null) { + result = next; + break; + } + } + } + + return result; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java index 73444a12e08..3f333e2c391 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2010 - 2018 CEA + * Copyright (c) 2010 - 2018 CEA, Christian W. Damus, and others * * * All rights reserved. This program and the accompanying materials @@ -13,6 +13,7 @@ * Soyatec - Initial API and implementation * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519408 * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Bug 531520 + * Christian W. Damus - bugs 539373, 536486 *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.figures; @@ -32,6 +33,7 @@ import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.LayoutManager; import org.eclipse.draw2d.MarginBorder; import org.eclipse.draw2d.RectangleFigure; +import org.eclipse.draw2d.TreeSearch; import org.eclipse.draw2d.XYLayout; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.PointList; @@ -74,6 +76,9 @@ public class LifelineFigure extends RoundedCompartmentFigure { } } + // Buffer on either side of the stem to take as hit area for mouse pointer + private static final int STEM_HIT_BUFFER = 20; + protected RectangleFigure lifelineHeaderBoundsFigure; @Deprecated @@ -89,6 +94,12 @@ public class LifelineFigure extends RoundedCompartmentFigure { */ private List<NodeFigure> childrenFigure = new ArrayList<>(); + // The polygon to which connections (messages etc.) attach + private PointList cachedPolygon; + + // A polygon defining the area in which the lifeline may be selected by the mouse pointer + private PointList cachedHitAreaPolygon; + /** * Constructor. */ @@ -115,33 +126,57 @@ public class LifelineFigure extends RoundedCompartmentFigure { */ @Override public PointList getPolygonPoints() { - // we create the nude Lifeline figure + if (cachedPolygon == null) { + // we create the basic Lifeline figure final PointList points = new PointList(8); + + int bottomOfHeader = ((LifeLineLayoutManager) this.getLifeLineLayoutManager()).getBottomHeader(); + Rectangle bounds = this.getBounds(); + int right = bounds.right(); + int midX = bounds.x + bounds.width / 2; + // top left corner - points.addPoint(this.getBounds().x, this.getBounds().y); + points.addPoint(bounds.x, bounds.y); // top right corner - points.addPoint(this.getBounds().x + this.getBounds().width, this.getBounds().y); + points.addPoint(right, bounds.y); // bottom header right corner - points.addPoint(this.getBounds().x + this.getBounds().width, ((LifeLineLayoutManager) this.getLifeLineLayoutManager()).getBottomHeader()); + points.addPoint(right, bottomOfHeader); // bottom middle header - points.addPoint(this.getBounds().x + this.getBounds().width / 2, ((LifeLineLayoutManager) this.getLifeLineLayoutManager()).getBottomHeader()); + points.addPoint(midX, bottomOfHeader); // middle bottom lifeline - points.addPoint(this.getBounds().x + this.getBounds().width / 2, this.getBounds().y + this.getBounds().height); + points.addPoint(midX, bounds.bottom()); // bottom middle header - points.addPoint(this.getBounds().x + this.getBounds().width / 2, ((LifeLineLayoutManager) this.getLifeLineLayoutManager()).getBottomHeader()); + points.addPoint(midX, bottomOfHeader); // bottom left header - points.addPoint(this.getBounds().x, ((LifeLineLayoutManager) this.getLifeLineLayoutManager()).getBottomHeader()); + points.addPoint(bounds.x, bottomOfHeader); // top left header - points.addPoint(this.getBounds().x, this.getBounds().y); + points.addPoint(bounds.x, bounds.y); + + // Duplicate this basic shape for the hit area but make a wider target on the stem + final PointList hitArea = points.getCopy(); + Point broadStem = new Point(midX + STEM_HIT_BUFFER, bottomOfHeader); + hitArea.setPoint(broadStem, 3); + broadStem.setY(bounds.bottom()); + hitArea.setPoint(broadStem, 4); + broadStem.setX(midX - STEM_HIT_BUFFER); + hitArea.insertPoint(broadStem, 5); // This is a new point at the bottom of the stem + broadStem.setY(bottomOfHeader); + hitArea.setPoint(broadStem, 6); + cachedHitAreaPolygon = hitArea; - if (this.childrenFigure.isEmpty()) { - return points; - } else { // for bug 531520: // all messages are now attached in the notation to the Lifeline // we continue to represent them attached to the ExecutionSpeficiation, that why we complete the polygon list with the ExecutionSpeficiation of the Lifeline - return completeFigureWithChildren(points); + cachedPolygon = completeFigureWithChildren(points); } + + return cachedPolygon; + } + + private PointList getHitAreaPolygon() { + // Ensure it is computed + getPolygonPoints(); + return cachedHitAreaPolygon; } /** @@ -397,16 +432,17 @@ public class LifelineFigure extends RoundedCompartmentFigure { // Draw dash line first to be under child graphics.setLineDash(new int[] { 5, 5 }); graphics.drawLine(new Point(rect.x + rect.width / 2, ((LifeLineLayoutManager) this.getLifeLineLayoutManager()).getBottomHeader()), new Point(rect.x + rect.width / 2, rect.y + rect.height - 1)); - graphics.popState(); - // to draw the anchor shape for debug (bug 531520) - // if (false == this.childrenFigure.isEmpty()) { - // graphics.setForegroundColor(new Color(Display.getDefault(), new RGB(255, 0, 0))); - // PointList pol = getPolygonPoints(); + // DEBUG: to draw the convex hull of the lifeline shape (bug 531520) + // if (!this.childrenFigure.isEmpty()) { + // graphics.setForegroundColor(org.eclipse.draw2d.ColorConstants.red); + // PointList pol = getPolygonPoints(); // getHitAreaPolygon(); // graphics.drawPolygon(pol); // graphics.setForegroundColor(getForegroundColor()); // } + graphics.popState(); + // Then finish to draw figure. super.paint(graphics); @@ -474,6 +510,10 @@ public class LifelineFigure extends RoundedCompartmentFigure { this.add(lifelineHeaderBoundsFigure); } + public IFigure getHeaderFigure() { + return lifelineHeaderBoundsFigure; + } + protected IMapMode getMapMode() { return MapModeUtil.getMapMode(); } @@ -509,6 +549,29 @@ public class LifelineFigure extends RoundedCompartmentFigure { this.childrenFigure = childrenFigure == null ? Collections.emptyList() : childrenFigure; } + @Override + public void invalidate() { + cachedPolygon = null; + cachedHitAreaPolygon = null; + super.invalidate(); + } + + @Override + public boolean containsPoint(int x, int y) { + // The easy case: on the lifeline itself (and its buffer zone) + boolean result = getHitAreaPolygon().polygonContainsPoint(x, y); + if (!result) { + // Drill into children for their border items etc. + result = FigureHitTestUtil.INSTANCE.anyChildContainsPoint(this, x, y); + } + return result; + } + + @Override + protected IFigure findDescendantAtExcluding(int x, int y, TreeSearch search) { + // Our client area is degenerate, so don't consider it as super does + return FigureHitTestUtil.INSTANCE.findChildAt(this, x, y, search); + } /** * diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineNodeFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineNodeFigure.java index 159687ec9f1..c36d6902b68 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineNodeFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineNodeFigure.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2018 CEA LIST and others. + * Copyright (c) 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -8,6 +8,7 @@ * * Contributors: * CEA LIST - Initial API and implementation + * Christian W. Damus - bug 539373 * *****************************************************************************/ @@ -34,10 +35,14 @@ public class LifelineNodeFigure extends SelectableBorderedNodeFigure { @Override public boolean containsPoint(int x, int y) { - if (Math.abs(this.getBounds().x + this.getBounds().width / 2 - x) < 20) { - return super.containsPoint(x, y); // check also the other bounds + // Hit test the lifeline itself with execution specifications + boolean result = getMainFigure().containsPoint(x, y); + if (!result) { + // Try the border items (e.g., time observations) + result = FigureHitTestUtil.INSTANCE.anyChildContainsPoint( + getBorderItemContainer(), x, y); } - return false; + return result; } @Override @@ -45,11 +50,11 @@ public class LifelineNodeFigure extends SelectableBorderedNodeFigure { if (search.prune(this)) { return null; } - IFigure result = getBorderItemContainer().findFigureAt(x, y, search); + IFigure result = FigureHitTestUtil.INSTANCE.findChildAt(getBorderItemContainer(), x, y, search); if (result != null) { return result; } return getMainFigure().findFigureAt(x, y, search); } -}
\ No newline at end of file +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java index e491632ecde..f13d8fa09cf 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java @@ -1,6 +1,5 @@ /***************************************************************************** - * Copyright (c) 2010 CEA - * + * Copyright (c) 2010, 2018 CEA LIST, EclipseSource and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,11 +10,13 @@ * * Contributors: * Soyatec - Initial API and implementation + * EclipseSource - Bug 536641 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.figures; import org.eclipse.draw2d.ColorConstants; +import org.eclipse.draw2d.ConnectionAnchor; import org.eclipse.draw2d.RotatableDecoration; import org.eclipse.draw2d.Shape; import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; @@ -23,6 +24,9 @@ import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode; import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; import org.eclipse.papyrus.uml.diagram.common.figure.edge.UMLEdgeFigure; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.ConnectionSourceAnchor; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.ConnectionTargetAnchor; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Cursor; @@ -180,4 +184,25 @@ public abstract class MessageFigure extends UMLEdgeFigure { public void setMapMode(IMapMode mapMode) { this.mapMode = mapMode; } + + + @Override + public ConnectionAnchor getConnectionAnchor(String terminal) { + if (AnchorConstants.START_TERMINAL.equals(terminal)) { + return new ConnectionSourceAnchor(this); + } else if (AnchorConstants.END_TERMINAL.equals(terminal)) { + return new ConnectionTargetAnchor(this); + } + return super.getConnectionAnchor(terminal); + } + + @Override + public String getConnectionAnchorTerminal(ConnectionAnchor c) { + if (c instanceof ConnectionSourceAnchor) { + return AnchorConstants.START_TERMINAL; + } else if (c instanceof ConnectionTargetAnchor) { + return AnchorConstants.END_TERMINAL; + } + return super.getConnectionAnchorTerminal(c); + } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/TimeConstraintFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/TimeConstraintFigure.java new file mode 100644 index 00000000000..0445201a03c --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/TimeConstraintFigure.java @@ -0,0 +1,70 @@ +/***************************************************************************** + * Copyright (c) 2018 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.sequence.figures; + +import org.eclipse.draw2d.Graphics; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; +import org.eclipse.swt.graphics.Color; +import org.eclipse.uml2.uml.TimeConstraint; +import org.eclipse.uml2.uml.TimeObservation; + +/** + * Specific figure for the {@link TimeConstraint} & {@link TimeObservation}. This may be simplified later as a single line only + */ +public class TimeConstraintFigure extends DefaultSizeNodeFigure implements IPapyrusNodeFigure { + + public TimeConstraintFigure() { + super(60, 1); + } + + @Override + public void paintFigure(Graphics graphics) { + super.paintFigure(graphics); + + graphics.pushState(); + + Rectangle clipRectangle = new Rectangle(); + graphics.getClip(clipRectangle); + graphics.setClip(clipRectangle.expand(Math.max(0, getLineWidth()), Math.max(0, getLineWidth()))); + + graphics.setLineWidth(getLineWidth()); + graphics.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y); + + graphics.popState(); + } + + + @Override + public Color getBorderColor() { + return null; + } + + @Override + public boolean isShadow() { + return false; + } + + @Override + public void setBorderColor(Color borderColor) { + + } + + @Override + public void setShadow(boolean shadow) { + + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/TimeObservationFigure.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/TimeObservationFigure.java index b9b98ebebdd..d639b57b842 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/TimeObservationFigure.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/TimeObservationFigure.java @@ -1,12 +1,25 @@ +/** + * Copyright (c) 2015, 2018 CEA LIST, Christian W. Damus, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * CEA LIST - Initial API and implementation + * Christian W. Damus - bug 536486 + */ package org.eclipse.papyrus.uml.diagram.sequence.figures; -public class TimeObservationFigure extends TimeMarkElementFigure { +public class TimeObservationFigure extends TimeConstraintFigure { /** - * Constructor. - * + * Initializes me. */ public TimeObservationFigure() { - removeAllPoints(); + super(); } -}
\ No newline at end of file +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/doc-files/DurationLinkFigure.png b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/doc-files/DurationLinkFigure.png Binary files differnew file mode 100644 index 00000000000..99d9ffac56c --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/doc-files/DurationLinkFigure.png diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java index b76858aad8f..780a84c2404 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2010 CEA + * Copyright (c) 2010, 2018 CEA, Christian W. Damus, and others * * * All rights reserved. This program and the accompanying materials @@ -11,6 +11,7 @@ * * Contributors: * Atos Origin - Initial API and implementation + * Christian W. Damus - bug 536486 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.locator; @@ -18,6 +19,7 @@ package org.eclipse.papyrus.uml.diagram.sequence.locator; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure; import org.eclipse.gmf.runtime.diagram.ui.internal.figures.BorderItemContainerFigure; import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure; import org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator; @@ -64,6 +66,10 @@ public class CenterLocator extends AdvancedBorderItemLocator { BorderItemContainerFigure borderItemContainerFigure = getBorderItemContainerFigure(); if (borderItemContainerFigure != null) { for (Object child : borderItemContainerFigure.getChildren()) { + if (child instanceof BorderedNodeFigure) { + // Unwrap it (the destruction occurrence, itself, can have border items) + child = ((BorderedNodeFigure) child).getMainFigure(); + } if (child instanceof DefaultSizeNodeFigure) { for (Object figure : ((DefaultSizeNodeFigure) child).getChildren()) { if (figure instanceof DestructionEventFigure) { @@ -106,7 +112,8 @@ public class CenterLocator extends AdvancedBorderItemLocator { public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) { // The valid position for destruction event is always the bottom if (getDestructionEventFigure() != null) { - if (borderItem.equals(getDestructionEventFigure().getParent())) { + // The destruction event supports border items, itself, so there are two levels of parent + if (borderItem.equals(getDestructionEventFigure().getParent().getParent())) { Rectangle realLocation = new Rectangle(proposedLocation); Point point = new Point(getParentBorder().getCenter().x - realLocation.getSize().width / 2, getParentBorder().y + getParentBorder().height - realLocation.height / 2); realLocation.setLocation(point); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/DurationConstraintLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/DurationConstraintLocator.java deleted file mode 100644 index 2ae0b926ab2..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/DurationConstraintLocator.java +++ /dev/null @@ -1,127 +0,0 @@ -/***************************************************************************** - * 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 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Celine Janssens (celine.janssens@all4tec.net) - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.uml.diagram.sequence.locator; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart; - -/** - * @author Celine JANSSENS - * This class is used for Duration Constraint (@see {@link LifelineEditPart}) in order to locate it just next to the middle of it's parent (the Lifeline) on the X axe. - * The Y Axe is free except if the top is upper than its Parent. - */ -public class DurationConstraintLocator extends AdvancedBorderItemLocator { - - /** - * Constructor. - * - * @param borderItem - * @param parentFigure - * @param constraint - */ - public DurationConstraintLocator(IFigure borderItem, IFigure parentFigure, Rectangle constraint) { - super(borderItem, parentFigure, constraint); - - } - - /** - * Constructor. - * - */ - public DurationConstraintLocator(IFigure parentFigure) { - super(parentFigure); - } - - - /** - * Constructor. - * - */ - public DurationConstraintLocator(IFigure parentFigure, int position) { - super(parentFigure, position); - } - - /** - * @see org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator#relocate(org.eclipse.draw2d.IFigure) - * - * @param borderItem - */ - @Override - public void relocate(IFigure borderItem) { - Dimension size = getSize(borderItem); - // The returned constraint is relative to the parent - Rectangle rectSuggested = getConstraint(); - rectSuggested.setSize(size); - // transform it to absolute - Rectangle suggestedRectIndiagram = rectSuggested.getCopy(); - suggestedRectIndiagram.x = suggestedRectIndiagram.x + getParentFigure().getBounds().x; - suggestedRectIndiagram.y = suggestedRectIndiagram.y + getParentFigure().getBounds().y; - // get the valid Location in Absolute coordinates - suggestedRectIndiagram = getValidLocation(suggestedRectIndiagram, borderItem); - - // transform it back in relative coordinate to its parent. - borderItem.setBounds(suggestedRectIndiagram.getCopy()); - suggestedRectIndiagram.x = suggestedRectIndiagram.x - getParentFigure().getBounds().x; - suggestedRectIndiagram.y = suggestedRectIndiagram.y - getParentFigure().getBounds().y; - - // Set the new Constraint in Relative. - setConstraint(suggestedRectIndiagram); - - } - - /** - * - * The Valid location for a Duration Constraint is just next to the center of its parent (the lifeline). - * - * @see org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator#getValidLocation(org.eclipse.draw2d.geometry.Rectangle, org.eclipse.draw2d.IFigure) - * - * @param proposedLocation - * @param borderItem - * @return - */ - @Override - public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) { - // the offset required to take the Lifeline Header height into account - int headerYOffset = 20; - - int parentMiddleX = getParentFigure().getBounds().x + (getParentFigure().getBounds().width / 2); - - // Place the DurationConstraint Just next to the lifeline (right or left depends on the proposedLocation ) - if (proposedLocation.x < parentMiddleX) { - proposedLocation.setX(parentMiddleX - proposedLocation.width()); - } else { - proposedLocation.setX(parentMiddleX); - - } - - // If the proposed Location is upper than the Parent Figure (The lifeline) , then set the location as close as possible from the top of the parent. - if (proposedLocation.y < getParentFigure().getBounds().y + headerYOffset) { - proposedLocation.setY(getParentFigure().getBounds().y + headerYOffset); - } - - // If the DurationConstraint is out of the Lifeline bottom then relocate it into the Lifeline - if (proposedLocation.y + proposedLocation.height > getParentFigure().getBounds().bottom()) { - proposedLocation.setY(getParentFigure().getBounds().bottom() - proposedLocation.height); - } - - - return super.getValidLocation(proposedLocation, borderItem); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/IntersectionPointSelectionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/IntersectionPointSelectionLocator.java new file mode 100644 index 00000000000..ac593325fbf --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/IntersectionPointSelectionLocator.java @@ -0,0 +1,54 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.locator; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.ConnectionLocator; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; + +/** ConnectionLocator that provides the location of the intersection point of two PointLists. */ +public class IntersectionPointSelectionLocator extends ConnectionLocator { + + private PointList pointList1; + private PointList pointList2; + + /** + * Constructor. + * + * @param connection + */ + public IntersectionPointSelectionLocator(Connection connection, PointList pointList1, PointList pointList2) { + super(connection); + this.pointList1 = pointList1; + this.pointList2 = pointList2; + } + + @Override + protected Point getLocation(PointList points) { + if (pointList1 == null || pointList2 == null) { + return super.getLocation(points); + } + + Rectangle intersect = pointList1.getBounds().intersect(pointList2.getBounds()); + if (!intersect.isEmpty()) { + return intersect.getLocation(); + } + // fallback to default (middle point) + return super.getLocation(points); + } +}
\ No newline at end of file diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/TimeElementLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/TimeElementLocator.java new file mode 100644 index 00000000000..574071f4696 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/TimeElementLocator.java @@ -0,0 +1,229 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, Christian W. Damus, 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 + * Christian W. Damus - bug 536486 + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.locator; + +import java.util.Optional; +import java.util.function.ToIntFunction; +import java.util.stream.Stream; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; +import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DestructionEventNodePlate; +import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineFigure; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.TimeConstraint; +import org.eclipse.uml2.uml.TimeObservation; + +/** + * Specific locator for {@link TimeObservation} or {@link TimeConstraint} on exec spec. + */ +public class TimeElementLocator implements IBorderItemLocator { + + private final IBorderItemLocator centeringDelegate; + + private IFigure parentFigure; + private Rectangle constraint; + private ToIntFunction<? super Rectangle> sideFunction; + + /** + * Initializes me with my parent figure and a function that computes the side on + * which to place the time element based on a proposed locating rectangle. + * + * @param parentFigure + * the parent figure + * @param sideFunction + * the proposed rectangle to side function. Valid outputs of the + * side function are the NSEW and {@link PositionConstants#CENTER CENTER} + * values of the {@link PositionConstants} + */ + public TimeElementLocator(IFigure parentFigure, ToIntFunction<? super Rectangle> sideFunction) { + super(); + + this.setParentFigure(parentFigure); + this.sideFunction = sideFunction; + + this.centeringDelegate = new CenterLocator(parentFigure, PositionConstants.NONE); + } + + @Override + public void setConstraint(Rectangle constraint) { + this.constraint = constraint; + } + + private Rectangle getConstraint() { + return constraint; + } + + @Override + public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) { + Rectangle realLocation = new Rectangle(proposedLocation); + Point newTopLeft = locateOnBorder(realLocation, borderItem); + realLocation.setLocation(newTopLeft); + return realLocation; + } + + @Override + public int getCurrentSideOfParent() { + if (getConstraint().y() >= 10) { + return PositionConstants.SOUTH; + } + return PositionConstants.NORTH; + } + + @Override + public void relocate(IFigure borderItem) { + Dimension size = getSize(borderItem); + Rectangle rectSuggested = new Rectangle( + getPreferredLocation(borderItem), size); + + // Point ptNewLocation = locateOnBorder(rectSuggested, borderItem); + borderItem.setBounds(rectSuggested); + } + + protected Point locateOnBorder(Rectangle rectSuggested, IFigure borderItem) { + Point relativeItem = rectSuggested.getTopLeft(); + Rectangle parentBounds = getParentFigure().getBounds(); + Rectangle itemBounds = borderItem.getBounds(); + + // On which side? + int side = sideFunction.applyAsInt(rectSuggested); + switch (side) { + case PositionConstants.WEST: // Applied on the lifeline head + relativeItem.setLocation(-(itemBounds.width() / 2), + getLifelineHead().height() / 2); + break; + case PositionConstants.EAST: // Applied on the lifeline head + relativeItem.setLocation(parentBounds.width() - (itemBounds.width() / 2), + getLifelineHead().height() / 2); + break; + case PositionConstants.NORTH: // Applied on an execution specification + relativeItem.setLocation((parentBounds.width() - rectSuggested.width()) / 2, 0); + break; + case PositionConstants.SOUTH: // Applied on an execution specification + relativeItem.setLocation((parentBounds.width() - rectSuggested.width()) / 2, + parentBounds.height()); + break; + case PositionConstants.CENTER: // Applied on a destruction occurrence and lifeline + if (isOnDestructionOccurrence()) { + // Center vertically, also + relativeItem.setLocation((parentBounds.width() - itemBounds.width()) / 2, + parentBounds.height() / 2); + } else { + return centeringDelegate.getValidLocation(rectSuggested, borderItem) + .getLocation(); + } + break; + default: + throw new IllegalArgumentException("unsupported side: " + side); + } + + Point result = getAbsoluteToBorder(relativeItem); + return result; + } + + protected boolean isOnDestructionOccurrence() { + return getParentFigure() instanceof DestructionEventNodePlate; + } + + protected Rectangle getLifelineHead() { + // The first (and only) child of the lifeline node plate is the lifeline figure + LifelineFigure lifeline = (LifelineFigure) getParentFigure().getChildren().get(0); + return lifeline.getHeaderFigure().getBounds(); + } + + protected IFigure getParentFigure() { + return parentFigure; + } + + protected void setParentFigure(IFigure parentFigure) { + this.parentFigure = parentFigure; + } + + /** + * Gets the size of the border item figure. + * + * @param borderItem + * the figure on border + * @return the size of the border item figure. + */ + protected final Dimension getSize(IFigure borderItem) { + Dimension size = getConstraint().getSize(); + if (size.isEmpty()) { + size = borderItem.getPreferredSize(); + } + return size; + } + + protected Point getPreferredLocation(IFigure borderItem) { + Point constraintLocation = locateOnBorder(getConstraint(), borderItem); + return constraintLocation; + } + + + /** + * Convert the relative coords in the model to ones that are Relative to the + * container (absolute in respect to the main figure) + * + * @param ptRelativeOffset + * @return point + */ + protected Point getAbsoluteToBorder(Point ptRelativeOffset) { + Point parentOrigin = getParentBorder().getTopLeft(); + return parentOrigin.translate(ptRelativeOffset); + } + + /** + * Utility to calculate the parent bounds with consideration for the handle + * bounds inset. + * + * @return <code>Rectangle</code> that is the bounds of the parent. + */ + protected Rectangle getParentBorder() { + Rectangle bounds = getParentFigure().getBounds().getCopy(); + if (getParentFigure() instanceof NodeFigure) { + bounds = ((NodeFigure) getParentFigure()).getHandleBounds() + .getCopy(); + } + return bounds; + } + + public static <T extends NamedElement> Optional<T> getTimedElement(EditPart timeElementEP, Class<T> type) { + return Optional.ofNullable(timeElementEP.getAdapter(EObject.class)) + .filter(NamedElement.class::isInstance).map(NamedElement.class::cast) + .flatMap(named -> getTimedElement(named, type)); + } + + public static <T extends NamedElement> Optional<T> getTimedElement(NamedElement timeElement, Class<T> type) { + Stream<T> timed = Stream.empty(); + + if (timeElement instanceof TimeConstraint) { + TimeConstraint constraint = (TimeConstraint) timeElement; + timed = constraint.getConstrainedElements().stream().filter(type::isInstance).map(type::cast); + } else if (timeElement instanceof TimeObservation) { + TimeObservation observation = (TimeObservation) timeElement; + timed = Stream.of(observation.getEvent()).filter(type::isInstance).map(type::cast); + } + + return timed.findFirst(); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java deleted file mode 100644 index b95b6d63723..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java +++ /dev/null @@ -1,125 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2010 CEA - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Atos Origin - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.parser.custom; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; -import org.eclipse.papyrus.uml.diagram.common.helper.DurationObservationHelper; -import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser; -import org.eclipse.uml2.uml.DurationObservation; -import org.eclipse.uml2.uml.Element; -import org.eclipse.uml2.uml.UMLPackage; - -/** - * Specific Parser for the DurationObservation. - */ -public class DurationObservationParser extends MessageFormatParser implements ISemanticParser { - - /** The String for displaying a line break */ - private static final String LINE_BREAK = System.getProperty("line.separator"); - - public DurationObservationParser() { - super(new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }); - } - - public DurationObservationParser(EAttribute[] features) { - super(features); - } - - public DurationObservationParser(EAttribute[] features, EAttribute[] editableFeatures) { - super(features, editableFeatures); - } - - /** - * Gets the e structural feature. - * - * @param notification - * @return the structural feature - */ - protected EStructuralFeature getEStructuralFeature(Object notification) { - EStructuralFeature featureImpl = null; - if (notification instanceof Notification) { - Object feature = ((Notification) notification).getFeature(); - if (feature instanceof EStructuralFeature) { - featureImpl = (EStructuralFeature) feature; - } - } - return featureImpl; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isAffectingEvent(Object event, int flags) { - EStructuralFeature feature = getEStructuralFeature(event); - return isValidFeature(feature); - } - - /** - * {@inheritDoc} - */ - @Override - public String getPrintString(IAdaptable element, int flags) { - Object adapter = element.getAdapter(EObject.class); - if (adapter instanceof DurationObservation) { - return DurationObservationHelper.getLabelString((DurationObservation) adapter); - } - return ""; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean areSemanticElementsAffected(EObject listener, Object notification) { - EStructuralFeature feature = getEStructuralFeature(notification); - return isValidFeature(feature); - } - - /** - * {@inheritDoc} - */ - @Override - @SuppressWarnings("unchecked") - public List getSemanticElementsBeingParsed(EObject element) { - List<Element> semanticElementsBeingParsed = new ArrayList<>(); - if (element instanceof DurationObservation) { - DurationObservation observation = (DurationObservation) element; - semanticElementsBeingParsed.add(observation); - } - return semanticElementsBeingParsed; - } - - /** - * Determines if the given feature has to be taken into account in this parser - * - * @param feature - * the feature to test - * @return true if is valid, false otherwise - */ - private boolean isValidFeature(EStructuralFeature feature) { - return UMLPackage.eINSTANCE.getNamedElement_Name().equals(feature) || UMLPackage.eINSTANCE.getMessage_SendEvent().equals(feature) || UMLPackage.eINSTANCE.getMessage_ReceiveEvent().equals(feature) - || UMLPackage.eINSTANCE.getDurationObservation_Event().equals(feature); - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomDestructionOccurrenceSpecificationEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomDestructionOccurrenceSpecificationEditPolicyProvider.java new file mode 100644 index 00000000000..2fe6cf5f841 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomDestructionOccurrenceSpecificationEditPolicyProvider.java @@ -0,0 +1,58 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.providers; + +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomDestructionOccurrenceSpecificationSemanticEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.TimeElementCreationFeedbackEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.locator.TimeElementLocator; +import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.CustomDestructionOccurrenceSpecificationCreationEditPolicy; + +/** + * Provider of custom edit policies for destruction occurrence specifications. + */ +public class CustomDestructionOccurrenceSpecificationEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider { + + @Override + public boolean provides(final IOperation operation) { + + if (operation instanceof CreateEditPoliciesOperation) { + final EditPart editPart = ((CreateEditPoliciesOperation) operation).getEditPart(); + if (editPart instanceof DestructionOccurrenceSpecificationEditPart) { + return true; + } + } + + return false; + } + + @Override + public void createEditPolicies(final EditPart editPart) { + editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomDestructionOccurrenceSpecificationCreationEditPolicy()); + editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomDestructionOccurrenceSpecificationSemanticEditPolicy()); + editPart.installEditPolicy(TimeElementCreationFeedbackEditPolicy.ROLE, + new TimeElementCreationFeedbackEditPolicy(parentFigure -> new TimeElementLocator(parentFigure, + __ -> PositionConstants.CENTER))); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java index 9f84304f685..8041edb58e4 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java @@ -1,6 +1,5 @@ /***************************************************************************** - * Copyright (c) 2010 CEA - * + * Copyright (c) 2010, 2018 CEA List, EclipseSource, Christian W. Damus, and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,17 +10,19 @@ * * Contributors: * Soyatec - Initial API and implementation + * EclipseSource - Bug 536641 + * Christian W. Damus - bug 536486 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.providers; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.notation.Connector; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.SilentEditpart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationBehaviorEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CCombinedFragmentCombinedFragmentCompartmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CCombinedFragmentEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CDestructionOccurrenceSpecificationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CInteractionEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CInteractionInteractionCompartmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CInteractionOperandEditPart; @@ -29,8 +30,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombinedFragmentCompartmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConsiderIgnoreFragmentEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationObservationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationConstraintLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationObservationLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomGeneralOrderingEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomMessageName2EditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomMessageName3EditPart; @@ -41,8 +42,11 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomMessageName7Edi import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomMessageNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomStateInvariantEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomStateInvariantLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomTimeConstraintBorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomTimeObservationBorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart; @@ -56,12 +60,12 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageFoundNameEditP import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageLostNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageReplyNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncNameEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ObservationLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantLabelEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintBorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationBorderNodeEditPart; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.GrillingEditpart; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil; /** * @author Jin Liu (jin.liu@soyatec.com) @@ -87,11 +91,6 @@ public class CustomEditPartProvider extends UMLEditPartProvider { } else if (BehaviorExecutionSpecificationBehaviorEditPart.BEHAVIOR_TYPE.equals(view.getType())) { return new BehaviorExecutionSpecificationBehaviorEditPart(view); } - if (view instanceof Connector) { - if (((Connector) view).getType().equals(SequenceUtil.OBSERVATION_LINK_TYPE)) { - return new ObservationLinkEditPart(view); - } - } switch (UMLVisualIDRegistry.getVisualID(view)) { // case SequenceDiagramEditPart.VISUAL_ID: // return new OLDPackageEditPart(view); @@ -130,24 +129,22 @@ public class CustomEditPartProvider extends UMLEditPartProvider { return new CustomStateInvariantEditPart(view); // case CombinedFragment2EditPart.VISUAL_ID: // return new CustomCombinedFragment2EditPart(view); - // case TimeConstraintEditPart.VISUAL_ID: - // return new CustomTimeConstraintEditPart(view); + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + return new CustomTimeConstraintBorderNodeEditPart(view); // case TimeConstraintAppliedStereotypeEditPart.VISUAL_ID: // return new CustomTimeConstraintAppliedStereotypeEditPart(view); // case TimeConstraintLabelEditPart.VISUAL_ID: // return new CustomTimeConstraintLabelEditPart(view); - // case TimeObservationEditPart.VISUAL_ID: - // return new CustomTimeObservationEditPart(view); + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return new CustomTimeObservationBorderNodeEditPart(view); // case TimeObservationLabelEditPart.VISUAL_ID: // return new CustomTimeObservationLabelEditPart(view); // case TimeObservationAppliedStereotypeEditPart.VISUAL_ID: // return new CustomTimeObservationAppliedStereotypeEditPart(view); - // case DurationConstraintEditPart.VISUAL_ID: - // return new CustomDurationConstraintEditPart(view); // case DurationConstraintAppliedStereotypeEditPart.VISUAL_ID: // return new CustomDurationConstraintAppliedStereotypeEditPart(view); - // case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: - // return new CustomDestructionOccurrenceSpecificationEditPart(view); + case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: + return new CDestructionOccurrenceSpecificationEditPart(view); // case ConstraintEditPart.VISUAL_ID: // return new CustomConstraintEditPart(view); // case Constraint2EditPart.VISUAL_ID: @@ -160,10 +157,6 @@ public class CustomEditPartProvider extends UMLEditPartProvider { // return new CustomDurationConstraintInMessageEditPart(view); // case DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID: // return new CustomDurationConstraintInMessageAppliedStereotypeEditPart(view); - case DurationObservationEditPart.VISUAL_ID: - return new CustomDurationObservationEditPart(view); - case DurationObservationAppliedStereotypeEditPart.VISUAL_ID: - return new CustomDurationObservationAppliedStereotypeEditPart(view); case InteractionInteractionCompartmentEditPart.VISUAL_ID: return new CInteractionInteractionCompartmentEditPart(view); // case CombinedFragmentCombinedFragmentCompartmentEditPart.VISUAL_ID: @@ -206,6 +199,10 @@ public class CustomEditPartProvider extends UMLEditPartProvider { // return new MessageEndEditPart(view); case StateInvariantLabelEditPart.VISUAL_ID: return new CustomStateInvariantLabelEditPart(view); + case DurationConstraintLinkEditPart.VISUAL_ID: + return new CustomDurationConstraintLinkEditPart(view); + case DurationObservationLinkEditPart.VISUAL_ID: + return new CustomDurationObservationLinkEditPart(view); } return null; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPolicyProvider.java index 3a1eee1d7bc..b27530ca401 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPolicyProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPolicyProvider.java @@ -34,7 +34,6 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AnnotatedConnectio import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AnnotatedLinkEndEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AnnotatedLinkStartEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceConnectionHandleEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil; import org.eclipse.papyrus.uml.diagram.sequence.util.TooltipUtil; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Constraint; @@ -69,7 +68,6 @@ public class CustomEditPolicyProvider implements IEditPolicyProvider { editPart.installEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE, new SequenceConnectionHandleEditPolicy()); } installHighlightPolicy(editPart); - SequenceUtil.installObservationLinkPolicy(editPart); // install annotated link edit policy. if (editPart instanceof IGraphicalEditPart) { Object model = editPart.getModel(); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java index b384aa3c2ef..16642d82c0f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST and others. + * Copyright (c) 2017, 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,11 +10,14 @@ * * Contributors: * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * Christian W. Damus - bug 536486 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.providers; +import static org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart.findNearestSide; + import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPolicy; import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; @@ -23,6 +26,9 @@ import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomExecutionSpecificationSemanticEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.TimeElementCreationFeedbackEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.locator.TimeElementLocator; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.CustomExecutionSpecificationCreationEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.CustomExecutionSpecificationXYLayoutEditPolicy; @@ -49,15 +55,16 @@ public class CustomExecutionSpecificationEditPolicyProvider extends AbstractProv return false; } - /** - * {@inheritDoc} - * - * @see org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider#createEditPolicies(org.eclipse.gef.EditPart) - */ @Override public void createEditPolicies(final EditPart editPart) { editPart.installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CustomExecutionSpecificationCreationEditPolicy()); editPart.installEditPolicy(EditPolicy.LAYOUT_ROLE, new CustomExecutionSpecificationXYLayoutEditPolicy()); + editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomExecutionSpecificationSemanticEditPolicy()); + + TimeElementCreationFeedbackEditPolicy tecfep = new TimeElementCreationFeedbackEditPolicy( + parentFigure -> new TimeElementLocator(parentFigure, + constraint -> findNearestSide(parentFigure, constraint))); + editPart.installEditPolicy(TimeElementCreationFeedbackEditPolicy.ROLE, tecfep); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomLifelineEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomLifelineEditPolicyProvider.java new file mode 100644 index 00000000000..99cc0665dda --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomLifelineEditPolicyProvider.java @@ -0,0 +1,70 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.providers; + +import java.util.OptionalInt; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.PositionConstants; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CustomLifelineSemanticEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.TimeElementCreationFeedbackEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.locator.TimeElementLocator; + +/** + * Provider of custom edit policies for lifelines. + */ +public class CustomLifelineEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider { + + @Override + public boolean provides(final IOperation operation) { + + if (operation instanceof CreateEditPoliciesOperation) { + final EditPart editPart = ((CreateEditPoliciesOperation) operation).getEditPart(); + if (editPart instanceof CLifeLineEditPart) { + return true; + } + } + + return false; + } + + @Override + public void createEditPolicies(final EditPart editPart) { + CLifeLineEditPart lifeline = (CLifeLineEditPart) editPart; + + editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new CustomLifelineSemanticEditPolicy()); + editPart.installEditPolicy(TimeElementCreationFeedbackEditPolicy.ROLE, new TimeElementCreationFeedbackEditPolicy( + parentFigure -> getTimeElementLocator(lifeline, parentFigure))); + } + + private IBorderItemLocator getTimeElementLocator(CLifeLineEditPart lifeline, IFigure parentFigure) { + return new TimeElementLocator(parentFigure, proposedConstraints -> { + OptionalInt side = lifeline.getCreateMessageIncomingSide(proposedConstraints.getTopLeft()); + + return side.isPresent() + ? PositionConstants.EAST_WEST ^ side.getAsInt() + : PositionConstants.CENTER; + }); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java index 3bd259b527b..be6c7daae84 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java @@ -1,6 +1,5 @@ /***************************************************************************** - * Copyright (c) 2010 CEA - * + * Copyright (c) 2010, 2018 CEA List, EclipseSource and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,6 +10,7 @@ * * Contributors: * Soyatec - Initial API and implementation + * EclipseSource - Bug 536641 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.providers; @@ -25,6 +25,7 @@ import org.eclipse.gmf.runtime.diagram.core.services.view.CreateNodeViewOperatio import org.eclipse.gmf.runtime.diagram.core.services.view.CreateViewForKindOperation; import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; import org.eclipse.gmf.runtime.notation.Bounds; +import org.eclipse.gmf.runtime.notation.Connector; import org.eclipse.gmf.runtime.notation.DecorationNode; import org.eclipse.gmf.runtime.notation.Edge; import org.eclipse.gmf.runtime.notation.Location; @@ -41,20 +42,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentCombi import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentAnnotatedElementEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConsiderIgnoreFragmentEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandGuardEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.uml2.uml.CombinedFragment; @@ -71,17 +59,6 @@ public class CustomViewProvider extends UMLViewProvider { if (op.getContainerView() == null) { return false; } - String visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint()); - if (DurationConstraintEditPart.VISUAL_ID.equals(visualID)) { - // avoid to - // modify - // UMLVisualIDRegistry.getNodeVisualID(View, - // EObject) - if (InteractionInteractionCompartmentEditPart.VISUAL_ID.equals(UMLVisualIDRegistry - .getVisualID(op.getContainerView()))) { - return true; - } - } return super.provides(op); } @@ -90,16 +67,6 @@ public class CustomViewProvider extends UMLViewProvider { if (op.getContainerView() == null) { return false; } - String visualID = UMLVisualIDRegistry.getVisualID(op.getSemanticHint()); - if (DurationConstraintEditPart.VISUAL_ID.equals(visualID)) { // avoid to - // modify - // UMLVisualIDRegistry.getNodeVisualID(View, - // EObject) - if (InteractionInteractionCompartmentEditPart.VISUAL_ID.equals(UMLVisualIDRegistry - .getVisualID(op.getContainerView()))) { - return true; - } - } return super.provides(op); } @@ -109,7 +76,7 @@ public class CustomViewProvider extends UMLViewProvider { PreferencesHint preferencesHint) { Edge edge = super.createEdge(semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint); - if (edge != null) { + if (edge != null && false == edge instanceof Connector) { edge.getStyles().add(NotationFactory.eINSTANCE.createLineStyle()); final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint .getPreferenceStore(); @@ -119,47 +86,6 @@ public class CustomViewProvider extends UMLViewProvider { return edge; } - @Override - public Node createTimeObservation_Shape(EObject domainElement, - View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry - .getType(TimeObservationEditPart.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint - .getPreferenceStore(); - PreferenceInitializerForElementHelper.initForegroundFromPrefs(node, - prefStore, "TimeObservation"); - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, - prefStore, "TimeObservation"); - PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, - prefStore, "TimeObservation"); - Node timeObservation_NameLabel = createLabel(node, - UMLVisualIDRegistry - .getType(TimeObservationLabelEditPart.VISUAL_ID), - true); - timeObservation_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE - .createLocation()); - Location timeObservation_NameLabel_Location = (Location) timeObservation_NameLabel.getLayoutConstraint(); - timeObservation_NameLabel_Location.setX(0); - timeObservation_NameLabel_Location.setY(0); - Node timeObservation_StereotypeLabel = createLabel( - node, - UMLVisualIDRegistry - .getType(TimeObservationAppliedStereotypeEditPart.VISUAL_ID), - true); - timeObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE - .createLocation()); - Location timeObservation_StereotypeLabel_Location = (Location) timeObservation_StereotypeLabel.getLayoutConstraint(); - timeObservation_StereotypeLabel_Location.setX(0); - timeObservation_StereotypeLabel_Location.setY(0); - return node; - } - protected Node createLabel(View owner, String hint, boolean isTimeObservationLable) { Shape node = NotationFactory.eINSTANCE.createShape(); @@ -169,45 +95,6 @@ public class CustomViewProvider extends UMLViewProvider { return node; } - @Override - public Node createDurationConstraint_Shape(EObject domainElement, - View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry - .getType(DurationConstraintEditPart.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint - .getPreferenceStore(); - PreferenceInitializerForElementHelper.initForegroundFromPrefs(node, - prefStore, "DurationConstraint"); - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, - prefStore, "DurationConstraint"); - PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, - prefStore, "DurationConstraint"); - Node durationConstraint_BodyLabel = createLabel(node, - UMLVisualIDRegistry - .getType(DurationConstraintLabelEditPart.VISUAL_ID)); - durationConstraint_BodyLabel.setLayoutConstraint(NotationFactory.eINSTANCE - .createLocation()); - Location durationConstraint_BodyLabel_Location = (Location) durationConstraint_BodyLabel.getLayoutConstraint(); - durationConstraint_BodyLabel_Location.setX(25); - durationConstraint_BodyLabel_Location.setY(0); - Node durationConstraint_StereotypeLabel = createLabel( - node, - UMLVisualIDRegistry - .getType(DurationConstraintAppliedStereotypeEditPart.VISUAL_ID)); - durationConstraint_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE - .createLocation()); - Location durationConstraint_StereotypeLabel_Location = (Location) durationConstraint_StereotypeLabel.getLayoutConstraint(); - durationConstraint_StereotypeLabel_Location.setX(0); - durationConstraint_StereotypeLabel_Location.setY(-22); - return node; - } - /** * This class has bee overloaded in order to set the combined fragment under the lifelines * @@ -261,82 +148,6 @@ public class CustomViewProvider extends UMLViewProvider { return i; } - - @Override - public Node createDurationConstraint_Shape_CN(EObject domainElement, - View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Node node = NotationFactory.eINSTANCE.createShape(); - node.getStyles() - .add(NotationFactory.eINSTANCE.createDescriptionStyle()); - node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle()); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry - .getType(DurationConstraintInMessageEditPart.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // custom layout for location - Location durationConstraint_Shape_CN_Location = (Location) node.getLayoutConstraint(); - durationConstraint_Shape_CN_Location.setX(0); - durationConstraint_Shape_CN_Location.setY(20); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint - .getPreferenceStore(); - PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, - prefStore, "DurationConstraint"); - Node durationConstraint_BodyLabel_CN = createLabel( - node, - UMLVisualIDRegistry - .getType(DurationConstraintInMessageLabelEditPart.VISUAL_ID)); - Node durationConstraint_StereotypeLabel_CN = createLabel( - node, - UMLVisualIDRegistry - .getType(DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID)); - durationConstraint_StereotypeLabel_CN.setLayoutConstraint(NotationFactory.eINSTANCE - .createLocation()); - Location durationConstraint_StereotypeLabel_CN_Location = (Location) durationConstraint_StereotypeLabel_CN.getLayoutConstraint(); - durationConstraint_StereotypeLabel_CN_Location.setX(0); - durationConstraint_StereotypeLabel_CN_Location.setY(-22); - return node; - } - - @Override - public Node createDurationObservation_Shape(EObject domainElement, - View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Node node = NotationFactory.eINSTANCE.createShape(); - node.getStyles() - .add(NotationFactory.eINSTANCE.createDescriptionStyle()); - node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle()); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry - .getType(DurationObservationEditPart.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // custom layout for location - Location durationObservation_Shape_Location = (Location) node.getLayoutConstraint(); - durationObservation_Shape_Location.setX(0); - durationObservation_Shape_Location.setY(0); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint - .getPreferenceStore(); - PreferenceInitializerForElementHelper.initBackgroundFromPrefs(node, - prefStore, "DurationObservation"); - Node durationObservation_NameLabel = createLabel(node, - UMLVisualIDRegistry - .getType(DurationObservationLabelEditPart.VISUAL_ID)); - Node durationObservation_StereotypeLabel = createLabel( - node, - UMLVisualIDRegistry - .getType(DurationObservationAppliedStereotypeEditPart.VISUAL_ID)); - durationObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE - .createLocation()); - Location durationObservation_StereotypeLabel_Location = (Location) durationObservation_StereotypeLabel.getLayoutConstraint(); - durationObservation_StereotypeLabel_Location.setX(0); - durationObservation_StereotypeLabel_Location.setY(0); - return node; - } - @Override public Node createConsiderIgnoreFragment_Shape(EObject domainElement, View containerView, int index, boolean persisted, diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/DurationConstraintContributionItem.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/DurationConstraintContributionItem.java deleted file mode 100644 index a7a44e3a929..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/DurationConstraintContributionItem.java +++ /dev/null @@ -1,319 +0,0 @@ -package org.eclipse.papyrus.uml.diagram.sequence.providers; - -import java.util.List; - -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.PrecisionPoint; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.common.command.Command; -import org.eclipse.gmf.runtime.common.core.command.CompositeCommand; -import org.eclipse.gmf.runtime.common.core.command.ICommand; -import org.eclipse.gmf.runtime.diagram.core.commands.SetConnectionAnchorsCommand; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; -import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor; -import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; -import org.eclipse.jface.action.ContributionItem; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.papyrus.infra.emf.gmf.command.EMFtoGMFCommandWrapper; -import org.eclipse.papyrus.infra.emf.gmf.command.GMFtoEMFCommandWrapper; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.uml.diagram.sequence.command.SetResizeAndLocationCommand; -import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomCommentAnnotatedElementEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationConstraintEditPart; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.CoolBar; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.menus.IWorkbenchContribution; -import org.eclipse.ui.services.IServiceLocator; -import org.eclipse.uml2.uml.DurationConstraint; - -//org.eclipse.papyrus.extensionpoints.editors.ui.DirectEditorsContributionItem -public class DurationConstraintContributionItem extends ContributionItem implements IWorkbenchContribution { - - /** - * Service locator given to this contribution item using the {@link IWorkbenchContribution} interface. - */ - private IServiceLocator serviceLocator; - - private MenuItem subMenuItem; - - /** - * - */ - public DurationConstraintContributionItem() { - setId("org.eclipse.papyrus.sequence.duraitonconstraint.menuitem"); - } - - /** - * @param id - */ - public DurationConstraintContributionItem(String id) { - super(id); - } - - /** - * The default implementation of this <code>IContributionItem</code> method does nothing. - * Subclasses may override. - */ - @Override - public void dispose() { - if (subMenuItem != null && !subMenuItem.isDisposed()) { - subMenuItem.dispose(); - } - } - - /** - * The default implementation of this <code>IContributionItem</code> method does nothing. - * Subclasses may override. - */ - @Override - public void fill(Composite parent) { - } - - /** - * The default implementation of this <code>IContributionItem</code> method does nothing. - * Subclasses may override. - */ - @Override - public void fill(Menu menu, int index) { - // retrieves current selection - final Object selectedElement = getSelectedElement(); - - // first case: this class was not able to retrieve the selection service - // or does not understand the current selection. - // does not build any sub-menu and returns. - if (selectedElement == null) { - return; - } - - // get the uml object type of this element, using the business resolver - final Object businessObject = EMFHelper.getEObject(selectedElement); - // no object found: exit - if (businessObject == null || !(businessObject instanceof DurationConstraint)) { - return; - } - - createSubMenu(menu, index, (DurationConstraint) businessObject); - } - - protected void createSubMenu(Menu menu, int index, DurationConstraint businessObject) { - subMenuItem = new MenuItem(menu, SWT.PUSH);// SWT.CASCADE); - subMenuItem.setText("Rotate Duration Constraint"); - - subMenuItem.addSelectionListener(new SelectionListener() { - - @Override - public void widgetDefaultSelected(SelectionEvent e) { - - } - - @Override - public void widgetSelected(SelectionEvent e) { - doRotate(); - } - }); - } - - /** - * Retrieves and return the current selected element - * - * @return the current selected element - */ - protected Object getSelectedElement() { - ISelection selection = getSelection(); - // this checks if it is the good instance AND if it is not null - if (selection instanceof IStructuredSelection) { - return ((IStructuredSelection) selection).getFirstElement(); - } - return null; - } - - /** - * Retrieves and return the current selection - * - * @return the current selection - */ - protected ISelection getSelection() { - ISelectionService selectionService = getSelectionService(); - if (selectionService != null) { - return selectionService.getSelection(); - } - return null; - } - - /** - * Returns the selection service for the current workbench - * - * @return the selection service for the current workbench or <code>null</code> if no selection - * service was found. - */ - protected ISelectionService getSelectionService() { - ISelectionService selectionService = serviceLocator.getService(ISelectionService.class); - return selectionService; - } - - /** - * The default implementation of this <code>IContributionItem</code> method does nothing. - * Subclasses may override. - */ - @Override - public void fill(ToolBar parent, int index) { - } - - /** - * The default implementation of this <code>IContributionItem</code> method does nothing. - * Subclasses may override. - * - * @since 3.0 - */ - @Override - public void fill(CoolBar parent, int index) { - } - - /** - * The default implementation of this <code>IContributionItem</code> method does nothing. - * Subclasses may override. - * - * @since 3.0 - */ - @Override - public void saveWidgetState() { - } - - /** - * The default implementation of this <code>IContributionItem</code> method returns <code>false</code>. Subclasses may override. - */ - @Override - public boolean isDirty() { - // @issue should this be false instead of calling isDynamic()? - return true; - } - - /** - * The default implementation of this <code>IContributionItem</code> method returns <code>true</code>. Subclasses may override. - */ - @Override - public boolean isEnabled() { - return true; - } - - /** - * The default implementation of this <code>IContributionItem</code> method returns <code>false</code>. Subclasses may override. - */ - @Override - public boolean isDynamic() { - return true; - } - - /** - * The default implementation of this <code>IContributionItem</code> method returns <code>false</code>. Subclasses may override. - */ - @Override - public boolean isGroupMarker() { - return false; - } - - /** - * The default implementation of this <code>IContributionItem</code> method returns <code>false</code>. Subclasses may override. - */ - @Override - public boolean isSeparator() { - return false; - } - - /** - * Returns a string representation of this contribution item suitable only for debugging. - */ - @Override - public String toString() { - return getClass().getName() + "(id=" + getId() + ")";//$NON-NLS-2$//$NON-NLS-1$ - } - - /** - * The default implementation of this <code>IContributionItem</code> method does nothing. - * Subclasses may override. - */ - @Override - public void update() { - } - - /** - * The <code>ContributionItem</code> implementation of this method declared on <code>IContributionItem</code> does nothing. Subclasses should - * override to update their - * state. - */ - @Override - public void update(String id) { - } - - /** - * {@inheritDoc} - */ - @Override - public void initialize(IServiceLocator serviceLocator) { - assert (serviceLocator != null); - this.serviceLocator = serviceLocator; - } - - private void doRotate() { - Object element = getSelectedElement(); - if (!(element instanceof CustomDurationConstraintEditPart)) { - return; - } - - CustomDurationConstraintEditPart durationPart = (CustomDurationConstraintEditPart) element; - boolean isVertical = durationPart.isArrowVertical(); - - CompositeCommand compositeCmd = new CompositeCommand("rotate"); - Command rotateCmd = new CustomDurationConstraintEditPart.RotateArrowCommand(durationPart.getEditingDomain(), durationPart); - compositeCmd.add(new EMFtoGMFCommandWrapper(rotateCmd)); - - // set bounds command - ICommand boundsCommand = new SetResizeAndLocationCommand(durationPart.getEditingDomain(), DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter(durationPart.getNotationView()), getNewBounds(durationPart.getBounds())); - compositeCmd.add(boundsCommand); - - // update anchor - List list = durationPart.getSourceConnections(); - for (Object o : list) { - if (o instanceof CustomCommentAnnotatedElementEditPart) { - CustomCommentAnnotatedElementEditPart connectionPart = (CustomCommentAnnotatedElementEditPart) o; - String terminal = AnchorHelper.getAnchorId(connectionPart.getEditingDomain(), connectionPart, true); - if (terminal.length() > 0) { - PrecisionPoint pt = BaseSlidableAnchor.parseTerminalString(terminal); - SetConnectionAnchorsCommand rotateAnchorsCommand = new SetConnectionAnchorsCommand(connectionPart.getEditingDomain(), "Rotate Duration Anchors"); - rotateAnchorsCommand.setEdgeAdaptor(new EObjectAdapter(connectionPart.getNotationView())); - if (isVertical) { - if (pt.y < 0.3) { - rotateAnchorsCommand.setNewSourceTerminal("(0,0.5){L}"); - } else if (pt.y > 0.7) { - rotateAnchorsCommand.setNewSourceTerminal("(1,0.5){R}"); - } - } else { - if (pt.x < 0.3) { - rotateAnchorsCommand.setNewSourceTerminal("(0.5,0){T}"); - } else if (pt.x > 0.7) { - rotateAnchorsCommand.setNewSourceTerminal("(0.5,1){D}"); - } - } - compositeCmd.add(rotateAnchorsCommand); - } - } - } - // execute command - durationPart.getEditingDomain().getCommandStack().execute(new GMFtoEMFCommandWrapper(compositeCmd)); - } - - private Rectangle getNewBounds(Rectangle bounds) { - Point p = bounds.getCenter(); - return new Rectangle(p.x - bounds.height / 2, p.y - bounds.width / 2, bounds.height, bounds.width); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java index 530c165c78b..71bc5b42427 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java @@ -25,12 +25,9 @@ import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvide import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CDestructionOccurrenceSpecificationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomContinuationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDestructionOccurrenceSpecificationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationConstraintEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomStateInvariantEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomTimeConstraintLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomTimeObservationLabelEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.SequenceDiagramEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AppliedStereotypeCommentCreationEditPolicyEx; @@ -96,8 +93,8 @@ public class PostEditPolicyProvider implements IEditPolicyProvider { @Override public void createEditPolicies(EditPart editPart) { // Replace AppliedStereotypeCommentCreationEditPolicy to a custom one. - if (editPart instanceof AbstractExecutionSpecificationEditPart || editPart instanceof CustomDestructionOccurrenceSpecificationEditPart || editPart instanceof CustomDurationConstraintEditPart || editPart instanceof CustomDurationConstraintEditPart - || editPart instanceof CustomStateInvariantEditPart || editPart instanceof CustomTimeConstraintLabelEditPart || editPart instanceof CustomTimeObservationLabelEditPart || editPart instanceof AbstractMessageEditPart + if (editPart instanceof AbstractExecutionSpecificationEditPart || editPart instanceof CDestructionOccurrenceSpecificationEditPart + || editPart instanceof CustomStateInvariantEditPart || editPart instanceof AbstractMessageEditPart || editPart instanceof GeneralOrderingEditPart || editPart instanceof CustomContinuationEditPart) { editPart.installEditPolicy(AppliedStereotypeCommentEditPolicy.APPLIED_STEREOTYPE_COMMENT, new AppliedStereotypeCommentCreationEditPolicyEx()); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/SemanticOccurrenceEditPolicyProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/SemanticOccurrenceEditPolicyProvider.java new file mode 100644 index 00000000000..ee8a4a6a090 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/SemanticOccurrenceEditPolicyProvider.java @@ -0,0 +1,60 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.providers; + +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.common.core.service.AbstractProvider; +import org.eclipse.gmf.runtime.common.core.service.IOperation; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.CreateEditPoliciesOperation; +import org.eclipse.gmf.runtime.diagram.ui.services.editpolicy.IEditPolicyProvider; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.OccurenceSemanticEditPolicy; +import org.eclipse.uml2.uml.DestructionOccurrenceSpecification; +import org.eclipse.uml2.uml.ExecutionSpecification; +import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.OccurrenceSpecification; + +/** + * <p> + * An {@link IEditPolicyProvider} installing an {@link OccurenceSemanticEditPolicy} on + * {@link Message} and {@link ExecutionSpecification} edit parts. + * </p> + * <p> + * Note: it doesn't have to be installed on {@link DestructionOccurrenceSpecification}, because that + * edit part already directly represents a single {@link OccurrenceSpecification}. + * </p> + */ +public class SemanticOccurrenceEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider { + + @Override + public boolean provides(IOperation operation) { + if (false == operation instanceof CreateEditPoliciesOperation) { + return false; + } + + CreateEditPoliciesOperation op = (CreateEditPoliciesOperation) operation; + EditPart editPart = op.getEditPart(); + + // Only install this on Message EditParts. We also need that policy for ExecSpecs, + // but CustomExecutionSpecificationEditPolicyProvider already takes care of that + return editPart instanceof AbstractMessageEditPart; + } + + @Override + public void createEditPolicies(EditPart editPart) { + editPart.installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new OccurenceSemanticEditPolicy()); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java index e108b1be794..01cdc14dc54 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java @@ -17,6 +17,7 @@ package org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling; import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PrecisionPoint; import org.eclipse.draw2d.geometry.PrecisionRectangle; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EObject; @@ -27,6 +28,7 @@ import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener; import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor; import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; import org.eclipse.gmf.runtime.notation.Bounds; import org.eclipse.gmf.runtime.notation.DecorationNode; @@ -391,17 +393,20 @@ public class ConnectRectangleToGridEditPolicy extends ConnectToGridEditPolicy im */ protected void updateAnchorFromHeight(IdentityAnchor anchor, Node node, int deltaHeight) { if (null != anchor) { - double yPercent = IdentityAnchorHelper.getYPercentage(anchor); - double xPercent = IdentityAnchorHelper.getXPercentage(anchor); - - // calculate bounds from notation - int nodeHeight = BoundForEditPart.getHeightFromView(node); - double oldHeight = nodeHeight - deltaHeight; - double preciseHeight = nodeHeight; - - double newPercentY = (yPercent * oldHeight) / preciseHeight; - final String newIdValue = IdentityAnchorHelper.createNewAnchorIdValue(xPercent, newPercentY); - execute(new SetCommand(getDiagramEditPart(getHost()).getEditingDomain(), anchor, NotationPackage.eINSTANCE.getIdentityAnchor_Id(), newIdValue)); + PrecisionPoint anchorLocation = BaseSlidableAnchor.parseTerminalString(anchor.getId()); + if (anchorLocation != null) { + double yPercent = anchorLocation.preciseY(); + double xPercent = anchorLocation.preciseX(); + + // calculate bounds from notation + int nodeHeight = BoundForEditPart.getHeightFromView(node); + double oldHeight = nodeHeight - deltaHeight; + double preciseHeight = nodeHeight; + + double newPercentY = (yPercent * oldHeight) / preciseHeight; + final String newIdValue = IdentityAnchorHelper.createNewAnchorIdValue(xPercent, newPercentY); + execute(new SetCommand(getDiagramEditPart(getHost()).getEditingDomain(), anchor, NotationPackage.eINSTANCE.getIdentityAnchor_Id(), newIdValue)); + } } } @@ -419,8 +424,12 @@ public class ConnectRectangleToGridEditPolicy extends ConnectToGridEditPolicy im */ protected void updateAnchorFromY(IdentityAnchor anchor, Node node, int oldY, int newY) { if (null != anchor && !anchor.getId().trim().equals("")) { //$NON-NLS-1$ - double yPercent = IdentityAnchorHelper.getYPercentage(anchor); - double xPercent = IdentityAnchorHelper.getXPercentage(anchor); + PrecisionPoint anchorLocation = BaseSlidableAnchor.parseTerminalString(anchor.getId()); + if (anchorLocation == null) { + return; + } + double yPercent = anchorLocation.preciseY(); + double xPercent = anchorLocation.preciseX(); // calculate bounds from notation double height = BoundForEditPart.getHeightFromView(node); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomDestructionOccurrenceSpecificationCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomDestructionOccurrenceSpecificationCreationEditPolicy.java new file mode 100644 index 00000000000..c3c88a2e8dc --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomDestructionOccurrenceSpecificationCreationEditPolicy.java @@ -0,0 +1,45 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling; + +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; +import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes; + +/** + * Custom creation edit policy for destruction occurrences, supporting time + * constraints and time observations. + */ +public class CustomDestructionOccurrenceSpecificationCreationEditPolicy extends DefaultCreationEditPolicy { + + @Override + protected ICommand getSetBoundsCommand(CreateViewRequest request, ViewDescriptor descriptor) { + if (UMLDIElementTypes.TIME_CONSTRAINT_SHAPE.getSemanticHint().equals(descriptor.getSemanticHint()) + || UMLDIElementTypes.TIME_OBSERVATION_SHAPE.getSemanticHint().equals(descriptor.getSemanticHint())) { + + // The visualization of the time constraint cannot be moved + Dimension size = new Dimension(40, 1); + return new SetBoundsCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), DiagramUIMessages.Commands_MoveElement, descriptor, size); + } + return super.getSetBoundsCommand(request, descriptor); + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomExecutionSpecificationCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomExecutionSpecificationCreationEditPolicy.java index 0316f632e59..4a34b0021b9 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomExecutionSpecificationCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomExecutionSpecificationCreationEditPolicy.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST and others. + * Copyright (c) 2017, 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,191 +10,146 @@ * * Contributors: * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation + * Christian W. Damus - bug 539373, 536486 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; +import static org.eclipse.papyrus.uml.service.types.utils.ElementUtil.isTypeOf; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; +import java.util.Optional; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.emf.ecore.EClass; import org.eclipse.gef.EditPart; import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.common.core.command.FileModificationValidator; -import org.eclipse.gmf.runtime.diagram.ui.commands.CommandUtilities; -import org.eclipse.gmf.runtime.diagram.ui.commands.CreateOrSelectElementCommand; -import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.diagram.ui.commands.SetBoundsCommand; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor; import org.eclipse.gmf.runtime.emf.type.core.IElementType; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.util.DurationLinkUtil; import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil; -import org.eclipse.swt.widgets.Display; +import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.uml2.uml.MessageOccurrenceSpecification; +import org.eclipse.uml2.uml.UMLPackage; /** * This allows to define the creation edit policy for the execution specification. */ public class CustomExecutionSpecificationCreationEditPolicy extends DefaultCreationEditPolicy { - /** - * {@inheritDoc} - * - * @see org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy#getCommand(org.eclipse.gef.Request) - */ + private DisplayEvent displayEvent; + + public CustomExecutionSpecificationCreationEditPolicy() { + super(); + } + + @Override + public void setHost(EditPart host) { + super.setHost(host); + + // Note that messages always actually connect to the lifeline, even if their + // connection figures show as connected to the execution, so we need to use + // the lifeline to find message ends + EditPart lifeline = SequenceUtil.getParentLifelinePart(getHost()); + displayEvent = new DisplayEvent(lifeline != null ? lifeline : host); + } + @Override - public Command getCommand(Request request) { - if (understandsRequest(request)) { - if (request instanceof CreateUnspecifiedTypeRequest) { - return getUnspecifiedTypeCreateCommand((CreateUnspecifiedTypeRequest) request); + protected ICommand getSetBoundsCommand(CreateViewRequest request, ViewDescriptor descriptor) { + if (UMLDIElementTypes.TIME_CONSTRAINT_SHAPE.getSemanticHint().equals(descriptor.getSemanticHint()) + || UMLDIElementTypes.TIME_OBSERVATION_SHAPE.getSemanticHint().equals(descriptor.getSemanticHint())) { + // check the position of the request to give the basic constraint for the created shape (should not be moveable) + Point location = request.getLocation().getCopy(); + location.setX(-10); + IFigure execFigure = ((IGraphicalEditPart) getHost()).getFigure(); + boolean isStart = DurationLinkUtil.isStart(execFigure, location); + if (isStart) { + location.setY(-1); + } else { + location.setY(Short.MAX_VALUE); } + Dimension size = new Dimension(40, 1); + return new SetBoundsCommand(((IGraphicalEditPart) getHost()).getEditingDomain(), DiagramUIMessages.Commands_MoveElement, descriptor, new Rectangle(location, size)); } - return super.getCommand(request); + return super.getSetBoundsCommand(request, descriptor); } - /** - * When this is a {@link CreateUnspecifiedTypeRequest}, we need to check if the position needed by the user is on an ExecutionSpecification because this is not allowed by the UML Norm - * but this will be possible graphically. - * - * @param request - * The unspecified type request. - * @return The command. - */ @SuppressWarnings("unchecked") - private Command getUnspecifiedTypeCreateCommand( - final CreateUnspecifiedTypeRequest request) { - - final Map<IElementType, Command> createCmds = new HashMap<>(); - List<IElementType> validTypes = new ArrayList<>(); - for (Iterator<IElementType> iter = request.getElementTypes().iterator(); iter - .hasNext();) { - IElementType elementType = iter.next(); - Request createRequest = request.getRequestForType(elementType); - if (createRequest != null) { - EditPart target = SequenceUtil.getParentLifelinePart(getHost().getTargetEditPart(createRequest)); - if (target == null) { - continue; - } - Command individualCmd = target.getCommand(createRequest); - - if (individualCmd != null && individualCmd.canExecute()) { - createCmds.put(elementType, individualCmd); - validTypes.add(elementType); - } - } + @Override + public EditPart getTargetEditPart(Request request) { + EditPart result = super.getTargetEditPart(request); + if (!(request instanceof CreateRequest)) { + return result; } - - if (createCmds.isEmpty()) { - return null; - } else if (createCmds.size() == 1) { - return (Command) createCmds.values().toArray()[0]; - } else { - CreateOrSelectElementCommand selectAndCreateViewCmd = new CreateOrSelectElementCommand( - DiagramUIMessages.CreateCommand_Label, Display.getCurrent() - .getActiveShell(), - validTypes) { - - private Command _createCmd; - - /** - * Execute the command that prompts the user with the popup - * menu, then executes the command prepared for the element - * type that the user selected. - */ - @Override - protected CommandResult doExecuteWithResult( - IProgressMonitor progressMonitor, IAdaptable info) - throws ExecutionException { - - CommandResult cmdResult = super.doExecuteWithResult(progressMonitor, info); - if (!cmdResult.getStatus().isOK()) { - return cmdResult; - } - - IElementType type = (IElementType) cmdResult - .getReturnValue(); - - _createCmd = createCmds.get(type); - Assert.isTrue(_createCmd != null && _createCmd.canExecute()); - - // validate the affected files - IStatus status = validateAffectedFiles(_createCmd); - if (!status.isOK()) { - return new CommandResult(status); - } - - _createCmd.execute(); - - // Set the result in the unspecified type request. - CreateRequest createRequest = request - .getRequestForType(type); - - Collection<?> newObject = ((Collection<?>) createRequest - .getNewObject()); - request.setNewObject(newObject); - - return CommandResult.newOKCommandResult(newObject); - } - - @Override - protected CommandResult doUndoWithResult( - IProgressMonitor progressMonitor, IAdaptable info) - throws ExecutionException { - - if (_createCmd != null && _createCmd.canUndo()) { - // validate the affected files - IStatus status = validateAffectedFiles(_createCmd); - if (!status.isOK()) { - return new CommandResult(status); - } - _createCmd.undo(); - } - return super.doUndoWithResult(progressMonitor, info); + CreateRequest create = (CreateRequest) request; + + Stream<? extends IElementType> elementTypes = null; + if (request instanceof CreateViewAndElementRequest) { + elementTypes = ((CreateViewAndElementRequest) request).getViewDescriptors().stream() + .map(v -> v.getElementAdapter().getAdapter(IElementType.class)); + } else if (request instanceof CreateUnspecifiedTypeRequest) { + elementTypes = ((CreateUnspecifiedTypeRequest) request).getElementTypes().stream(); + } + if (elementTypes != null) { + Predicate<IElementType> isInteresting = type -> isTypeOf(type, UMLElementTypes.TIME_CONSTRAINT); + isInteresting = isInteresting.or(type -> isTypeOf(type, UMLElementTypes.TIME_OBSERVATION)); + isInteresting = isInteresting.or(type -> isTypeOf(type, UMLElementTypes.EXECUTION_SPECIFICATION)); + Optional<EClass> interestingType = elementTypes.map(type -> { + if (isTypeOf(type, UMLElementTypes.TIME_CONSTRAINT)) { + return UMLPackage.Literals.TIME_CONSTRAINT; + } else if (isTypeOf(type, UMLElementTypes.TIME_OBSERVATION)) { + return UMLPackage.Literals.TIME_OBSERVATION; + } else if (isTypeOf(type, UMLElementTypes.EXECUTION_SPECIFICATION)) { + return UMLPackage.Literals.EXECUTION_SPECIFICATION; + } else { + return null; } - - @Override - protected CommandResult doRedoWithResult( - IProgressMonitor progressMonitor, IAdaptable info) - throws ExecutionException { - - if (_createCmd != null && CommandUtilities.canRedo(_createCmd)) { - // validate the affected files - IStatus status = validateAffectedFiles(_createCmd); - if (!status.isOK()) { - return new CommandResult(status); + }).findFirst(); + + result = interestingType.<EditPart> map(type -> { + switch (type.getClassifierID()) { + case UMLPackage.TIME_CONSTRAINT: + case UMLPackage.TIME_OBSERVATION: + Point loc = create.getLocation(); + if (loc != null) { + // Is a message end, here? Note that messages always actually connect to the + // lifeline, even if their connection figures show as connected to me, so + // we need to delegate to the lifeline to create the notation. Otherwise, + // re-targeting of the message to some other execution or to the lifeline + // itself will be complicated by the fact of the time element being a border + // node of this execution. Besides that it is more consistent with the + // edge anchoring implementation anyways + MessageOccurrenceSpecification messageOcc = displayEvent.getMessageEvent(((IGraphicalEditPart) getHost()).getFigure(), loc); + if (messageOcc != null) { + return SequenceUtil.getParentLifelinePart(getHost()); } - _createCmd.redo(); - } - return super.doRedoWithResult(progressMonitor, info); - } - - private IStatus validateAffectedFiles(Command command) { - Collection<?> affectedFiles = CommandUtilities - .getAffectedFiles(command); - int fileCount = affectedFiles.size(); - if (fileCount > 0) { - return FileModificationValidator - .approveFileModification(affectedFiles - .toArray(new IFile[fileCount])); } - return Status.OK_STATUS; + break; + case UMLPackage.EXECUTION_SPECIFICATION: + // The lifeline is responsible for creating all execution specifications, as they + // are semantically all children of it (nesting is strictly visual) + return SequenceUtil.getParentLifelinePart(getHost()); } - }; - - return new ICommandProxy(selectAndCreateViewCmd); + return null; + }).orElse(result); } + + return result; } + } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java index b1608506ae5..40a47ae6d23 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST, ALL4TEC and others. + * Copyright (c) 2017 CEA LIST, ALL4TEC, EclipseSource and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -12,6 +12,7 @@ * CEA LIST - Initial API and implementation * Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 519621, 519756, 526191 * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Bug 531596 + * EclipseSource - Bug 536641 * *****************************************************************************/ @@ -517,6 +518,10 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol relativeSnappedLocation = SequenceUtil.getSnappedLocation(getHost(), relativeSnappedLocation); getHostFigure().getParent().translateToRelative(relativeSnappedLocation); + if (false == request.getTargetEditPart() instanceof LifelineEditPart) { + // TODO This may happen when creating e.g. a Context link + return null; + } if (LifelineEditPartUtil.getNextEventsFromPosition(relativeSnappedLocation, (LifelineEditPart) request.getTargetEditPart()).isEmpty()) { NodeEditPart targetEditPart = (NodeEditPart) request.getTargetEditPart(); @@ -696,7 +701,7 @@ public class LifeLineGraphicalNodeEditPolicy extends DefaultGraphicalNodeEditPol // Check if the target is lower than the source Point sourceLocation = SequenceUtil.getAbsoluteEdgeExtremity((ConnectionNodeEditPart) request.getConnectionEditPart(), true); - if (!isTargetLowerThanSource(sourceLocation, request.getLocation().getCopy())) { + if (sourceLocation != null && !isTargetLowerThanSource(sourceLocation, request.getLocation().getCopy())) { Object object = request.getExtendedData().get(SequenceUtil.DO_NOT_CHECK_HORIZONTALITY); if (!(object instanceof Boolean) || ((object instanceof Boolean) && !((Boolean) object))) {// If not HorizontalMove parameter true return UnexecutableCommand.INSTANCE; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java index 984bc044363..512a99f4f5c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java @@ -10,7 +10,7 @@ * * Contributors: * CEA LIST - Initial API and implementation - * Christian W. Damus - bug 530201 + * Christian W. Damus - bugs 530201, 536486 * *****************************************************************************/ @@ -121,7 +121,7 @@ public class LifelineCreationEditPolicy extends DefaultCreationEditPolicy implem /** * {@inheritDoc} - * + * * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy#getReparentCommand(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) */ @Override @@ -136,7 +136,7 @@ public class LifelineCreationEditPolicy extends DefaultCreationEditPolicy implem return super.getReparentCommand(gep); } - + /** * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy#getReparentViewCommand(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) * @@ -174,6 +174,8 @@ public class LifelineCreationEditPolicy extends DefaultCreationEditPolicy implem controlledByLifeline = true; } else if (ElementUtil.isTypeOf(elementType, UMLDIElementTypes.TIME_CONSTRAINT_SHAPE)) { controlledByLifeline = true; + } else if (ElementUtil.isTypeOf(elementType, UMLDIElementTypes.TIME_OBSERVATION_SHAPE)) { + controlledByLifeline = true; } else if (ElementUtil.isTypeOf(elementType, UMLDIElementTypes.STATE_INVARIANT_SHAPE)) { controlledByLifeline = true; } else if (ElementUtil.isTypeOf(elementType, UMLDIElementTypes.COMBINED_FRAGMENT_CO_REGION_SHAPE)) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveArrowRequest.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveArrowRequest.java new file mode 100644 index 00000000000..235ace2c1b6 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveArrowRequest.java @@ -0,0 +1,46 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.requests; + +import org.eclipse.gef.requests.ChangeBoundsRequest; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure.Orientation; + +/** + * A request for moving the position of the arrow of a DurationLinkFigure. + */ +public class MoveArrowRequest extends ChangeBoundsRequest { + public static final String REQ_MOVE_ARROW = "MoveArrowRequest"; + private Orientation arrowOrientation; + + @Override + public Object getType() { + return REQ_MOVE_ARROW; + } + + /** + * @param arrowOrientation + */ + public void setArrowOrientation(Orientation arrowOrientation) { + this.arrowOrientation = arrowOrientation; + } + + /** + * @return the arrowOrientation + */ + public Orientation getArrowOrientation() { + return arrowOrientation; + } +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java index ff8a068081f..5d052cba159 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java @@ -14,11 +14,7 @@ *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.requests; -import java.util.List; - -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.Request; +import org.eclipse.gef.requests.ChangeBoundsRequest; /** * <p> @@ -26,16 +22,13 @@ import org.eclipse.gef.Request; * This should expand one of the Operands, and shrink the other one of the same * amount. * </p> - * + * * @since 5.0 */ -public class MoveSeparatorRequest extends Request { +public class MoveSeparatorRequest extends ChangeBoundsRequest { public static final String REQ_MOVE_SEPARATOR = "MoveSeparatorRequest"; private final int separatorIndex; - private Point moveDelta; - private Point location; - private List<? extends EditPart> editParts; public MoveSeparatorRequest(int separatorIndex) { this.separatorIndex = separatorIndex; @@ -54,42 +47,4 @@ public class MoveSeparatorRequest extends Request { return separatorIndex; } - /** - * @param moveDelta - */ - public void setMoveDelta(Point moveDelta) { - this.moveDelta = moveDelta; - } - - public Point getMoveDelta() { - return moveDelta; - } - - /** - * @param location - */ - public void setLocation(Point location) { - this.location = location; - } - - /** - * @return the location - */ - public Point getLocation() { - return location; - } - - /** - * @param editParts - */ - public void setEditParts(List<? extends EditPart> editParts) { - this.editParts = editParts; - } - - /** - * @return the editParts - */ - public List<? extends EditPart> getEditParts() { - return editParts; - } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/service/DurationCreationTool.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/service/DurationCreationTool.java index 90fed8a3295..c0a36098eb4 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/service/DurationCreationTool.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/service/DurationCreationTool.java @@ -464,47 +464,6 @@ public class DurationCreationTool extends AspectUnspecifiedTypeCreationTool { return null; } Request req = getTargetRequest(); - /* - * if(targetPart instanceof ConnectionNodeEditPart) { - * // a message part is targeted. Instead, we must take the nearby lifeline part. - * // redirect to the message part will be performed later in case we really want to draw a duration on a message - * ConnectionNodeEditPart conn = (ConnectionNodeEditPart)targetPart; - * EditPart source = ((ConnectionNodeEditPart)targetPart).getSource(); - * EditPart target = ((ConnectionNodeEditPart)targetPart).getTarget(); - * if(source instanceof NodeEditPart && target instanceof NodeEditPart) { - * ConnectionAnchor sourceAnch = ((NodeEditPart)source).getSourceConnectionAnchor(conn); - * ConnectionAnchor targetAnch = ((NodeEditPart)target).getSourceConnectionAnchor(conn); - * double sourceDist = getLocation().getDistance(sourceAnch.getReferencePoint()); - * double targetDist = getLocation().getDistance(targetAnch.getReferencePoint()); - * if(sourceDist > targetDist) { - * targetPart = target; - * } else { - * targetPart = source; - * } - * } - * } - * LifelineEditPart lifelinePart = SequenceUtil.getParentLifelinePart(targetPart); - * if(lifelinePart instanceof LifelineEditPart) { - * Object paramOcc1 = req.getExtendedData().get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION); - * List<OccurrenceSpecification> occ1List = SequenceUtil.getAsOccSpecList(paramOcc1); - * Object paramOcc2 = req.getExtendedData().get(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION_2); - * List<OccurrenceSpecification> occ2List = SequenceUtil.getAsOccSpecList(paramOcc2); - * if(!occ1List.isEmpty() && !occ2List.isEmpty() && Collections.disjoint(occ1List, occ2List)) { - * OccurrenceSpecification[] pair = SequenceUtil.getPairOfCorrespondingOccSpec(occ1List, occ2List); - * if(pair != null && pair.length > 1) { - * OccurrenceSpecification occ1 = pair[0]; - * OccurrenceSpecification occ2 = pair[1]; - * if(DurationConstraintHelper.endsOfSameMessage(occ1, occ2)) { - * // call request on the link - * EditPart part = SequenceUtil.getLinkedEditPart(lifelinePart, occ2); - * if(part != null) { - * return part.getCommand(req); - * } - * } - * } - * } - * } - */ if (targetPart instanceof InteractionInteractionCompartmentEditPart || targetPart instanceof ConnectionNodeEditPart) { return targetPart.getCommand(req); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java new file mode 100644 index 00000000000..fc688d87501 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java @@ -0,0 +1,163 @@ +/***************************************************************************** + * Copyright (c) 2018 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.sequence.util; + +import java.util.List; + +import org.eclipse.gef.EditPart; +import org.eclipse.gef.requests.CreateConnectionRequest; +import org.eclipse.gef.requests.ReconnectRequest; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.gmf.runtime.notation.Connector; +import org.eclipse.gmf.runtime.notation.IdentityAnchor; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; +import org.eclipse.uml2.uml.DurationConstraint; +import org.eclipse.uml2.uml.DurationObservation; + +/** + * <p> + * Util class related to the manipulation of DurationLinks, typically used by + * {@link GraphicalNodeEditPolicy} or {@link EditPart} + * </p> + */ +public class DurationLinkUtil extends OccurrenceSpecificationUtil { + + /** + * Test if the given {@link CreateConnectionRequest} is creating a DurationLink + * + * @param request + * @return + */ + public static boolean isCreateDurationLink(CreateConnectionRequest request) { + CreateRelationshipRequest createElementRequest = getCreateRelationshipRequest(request); + if (createElementRequest == null) { + if (request instanceof CreateAspectUnspecifiedTypeConnectionRequest) { + CreateAspectUnspecifiedTypeConnectionRequest createRequest = (CreateAspectUnspecifiedTypeConnectionRequest) request; + List<?> types = createRequest.getElementTypes(); + if (types.stream().allMatch( + type -> type == UMLElementTypes.DurationConstraint_Edge || + type == UMLElementTypes.DurationObservation_Edge)) { + return true; + } + } + } else { + IElementType type = createElementRequest.getElementType(); + return type == UMLElementTypes.DurationConstraint_Edge || type == UMLElementTypes.DurationObservation_Edge; + } + return false; + } + + + /** + * Test if the given {@link CreateConnectionViewRequest} is creating a DurationLink + * + * @param createRequest + * @return + */ + public static boolean isDurationLink(CreateConnectionViewRequest createRequest) { + String semanticHint = createRequest.getConnectionViewDescriptor().getSemanticHint(); + switch (semanticHint) { + case DurationConstraintLinkEditPart.VISUAL_ID: + case DurationObservationLinkEditPart.VISUAL_ID: + return true; + } + return false; + } + + + /** + * <p> + * Test if this request is trying to reconnect a DurationLink edit part + * </p> + * + * @param request + * @return + * + * @see DurationConstraintLinkEditPart + * @see DurationObservationLinkEditPart + */ + public static boolean isDurationLink(ReconnectRequest request) { + return request.getConnectionEditPart() instanceof DurationConstraintLinkEditPart || + request.getConnectionEditPart() instanceof DurationObservationLinkEditPart; + } + + /** + * <p> + * Test if the connector view is consistent with a new value. If the new value is not a List, + * this method always returns true. Otherwise, the list items will be compared with the + * semantic source/target of the given connector. + * </p> + * + * @param connector + * A connector representing a DurationLink (Constraint or Observation) in the Sequence Diagram + * @param setRequest + * A {@link SetRequest} modifying a duration link source/target (for {@link DurationConstraint#getConstrainedElements()} + * or {@link DurationObservation#getEvents()}, + * @return + * <code>true</code> if the Connector is consistent with the new proposed value, <code>false</code> if the connector + * is no longer consistent. If the result is <code>false</code>, actions should be taken to preserve the diagram + * consistency. + */ + public static boolean isConsistent(Connector connector, SetRequest setRequest) { + Object newValue = setRequest.getValue(); + if (false == newValue instanceof List) { + // Not supported; do nothing. Probably shouldn't happen anyway. + return true; + } + + List<?> values = (List<?>) newValue; + if (values.isEmpty()) { + // FIXME Workaround for the Properties View. When using the multi-reference editor's dialog, + // the editor will first send a clear() request, then a addAll() request; so we'd always + // destroy the connector, even if it's actually still valid. To be safe, we ignore this case + // Keeping an invalid connector in the diagram is better than destroying a valid one. + return true; + } + + View sourceView = connector.getSource(); + String sourceAnchor = connector.getSourceAnchor() instanceof IdentityAnchor ? ((IdentityAnchor) connector.getSourceAnchor()).getId() : ""; + + View targetView = connector.getTarget(); + String targetAnchor = connector.getSourceAnchor() instanceof IdentityAnchor ? ((IdentityAnchor) connector.getTargetAnchor()).getId() : ""; + + if (sourceView == null || targetView == null) { + return false; + } + + if (values.isEmpty()) { + return false; + } + + Object sourceEvent = values.get(0); + if (sourceEvent != DurationLinkUtil.findSemanticOccurrence(sourceView, sourceAnchor)) { + return false; + } + + if (values.size() > 1) { // source != target + Object targetEvent = values.get(1); + return targetEvent == DurationLinkUtil.findSemanticOccurrence(targetView, targetAnchor); + } else { // source == target + return sourceEvent == DurationLinkUtil.findSemanticOccurrence(targetView, targetAnchor); + } + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/GeneralOrderingUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/GeneralOrderingUtil.java new file mode 100644 index 00000000000..14dc93a014d --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/GeneralOrderingUtil.java @@ -0,0 +1,146 @@ +/***************************************************************************** + * Copyright (c) 2018 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.util; + +import java.util.List; +import java.util.function.Predicate; + +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.requests.CreateConnectionRequest; +import org.eclipse.gef.requests.ReconnectRequest; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; +import org.eclipse.gmf.runtime.emf.type.core.IElementType; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.gmf.runtime.notation.Connector; +import org.eclipse.gmf.runtime.notation.IdentityAnchor; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectUnspecifiedTypeConnectionTool.CreateAspectUnspecifiedTypeConnectionRequest; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; +import org.eclipse.uml2.uml.GeneralOrdering; +import org.eclipse.uml2.uml.UMLPackage.Literals; + +/** + * <p> + * Util class related to the manipulation of GeneralOrdering Links, typically used by + * {@link GraphicalNodeEditPolicy} or {@link EditPart} + * </p> + */ +public class GeneralOrderingUtil extends OccurrenceSpecificationUtil { + + /** + * Test if the given {@link CreateConnectionRequest} is creating a GeneralOrdering link + * + * @param request + * @return + */ + public static boolean isCreateGeneralOrderingLink(CreateConnectionRequest request) { + CreateRelationshipRequest createElementRequest = getCreateRelationshipRequest(request); + if (createElementRequest == null) { + if (request instanceof CreateAspectUnspecifiedTypeConnectionRequest) { + CreateAspectUnspecifiedTypeConnectionRequest createRequest = (CreateAspectUnspecifiedTypeConnectionRequest) request; + List<?> types = createRequest.getElementTypes(); + if (types.stream().allMatch(Predicate.isEqual(UMLElementTypes.GeneralOrdering_Edge))) { + return true; + } + } + } else { + IElementType type = createElementRequest.getElementType(); + return type == UMLElementTypes.GeneralOrdering_Edge; + } + return false; + } + + + /** + * Test if the given {@link CreateConnectionViewRequest} is creating a GeneralOrdering + * + * @param createRequest + * @return + */ + public static boolean isGeneralOrderingLink(CreateConnectionViewRequest createRequest) { + String semanticHint = createRequest.getConnectionViewDescriptor().getSemanticHint(); + return GeneralOrderingEditPart.VISUAL_ID.equals(semanticHint); + } + + /** + * <p> + * Test if this request is trying to reconnect a GeneralOrderingLink edit part + * </p> + * + * @param request + * @return + * + * @see GeneralOrderingEditPart + */ + public static boolean isGeneralOrderingLink(ReconnectRequest request) { + return request.getConnectionEditPart() instanceof GeneralOrderingEditPart; + } + + /** + * <p> + * Test if the connector view is consistent with a new value. + * </p> + * + * @param connector + * A connector representing a GeneralOrdering Link in the Sequence Diagram + * @param setRequest + * A {@link SetRequest} modifying a GeneralOrdering 'before' or 'after' reference + * @return + * <code>true</code> if the Connector is consistent with the new proposed value, <code>false</code> if the connector + * is no longer consistent. If the result is <code>false</code>, actions should be taken to preserve the diagram + * consistency. + * + * @see GeneralOrdering#getBefore() + * @see GeneralOrdering#getAfter() + */ + public static boolean isConsistent(Connector connector, SetRequest setRequest) { + Object newValue = setRequest.getValue(); + EStructuralFeature feature = setRequest.getFeature(); + if (feature != Literals.GENERAL_ORDERING__BEFORE && feature != Literals.GENERAL_ORDERING__AFTER) { + return true; // The set request doesn't affect that link; do nothing + } + + if (newValue == null) { // Before or After was unset; the link is no longer consistent + return false; + } + + View sourceView = connector.getSource(); + String sourceAnchor = connector.getSourceAnchor() instanceof IdentityAnchor ? ((IdentityAnchor) connector.getSourceAnchor()).getId() : ""; + + View targetView = connector.getTarget(); + String targetAnchor = connector.getSourceAnchor() instanceof IdentityAnchor ? ((IdentityAnchor) connector.getTargetAnchor()).getId() : ""; + + if (sourceView == null || targetView == null) { + return false; + } + + if (feature == Literals.GENERAL_ORDERING__BEFORE) { + if (newValue != DurationLinkUtil.findSemanticOccurrence(sourceView, sourceAnchor)) { + return false; + } + } else if (feature == Literals.GENERAL_ORDERING__AFTER) { + if (newValue != DurationLinkUtil.findSemanticOccurrence(targetView, targetAnchor)) { + return false; + } + } + + return true; + } + + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LinkRouteModelElementFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LinkRouteModelElementFactory.java deleted file mode 100644 index 7408f80110a..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LinkRouteModelElementFactory.java +++ /dev/null @@ -1,176 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2013, 2014 CEA and others - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Soyatec - Initial API and implementation - * Christian W. Damus (CEA) - bug 417409 - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.sequence.util; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.databinding.observable.Diffs; -import org.eclipse.core.databinding.observable.IObservable; -import org.eclipse.core.databinding.observable.value.ValueDiff; -import org.eclipse.emf.common.command.Command; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EAnnotation; -import org.eclipse.emf.edit.domain.EditingDomain; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gmf.runtime.notation.Edge; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.papyrus.infra.emf.commands.CreateEAnnotationCommand; -import org.eclipse.papyrus.infra.emf.utils.EMFHelper; -import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper; -import org.eclipse.papyrus.infra.properties.contexts.DataContextElement; -import org.eclipse.papyrus.infra.properties.ui.modelelement.AnnotationModelElement; -import org.eclipse.papyrus.infra.properties.ui.modelelement.AnnotationModelElementFactory; -import org.eclipse.papyrus.infra.ui.emf.databinding.AnnotationObservableValue; -import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider; -import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider; -import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider; - -public class LinkRouteModelElementFactory extends AnnotationModelElementFactory { - - public static final String STYLE = "style"; - - public static final String ROUTING = "routing"; - - public static final String MANUAL = "Manual"; - - public static final String AUTOMATIC = "Automatic"; - - public static final Map<Object, LinkRouteModelElement> elements = new HashMap<>(); - - @Override - protected AnnotationModelElement doCreateFromSource(Object sourceElement, DataContextElement context) { - View view = NotationHelper.findView(sourceElement); - if (view != null && view instanceof Edge) { - EditingDomain domain = EMFHelper.resolveEditingDomain(view); - LinkRouteModelElement m = new LinkRouteModelElement((Edge) view, domain); - elements.put(view, m); - return m; - } - return null; - } - - public static LinkRouteModelElement getElement(Object sourceElement) { - if (elements.get(sourceElement) == null) { - View view = NotationHelper.findView(sourceElement); - EditingDomain domain = EMFHelper.resolveEditingDomain(view); - LinkRouteModelElement m = new LinkRouteModelElement((Edge) view, domain); - elements.put(view, m); - } - return elements.get(sourceElement); - } - - public static boolean isRoutingNotification(Notification event) { - if (event.getNewValue() instanceof EAnnotation && LinkRouteModelElementFactory.ROUTING.equals(((EAnnotation) event.getNewValue()).getSource())) { - return true; - } - return false; - } - - public static String getRoutingStyle(View view) { - EAnnotation ea = view.getEAnnotation(ROUTING); - if (ea != null && ea.getDetails().containsKey(STYLE)) { - return ea.getDetails().get(STYLE); - } - return AUTOMATIC; - } - - public static boolean isAutomaticRouting(View view) { - return AUTOMATIC.equalsIgnoreCase(getRoutingStyle(view)); - } - - public static void switchToManualRouting(View edge) { - if (LinkRouteModelElementFactory.isAutomaticRouting(edge)) { - LinkRouteModelElement element = LinkRouteModelElementFactory.getElement(edge); - AnnotationObservableValue observable = (AnnotationObservableValue) element.getObservable(STYLE); - observable.setValue(LinkRouteModelElementFactory.MANUAL); - } - } - - public static class LinkRouteModelElement extends AnnotationModelElement { - - public LinkRouteModelElement(Edge source, EditingDomain domain) { - super(source, domain, ROUTING); - } - - @Override - public IStaticContentProvider getContentProvider(String propertyPath) { - if (propertyPath.equals(STYLE)) { - return new AbstractStaticContentProvider() { - - @Override - public Object[] getElements() { - return new String[] { AUTOMATIC, MANUAL }; - } - - }; - } - return EmptyContentProvider.instance; - } - - @Override - public ILabelProvider getLabelProvider(String propertyPath) { - return new org.eclipse.jface.viewers.LabelProvider(); - } - - @Override - public IObservable doGetObservable(String propertyPath) { - return new AnnotationObservableValue(source, domain, ROUTING, STYLE) { - - @Override - protected Command getCommand(final Object value) { - return new CreateEAnnotationCommand((TransactionalEditingDomain) domain, source, ROUTING) { - - @Override - protected void doExecute() { - EAnnotation annotation = createEAnnotation(); - replaceEannotation(annotation, getObject()); - replaceEntry(annotation, STYLE, value == null ? "" : value.toString()); - } - }; - } - - @Override - protected Object doGetValue() { - Object value = super.doGetValue(); - if (value == null) { - return AUTOMATIC; - } - return value; - } - - @Override - protected void doSetValue(Object value) { - Object oldValue = doGetValue(); - - Command emfCommand = getCommand(value); - if (emfCommand != null) { - domain.getCommandStack().execute(emfCommand); - } - ValueDiff createValueDiff = Diffs.createValueDiff(oldValue, value); - fireValueChange(createValueDiff); - } - }; - } - - @Override - public boolean forceRefresh(String propertyPath) { - return true; - } - } -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java index d9429add8b7..9c076e67a5c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java @@ -21,17 +21,12 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.draw2d.ConnectionAnchor; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature.Setting; -import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gef.EditPart; import org.eclipse.gef.Request; import org.eclipse.gef.RequestConstants; @@ -39,31 +34,18 @@ import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.requests.ChangeBoundsRequest; import org.eclipse.gef.requests.ReconnectRequest; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil; -import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; import org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -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.editparts.ShapeNodeEditPart; import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; -import org.eclipse.gmf.runtime.notation.IdentityAnchor; -import org.eclipse.gmf.runtime.notation.NotationFactory; import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.gmf.runtime.notation.impl.ConnectorImpl; import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; -import org.eclipse.papyrus.uml.diagram.sequence.command.SetResizeAndLocationCommand; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CustomDurationConstraintEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ObservationLinkEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.OLDLifelineXYLayoutEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SenderRequestUtils; import org.eclipse.uml2.common.util.CacheAdapter; @@ -134,17 +116,6 @@ public class OccurrenceSpecificationMoveHelper { if (command != null) { globalCmd.add(command); } - // reconnect the corresponding general ordering(s) if necessary - command = getReconnectGeneralOrderingCommand(movedOccurrenceSpecification1, yLocation1, lifelinePart, notToMoveEditParts); - if (command != null) { - globalCmd.add(command); - } - if (movedOccurrenceSpecification2 != null) { - command = getReconnectGeneralOrderingCommand(movedOccurrenceSpecification2, yLocation2, lifelinePart, notToMoveEditParts); - if (command != null) { - globalCmd.add(command); - } - } // return null rather than an empty non executable command if (globalCmd.isEmpty()) { return null; @@ -153,75 +124,6 @@ public class OccurrenceSpecificationMoveHelper { } /** - * Get the command to reconnect general ordering attached to a moved occurrence specification - * - * @param movedOccurrenceSpecification - * moving occurrence specification - * @param yLocation - * y location where occurrence specification is moved - * @param lifelinePart - * lifeline edit part containing the moved element - * @param notToMoveEditParts - * list of edit parts which must not be moved in the created command - * @return command to reconnect general ordering edit parts linked to the occurrence specification or null - */ - private static Command getReconnectGeneralOrderingCommand(OccurrenceSpecification movedOccurrenceSpecification, int yLocation, LifelineEditPart lifelinePart, List<EditPart> notToMoveEditParts) { - // the global command which shall be completed and returned - CompoundCommand command = new CompoundCommand(); - Point referencePoint = getReferencePoint(lifelinePart, movedOccurrenceSpecification, yLocation); - EditPart childToReconnectTo = SequenceUtil.findPartToReconnectTo(lifelinePart, referencePoint); - // if referencePoint is on a moved part, it must be translated with the location delta of this part - if (!notToMoveEditParts.isEmpty() && childToReconnectTo != lifelinePart) { - Point oldLoc = SequenceUtil.findLocationOfEvent(lifelinePart, movedOccurrenceSpecification); - if (oldLoc == null) { - return null; - } - referencePoint.y = oldLoc.y; - } - // reconnect general ordering from the event - for (GeneralOrdering go : movedOccurrenceSpecification.getToAfters()) { - Collection<Setting> settings = CacheAdapter.getInstance().getNonNavigableInverseReferences(go); - for (Setting ref : settings) { - if (NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) { - View view = (View) ref.getEObject(); - EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart); - // the general ordering part must start or finish on the lifeline (with the event) - if (part instanceof ConnectionEditPart && !notToMoveEditParts.contains(part)) { - Request reconnectRequest = makeReconnectRequest((ConnectionEditPart) part, true, referencePoint, childToReconnectTo); - Command reconnect = childToReconnectTo.getCommand(reconnectRequest); - if (reconnect.canExecute()) { - command.add(reconnect); - } - } - } - } - } - // reconnect general ordering to the event - for (GeneralOrdering go : movedOccurrenceSpecification.getToBefores()) { - Collection<Setting> settings = CacheAdapter.getInstance().getNonNavigableInverseReferences(go); - for (Setting ref : settings) { - if (NotationPackage.eINSTANCE.getView_Element().equals(ref.getEStructuralFeature())) { - View view = (View) ref.getEObject(); - EditPart part = DiagramEditPartsUtil.getEditPartFromView(view, lifelinePart); - // the general ordering part must start or finish on the lifeline (with the event) - if (part instanceof ConnectionEditPart && !notToMoveEditParts.contains(part)) { - Request reconnectRequest = makeReconnectRequest((ConnectionEditPart) part, false, referencePoint, childToReconnectTo); - Command reconnect = childToReconnectTo.getCommand(reconnectRequest); - if (reconnect.canExecute()) { - command.add(reconnect); - } - } - } - } - } - // return null rather than an empty non executable command - if (command.isEmpty()) { - return null; - } - return command; - } - - /** * Get the command to reconnect message attached to a moved occurrence specification * * @param movedOccurrenceSpecification @@ -329,15 +231,6 @@ public class OccurrenceSpecificationMoveHelper { } } } - // relocate each observation linked time element - for (Object targetConnection : lifelinePart.getTargetConnections()) { - if (targetConnection instanceof ObservationLinkEditPart) { - Command cmd = getMoveSingleTimeRelatedElementCommand((ObservationLinkEditPart) targetConnection, movedOccurrenceSpecification1, movedOccurrenceSpecification2, yLocation1, yLocation2, lifelinePart); - if (cmd != null) { - globalCmd.add(cmd); - } - } - } // refresh layout commands : // one before the commands for the undo and one after for classic execution if (!globalCmd.isEmpty() && lifelineFigure instanceof BorderedNodeFigure) { @@ -358,57 +251,6 @@ public class OccurrenceSpecificationMoveHelper { return globalCmd; } - private static Command getMoveSingleTimeRelatedElementCommand(final ObservationLinkEditPart targetConnection, final OccurrenceSpecification movedOccurrenceSpecification1, final OccurrenceSpecification movedOccurrenceSpecification2, final int yLocation1, - final int yLocation2, final LifelineEditPart lifelinePart) { - AbstractTransactionalCommand updateTargetAnchorCommand = new AbstractTransactionalCommand(((IGraphicalEditPart) targetConnection).getEditingDomain(), "update target anchor", null) { - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - // both bounds may have changed - Point referencePoint1 = getReferencePoint(lifelinePart, movedOccurrenceSpecification1, yLocation1); - Point referencePoint2 = getReferencePoint(lifelinePart, movedOccurrenceSpecification2, yLocation2); - int position1 = PositionConstants.NONE; - int position2 = PositionConstants.NONE; - TimeObservationLabelEditPart tolEP = (TimeObservationLabelEditPart) targetConnection.getSource(); - if (tolEP == null) { - return CommandResult.newCancelledCommandResult(); - } - if (movedOccurrenceSpecification1 != null) { - position1 = SequenceUtil.positionWhereEventIsLinkedToPart(movedOccurrenceSpecification1, tolEP); - } - if (movedOccurrenceSpecification2 != null) { - position2 = SequenceUtil.positionWhereEventIsLinkedToPart(movedOccurrenceSpecification2, tolEP); - } - ConnectionAnchor targetAnchor = null; - if (position1 == PositionConstants.CENTER) { - targetAnchor = LifelineEditPartUtil.getNodeFigure(lifelinePart).getSourceConnectionAnchorAt(referencePoint1); - } else if (position2 == PositionConstants.CENTER) { - targetAnchor = LifelineEditPartUtil.getNodeFigure(lifelinePart).getSourceConnectionAnchorAt(referencePoint2); - } - if (targetAnchor != null) { - String newTargetTerminal = lifelinePart.mapConnectionAnchorToTerminal(targetAnchor); - ConnectorImpl c = (ConnectorImpl) targetConnection.getModel(); - if (newTargetTerminal != null) { - if (newTargetTerminal.length() == 0) { - c.setTargetAnchor(null); - } else { - IdentityAnchor a = (IdentityAnchor) c.getTargetAnchor(); - if (a == null) { - a = NotationFactory.eINSTANCE.createIdentityAnchor(); - } - a.setId(newTargetTerminal); - c.setTargetAnchor(a); - } - } - } - return CommandResult.newOKCommandResult(); - } - }; - // return the resize command - ICommandProxy resize = new ICommandProxy(updateTargetAnchorCommand); - return resize; - } - /** * Get a command to move the time related element's edit part * @@ -516,16 +358,6 @@ public class OccurrenceSpecificationMoveHelper { newBounds = new Rectangle(referencePoint2.x, Math.min(top, bottom), -1, Math.abs(bottom - top)); } } - if (newBounds != null) { - TransactionalEditingDomain editingDomain = timePart.getEditingDomain(); - if (timePart instanceof CustomDurationConstraintEditPart) { - CustomDurationConstraintEditPart dcep = (CustomDurationConstraintEditPart) timePart; - newBounds = dcep.updateMoveBounds(newBounds); - } - // return the resize command - ICommandProxy resize = new ICommandProxy(new SetResizeAndLocationCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, new EObjectAdapter((View) timePart.getModel()), newBounds)); - return resize; - } return null; } @@ -1119,7 +951,7 @@ public class OccurrenceSpecificationMoveHelper { if (timeElement instanceof TimeObservation) { NamedElement occurence = ((TimeObservation) timeElement).getEvent(); occurrences = Collections.singletonList(occurence); - } else if (timeElement instanceof TimeConstraint || timeElement instanceof DurationConstraint) { + } else if (timeElement instanceof TimeConstraint) { occurrences = ((IntervalConstraint) timeElement).getConstrainedElements(); } // check whether one of the time occurrences correspond to a DestructionEvent diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java new file mode 100644 index 00000000000..2f3b38f15df --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java @@ -0,0 +1,268 @@ +/***************************************************************************** + * Copyright (c) 2018 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.diagram.sequence.util; + +import org.eclipse.draw2d.Connection; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.PointList; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.Request; +import org.eclipse.gef.requests.CreateConnectionRequest; +import org.eclipse.gef.requests.CreateRequest; +import org.eclipse.gef.requests.ReconnectRequest; +import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.gmf.runtime.notation.Anchor; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.IdentityAnchor; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.uml.diagram.sequence.anchors.AnchorConstants; +import org.eclipse.uml2.uml.ExecutionSpecification; +import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.MessageEnd; +import org.eclipse.uml2.uml.OccurrenceSpecification; + +/** + * <p> + * Util class related to the manipulation of Links targetting {@link OccurrenceSpecification}s, + * typically used by {@link GraphicalNodeEditPolicy} or {@link EditPart}. + * </p> + * <p> + * Most methods are meant to be used with Edges connecting some {@link OccurrenceSpecification} + * that are not necessarily displayed on the Diagram. + * </p> + * <p> + * To identify the right {@link OccurrenceSpecification}, the methods may rely either on the + * {@link IFigure} that is under the mouse cursor, by determining if the mouse is closer to + * the start or finish (Or source/target for edges) point representing an {@link OccurrenceSpecification}. + * </p> + * <p> + * When only the {@link Edge} view is available, the methods will rely on the current {@link Edge#getSourceAnchor()} + * and {@link Edge#getTargetAnchor()}. Anchors are expected to match one of the values defined in {@link AnchorConstants}. + * </p> + * + * @see DurationLinkUtil + * @see GeneralOrderingUtil + * @see AnchorConstants#START_TERMINAL + * @see AnchorConstants#END_TERMINAL + */ +public class OccurrenceSpecificationUtil { + + + /** + * Retrieve the semantic {@link CreateRelationshipRequest} from the given GEF {@link CreateConnectionRequest}, + * or <code>null</code>. + * + * @param request + * @return + */ + public static CreateRelationshipRequest getCreateRelationshipRequest(CreateConnectionRequest request) { + if (false == request instanceof CreateConnectionViewAndElementRequest) { + return null; + } + CreateElementRequestAdapter requestAdapter = ((CreateConnectionViewAndElementRequest) request).getConnectionViewAndElementDescriptor().getCreateElementRequestAdapter(); + if (requestAdapter == null) { + return null; + } + CreateRelationshipRequest createElementRequest = (CreateRelationshipRequest) requestAdapter.getAdapter(CreateRelationshipRequest.class); + return createElementRequest; + } + + /** + * Test whether the given request is closer to the start (top) or to the finish (bottom) point of the execution specification + * + * @param createRequest + * The create request + * @return + * <code>true</code> if the given request is closer to the top of the figure; false if it is closer to the bottom + */ + public static boolean isStart(IFigure targetFigure, CreateRequest createRequest) { + return isStart(targetFigure, createRequest.getLocation()); + } + + /** + * Test whether the given request is closer to the start (top) or to the finish (bottom) point of the execution specification + * + * @param Point + * The current request location + * @return + * <code>true</code> if the given request is closer to the top of the figure; false if it is closer to the bottom + */ + public static boolean isStart(IFigure targetFigure, Point requestLocation) { + Rectangle bounds = targetFigure.getBounds().getCopy(); + targetFigure.translateToAbsolute(bounds); + + double distanceToTop = requestLocation.getDistance(bounds.getTop()); + double distanceToBottom = requestLocation.getDistance(bounds.getBottom()); + return distanceToTop < distanceToBottom; + } + + /** + * Test whether the given request is closer to the source or to the target point of the message + * + * @param targetFigure + * The connection figure representing the message + * @param createRequest + * The create request + * @return + * <code>true</code> if the given request is closer to the source of the connection; false if it is closer to the target + */ + public static boolean isSource(IFigure targetFigure, CreateRequest createRequest) { + return isSource(targetFigure, createRequest.getLocation()); + } + + /** + * Test whether the given request is closer to the source or to the target point of the message + * + * @param targetFigure + * The connection figure representing the message + * @param requestLocation + * The mouse location for the current {@link Request}, in Viewer coordinates + * @return + * <code>true</code> if the given request is closer to the source of the connection; false if it is closer to the target + */ + public static boolean isSource(IFigure targetFigure, Point requestLocation) { + requestLocation = requestLocation.getCopy(); + IFigure connection = targetFigure; + if (connection instanceof Connection) { + PointList points = ((Connection) connection).getPoints(); + connection.translateToRelative(requestLocation); + if (points.size() >= 2) { + Point source = points.getFirstPoint(); + Point target = points.getLastPoint(); + double distanceToSource = requestLocation.getDistance(source); + double distanceToTarget = requestLocation.getDistance(target); + return distanceToSource < distanceToTarget; + } + } + + // Default; shouldn't happen, unless the Message figure is invalid, + // in which case we can't determine the source/target). + return true; + } + + + /** + * Find the semantic {@link OccurrenceSpecification} represented by the given <code>connectorEnd</code>. + * The connector should be the source or target of a connector (e.g. DurationLink or GeneralOrdering). + * + * @param connectorEnd + * the source or target of a connector + * @param anchorTerminal + * The connection anchor corresponding to the given connector end. + * @return + * The semantic occurrence specification represented by the given connector end (View), or null + * if the view doesn't represent a valid {@link OccurrenceSpecification}. + */ + public static OccurrenceSpecification findSemanticOccurrence(View connectorEnd, String anchorTerminal) { + EObject semantic = connectorEnd.getElement(); + if (semantic instanceof OccurrenceSpecification) { + return (OccurrenceSpecification) semantic; + } else if (semantic instanceof ExecutionSpecification) { + switch (anchorTerminal) { + case AnchorConstants.START_TERMINAL: + return ((ExecutionSpecification) semantic).getStart(); + case AnchorConstants.END_TERMINAL: + return ((ExecutionSpecification) semantic).getFinish(); + default: + return null; + } + } else if (semantic instanceof Message) { + switch (anchorTerminal) { + case AnchorConstants.START_TERMINAL: + MessageEnd sendEvent = ((Message) semantic).getSendEvent(); + return sendEvent instanceof OccurrenceSpecification ? (OccurrenceSpecification) sendEvent : null; + case AnchorConstants.END_TERMINAL: + MessageEnd receiveEvent = ((Message) semantic).getReceiveEvent(); + return receiveEvent instanceof OccurrenceSpecification ? (OccurrenceSpecification) receiveEvent : null; + default: + return null; + } + } + return null; + } + + /** + * <p> + * Return the target {@link OccurrenceSpecification} represented by this {@link ReconnectRequest}. + * </p> + * <p> + * If there is no {@link OccurrenceSpecification} at this request's location, the default EObject + * represented by {@link ReconnectRequest#getTarget()} is returned. + * </p> + * + * @param request + * @return + */ + public static EObject getOccurrence(ReconnectRequest request) { + EObject element = EMFHelper.getEObject(request.getTarget()); + IFigure targetFigure = ((IGraphicalEditPart) request.getTarget()).getFigure(); + if (element instanceof Message) { + if (OccurrenceSpecificationUtil.isSource(targetFigure, request.getLocation())) { + return ((Message) element).getSendEvent(); + } else { + return ((Message) element).getReceiveEvent(); + } + } else if (element instanceof ExecutionSpecification) { + if (OccurrenceSpecificationUtil.isStart(targetFigure, request.getLocation())) { + return ((ExecutionSpecification) element).getStart(); + } else { + return ((ExecutionSpecification) element).getFinish(); + } + } + return element; + } + + /** + * <p> + * Return the {@link OccurrenceSpecification} that is the {@link Edge#getSource() Source} + * of this Edge. + * </p> + * + * @param connection + * @return + */ + public static EObject getSourceOccurrence(Edge connection) { + Anchor sourceAnchor = connection.getSourceAnchor(); + if (sourceAnchor instanceof IdentityAnchor) { + return findSemanticOccurrence(connection.getSource(), ((IdentityAnchor) sourceAnchor).getId()); + } + return connection.getSource().getElement(); + } + + /** + * <p> + * Return the {@link OccurrenceSpecification} that is the {@link Edge#getTarget() Target} + * of this Edge. + * </p> + * + * @param connection + * @return + */ + public static EObject getTargetOccurrence(Edge connection) { + Anchor targetAnchor = connection.getTargetAnchor(); + if (targetAnchor instanceof IdentityAnchor) { + return findSemanticOccurrence(connection.getTarget(), ((IdentityAnchor) targetAnchor).getId()); + } + return connection.getTarget().getElement(); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java index 81e3120af52..541196959fe 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java @@ -15,15 +15,10 @@ *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.util; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.draw2d.PositionConstants; -import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gef.EditPart; @@ -31,7 +26,6 @@ import org.eclipse.gef.Request; import org.eclipse.gef.commands.Command; import org.eclipse.gef.commands.CompoundCommand; import org.eclipse.gef.commands.UnexecutableCommand; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; import org.eclipse.gmf.runtime.common.core.command.ICommand; import org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand; import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy; @@ -41,7 +35,6 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart; import org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand; import org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest; @@ -51,17 +44,13 @@ import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; import org.eclipse.papyrus.uml.diagram.sequence.RestoreExecutionEndAdvice; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ObservationLinkEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.OLDLifelineXYLayoutEditPolicy; import org.eclipse.uml2.uml.DestructionOccurrenceSpecification; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.ExecutionSpecification; -import org.eclipse.uml2.uml.Lifeline; import org.eclipse.uml2.uml.Message; import org.eclipse.uml2.uml.MessageEnd; import org.eclipse.uml2.uml.OccurrenceSpecification; -import org.eclipse.uml2.uml.TimeObservation; /** * An Helper to get deleting command for the sequence diagram elements. @@ -73,11 +62,11 @@ public class SequenceDeleteHelper { * constraint/observation linked with these ends * * @param deleteViewsCmd - * the command to complete + * the command to complete * @param editingDomain - * the editing domain + * the editing domain * @param executionPart - * the execution specification edit part on which the request is called + * the execution specification edit part on which the request is called * @return the deletion command deleteViewsCmd for convenience */ public static CompoundCommand completeDeleteMessageViewCommand(CompoundCommand deleteViewsCmd, TransactionalEditingDomain editingDomain, EditPart messagePart) { @@ -92,12 +81,6 @@ public class SequenceDeleteHelper { MessageEnd receive = message.getReceiveEvent(); addDeleteRelatedTimePartsToCommand(deleteViewsCmd, editingDomain, tgtLifelinePart, receive); // also delete time observation links which are related to message end - if (send instanceof OccurrenceSpecification) { - addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd, editingDomain, (OccurrenceSpecification) send, srcLifelinePart, false); - } - if (receive instanceof OccurrenceSpecification) { - addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd, editingDomain, (OccurrenceSpecification) receive, tgtLifelinePart, false); - } } } return deleteViewsCmd; @@ -124,11 +107,11 @@ public class SequenceDeleteHelper { * constraint/observation linked with these ends * * @param deleteViewsCmd - * the command to complete + * the command to complete * @param editingDomain - * the editing domain + * the editing domain * @param executionPart - * the execution specification edit part on which the request is called + * the execution specification edit part on which the request is called * @return the deletion command deleteViewsCmd for convenience */ public static CompoundCommand completeDeleteExecutionSpecificationViewCommand(CompoundCommand deleteViewsCmd, TransactionalEditingDomain editingDomain, EditPart executionPart) { @@ -152,26 +135,6 @@ public class SequenceDeleteHelper { } } } - // delete each observation linked time element - for (Object targetConnection : lifelinePart.getTargetConnections()) { - if (targetConnection instanceof ObservationLinkEditPart) { - ObservationLinkEditPart observationLinkEditPart = (ObservationLinkEditPart) targetConnection; - TimeObservationLabelEditPart source = (TimeObservationLabelEditPart) observationLinkEditPart.getSource(); - OccurrenceSpecification start = execution.getStart(); - OccurrenceSpecification finish = execution.getFinish(); - int positionForStart = SequenceUtil.positionWhereEventIsLinkedToPart(start, source); - int positionForFinish = SequenceUtil.positionWhereEventIsLinkedToPart(finish, source); - if (positionForStart != PositionConstants.NONE) { - // time part is linked, delete the view - // Command deleteTimeViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View)source.getModel())); - // deleteViewsCmd.add(deleteTimeViewCommand); - addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd, editingDomain, start, lifelinePart, false); - } - if (positionForFinish != PositionConstants.NONE) { - addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd, editingDomain, finish, lifelinePart, false); - } - } - } } } } @@ -182,11 +145,11 @@ public class SequenceDeleteHelper { * Delete the views associated with a list of elements. * * @param cmd - * the CompositeTransactionalCommand + * the CompositeTransactionalCommand * @param element - * the list of model elements + * the list of model elements * @param editingDomain - * the editing domain to use. + * the editing domain to use. */ public static void deleteView(CompositeTransactionalCommand cmd, List<Element> elements, TransactionalEditingDomain editingDomain) { for (Element element : elements) { @@ -198,11 +161,11 @@ public class SequenceDeleteHelper { * Delete the views associated with an element. * * @param cmd - * the CompositeTransactionalCommand + * the CompositeTransactionalCommand * @param element - * the model element referenced by the views + * the model element referenced by the views * @param editingDomain - * the editing domain to use. + * the editing domain to use. */ public static void deleteView(CompositeTransactionalCommand cmd, Element element, TransactionalEditingDomain editingDomain) { // Destroy its views @@ -245,12 +208,6 @@ public class SequenceDeleteHelper { DestroyElementRequest delEnd = new DestroyElementRequest(req.getEditingDomain(), es.getFinish(), false); deleteElementsCommand.add(new ICommandProxy(new DestroyElementCommand(delEnd))); destroyMessageEvents(deleteElementsCommand, host, req.getEditingDomain()); - if (host.getParent() instanceof LifelineEditPart) { - List<OccurrenceSpecification> oss = new ArrayList<>(); - oss.add(es.getStart()); - oss.add(es.getFinish()); - SequenceDeleteHelper.addDeleteRelatedTimeObservationLinkCommand(deleteElementsCommand, req.getEditingDomain(), (LifelineEditPart) host.getParent(), oss, true); - } SequenceDeleteHelper.addDestroyExecutionSpecificationChildrenCommand(deleteElementsCommand, req.getEditingDomain(), host); } @@ -269,10 +226,8 @@ public class SequenceDeleteHelper { MessageEnd receiveEvent = message.getReceiveEvent(); MessageEnd sendEvent = message.getSendEvent(); destroyMessageEvent(deleteElementsCommand, sendEvent, transactionalEditingDomain); - addDeleteMessageRelatedTimeObservationLinkCommand(transactionalEditingDomain, connectionEP, deleteElementsCommand, sendEvent, true); if (false == receiveEvent instanceof DestructionOccurrenceSpecification) { destroyMessageEvent(deleteElementsCommand, receiveEvent, transactionalEditingDomain); - addDeleteMessageRelatedTimeObservationLinkCommand(transactionalEditingDomain, connectionEP, deleteElementsCommand, receiveEvent, true); } } } @@ -303,72 +258,4 @@ public class SequenceDeleteHelper { destroyMessageEvents(deleteElementsCommand, p.getTargetConnections(), editingDomain); } } - - /** - * Add delete message related time observation link command - * - * @param editingDomain - * @param editPart - * @param command - * @param messageEnd - * @param deleteRelatedEvent - */ - static void addDeleteMessageRelatedTimeObservationLinkCommand(TransactionalEditingDomain editingDomain, EditPart editPart, CompoundCommand compoundCommand, MessageEnd messageEnd, boolean deleteRelatedEvent) { - // Bug fix: messageEnd maybe a Gate instance. - if (messageEnd != null && messageEnd instanceof OccurrenceSpecification) { - OccurrenceSpecification occurrenceSpecification = (OccurrenceSpecification) messageEnd; - EList<Lifeline> receiveCovereds = occurrenceSpecification.getCovereds(); - if (receiveCovereds.size() > 0) { - LifelineEditPart srcLifelinePart = (LifelineEditPart) SequenceUtil.getEditPart(editPart, receiveCovereds.get(0), LifelineEditPart.class); - addDeleteRelatedTimeObservationLinkCommand(compoundCommand, editingDomain, occurrenceSpecification, srcLifelinePart, deleteRelatedEvent); - } - } - } - - /** - * Add command for deleting time observation link which related to occurence specification - * - * @param deleteViewsCmd - * @param editingDomain - * @param os - * @param srcLifelinePart - * @param deleteRelatedEvent - */ - private static void addDeleteRelatedTimeObservationLinkCommand(CompoundCommand deleteViewsCmd, TransactionalEditingDomain editingDomain, OccurrenceSpecification os, LifelineEditPart srcLifelinePart, boolean deleteRelatedEvent) { - List<OccurrenceSpecification> oss = new ArrayList<>(); - oss.add(os); - addDeleteRelatedTimeObservationLinkCommand(deleteViewsCmd, editingDomain, srcLifelinePart, oss, deleteRelatedEvent); - } - - /** - * Add command for deleting time observation link which related to occurence specification - * - * @param deleteViewsCmd - * @param editingDomain - * @param srcLifelinePart - * @param oss - * @param deleteRelatedEvent - */ - public static void addDeleteRelatedTimeObservationLinkCommand(CompoundCommand deleteViewsCmd, TransactionalEditingDomain editingDomain, LifelineEditPart srcLifelinePart, List<OccurrenceSpecification> oss, boolean deleteRelatedEvent) { - List<TimeObservationLabelEditPart> timeObservationEditParts = SequenceUtil.findOccurenceSpecificationRelatedTimeObservationPart(srcLifelinePart, oss); - for (final TimeObservationLabelEditPart timeObservationEditPart : timeObservationEditParts) { - View view = (View) timeObservationEditPart.getModel(); - List<?> sourceEdges = view.getSourceEdges(); - for (Object sourceEdge : sourceEdges) { - Command deleteTimeViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View) sourceEdge)); - deleteViewsCmd.add(deleteTimeViewCommand); - } - if (deleteRelatedEvent) { - deleteViewsCmd.add(new ICommandProxy(new AbstractTransactionalCommand(editingDomain, "Remove TimeObservation related event", null) { - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - TimeObservation timeObservation = (TimeObservation) (timeObservationEditPart.resolveSemanticElement()); - timeObservation.setEvent(null); - return CommandResult.newOKCommandResult(); - } - })); - } - } - } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java index 30b1e48a67c..a78936a3ae2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java @@ -86,43 +86,18 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CLifeLineEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionInteractionCompartmentEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionUseEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageAsyncAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageAsyncEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageAsyncNameEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateAppliedStereotypeEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageCreateNameEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageDeleteNameEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageFoundAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageFoundEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageFoundNameEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageLostAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageLostEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageLostNameEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageReplyAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageReplyEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageReplyNameEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncNameEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ObservationLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ObservationLinkPolicy; import org.eclipse.swt.widgets.Display; import org.eclipse.uml2.common.util.CacheAdapter; import org.eclipse.uml2.uml.CombinedFragment; import org.eclipse.uml2.uml.Continuation; import org.eclipse.uml2.uml.DestructionOccurrenceSpecification; -import org.eclipse.uml2.uml.DurationConstraint; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification; import org.eclipse.uml2.uml.ExecutionSpecification; @@ -536,6 +511,10 @@ public class SequenceUtil { // get position from anchor id String oldTerminal = ((IdentityAnchor) idAnchor).getId(); PrecisionPoint pp = BaseSlidableAnchor.parseTerminalString(oldTerminal); + if (pp == null) { + // Not a BaseSlidableAnchor + return null; + } if (pp.preciseX() <= 1 && pp.preciseX() >= 0 && pp.preciseY() >= 0 && pp.preciseY() <= 1) { int xPos = linkedPartBounds.x + delta.width + (int) Math.round(anchorOwningFigure.getBounds().width * pp.preciseX()); int yPos = linkedPartBounds.y + delta.height + (int) Math.round(anchorOwningFigure.getBounds().height * pp.preciseY()); @@ -829,32 +808,6 @@ public class SequenceUtil { } else { return PositionConstants.NONE; } - } else if (timeElement instanceof DurationConstraint) { - if (((DurationConstraint) timeElement).getConstrainedElements().contains(occSpec)) { - List<Element> events = ((DurationConstraint) timeElement).getConstrainedElements(); - LifelineEditPart lifelinePart = getParentLifelinePart(timeElementPart); - if (lifelinePart != null && events.size() >= 2) { - OccurrenceSpecification otherEvent = null; - if (!occSpec.equals(events.get(0)) && events.get(0) instanceof OccurrenceSpecification) { - otherEvent = (OccurrenceSpecification) events.get(0); - } else if (!occSpec.equals(events.get(1)) && events.get(1) instanceof OccurrenceSpecification) { - otherEvent = (OccurrenceSpecification) events.get(1); - } - if (otherEvent != null) { - Point otherLoc = findLocationOfEvent(lifelinePart, otherEvent); - Point thisLoc = findLocationOfEvent(lifelinePart, occSpec); - if (otherLoc != null && thisLoc != null) { - if (otherLoc.y > thisLoc.y) { - return PositionConstants.TOP; - } else { - return PositionConstants.BOTTOM; - } - } - } - } - } else { - return PositionConstants.NONE; - } } return PositionConstants.NONE; } @@ -1649,50 +1602,6 @@ public class SequenceUtil { } /** - * Find Time Observations editpart which are related to specific OccurenceSpecification - * - * @param lifelinePart - * @param oss - * @return List<TimeObservationLabelEditPart> - */ - public static List<TimeObservationLabelEditPart> findOccurenceSpecificationRelatedTimeObservationPart(LifelineEditPart lifelinePart, List<OccurrenceSpecification> oss) { - List<TimeObservationLabelEditPart> list = new ArrayList<>(); - if (oss == null || oss.size() == 0) { - return list; - } - if (lifelinePart != null && lifelinePart.getTargetConnections().size() > 0) { - for (Object targetConnection : lifelinePart.getTargetConnections()) { - if (targetConnection instanceof ObservationLinkEditPart) { - ObservationLinkEditPart observationLinkEditPart = (ObservationLinkEditPart) targetConnection; - if (observationLinkEditPart.getSource() instanceof TimeObservationLabelEditPart) { - TimeObservationLabelEditPart source = (TimeObservationLabelEditPart) observationLinkEditPart.getSource(); - EObject timeElement = source.resolveSemanticElement(); - if (timeElement instanceof TimeObservation) { - if (oss.contains(((TimeObservation) timeElement).getEvent())) { - list.add(source); - } - } - } - } - } - } - return list; - } - - /** - * Find Time Observations editpart which are related to specific OccurenceSpecification - * - * @param lifelinePart - * @param os - * @return List<TimeObservationLabelEditPart> - */ - public static List<TimeObservationLabelEditPart> findOccurenceSpecificationRelatedTimeObservationPart(LifelineEditPart lifelinePart, OccurrenceSpecification os) { - List<OccurrenceSpecification> oss = new ArrayList<>(); - oss.add(os); - return findOccurenceSpecificationRelatedTimeObservationPart(lifelinePart, oss); - } - - /** * Find specific editpart by semantic model * * @param editPart @@ -1723,32 +1632,6 @@ public class SequenceUtil { } /** - * Intall observation link policy to specific editpart - * - * @param editPart - */ - public static void installObservationLinkPolicy(EditPart editPart) { - String editPolicy = "observationlink"; - if (editPart instanceof LifelineEditPart || editPart instanceof TimeObservationLabelEditPart) { - editPart.installEditPolicy(editPolicy, new ObservationLinkPolicy(editPart)); - } - if (editPart instanceof DurationObservationEditPart) { - editPart.installEditPolicy(editPolicy, new ObservationLinkPolicy(editPart)); - } - if (editPart instanceof MessageSyncEditPart || editPart instanceof MessageAsyncEditPart || editPart instanceof MessageReplyEditPart || editPart instanceof MessageCreateEditPart || editPart instanceof MessageDeleteEditPart - || editPart instanceof MessageLostEditPart - || editPart instanceof MessageFoundEditPart) { - editPart.installEditPolicy(editPolicy, new ObservationLinkPolicy(editPart)); - } else if (editPart instanceof MessageSyncNameEditPart || editPart instanceof MessageAsyncNameEditPart || editPart instanceof MessageReplyNameEditPart || editPart instanceof MessageCreateNameEditPart || editPart instanceof MessageDeleteNameEditPart - || editPart instanceof MessageLostNameEditPart || editPart instanceof MessageFoundNameEditPart) { - editPart.getParent().installEditPolicy(editPolicy, new ObservationLinkPolicy(editPart)); - } else if (editPart instanceof MessageSyncAppliedStereotypeEditPart || editPart instanceof MessageAsyncAppliedStereotypeEditPart || editPart instanceof MessageReplyAppliedStereotypeEditPart || editPart instanceof MessageCreateAppliedStereotypeEditPart - || editPart instanceof MessageDeleteAppliedStereotypeEditPart || editPart instanceof MessageLostAppliedStereotypeEditPart || editPart instanceof MessageFoundAppliedStereotypeEditPart) { - editPart.getParent().installEditPolicy(editPolicy, new ObservationLinkPolicy(editPart)); - } - } - - /** * update the bounds of the rectangle to snap to grid * Snap is done with screen position. * diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/PapyrusUMLSequenceDiagram.paletteconfiguration b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/PapyrusUMLSequenceDiagram.paletteconfiguration index f2db127863a..76aa8f1c09b 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/PapyrusUMLSequenceDiagram.paletteconfiguration +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/PapyrusUMLSequenceDiagram.paletteconfiguration @@ -56,12 +56,6 @@ <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.Constraint_Shape"/> </elementDescriptors> </ownedConfigurations> - <ownedConfigurations xmi:type="paletteconfiguration:ToolConfiguration" id="createDurationObservation11CreationTool" label="Duration Observation" description="Create a Duration Observation on a Message" kind="CreationTool"> - <icon xmi:type="paletteconfiguration:IconDescriptor" pluginID="org.eclipse.uml2.uml.edit" iconPath="/icons/full/obj16/DurationObservation.gif"/> - <elementDescriptors xmi:type="paletteconfiguration:ElementDescriptor"> - <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.DurationObservation_Shape"/> - </elementDescriptors> - </ownedConfigurations> <ownedConfigurations xmi:type="paletteconfiguration:ToolConfiguration" id="createTimeConstraint12CreationTool" label="Time Constraint" description="Create a Time Constraint" kind="CreationTool"> <icon xmi:type="paletteconfiguration:IconDescriptor" pluginID="org.eclipse.uml2.uml.edit" iconPath="/icons/full/obj16/TimeConstraint.gif"/> <elementDescriptors xmi:type="paletteconfiguration:ElementDescriptor"> @@ -74,15 +68,6 @@ <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.TimeObservation_Shape"/> </elementDescriptors> </ownedConfigurations> - <ownedConfigurations xmi:type="paletteconfiguration:ToolConfiguration" id="createDurationConstraint14CreationTool" label="Duration Constraint" description="Create a Duration Constraint" kind="CreationTool"> - <icon xmi:type="paletteconfiguration:IconDescriptor" pluginID="org.eclipse.uml2.uml.edit" iconPath="/icons/full/obj16/DurationConstraint.gif"/> - <elementDescriptors xmi:type="paletteconfiguration:ElementDescriptor"> - <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.DurationConstraint_Shape"/> - </elementDescriptors> - <elementDescriptors xmi:type="paletteconfiguration:ElementDescriptor"> - <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.DurationConstraint_Shape_CN"/> - </elementDescriptors> - </ownedConfigurations> <ownedConfigurations xmi:type="paletteconfiguration:ToolConfiguration" id="createNEWGateCreationTool" label="Gate" description="New create a gate" kind="CreationTool"> <icon xmi:type="paletteconfiguration:IconDescriptor" pluginID="org.eclipse.uml2.uml.edit" iconPath="/icons/full/obj16/Gate.gif"/> <elementDescriptors xmi:type="paletteconfiguration:ElementDescriptor"> @@ -146,6 +131,18 @@ <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.GeneralOrdering_Edge"/> </elementDescriptors> </ownedConfigurations> + <ownedConfigurations xmi:type="paletteconfiguration:ToolConfiguration" id="createDurationConstraintEdgeTool" label="Duration Constraint" description="Create a Duration Constraint between two elements" kind="ConnectionTool"> + <icon xmi:type="paletteconfiguration:IconDescriptor" pluginID="org.eclipse.uml2.uml.edit" iconPath="/icons/full/obj16/DurationConstraint.gif"/> + <elementDescriptors xmi:type="paletteconfiguration:ElementDescriptor"> + <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#_zZRfUH3REeiyRednYY2ROQ"/> + </elementDescriptors> + </ownedConfigurations> + <ownedConfigurations xmi:type="paletteconfiguration:ToolConfiguration" id="createDurationObservationEdgeTool" label="Duration Observation" description="Create a Duration Observation between two elements" kind="ConnectionTool"> + <icon xmi:type="paletteconfiguration:IconDescriptor" pluginID="org.eclipse.uml2.uml.edit" iconPath="/icons/full/obj16/DurationObservation.gif"/> + <elementDescriptors xmi:type="paletteconfiguration:ElementDescriptor"> + <elementType xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#__qpi0H38EeiKffoiPArZXg"/> + </elementDescriptors> + </ownedConfigurations> <ownedConfigurations xmi:type="paletteconfiguration:ToolConfiguration" id="createCommentlink9CreationTool" label="Comment link" description="Create a comment link" kind="ConnectionTool"> <icon xmi:type="paletteconfiguration:IconDescriptor" pluginID="org.eclipse.uml2.uml.edit" iconPath="/icons/full/obj16/Comment.gif"/> <elementDescriptors xmi:type="paletteconfiguration:ElementDescriptor"> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations index bb84ce2dda9..2f2a8db69b0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations @@ -1,10 +1,19 @@ <?xml version="1.0" encoding="UTF-8"?> -<elementtypesconfigurations:ElementTypeSetConfiguration xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmi:id="_uuwoQENKEeimO7ZhVBpjkg" description="Notational edit-helper advices for the Sequence Diagram." identifier="org.eclipse.papyrus.uml.diagram.sequence.advice" name="Sequence Diagram Advice" metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML"> - <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_BvoRIENLEeimO7ZhVBpjkg" description="Advice for configuration of the view for the default operand of a new combined fragment." identifier="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.defaultInteractionOperand" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.DefaultInteractionOperandAdvice"> - <target xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.CombinedFragment_Shape"/> +<elementtypesconfigurations:ElementTypeSetConfiguration xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:elementtypesconfigurations="http://www.eclipse.org/papyrus/infra/elementtypesconfigurations/1.2" xmi:id="_uuwoQENKEeimO7ZhVBpjkg" description="Notational edit-helper advices for the Sequence Diagram." identifier="org.eclipse.papyrus.uml.diagram.sequence.advice" name="Sequence Diagram Advice" metamodelNsURI="http://www.eclipse.org/uml2/5.0.0/UML"> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_BvoRIENLEeimO7ZhVBpjkg" description="Advice for configuration of the view for the default operand of a new combined fragment." identifier="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.defaultInteractionOperand" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.DefaultInteractionOperandAdvice"> + <target xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.CombinedFragment_Shape"/> </adviceBindingsConfigurations> - <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_MdNHsFePEeiIR4R5xrPjKA" description="" identifier="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.interactionoperandviewadvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.InteractionOperandViewAdvice"> - <before xsi:type="elementtypesconfigurations:ExternallyRegisteredAdvice" href="platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.common/model/gmfdiag-common.elementtypesconfigurations#_U91U4F6dEeev1-J3e2LKZA"/> - <target xsi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.InteractionOperand_Shape"/> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_MdNHsFePEeiIR4R5xrPjKA" description="" identifier="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.interactionoperandviewadvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.InteractionOperandViewAdvice"> + <before xmi:type="elementtypesconfigurations:ExternallyRegisteredAdvice" href="platform:/plugin/org.eclipse.papyrus.infra.gmfdiag.common/model/gmfdiag-common.elementtypesconfigurations#_U91U4F6dEeev1-J3e2LKZA"/> + <target xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations#org.eclipse.papyrus.umldi.InteractionOperand_Shape"/> + </adviceBindingsConfigurations> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_fKI5cJP_EeiUfLwbDmLfuw" description="Graphical advice for preserving DurationConstraintLink consistency" identifier="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.DurationConstraintLinkAdvice" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.DurationConstraintLinkAdvice"> + <target xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationConstraint"/> + </adviceBindingsConfigurations> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_fhVRcJP_EeiUfLwbDmLfuw" description="Graphical advice for preserving DurationObservationLink consistency" identifier="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.DurationObservationLinkAdvice" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.DurationObservationLinkAdvice"> + <target xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationObservation"/> + </adviceBindingsConfigurations> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_oW2fQJYxEeies4N3OENAgQ" description="Graphical advice for preserving GeneralOrdering link consistency" identifier="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.GeneralOrderingLinkHelperAdvice" editHelperAdviceClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.advice.GeneralOrderingLinkHelperAdvice"> + <target xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.GeneralOrdering"/> </adviceBindingsConfigurations> </elementtypesconfigurations:ElementTypeSetConfiguration> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/sequenceDiagram.gmfgen b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/sequenceDiagram.gmfgen index 4422b7f4bef..daee1a5bcf0 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/sequenceDiagram.gmfgen +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/sequenceDiagram.gmfgen @@ -11,7 +11,7 @@ domainFileExtension="PapyrusUMLSequence" dynamicTemplates="true" templateDirectory="/org.eclipse.papyrus.def/xtend/" - copyrightText="Copyright (c) 2016 CEA LIST.

All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-2.0

SPDX-License-Identifier: EPL-2.0

Contributors:
 CEA LIST - Initial API and implementation" + copyrightText="Copyright (c) 2018 CEA LIST.

All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
http://www.eclipse.org/legal/epl-2.0

SPDX-License-Identifier: EPL-2.0

Contributors:
 CEA LIST - Initial API and implementation" pluginDirectory="/org.eclipse.papyrus.uml.diagram.sequence/src-gen"> <audits> <categories @@ -155,7 +155,7 @@ itemSemanticEditPolicyClassName="CombinedFragmentItemSemanticEditPolicy" notationViewFactoryClassName="CombinedFragmentViewFactory" canonicalEditPolicyClassName="CombinedFragmentCanonicalEditPolicy" - childNodes="/0/@diagram/@childNodes.17" + childNodes="/0/@diagram/@childNodes.12" compartments="/0/@diagram/@compartments.1" graphicalNodeEditPolicyClassName="CombinedFragmentGraphicalNodeEditPolicy" createCommandClassName="CombinedFragmentCreateCommand" @@ -247,7 +247,7 @@ itemSemanticEditPolicyClassName="InteractionUseItemSemanticEditPolicy" notationViewFactoryClassName="InteractionUseViewFactory" canonicalEditPolicyClassName="InteractionUseCanonicalEditPolicy" - childNodes="/0/@diagram/@childNodes.17" + childNodes="/0/@diagram/@childNodes.12" graphicalNodeEditPolicyClassName="InteractionUseGraphicalNodeEditPolicy" createCommandClassName="InteractionUseCreateCommand" containers="/0/@diagram/@childNodes.2 /0/@diagram/@compartments.0"> @@ -388,7 +388,7 @@ itemSemanticEditPolicyClassName="LifelineItemSemanticEditPolicy" notationViewFactoryClassName="LifelineViewFactory" canonicalEditPolicyClassName="LifelineCanonicalEditPolicy" - childNodes="/0/@diagram/@childNodes.6 /0/@diagram/@childNodes.7 /0/@diagram/@childNodes.8 /0/@diagram/@childNodes.9 /0/@diagram/@childNodes.10 /0/@diagram/@childNodes.11 /0/@diagram/@childNodes.12" + childNodes="/0/@diagram/@childNodes.6 /0/@diagram/@childNodes.7 /0/@diagram/@childNodes.8 /0/@diagram/@childNodes.9 /0/@diagram/@childNodes.13 /0/@diagram/@childNodes.14" graphicalNodeEditPolicyClassName="LifelineGraphicalNodeEditPolicy" createCommandClassName="LifelineCreateCommand" containers="/0/@diagram/@compartments.0"> @@ -484,6 +484,7 @@ itemSemanticEditPolicyClassName="ActionExecutionSpecificationItemSemanticEditPolicy" notationViewFactoryClassName="ActionExecutionSpecificationViewFactory" canonicalEditPolicyClassName="ActionExecutionSpecificationCanonicalEditPolicy" + childNodes="/0/@diagram/@childNodes.13 /0/@diagram/@childNodes.14" graphicalNodeEditPolicyClassName="ActionExecutionSpecificationGraphicalNodeEditPolicy" createCommandClassName="ActionExecutionSpecificationCreateCommand" containers="/0/@diagram/@childNodes.5"> @@ -508,7 +509,7 @@ <behaviour xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWithMessageEditPolicy"/> + editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationGraphicalNodeEditPolicy"/> <behaviour xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.gef.EditPolicy.COMPONENT_ROLE" @@ -528,6 +529,7 @@ itemSemanticEditPolicyClassName="BehaviorExecutionSpecificationItemSemanticEditPolicy" notationViewFactoryClassName="BehaviorExecutionSpecificationViewFactory" canonicalEditPolicyClassName="BehaviorExecutionSpecificationCanonicalEditPolicy" + childNodes="/0/@diagram/@childNodes.13 /0/@diagram/@childNodes.14" graphicalNodeEditPolicyClassName="BehaviorExecutionSpecificationGraphicalNodeEditPolicy" createCommandClassName="BehaviorExecutionSpecificationCreateCommand" containers="/0/@diagram/@childNodes.5"> @@ -552,7 +554,7 @@ <behaviour xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.gef.EditPolicy.GRAPHICAL_NODE_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWithMessageEditPolicy"/> + editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationGraphicalNodeEditPolicy"/> <behaviour xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.gef.EditPolicy.COMPONENT_ROLE" @@ -635,274 +637,8 @@ getterName="getInvariantFigure" figureQualifiedClassName="org.eclipse.draw2d.IFigure"/> <modelFacet - parser="/0/@labelParsers/@implementations.10"/> - </labels> - </childNodes> - <childNodes - xsi:type="gmfgen:GenChildSideAffixedNode" - visualID="3019" - editPartClassName="TimeConstraintEditPart" - itemSemanticEditPolicyClassName="TimeConstraintItemSemanticEditPolicy" - notationViewFactoryClassName="TimeConstraintViewFactory" - canonicalEditPolicyClassName="TimeConstraintCanonicalEditPolicy" - graphicalNodeEditPolicyClassName="TimeConstraintGraphicalNodeEditPolicy" - createCommandClassName="TimeConstraintCreateCommand" - containers="/0/@diagram/@childNodes.5"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <elementType - xsi:type="gmfgen:MetamodelType" - uniqueIdentifier="org.eclipse.papyrus.umldi.TimeConstraint_Shape" - definedExternally="true" - editHelperClassName="TimeConstraintEditHelper"/> - <viewmap - xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.TimeMarkElementFigure"/> - <modelFacet> - <metaClass - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/TimeConstraint"/> - <containmentMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> - <childMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> - <modelElementInitializer - xsi:type="gmfgen:GenFeatureSeqInitializer"> - <initializers - xsi:type="gmfgen:GenReferenceNewElementSpec"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Constraint/specification"/> - <newElementInitializers> - <initializers - xsi:type="gmfgen:GenFeatureValueSpec" - value="/0/@expressionProviders/@providers.0/@expressions.8"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> - </initializers> - <elementClass - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/TimeInterval"/> - </newElementInitializers> - </initializers> - <initializers - xsi:type="gmfgen:GenFeatureValueSpec" - value="/0/@expressionProviders/@providers.0/@expressions.9"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> - </initializers> - </modelElementInitializer> - </modelFacet> - <labels - xsi:type="gmfgen:GenExternalNodeLabel" - visualID="5009" - editPartClassName="TimeConstraintLabelEditPart" - itemSemanticEditPolicyClassName="TimeConstraintLabelItemSemanticEditPolicy" - notationViewFactoryClassName="TimeConstraintLabelViewFactory"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <viewmap - xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MultilineLabelFigure"/> - <modelFacet parser="/0/@labelParsers/@implementations.7"/> </labels> - <labels - xsi:type="gmfgen:GenExternalNodeLabel" - visualID="5013" - editPartClassName="TimeConstraintAppliedStereotypeEditPart" - itemSemanticEditPolicyClassName="TimeConstraintAppliedStereotypeItemSemanticEditPolicy" - notationViewFactoryClassName="TimeConstraintLabelViewFactory" - readOnly="true" - elementIcon="true"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <viewmap - xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeWrappingLabelFigure"> - <attributes - xsi:type="gmfgen:LabelOffsetAttributes" - y="-22"/> - </viewmap> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy"/> - <modelFacet - parser="/0/@labelParsers/@implementations.9"/> - </labels> - </childNodes> - <childNodes - xsi:type="gmfgen:GenChildSideAffixedNode" - visualID="3020" - editPartClassName="TimeObservationEditPart" - itemSemanticEditPolicyClassName="TimeObservationItemSemanticEditPolicy" - notationViewFactoryClassName="TimeObservationViewFactory" - canonicalEditPolicyClassName="TimeObservationCanonicalEditPolicy" - graphicalNodeEditPolicyClassName="TimeObservationGraphicalNodeEditPolicy" - createCommandClassName="TimeObservationCreateCommand" - containers="/0/@diagram/@childNodes.5"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <elementType - xsi:type="gmfgen:MetamodelType" - uniqueIdentifier="org.eclipse.papyrus.umldi.TimeObservation_Shape" - definedExternally="true" - editHelperClassName="TimeObservationEditHelper"/> - <viewmap - xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.TimeMarkElementFigure"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy.KEY" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy"/> - <modelFacet> - <metaClass - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/TimeObservation"/> - <containmentMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/> - <childMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/> - <modelElementInitializer - xsi:type="gmfgen:GenFeatureSeqInitializer"> - <initializers - xsi:type="gmfgen:GenFeatureValueSpec" - value="/0/@expressionProviders/@providers.0/@expressions.10"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> - </initializers> - </modelElementInitializer> - </modelFacet> - <labels - xsi:type="gmfgen:GenExternalNodeLabel" - visualID="5010" - editPartClassName="TimeObservationLabelEditPart" - itemSemanticEditPolicyClassName="TimeObservationLabelItemSemanticEditPolicy" - notationViewFactoryClassName="TimeObservationLabelViewFactory"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <viewmap - xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MultilineLabelFigure"/> - <modelFacet - parser="/0/@labelParsers/@implementations.8"/> - </labels> - <labels - xsi:type="gmfgen:GenExternalNodeLabel" - visualID="5014" - editPartClassName="TimeObservationAppliedStereotypeEditPart" - itemSemanticEditPolicyClassName="TimeObservationAppliedStereotypeItemSemanticEditPolicy" - notationViewFactoryClassName="TimeObservationLabelViewFactory" - readOnly="true" - elementIcon="true"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <viewmap - xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeWrappingLabelFigure"> - <attributes - xsi:type="gmfgen:LabelOffsetAttributes" - y="-22"/> - </viewmap> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy"/> - <modelFacet - parser="/0/@labelParsers/@implementations.9"/> - </labels> - </childNodes> - <childNodes - xsi:type="gmfgen:GenChildSideAffixedNode" - visualID="3021" - editPartClassName="DurationConstraintEditPart" - itemSemanticEditPolicyClassName="DurationConstraintItemSemanticEditPolicy" - notationViewFactoryClassName="DurationConstraintViewFactory" - canonicalEditPolicyClassName="DurationConstraintCanonicalEditPolicy" - graphicalNodeEditPolicyClassName="DurationConstraintGraphicalNodeEditPolicy" - createCommandClassName="DurationConstraintCreateCommand" - containers="/0/@diagram/@childNodes.5"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <elementType - xsi:type="gmfgen:MetamodelType" - uniqueIdentifier="org.eclipse.papyrus.umldi.DurationConstraint_Shape" - definedExternally="true" - editHelperClassName="DurationConstraintEditHelper"/> - <viewmap - xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.DurationConstraintFigure"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy.KEY" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy"/> - <modelFacet> - <metaClass - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/DurationConstraint"/> - <containmentMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> - <childMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> - <modelElementInitializer - xsi:type="gmfgen:GenFeatureSeqInitializer"> - <initializers - xsi:type="gmfgen:GenReferenceNewElementSpec"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Constraint/specification"/> - <newElementInitializers> - <initializers - xsi:type="gmfgen:GenFeatureValueSpec" - value="/0/@expressionProviders/@providers.0/@expressions.11"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> - </initializers> - <elementClass - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/DurationInterval"/> - </newElementInitializers> - </initializers> - <initializers - xsi:type="gmfgen:GenFeatureValueSpec" - value="/0/@expressionProviders/@providers.0/@expressions.12"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> - </initializers> - </modelElementInitializer> - </modelFacet> - <labels - xsi:type="gmfgen:GenExternalNodeLabel" - visualID="5011" - editPartClassName="DurationConstraintLabelEditPart" - itemSemanticEditPolicyClassName="DurationConstraintLabelItemSemanticEditPolicy" - notationViewFactoryClassName="DurationConstraintLabelViewFactory"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <viewmap - xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MultilineLabelFigure"/> - <modelFacet - parser="/0/@labelParsers/@implementations.7"/> - </labels> - <labels - xsi:type="gmfgen:GenExternalNodeLabel" - visualID="5015" - editPartClassName="DurationConstraintAppliedStereotypeEditPart" - itemSemanticEditPolicyClassName="DurationConstraintAppliedStereotypeItemSemanticEditPolicy" - notationViewFactoryClassName="DurationConstraintLabelViewFactory" - readOnly="true" - elementIcon="true"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <viewmap - xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeWrappingLabelFigure"> - <attributes - xsi:type="gmfgen:LabelOffsetAttributes" - y="-22"/> - </viewmap> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy"/> - <modelFacet - parser="/0/@labelParsers/@implementations.9"/> - </labels> </childNodes> <childNodes xsi:type="gmfgen:GenChildSideAffixedNode" @@ -911,6 +647,7 @@ itemSemanticEditPolicyClassName="DestructionOccurrenceSpecificationItemSemanticEditPolicy" notationViewFactoryClassName="DestructionEventViewFactory" canonicalEditPolicyClassName="DestructionOccurrenceSpecificationCanonicalEditPolicy" + childNodes="/0/@diagram/@childNodes.13 /0/@diagram/@childNodes.14" graphicalNodeEditPolicyClassName="DestructionOccurrenceSpecificationGraphicalNodeEditPolicy" createCommandClassName="DestructionOccurrenceSpecificationCreateCommand" containers="/0/@diagram/@childNodes.5" @@ -1024,7 +761,7 @@ getterName="getConstraintFigure" figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure"/> <modelFacet - parser="/0/@labelParsers/@implementations.10"/> + parser="/0/@labelParsers/@implementations.7"/> </labels> </childNodes> <childNodes @@ -1096,186 +833,133 @@ </labels> </childNodes> <childNodes - visualID="3023" - editPartClassName="DurationConstraintInMessageEditPart" - itemSemanticEditPolicyClassName="DurationConstraintInMessageItemSemanticEditPolicy" - notationViewFactoryClassName="DurationConstraintViewFactory" - canonicalEditPolicyClassName="DurationConstraintInMessageCanonicalEditPolicy" - graphicalNodeEditPolicyClassName="DurationConstraintInMessageGraphicalNodeEditPolicy" - createCommandClassName="DurationConstraintInMessageCreateCommand" - containers="/0/@diagram/@topLevelNodes.0"> + xsi:type="gmfgen:GenChildSideAffixedNode" + visualID="3025" + editPartClassName="GateEditPart" + itemSemanticEditPolicyClassName="GateItemSemanticEditPolicy" + canonicalEditPolicyClassName="GateCanonicalEditPolicy" + graphicalNodeEditPolicyClassName="GateGraphicalNodeEditPolicy" + createCommandClassName="GateCreateCommand" + containers="/0/@diagram/@childNodes.1 /0/@diagram/@childNodes.3 /0/@diagram/@topLevelNodes.0"> <diagramRunTimeClass href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> <elementType - xsi:type="gmfgen:SpecializationType" - uniqueIdentifier="org.eclipse.papyrus.umldi.DurationConstraint_Shape_CN" + xsi:type="gmfgen:MetamodelType" + uniqueIdentifier="org.eclipse.papyrus.umldi.Gate_Shape" + displayName="Gate" definedExternally="true" - metamodelType="/0/@diagram/@childNodes.11/@elementType"/> + editHelperClassName="GateEditHelper"/> <viewmap xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gef.EditPolicy.COMPONENT_ROLE" - editPolicyQualifiedClassName="org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MoveableNonResizableLabelEditPolicy"/> + figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.AffixedNamedElementFigure"> + <attributes + xsi:type="gmfgen:DefaultSizeAttributes" + width="16" + height="16"/> + </viewmap> <behaviour xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy.KEY" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy"/> + key="org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY" + editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.MaskManagedNodeEditPolicy"/> <modelFacet> <metaClass - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/DurationConstraint"/> + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Gate"/> <containmentMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Interaction/formalGate"/> <childMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> - <modelElementInitializer - xsi:type="gmfgen:GenFeatureSeqInitializer"> - <initializers - xsi:type="gmfgen:GenReferenceNewElementSpec"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Constraint/specification"/> - <newElementInitializers> - <initializers - xsi:type="gmfgen:GenFeatureValueSpec" - value="/0/@expressionProviders/@providers.0/@expressions.15"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> - </initializers> - <elementClass - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/DurationInterval"/> - </newElementInitializers> - </initializers> - <initializers - xsi:type="gmfgen:GenFeatureValueSpec" - value="/0/@expressionProviders/@providers.0/@expressions.16"> - <feature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> - </initializers> - </modelElementInitializer> + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Interaction/formalGate"/> </modelFacet> <labels - visualID="5018" - editPartClassName="DurationConstraintInMessageLabelEditPart" - itemSemanticEditPolicyClassName="DurationConstraintInMessageLabelItemSemanticEditPolicy" - notationViewFactoryClassName="DurationConstraintLabelViewFactory"> - <diagramRunTimeClass - href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> - <viewmap - xsi:type="gmfgen:ParentAssignedViewmap" - getterName="getNameLabel" - figureQualifiedClassName="org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gef.EditPolicy.SELECTION_FEEDBACK_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy"/> - <modelFacet - parser="/0/@labelParsers/@implementations.7"/> - </labels> - <labels xsi:type="gmfgen:GenExternalNodeLabel" - visualID="5019" - editPartClassName="DurationConstraintInMessageAppliedStereotypeEditPart" - itemSemanticEditPolicyClassName="DurationConstraintInMessageAppliedStereotypeItemSemanticEditPolicy" - notationViewFactoryClassName="DurationConstraintLabelViewFactory" - readOnly="true" + visualID="5024" elementIcon="true"> <diagramRunTimeClass href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> <viewmap xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeWrappingLabelFigure"> + figureQualifiedClassName="org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel"> <attributes xsi:type="gmfgen:LabelOffsetAttributes" - y="-22"/> + x="25" + y="3"/> </viewmap> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy"/> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + xsi:type="gmfgen:FeatureLabelModelFacet" + parser="/0/@labelParsers/@implementations.1"> + <metaFeatures + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> + </modelFacet> </labels> </childNodes> <childNodes - visualID="3024" - editPartClassName="DurationObservationEditPart" - itemSemanticEditPolicyClassName="DurationObservationItemSemanticEditPolicy" - notationViewFactoryClassName="DurationObservationViewFactory" - canonicalEditPolicyClassName="DurationObservationCanonicalEditPolicy" - graphicalNodeEditPolicyClassName="DurationObservationGraphicalNodeEditPolicy" - createCommandClassName="DurationObservationCreateCommand" - containers="/0/@diagram/@compartments.0"> + xsi:type="gmfgen:GenChildSideAffixedNode" + visualID="3019" + editPartClassName="TimeConstraintBorderNodeEditPart" + itemSemanticEditPolicyClassName="TimeConstraintBorderNodeItemSemanticEditPolicy" + canonicalEditPolicyClassName="TimeConstraintBorderNodeCanonicalEditPolicy" + graphicalNodeEditPolicyClassName="TimeConstraintBorderNodeGraphicalNodeEditPolicy" + createCommandClassName="TimeConstraintBorderNodeCreateCommand" + containers="/0/@diagram/@childNodes.6 /0/@diagram/@childNodes.7 /0/@diagram/@childNodes.9 /0/@diagram/@childNodes.5"> <diagramRunTimeClass href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> <elementType xsi:type="gmfgen:MetamodelType" - uniqueIdentifier="org.eclipse.papyrus.umldi.DurationObservation_Shape" + uniqueIdentifier="org.eclipse.papyrus.umldi.TimeConstraint_Shape" + displayName="TimeConstraint" definedExternally="true" - editHelperClassName="DurationObservationEditHelper"/> + editHelperClassName="TimeConstraintEditHelper"/> <viewmap xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gef.EditPolicy.COMPONENT_ROLE" - editPolicyQualifiedClassName="org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MoveableNonResizableLabelEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy.KEY" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy"/> + figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.TimeConstraintFigure"> + <attributes + xsi:type="gmfgen:DefaultSizeAttributes" + height="1"/> + </viewmap> <modelFacet> <metaClass - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/DurationObservation"/> + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/TimeConstraint"/> <containmentMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/> + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> <childMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/> + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> <modelElementInitializer xsi:type="gmfgen:GenFeatureSeqInitializer"> <initializers xsi:type="gmfgen:GenFeatureValueSpec" - value="/0/@expressionProviders/@providers.0/@expressions.17"> + value="/0/@expressionProviders/@providers.0/@expressions.18"> <feature href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> </initializers> </modelElementInitializer> </modelFacet> <labels - visualID="5016" - editPartClassName="DurationObservationLabelEditPart" - itemSemanticEditPolicyClassName="DurationObservationLabelItemSemanticEditPolicy" - notationViewFactoryClassName="DurationObservationLabelViewFactory" + xsi:type="gmfgen:GenExternalNodeLabel" + visualID="5009" elementIcon="true"> <diagramRunTimeClass href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> <viewmap - xsi:type="gmfgen:ParentAssignedViewmap" - getterName="getNameLabel" - figureQualifiedClassName="org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gef.EditPolicy.SELECTION_FEEDBACK_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy"/> + xsi:type="gmfgen:FigureViewmap" + figureQualifiedClassName="org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel"> + <attributes + xsi:type="gmfgen:LabelOffsetAttributes" + x="25" + y="3"/> + </viewmap> <modelFacet - parser="/0/@labelParsers/@implementations.6"/> + xsi:type="gmfgen:FeatureLabelModelFacet" + parser="/0/@labelParsers/@implementations.7"> + <metaFeatures + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> + </modelFacet> </labels> <labels xsi:type="gmfgen:GenExternalNodeLabel" - visualID="5017" - editPartClassName="DurationObservationAppliedStereotypeEditPart" - itemSemanticEditPolicyClassName="DurationObservationAppliedStereotypeItemSemanticEditPolicy" - notationViewFactoryClassName="DurationObservationLabelViewFactory" - readOnly="true" - elementIcon="true"> + visualID="5013" + editPartClassName="TimeConstraintAppliedStereotypeEditPart" + itemSemanticEditPolicyClassName="TimeConstraintAppliedStereotypeItemSemanticEditPolicy" + notationViewFactoryClassName="TimeConstraintLabelViewFactory" + readOnly="true"> <diagramRunTimeClass href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> <viewmap @@ -1290,49 +974,55 @@ key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy"/> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + parser="/0/@labelParsers/@implementations.6"/> </labels> </childNodes> <childNodes xsi:type="gmfgen:GenChildSideAffixedNode" - visualID="3025" - editPartClassName="GateEditPart" - itemSemanticEditPolicyClassName="GateItemSemanticEditPolicy" - canonicalEditPolicyClassName="GateCanonicalEditPolicy" - graphicalNodeEditPolicyClassName="GateGraphicalNodeEditPolicy" - createCommandClassName="GateCreateCommand" - containers="/0/@diagram/@childNodes.1 /0/@diagram/@childNodes.3 /0/@diagram/@topLevelNodes.0"> + visualID="3020" + editPartClassName="TimeObservationBorderNodeEditPart" + itemSemanticEditPolicyClassName="TimeObservationBorderNodeItemSemanticEditPolicy" + canonicalEditPolicyClassName="TimeObservationBorderNodeCanonicalEditPolicy" + graphicalNodeEditPolicyClassName="TimeObservationBorderNodeGraphicalNodeEditPolicy" + createCommandClassName="TimeObservationBorderNodeCreateCommand" + containers="/0/@diagram/@childNodes.6 /0/@diagram/@childNodes.7 /0/@diagram/@childNodes.9 /0/@diagram/@childNodes.5"> <diagramRunTimeClass href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> <elementType xsi:type="gmfgen:MetamodelType" - uniqueIdentifier="org.eclipse.papyrus.umldi.Gate_Shape" - displayName="Gate" + uniqueIdentifier="org.eclipse.papyrus.umldi.TimeObservation_Shape" + displayName="TimeObservation" definedExternally="true" - editHelperClassName="GateEditHelper"/> + editHelperClassName="TimeObservationEditHelper"/> <viewmap xsi:type="gmfgen:FigureViewmap" - figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.AffixedNamedElementFigure"> + figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.TimeObservationFigure"> <attributes xsi:type="gmfgen:DefaultSizeAttributes" - width="16" - height="16"/> + height="1"/> </viewmap> - <behaviour - xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.MaskManagedNodeEditPolicy"/> <modelFacet> <metaClass - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Gate"/> + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/TimeObservation"/> <containmentMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Interaction/formalGate"/> + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/> <childMetaFeature - href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Interaction/formalGate"/> + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/> + <modelElementInitializer + xsi:type="gmfgen:GenFeatureSeqInitializer"> + <initializers + xsi:type="gmfgen:GenFeatureValueSpec" + value="/0/@expressionProviders/@providers.0/@expressions.18"> + <feature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> + </initializers> + </modelElementInitializer> </modelFacet> <labels xsi:type="gmfgen:GenExternalNodeLabel" - visualID="5024" + visualID="5010" + editPartClassName="TimeObservationNameEditPart" + itemSemanticEditPolicyClassName="TimeObservationNameItemSemanticEditPolicy" elementIcon="true"> <diagramRunTimeClass href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> @@ -1346,11 +1036,33 @@ </viewmap> <modelFacet xsi:type="gmfgen:FeatureLabelModelFacet" - parser="/0/@labelParsers/@implementations.1"> + parser="/0/@labelParsers/@implementations.8"> <metaFeatures href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> </modelFacet> </labels> + <labels + xsi:type="gmfgen:GenExternalNodeLabel" + visualID="5014" + editPartClassName="TimeObservationAppliedStereotypeEditPart" + itemSemanticEditPolicyClassName="TimeObservationAppliedStereotypeItemSemanticEditPolicy" + readOnly="true"> + <diagramRunTimeClass + href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> + <viewmap + xsi:type="gmfgen:FigureViewmap" + figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeWrappingLabelFigure"> + <attributes + xsi:type="gmfgen:LabelOffsetAttributes" + y="-22"/> + </viewmap> + <behaviour + xsi:type="gmfgen:CustomBehaviour" + key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" + editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy"/> + <modelFacet + parser="/0/@labelParsers/@implementations.6"/> + </labels> </childNodes> <topLevelNodes visualID="2001" @@ -1358,7 +1070,7 @@ itemSemanticEditPolicyClassName="InteractionItemSemanticEditPolicy" notationViewFactoryClassName="InteractionViewFactory" canonicalEditPolicyClassName="InteractionCanonicalEditPolicy" - childNodes="/0/@diagram/@childNodes.15 /0/@diagram/@childNodes.17" + childNodes="/0/@diagram/@childNodes.12" compartments="/0/@diagram/@compartments.0" graphicalNodeEditPolicyClassName="InteractionGraphicalNodeEditPolicy" createCommandClassName="InteractionCreateCommand"> @@ -1447,10 +1159,6 @@ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MessageSync"/> <behaviour xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy"/> <behaviour @@ -1514,7 +1222,7 @@ y="-33"/> </viewmap> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + parser="/0/@labelParsers/@implementations.6"/> </labels> <creationConstraints sourceEnd="/0/@expressionProviders/@providers.1/@expressions.2" @@ -1539,10 +1247,6 @@ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MessageAsync"/> <behaviour xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy"/> <behaviour @@ -1605,7 +1309,7 @@ y="-33"/> </viewmap> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + parser="/0/@labelParsers/@implementations.6"/> </labels> <creationConstraints sourceEnd="/0/@expressionProviders/@providers.1/@expressions.22" @@ -1630,10 +1334,6 @@ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MessageReply"/> <behaviour xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy"/> <behaviour @@ -1696,7 +1396,7 @@ y="-33"/> </viewmap> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + parser="/0/@labelParsers/@implementations.6"/> </labels> <creationConstraints sourceEnd="/0/@expressionProviders/@providers.1/@expressions.8" @@ -1721,10 +1421,6 @@ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MessageCreate"/> <behaviour xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy"/> <behaviour @@ -1788,7 +1484,7 @@ y="-33"/> </viewmap> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + parser="/0/@labelParsers/@implementations.6"/> </labels> <creationConstraints sourceEnd="/0/@expressionProviders/@providers.1/@expressions.11" @@ -1813,10 +1509,6 @@ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MessageDelete"/> <behaviour xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy"/> <behaviour @@ -1879,7 +1571,7 @@ y="-33"/> </viewmap> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + parser="/0/@labelParsers/@implementations.6"/> </labels> <creationConstraints sourceEnd="/0/@expressionProviders/@providers.1/@expressions.14" @@ -1904,10 +1596,6 @@ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MessageLost"/> <behaviour xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy"/> <behaviour @@ -1971,7 +1659,7 @@ y="-33"/> </viewmap> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + parser="/0/@labelParsers/@implementations.6"/> </labels> <creationConstraints sourceEnd="/0/@expressionProviders/@providers.1/@expressions.22" @@ -1996,10 +1684,6 @@ figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.MessageFound"/> <behaviour xsi:type="gmfgen:CustomBehaviour" - key="org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CREATION_ROLE" - editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy"/> - <behaviour - xsi:type="gmfgen:CustomBehaviour" key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy"/> <behaviour @@ -2062,7 +1746,7 @@ y="-33"/> </viewmap> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + parser="/0/@labelParsers/@implementations.6"/> </labels> <creationConstraints sourceEnd="/0/@expressionProviders/@providers.1/@expressions.20" @@ -2174,7 +1858,7 @@ y="-33"/> </viewmap> <modelFacet - parser="/0/@labelParsers/@implementations.9"/> + parser="/0/@labelParsers/@implementations.6"/> </labels> </links> <links @@ -2224,13 +1908,192 @@ parser="/0/@labelParsers/@implementations.0"/> </labels> </links> + <links + visualID="4013" + editPartClassName="DurationConstraintLinkEditPart" + itemSemanticEditPolicyClassName="DurationConstraintSemanticEditPolicy" + createCommandClassName="DurationConstraintCreateCommand" + reorientCommandClassName="DurationConstraintReorientCommand"> + <diagramRunTimeClass + href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Connector"/> + <elementType + xsi:type="gmfgen:MetamodelType" + uniqueIdentifier="org.eclipse.papyrus.umldi.DurationConstraint_Edge" + displayName="DurationConstraint" + definedExternally="true" + editHelperClassName="DurationConstraintEditHelper"/> + <viewmap + xsi:type="gmfgen:FigureViewmap" + figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure"/> + <behaviour + xsi:type="gmfgen:CustomBehaviour" + key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" + editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy"/> + <modelFacet + xsi:type="gmfgen:TypeLinkModelFacet"> + <metaClass + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/DurationConstraint"/> + <containmentMetaFeature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> + <childMetaFeature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Namespace/ownedRule"/> + <modelElementInitializer + xsi:type="gmfgen:GenFeatureSeqInitializer"> + <initializers + xsi:type="gmfgen:GenFeatureValueSpec" + value="/0/@expressionProviders/@providers.0/@expressions.18"> + <feature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> + </initializers> + </modelElementInitializer> + <sourceMetaFeature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Constraint/constrainedElement"/> + <targetMetaFeature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Constraint/constrainedElement"/> + </modelFacet> + <labels + visualID="6020" + editPartClassName="DurationConstraintLinkNameEditPart" + itemSemanticEditPolicyClassName="DurationConstraintLinkItemSemanticEditPolicy" + notationViewFactoryClassName="MessageNameViewFactory"> + <diagramRunTimeClass + href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> + <viewmap + xsi:type="gmfgen:ParentAssignedViewmap" + getterName="getDurationLabelFigure" + figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"> + <attributes + xsi:type="gmfgen:LabelOffsetAttributes" + x="1" + y="-13"/> + </viewmap> + <modelFacet + xsi:type="gmfgen:FeatureLabelModelFacet" + parser="/0/@labelParsers/@implementations.7" + editorPattern="" + editPattern=""> + <metaFeatures + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> + </modelFacet> + </labels> + <labels + visualID="6021" + editPartClassName="DurationConstraintLinkAppliedStereotypeEditPart" + itemSemanticEditPolicyClassName="DurationConstraintLinkAppliedStereotypeItemSemanticEditPolicy" + notationViewFactoryClassName="MessageLabelViewFactory" + readOnly="true"> + <diagramRunTimeClass + href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> + <viewmap + xsi:type="gmfgen:ParentAssignedViewmap" + getterName="getAppliedStereotypeLabel" + figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"> + <attributes + xsi:type="gmfgen:LabelOffsetAttributes" + x="1" + y="-33"/> + </viewmap> + <modelFacet + parser="/0/@labelParsers/@implementations.6"/> + </labels> + </links> + <links + visualID="4014" + editPartClassName="DurationObservationLinkEditPart" + itemSemanticEditPolicyClassName="DurationObservationSemanticEditPolicy" + createCommandClassName="DurationObservationCreateCommand" + reorientCommandClassName="DurationObservationReorientCommand"> + <diagramRunTimeClass + href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Connector"/> + <elementType + xsi:type="gmfgen:MetamodelType" + uniqueIdentifier="org.eclipse.papyrus.umldi.DurationObservation_Edge" + displayName="DurationObservation" + definedExternally="true" + editHelperClassName="DurationObservationEditHelper"/> + <viewmap + xsi:type="gmfgen:FigureViewmap" + figureQualifiedClassName="org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure"/> + <behaviour + xsi:type="gmfgen:CustomBehaviour" + key="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY" + editPolicyQualifiedClassName="org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy"/> + <modelFacet + xsi:type="gmfgen:TypeLinkModelFacet"> + <metaClass + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/DurationObservation"/> + <containmentMetaFeature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/> + <childMetaFeature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/Package/packagedElement"/> + <modelElementInitializer + xsi:type="gmfgen:GenFeatureSeqInitializer"> + <initializers + xsi:type="gmfgen:GenFeatureValueSpec" + value="/0/@expressionProviders/@providers.0/@expressions.18"> + <feature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> + </initializers> + </modelElementInitializer> + <sourceMetaFeature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/DurationObservation/event"/> + <targetMetaFeature + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/DurationObservation/event"/> + </modelFacet> + <labels + visualID="6022" + editPartClassName="DurationObservationLinkNameEditPart" + itemSemanticEditPolicyClassName="DurationObservationLinkItemSemanticEditPolicy" + notationViewFactoryClassName="MessageNameViewFactory" + elementIcon="true"> + <diagramRunTimeClass + href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> + <viewmap + xsi:type="gmfgen:ParentAssignedViewmap" + getterName="getDurationLabelFigure" + figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"> + <attributes + xsi:type="gmfgen:LabelOffsetAttributes" + x="1" + y="-13"/> + </viewmap> + <modelFacet + xsi:type="gmfgen:FeatureLabelModelFacet" + parser="/0/@labelParsers/@implementations.8" + editorPattern="" + editPattern=""> + <metaFeatures + href="../../../plugin/org.eclipse.uml2.uml/model/UML.genmodel#//uml/NamedElement/name"/> + </modelFacet> + </labels> + <labels + visualID="6023" + editPartClassName="DurationObservationLinkAppliedStereotypeEditPart" + itemSemanticEditPolicyClassName="DurationObservationLinkAppliedStereotypeItemSemanticEditPolicy" + notationViewFactoryClassName="MessageLabelViewFactory" + readOnly="true"> + <diagramRunTimeClass + href="../../../plugin/org.eclipse.gmf.runtime.notation/model/notation.genmodel#//notation/Node"/> + <viewmap + xsi:type="gmfgen:ParentAssignedViewmap" + getterName="getAppliedStereotypeLabel" + figureQualifiedClassName="org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"> + <attributes + xsi:type="gmfgen:LabelOffsetAttributes" + x="1" + y="-33"/> + </viewmap> + <modelFacet + parser="/0/@labelParsers/@implementations.6"/> + </labels> + </links> <compartments visualID="7001" editPartClassName="InteractionInteractionCompartmentEditPart" itemSemanticEditPolicyClassName="InteractionInteractionCompartmentItemSemanticEditPolicy" notationViewFactoryClassName="InteractionInteractionCompartmentViewFactory" canonicalEditPolicyClassName="InteractionInteractionCompartmentCanonicalEditPolicy" - childNodes="/0/@diagram/@childNodes.0 /0/@diagram/@childNodes.1 /0/@diagram/@childNodes.5 /0/@diagram/@childNodes.3 /0/@diagram/@childNodes.13 /0/@diagram/@childNodes.14 /0/@diagram/@childNodes.16" + childNodes="/0/@diagram/@childNodes.0 /0/@diagram/@childNodes.1 /0/@diagram/@childNodes.5 /0/@diagram/@childNodes.3 /0/@diagram/@childNodes.10 /0/@diagram/@childNodes.11" title="InteractionCompartment" canCollapse="false" needsTitle="false" @@ -2313,7 +2176,7 @@ <plugin iD="org.eclipse.papyrus.uml.diagram.sequence" provider="CEA" - version="4.0.0.qualifier"> + version="5.1.0.qualifier"> <requiredPlugins>org.eclipse.draw2d</requiredPlugins> <requiredPlugins>org.eclipse.papyrus.uml.diagram.common</requiredPlugins> <requiredPlugins>org.eclipse.gmf.runtime.draw2d.ui</requiredPlugins> @@ -2392,6 +2255,8 @@ <expressions xsi:type="gmfgen:GenConstraint" body="return UMLValidationHelper.validateFragmentsOrder(context, ctx);"/> + <expressions + body="return SequenceUtil.getNearest()"/> </providers> <providers xsi:type="gmfgen:GenExpressionInterpreter"> @@ -2472,7 +2337,7 @@ uses="/0/@diagram/@links.10/@labels.0/@modelFacet"/> <implementations xsi:type="gmfgen:PredefinedParser" - uses="/0/@diagram/@childNodes.3/@labels.0/@modelFacet /0/@diagram/@childNodes.4/@labels.0/@modelFacet /0/@diagram/@childNodes.8/@labels.0/@modelFacet /0/@diagram/@childNodes.13/@labels.0/@modelFacet /0/@diagram/@topLevelNodes.0/@labels.0/@modelFacet /0/@diagram/@childNodes.17/@labels.0/@modelFacet"/> + uses="/0/@diagram/@childNodes.3/@labels.0/@modelFacet /0/@diagram/@childNodes.4/@labels.0/@modelFacet /0/@diagram/@childNodes.8/@labels.0/@modelFacet /0/@diagram/@childNodes.10/@labels.0/@modelFacet /0/@diagram/@topLevelNodes.0/@labels.0/@modelFacet /0/@diagram/@childNodes.12/@labels.0/@modelFacet"/> <implementations xsi:type="gmfgen:CustomParser" uses="/0/@diagram/@childNodes.5/@labels.0/@modelFacet" @@ -2487,28 +2352,20 @@ qualifiedName=" org.eclipse.papyrus.uml.diagram.sequence.parser.custom.MessageCustomParser"/> <implementations xsi:type="gmfgen:CustomParser" - uses="/0/@diagram/@childNodes.14/@labels.0/@modelFacet" + uses="/0/@diagram/@childNodes.11/@labels.0/@modelFacet" qualifiedName="org.eclipse.papyrus.uml.diagram.common.parser.CommentParser"/> <implementations xsi:type="gmfgen:CustomParser" - uses="/0/@diagram/@childNodes.16/@labels.0/@modelFacet" - qualifiedName="org.eclipse.papyrus.uml.diagram.sequence.parser.custom.DurationObservationParser"/> - <implementations - xsi:type="gmfgen:CustomParser" - uses="/0/@diagram/@childNodes.11/@labels.0/@modelFacet /0/@diagram/@childNodes.15/@labels.0/@modelFacet /0/@diagram/@childNodes.9/@labels.0/@modelFacet" - qualifiedName="org.eclipse.papyrus.uml.diagram.sequence.parser.custom.TimeConstraintParser"/> - <implementations - xsi:type="gmfgen:CustomParser" - uses="/0/@diagram/@childNodes.10/@labels.0/@modelFacet" - qualifiedName="org.eclipse.papyrus.uml.diagram.sequence.parser.custom.TimeObservationParser"/> - <implementations - xsi:type="gmfgen:CustomParser" - uses="/0/@diagram/@links.2/@labels.1/@modelFacet /0/@diagram/@childNodes.11/@labels.1/@modelFacet /0/@diagram/@links.9/@labels.0/@modelFacet /0/@diagram/@links.1/@labels.1/@modelFacet /0/@diagram/@childNodes.16/@labels.1/@modelFacet /0/@diagram/@childNodes.9/@labels.1/@modelFacet /0/@diagram/@childNodes.15/@labels.1/@modelFacet /0/@diagram/@links.0/@labels.1/@modelFacet /0/@diagram/@childNodes.10/@labels.1/@modelFacet /0/@diagram/@links.6/@labels.1/@modelFacet /0/@diagram/@links.5/@labels.1/@modelFacet /0/@diagram/@links.3/@labels.1/@modelFacet /0/@diagram/@links.4/@labels.1/@modelFacet" + uses="/0/@diagram/@links.2/@labels.1/@modelFacet /0/@diagram/@links.9/@labels.0/@modelFacet /0/@diagram/@links.1/@labels.1/@modelFacet /0/@diagram/@links.0/@labels.1/@modelFacet /0/@diagram/@links.6/@labels.1/@modelFacet /0/@diagram/@links.5/@labels.1/@modelFacet /0/@diagram/@links.3/@labels.1/@modelFacet /0/@diagram/@links.4/@labels.1/@modelFacet /0/@diagram/@links.12/@labels.1/@modelFacet /0/@diagram/@links.11/@labels.1/@modelFacet /0/@diagram/@childNodes.13/@labels.1/@modelFacet /0/@diagram/@childNodes.14/@labels.1/@modelFacet" qualifiedName="org.eclipse.papyrus.uml.diagram.common.parser.stereotype.AppliedStereotypeParser"/> <implementations xsi:type="gmfgen:CustomParser" - uses="/0/@diagram/@childNodes.13/@labels.1/@modelFacet /0/@diagram/@childNodes.8/@labels.1/@modelFacet" + uses="/0/@diagram/@childNodes.10/@labels.1/@modelFacet /0/@diagram/@childNodes.8/@labels.1/@modelFacet /0/@diagram/@links.11/@labels.0/@modelFacet /0/@diagram/@childNodes.13/@labels.0/@modelFacet" qualifiedName="org.eclipse.papyrus.uml.diagram.common.parser.ConstraintParser"/> + <implementations + xsi:type="gmfgen:CustomParser" + uses="/0/@diagram/@links.12/@labels.0/@modelFacet /0/@diagram/@childNodes.14/@labels.0/@modelFacet" + qualifiedName="org.eclipse.papyrus.uml.diagram.common.parser.ObservationParser"/> </labelParsers> <contextMenus context="/0/@diagram"> @@ -2543,30 +2400,25 @@ superOwnedEditPart="org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart"/> <extensionNodes xsi:type="papyrusgmfgenextension:SpecificLocator" - comment="Affixed locator for Lifelines to place element with a time bar" - classpath="org.eclipse.papyrus.uml.diagram.sequence.locator.CenterLocator" - genChildSideAffixedNode="/0/@diagram/@childNodes.9 /0/@diagram/@childNodes.10 /0/@diagram/@childNodes.11"/> - <extensionNodes - xsi:type="papyrusgmfgenextension:SpecificLocator" comment="Specific locator for the itemBorder of the lifeline." classpath="org.eclipse.papyrus.uml.diagram.sequence.locator.CenterLocator" - genChildSideAffixedNode="/0/@diagram/@childNodes.12 /0/@diagram/@childNodes.8"/> + genChildSideAffixedNode="/0/@diagram/@childNodes.9 /0/@diagram/@childNodes.8 /0/@diagram/@childNodes.13 /0/@diagram/@childNodes.14"/> <extensionNodes xsi:type="papyrusgmfgenextension:ExtendedGenView" comment="this is an extension to manage the comment" - genView="/0/@diagram/@childNodes.14" + genView="/0/@diagram/@childNodes.11" name="comment extended node" superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.AbstractCommentEditPart"/> <extensionNodes xsi:type="papyrusgmfgenextension:ExtendedGenView" comment="ConstraintEditPart extension" - genView="/0/@diagram/@childNodes.13" + genView="/0/@diagram/@childNodes.10" name="ConstraintEditPart extension" superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.AbstractConstraintEditPart"/> <extensionNodes xsi:type="papyrusgmfgenextension:EditPartUsingDeleteService" comment="" - genView="/0/@diagram/@childNodes.5 /0/@diagram/@childNodes.7 /0/@diagram/@childNodes.6 /0/@diagram/@links.0 /0/@diagram/@links.1 /0/@diagram/@links.2 /0/@diagram/@links.3 /0/@diagram/@links.4 /0/@diagram/@links.5 /0/@diagram/@links.6 /0/@diagram/@childNodes.1 /0/@diagram/@childNodes.2 /0/@diagram/@childNodes.12 /0/@diagram/@topLevelNodes.0 /0/@diagram/@childNodes.0"/> + genView="/0/@diagram/@childNodes.5 /0/@diagram/@childNodes.7 /0/@diagram/@childNodes.6 /0/@diagram/@links.0 /0/@diagram/@links.1 /0/@diagram/@links.2 /0/@diagram/@links.3 /0/@diagram/@links.4 /0/@diagram/@links.5 /0/@diagram/@links.6 /0/@diagram/@childNodes.1 /0/@diagram/@childNodes.2 /0/@diagram/@childNodes.9 /0/@diagram/@topLevelNodes.0 /0/@diagram/@childNodes.0"/> <extensionNodes xsi:type="papyrusgmfgenextension:ExtendedGenView" comment="Add custom super class for Message EditParts" @@ -2594,7 +2446,6 @@ <extensionNodes xsi:type="papyrusgmfgenextension:ExtendedGenView" comment="Add extension of PapyrusLabelEditPart" - genView="/0/@diagram/@childNodes.11/@labels.0 /0/@diagram/@childNodes.9/@labels.0 /0/@diagram/@childNodes.10/@labels.0" name="PapyrusLabelEditPart" superOwnedEditPart="org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart"/> <extensionNodes @@ -2607,16 +2458,16 @@ xsi:type="papyrusgmfgenextension:SpecificLocatorExternalLabel" comment="specific locator to move Gate name" classpath="org.eclipse.papyrus.uml.diagram.common.locator.ExternalLabelPositionLocator" - genExternalNodeLabel="/0/@diagram/@childNodes.17/@labels.0"/> + genExternalNodeLabel="/0/@diagram/@childNodes.12/@labels.0"/> <extensionNodes xsi:type="papyrusgmfgenextension:SpecificLocator" comment="specific locator to move gates" classpath="org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator" - genChildSideAffixedNode="/0/@diagram/@childNodes.17"/> + genChildSideAffixedNode="/0/@diagram/@childNodes.12"/> <extensionNodes xsi:type="papyrusgmfgenextension:ExtendedGenView" comment="add superclass for floating Label" - genView="/0/@diagram/@childNodes.17/@labels.0" + genView="/0/@diagram/@childNodes.12/@labels.0" name="FloatingLabelEditPart" superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.FloatingLabelEditPart"/> <extensionNodes @@ -2624,20 +2475,37 @@ comment="Name" role="Name" iconPathRole="platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/label_role/name.png" - linkLabels="/0/@diagram/@links.0/@labels.0 /0/@diagram/@links.1/@labels.0 /0/@diagram/@links.2/@labels.0 /0/@diagram/@links.3/@labels.0 /0/@diagram/@links.4/@labels.0 /0/@diagram/@links.5/@labels.0 /0/@diagram/@links.6/@labels.0" - externalNodeLabels="/0/@diagram/@childNodes.17/@labels.0"/> + linkLabels="/0/@diagram/@links.0/@labels.0 /0/@diagram/@links.1/@labels.0 /0/@diagram/@links.2/@labels.0 /0/@diagram/@links.3/@labels.0 /0/@diagram/@links.4/@labels.0 /0/@diagram/@links.5/@labels.0 /0/@diagram/@links.6/@labels.0 /0/@diagram/@links.11/@labels.0 /0/@diagram/@links.12/@labels.0" + externalNodeLabels="/0/@diagram/@childNodes.12/@labels.0"/> <extensionNodes xsi:type="papyrusgmfgenextension:LabelVisibilityPreference" comment="Stereotype" role="Stereotype" iconPathRole="platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Stereotype.gif" - linkLabels="/0/@diagram/@links.0/@labels.1 /0/@diagram/@links.1/@labels.1 /0/@diagram/@links.2/@labels.1 /0/@diagram/@links.3/@labels.1 /0/@diagram/@links.4/@labels.1 /0/@diagram/@links.5/@labels.1 /0/@diagram/@links.6/@labels.1 /0/@diagram/@links.9/@labels.0 /0/@diagram/@links.10/@labels.0"/> + linkLabels="/0/@diagram/@links.0/@labels.1 /0/@diagram/@links.1/@labels.1 /0/@diagram/@links.2/@labels.1 /0/@diagram/@links.3/@labels.1 /0/@diagram/@links.4/@labels.1 /0/@diagram/@links.5/@labels.1 /0/@diagram/@links.6/@labels.1 /0/@diagram/@links.9/@labels.0 /0/@diagram/@links.10/@labels.0 /0/@diagram/@links.11/@labels.1 /0/@diagram/@links.12/@labels.1"/> <extensionNodes xsi:type="papyrusgmfgenextension:ExtendedGenView" comment="precise the super class of the GateEditPart" - genView="/0/@diagram/@childNodes.17" + genView="/0/@diagram/@childNodes.12" name="GateEditPart superclass" superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.RoundedBorderNamedElementEditPart"/> + <extensionNodes + xsi:type="papyrusgmfgenextension:ExtendedGenView" + genView="/0/@diagram/@links.11 /0/@diagram/@links.12" + name="Duration Links superclass" + superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart"/> + <extensionNodes + xsi:type="papyrusgmfgenextension:ExtendedGenView" + comment="precise the super class of the TimeConstraintEditPart" + genView="/0/@diagram/@childNodes.13" + name="TimeConstraint Super EditPart" + superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.BorderNodeEditPart"/> + <extensionNodes + xsi:type="papyrusgmfgenextension:ExtendedGenView" + comment="Customization of the edit-part implementation for TimeObservations" + genView="/0/@diagram/@childNodes.14" + name="TimeObservation" + superOwnedEditPart="org.eclipse.papyrus.uml.diagram.common.editparts.BorderNodeEditPart"/> </papyrusgmfgenextension:PapyrusExtensionRootNode> <papyrusgmfgenextension:VisualIDOverride genView="/0/@diagram" @@ -2661,36 +2529,6 @@ </child> <child genView="/0/@diagram/@childNodes.9" - visualID="TimeConstraint_Shape"> - <child - genView="/0/@diagram/@childNodes.9/@labels.0" - visualID="TimeConstraint_ConstraintLabel"/> - <child - genView="/0/@diagram/@childNodes.9/@labels.1" - visualID="TimeConstraint_StereotypeLabel"/> - </child> - <child - genView="/0/@diagram/@childNodes.10" - visualID="TimeObservation_Shape"> - <child - genView="/0/@diagram/@childNodes.10/@labels.0" - visualID="TimeObservation_NameLabel"/> - <child - genView="/0/@diagram/@childNodes.10/@labels.1" - visualID="TimeObservation_StereotypeLabel"/> - </child> - <child - genView="/0/@diagram/@childNodes.11" - visualID="DurationConstraint_Shape"> - <child - genView="/0/@diagram/@childNodes.11/@labels.0" - visualID="DurationConstraint_BodyLabel"/> - <child - genView="/0/@diagram/@childNodes.11/@labels.1" - visualID="DurationConstraint_StereotypeLabel"/> - </child> - <child - genView="/0/@diagram/@childNodes.12" visualID="DestructionOccurrenceSpecification_Shape"/> <child genView="/0/@diagram/@childNodes.0" @@ -2727,43 +2565,23 @@ <child visualID="CombinedFragment_CoRegionShape"/> <child - genView="/0/@diagram/@childNodes.13" + genView="/0/@diagram/@childNodes.10" visualID="Constraint_Shape"> <child - genView="/0/@diagram/@childNodes.13/@labels.0" + genView="/0/@diagram/@childNodes.10/@labels.0" visualID="Constraint_NameLabel"/> <child - genView="/0/@diagram/@childNodes.13/@labels.1" + genView="/0/@diagram/@childNodes.10/@labels.1" visualID="Constraint_BodyLabel"/> </child> <child - genView="/0/@diagram/@childNodes.14" + genView="/0/@diagram/@childNodes.11" visualID="Comment_Shape"> <child - genView="/0/@diagram/@childNodes.14/@labels.0" + genView="/0/@diagram/@childNodes.11/@labels.0" visualID="Comment_BodyLabel"/> </child> <child - genView="/0/@diagram/@childNodes.15" - visualID="DurationConstraint_Shape_CN"> - <child - genView="/0/@diagram/@childNodes.15/@labels.0" - visualID="DurationConstraint_BodyLabel_CN"/> - <child - genView="/0/@diagram/@childNodes.15/@labels.1" - visualID="DurationConstraint_StereotypeLabel_CN"/> - </child> - <child - genView="/0/@diagram/@childNodes.16" - visualID="DurationObservation_Shape"> - <child - genView="/0/@diagram/@childNodes.16/@labels.0" - visualID="DurationObservation_NameLabel"/> - <child - genView="/0/@diagram/@childNodes.16/@labels.1" - visualID="DurationObservation_StereotypeLabel"/> - </child> - <child genView="/0/@diagram/@compartments.0" visualID="Interaction_SubfragmentCompartment"/> <child @@ -2867,11 +2685,51 @@ visualID="Constraint_KeywordLabel"/> </child> <child - genView="/0/@diagram/@childNodes.17" + genView="/0/@diagram/@childNodes.12" visualID="Gate_Shape"> <child - genView="/0/@diagram/@childNodes.17/@labels.0" + genView="/0/@diagram/@childNodes.12/@labels.0" visualID="Gate_NameLabel"/> </child> + <child + genView="/0/@diagram/@links.11" + visualID="DurationConstraint_Edge"> + <child + genView="/0/@diagram/@links.11/@labels.0" + visualID="DurationConstraint_NameLabel"/> + <child + genView="/0/@diagram/@links.11/@labels.1" + visualID="DurationConstraint_StereotypeLabel"/> + </child> + <child + genView="/0/@diagram/@links.12" + visualID="DurationObservation_Edge"> + <child + genView="/0/@diagram/@links.12/@labels.0" + visualID="DurationObservation_NameLabel"/> + <child + genView="/0/@diagram/@links.12/@labels.1" + visualID="DurationObservation_StereotypeLabel"/> + </child> + <child + genView="/0/@diagram/@childNodes.13" + visualID="TimeConstraint_Shape"> + <child + genView="/0/@diagram/@childNodes.13/@labels.0" + visualID="TimeConstraint_NameLabel"/> + <child + genView="/0/@diagram/@childNodes.13/@labels.1" + visualID="TimeConstraint_StereotypeLabel"/> + </child> + <child + genView="/0/@diagram/@childNodes.14" + visualID="TimeObservation_Shape"> + <child + genView="/0/@diagram/@childNodes.14/@labels.0" + visualID="TimeObservation_NameLabel"/> + <child + genView="/0/@diagram/@childNodes.14/@labels.1" + visualID="TimeObservation_StereotypeLabel"/> + </child> </papyrusgmfgenextension:VisualIDOverride> </xmi:XMI> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml index b77bce0dd9b..106d802d64a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml @@ -135,8 +135,8 @@ <viewProvider class="org.eclipse.papyrus.uml.diagram.sequence.providers.UMLViewProvider"> <Priority name="Lowest"/> <context viewClass="org.eclipse.gmf.runtime.notation.Diagram" semanticHints="PapyrusUMLSequenceDiagram"/> - <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="Interaction_Shape,ConsiderIgnoreFragment_Shape,CombinedFragment_Shape,InteractionOperand_Shape,InteractionUse_Shape,Continuation_Shape,Lifeline_Shape,ActionExecutionSpecification_Shape,BehaviorExecutionSpecification_Shape,StateInvariant_Shape,TimeConstraint_Shape,TimeObservation_Shape,DurationConstraint_Shape,DestructionOccurrenceSpecification_Shape,Constraint_Shape,Comment_Shape,DurationConstraint_Shape_CN,DurationObservation_Shape,Gate_Shape"/> - <context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="Message_SynchEdge,Message_AsynchEdge,Message_ReplyEdge,Message_CreateEdge,Message_DeleteEdge,Message_LostEdge,Message_FoundEdge,Comment_AnnotatedElementEdge,Constraint_ConstrainedElementEdge,GeneralOrdering_Edge,Constraint_ContextEdge"/> + <context viewClass="org.eclipse.gmf.runtime.notation.Node" semanticHints="Interaction_Shape,ConsiderIgnoreFragment_Shape,CombinedFragment_Shape,InteractionOperand_Shape,InteractionUse_Shape,Continuation_Shape,Lifeline_Shape,ActionExecutionSpecification_Shape,BehaviorExecutionSpecification_Shape,StateInvariant_Shape,DestructionOccurrenceSpecification_Shape,Constraint_Shape,Comment_Shape,Gate_Shape,TimeConstraint_Shape,TimeObservation_Shape"/> + <context viewClass="org.eclipse.gmf.runtime.notation.Edge" semanticHints="Message_SynchEdge,Message_AsynchEdge,Message_ReplyEdge,Message_CreateEdge,Message_DeleteEdge,Message_LostEdge,Message_FoundEdge,Comment_AnnotatedElementEdge,Constraint_ConstrainedElementEdge,GeneralOrdering_Edge,Constraint_ContextEdge,DurationConstraint_Edge,DurationObservation_Edge"/> </viewProvider> </extension> @@ -148,13 +148,13 @@ <method name="getType()" value="PapyrusUMLSequenceDiagram"/> </object> <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-nodes"> - <method name="getType()" value="Interaction_Shape,ConsiderIgnoreFragment_Shape,CombinedFragment_Shape,InteractionOperand_Shape,InteractionUse_Shape,Continuation_Shape,Lifeline_Shape,ActionExecutionSpecification_Shape,BehaviorExecutionSpecification_Shape,StateInvariant_Shape,TimeConstraint_Shape,TimeObservation_Shape,DurationConstraint_Shape,DestructionOccurrenceSpecification_Shape,Constraint_Shape,Comment_Shape,DurationConstraint_Shape_CN,DurationObservation_Shape,Gate_Shape"/> + <method name="getType()" value="Interaction_Shape,ConsiderIgnoreFragment_Shape,CombinedFragment_Shape,InteractionOperand_Shape,InteractionUse_Shape,Continuation_Shape,Lifeline_Shape,ActionExecutionSpecification_Shape,BehaviorExecutionSpecification_Shape,StateInvariant_Shape,DestructionOccurrenceSpecification_Shape,Constraint_Shape,Comment_Shape,Gate_Shape,TimeConstraint_Shape,TimeObservation_Shape"/> </object> <object class="org.eclipse.gmf.runtime.notation.Edge" id="generated-links"> - <method name="getType()" value="Message_SynchEdge,Message_AsynchEdge,Message_ReplyEdge,Message_CreateEdge,Message_DeleteEdge,Message_LostEdge,Message_FoundEdge,Comment_AnnotatedElementEdge,Constraint_ConstrainedElementEdge,GeneralOrdering_Edge,Constraint_ContextEdge"/> + <method name="getType()" value="Message_SynchEdge,Message_AsynchEdge,Message_ReplyEdge,Message_CreateEdge,Message_DeleteEdge,Message_LostEdge,Message_FoundEdge,Comment_AnnotatedElementEdge,Constraint_ConstrainedElementEdge,GeneralOrdering_Edge,Constraint_ContextEdge,DurationConstraint_Edge,DurationObservation_Edge"/> </object> <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-labels"> - <method name="getType()" value="Interaction_NameLabel,InteractionUse_NameLabel,InteractionUse_TypeLabel,Continuation_NameLabel,Lifeline_NameLabel,StateInvariant_NameLabel,StateInvariant_ConstraintLabel,TimeConstraint_ConstraintLabel,TimeConstraint_StereotypeLabel,TimeObservation_NameLabel,TimeObservation_StereotypeLabel,DurationConstraint_BodyLabel,DurationConstraint_StereotypeLabel,Constraint_NameLabel,Constraint_BodyLabel,Comment_BodyLabel,DurationConstraint_BodyLabel_CN,DurationConstraint_StereotypeLabel_CN,DurationObservation_NameLabel,DurationObservation_StereotypeLabel,Gate_NameLabel"/> + <method name="getType()" value="Interaction_NameLabel,InteractionUse_NameLabel,InteractionUse_TypeLabel,Continuation_NameLabel,Lifeline_NameLabel,StateInvariant_NameLabel,StateInvariant_ConstraintLabel,Constraint_NameLabel,Constraint_BodyLabel,Comment_BodyLabel,Gate_NameLabel,TimeConstraint_NameLabel,TimeConstraint_StereotypeLabel,TimeObservation_NameLabel,TimeObservation_StereotypeLabel"/> </object> <object class="org.eclipse.gmf.runtime.notation.Node" id="generated-compartments"> <method name="getType()" value="Interaction_SubfragmentCompartment,CombinedFragment_SubfragmentCompartment"/> @@ -349,6 +349,12 @@ </Priority> </editpolicyProvider> <editpolicyProvider + class="org.eclipse.papyrus.uml.diagram.sequence.providers.CustomDestructionOccurrenceSpecificationEditPolicyProvider"> + <Priority + name="Highest"> + </Priority> + </editpolicyProvider> + <editpolicyProvider class="org.eclipse.papyrus.uml.diagram.sequence.providers.CustomExecutionSpecificationEditPolicyProvider"> <Priority name="Highest"> @@ -378,6 +384,18 @@ name="Highest"> </Priority> </editpolicyProvider> + <editpolicyProvider + class="org.eclipse.papyrus.uml.diagram.sequence.providers.CustomLifelineEditPolicyProvider"> + <Priority + name="Highest"> + </Priority> + </editpolicyProvider> + <editpolicyProvider + class="org.eclipse.papyrus.uml.diagram.sequence.providers.SemanticOccurrenceEditPolicyProvider"> + <Priority + name="Medium"> + </Priority> + </editpolicyProvider> </extension> <extension point="org.eclipse.gmf.runtime.diagram.ui.editpartProviders"> <editpartProvider class="org.eclipse.papyrus.uml.diagram.sequence.providers.CustomEditPartProvider"> @@ -480,10 +498,6 @@ <menuContribution locationURI="popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu"> <dynamic - class="org.eclipse.papyrus.uml.diagram.sequence.providers.DurationConstraintContributionItem" - id="org.eclipse.papyrus.sequence.duraitonconstraint.DynamicMenu"> - </dynamic> - <dynamic class="org.eclipse.papyrus.uml.diagram.sequence.providers.DisplayBehaviorContributionItem" id="org.eclipse.papyrus.uml.diagram.sequence.displayBehaviorMenu"> </dynamic> @@ -567,6 +581,22 @@ type="Constraint_KeywordLabel"> </mapping> <mapping + humanReadableType="Name" + type="DurationConstraint_NameLabel"> + </mapping> + <mapping + humanReadableType="Stereotype" + type="DurationConstraint_StereotypeLabel"> + </mapping> + <mapping + humanReadableType="Name" + type="DurationObservation_NameLabel"> + </mapping> + <mapping + humanReadableType="Stereotype" + type="DurationObservation_StereotypeLabel"> + </mapping> + <mapping humanReadableType="Floating Label" type="Gate_NameLabel"> </mapping> diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java index 79b3c33d2de..e278566d12e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java @@ -25,16 +25,21 @@ import org.eclipse.gef.editpolicies.LayoutEditPolicy; import org.eclipse.gef.editpolicies.NonResizableEditPolicy; import org.eclipse.gef.editpolicies.ResizableEditPolicy; import org.eclipse.gef.requests.CreateRequest; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWithMessageEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationComponentEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationGraphicalNodeEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.swt.graphics.Color; /** @@ -69,13 +74,18 @@ public class ActionExecutionSpecificationEditPart extends AbstractExecutionSpeci */ @Override protected void createDefaultEditPolicies() { + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); + // in Papyrus diagrams are not strongly synchronised + // installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ActionExecutionSpecificationCanonicalEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ElementCreationWithMessageEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ExecutionSpecificationGraphicalNodeEditPolicy()); installEditPolicy(EditPolicy.COMPONENT_ROLE, new ExecutionSpecificationComponentEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -100,6 +110,15 @@ public class ActionExecutionSpecificationEditPart extends AbstractExecutionSpeci @Override protected EditPolicy createChildEditPolicy(EditPart child) { + View childView = (View) child.getModel(); + String vid = UMLVisualIDRegistry.getVisualID(childView); + if (vid != null) { + switch (vid) { + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return new BorderItemResizableEditPolicy(); + } + } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); if (result == null) { result = new NonResizableEditPolicy(); @@ -170,7 +189,7 @@ public class ActionExecutionSpecificationEditPart extends AbstractExecutionSpeci * @generated */ @Override - protected NodeFigure createNodeFigure() { + protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); } @@ -185,6 +204,11 @@ public class ActionExecutionSpecificationEditPart extends AbstractExecutionSpeci */ @Override protected IFigure setupContentPane(IFigure nodeShape) { + if (nodeShape.getLayoutManager() == null) { + ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); + layout.setSpacing(5); + nodeShape.setLayoutManager(layout); + } return nodeShape; // use nodeShape itself as contentPane } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java index c2fa42a02f4..f7e8a4c6f4f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java @@ -25,16 +25,21 @@ import org.eclipse.gef.editpolicies.LayoutEditPolicy; import org.eclipse.gef.editpolicies.NonResizableEditPolicy; import org.eclipse.gef.editpolicies.ResizableEditPolicy; import org.eclipse.gef.requests.CreateRequest; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWithMessageEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationComponentEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ExecutionSpecificationGraphicalNodeEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.swt.graphics.Color; /** @@ -69,13 +74,18 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe */ @Override protected void createDefaultEditPolicies() { + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); + // in Papyrus diagrams are not strongly synchronised + // installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.sequence.edit.policies.BehaviorExecutionSpecificationCanonicalEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ElementCreationWithMessageEditPolicy()); + installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ExecutionSpecificationGraphicalNodeEditPolicy()); installEditPolicy(EditPolicy.COMPONENT_ROLE, new ExecutionSpecificationComponentEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -89,6 +99,15 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe @Override protected EditPolicy createChildEditPolicy(EditPart child) { + View childView = (View) child.getModel(); + String vid = UMLVisualIDRegistry.getVisualID(childView); + if (vid != null) { + switch (vid) { + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return new BorderItemResizableEditPolicy(); + } + } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); if (result == null) { result = new NonResizableEditPolicy(); @@ -169,7 +188,7 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe * @generated */ @Override - protected NodeFigure createNodeFigure() { + protected NodeFigure createMainFigure() { return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); } @@ -184,6 +203,11 @@ public class BehaviorExecutionSpecificationEditPart extends AbstractExecutionSpe */ @Override protected IFigure setupContentPane(IFigure nodeShape) { + if (nodeShape.getLayoutManager() == null) { + ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); + layout.setSpacing(5); + nodeShape.setLayoutManager(layout); + } return nodeShape; // use nodeShape itself as contentPane } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContextLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContextLinkEditPart.java index 60910738d20..a9aaefd455e 100755..100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContextLinkEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContextLinkEditPart.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 CEA LIST. + * Copyright (c) 2016, 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * CEA LIST - Initial API and implementation + * Christian W. Damus - bug 536486 */ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DestructionOccurrenceSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DestructionOccurrenceSpecificationEditPart.java index db5c2a72ecb..d4a43ce1ead 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DestructionOccurrenceSpecificationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DestructionOccurrenceSpecificationEditPart.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 CEA LIST. + * Copyright (c) 2016, 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * CEA LIST - Initial API and implementation + * Christian W. Damus - bug 536486 */ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; @@ -24,21 +25,26 @@ import org.eclipse.gef.editpolicies.LayoutEditPolicy; import org.eclipse.gef.editpolicies.NonResizableEditPolicy; import org.eclipse.gef.editpolicies.ResizableEditPolicy; import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderItemEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultCreationEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.DestructionEventFigure; +import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.swt.graphics.Color; /** * @generated */ -public class DestructionOccurrenceSpecificationEditPart extends AbstractBorderItemEditPart { +public class DestructionOccurrenceSpecificationEditPart extends BorderedBorderItemEditPart { /** * @generated @@ -67,12 +73,17 @@ public class DestructionOccurrenceSpecificationEditPart extends AbstractBorderIt */ @Override protected void createDefaultEditPolicies() { + installEditPolicy(EditPolicyRoles.CREATION_ROLE, new DefaultCreationEditPolicy()); super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, getPrimaryDragEditPolicy()); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); + installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new DragDropEditPolicy()); + // in Papyrus diagrams are not strongly synchronised + // installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CANONICAL_ROLE, new org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DestructionOccurrenceSpecificationCanonicalEditPolicy()); + installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); @@ -86,6 +97,15 @@ public class DestructionOccurrenceSpecificationEditPart extends AbstractBorderIt @Override protected EditPolicy createChildEditPolicy(EditPart child) { + View childView = (View) child.getModel(); + String vid = UMLVisualIDRegistry.getVisualID(childView); + if (vid != null) { + switch (vid) { + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return new BorderItemResizableEditPolicy(); + } + } EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); if (result == null) { result = new NonResizableEditPolicy(); @@ -152,7 +172,7 @@ public class DestructionOccurrenceSpecificationEditPart extends AbstractBorderIt * @generated */ @Override - protected NodeFigure createNodeFigure() { + protected NodeFigure createMainFigure() { NodeFigure figure = createNodePlate(); figure.setLayoutManager(new StackLayout()); IFigure shape = createNodeShape(); @@ -171,6 +191,11 @@ public class DestructionOccurrenceSpecificationEditPart extends AbstractBorderIt * @generated */ protected IFigure setupContentPane(IFigure nodeShape) { + if (nodeShape.getLayoutManager() == null) { + ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); + layout.setSpacing(5); + nodeShape.setLayoutManager(layout); + } return nodeShape; // use nodeShape itself as contentPane } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintEditPart.java deleted file mode 100644 index 56b0f35ba68..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintEditPart.java +++ /dev/null @@ -1,256 +0,0 @@ - -/** - * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * CEA LIST - Initial API and implementation - */ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.StackLayout; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.LayoutEditPolicy; -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; -import org.eclipse.gef.handles.MoveHandle; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator; -import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationConstraintFigure; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; -import org.eclipse.swt.graphics.Color; - -/** - * @generated - */ -public class DurationConstraintEditPart extends BorderedBorderItemEditPart { - - /** - * @generated - */ - public static final String VISUAL_ID = "DurationConstraint_Shape"; - - /** - * @generated - */ - protected IFigure contentPane; - - /** - * @generated - */ - protected IFigure primaryShape; - - /** - * @generated - */ - public DurationConstraintEditPart(View view) { - super(view); - } - - /** - * @generated - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, getPrimaryDragEditPolicy()); - installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(DeleteTimeElementWithoutEventPolicy.KEY, new DeleteTimeElementWithoutEventPolicy()); - // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies - // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); - } - - /** - * @generated - */ - protected LayoutEditPolicy createLayoutEditPolicy() { - org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { - - @Override - protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); - String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { - case DurationConstraintLabelEditPart.VISUAL_ID: - case DurationConstraintAppliedStereotypeEditPart.VISUAL_ID: - return new BorderItemSelectionEditPolicy() { - - @Override - protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); - mh.setBorder(null); - return Collections.singletonList(mh); - } - }; - } - } - EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { - result = new NonResizableEditPolicy(); - } - return result; - } - - @Override - protected Command getMoveChildrenCommand(Request request) { - return null; - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - }; - return lep; - } - - /** - * @generated - */ - protected IFigure createNodeShape() { - return primaryShape = new DurationConstraintFigure(); - } - - /** - * org.eclipse.papyrus.uml.diagram.sequence.figures.DurationConstraintFigure - * org.eclipse.papyrus.uml.diagram.sequence.figures.DurationConstraintFigure - * - * @generated - */ - public DurationConstraintFigure getPrimaryShape() { - return (DurationConstraintFigure) primaryShape; - } - - /** - * @generated - */ - @Override - protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof DurationConstraintLabelEditPart - || borderItemEditPart instanceof DurationConstraintAppliedStereotypeEditPart) { - BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); - locator.setBorderItemOffset(new Dimension(-20, -20)); - borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else { - super.addBorderItem(borderItemContainer, borderItemEditPart); - } - } - - /** - * @generated - */ - protected NodeFigure createNodePlate() { - RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(40, 40); - return result; - } - - /** - * Creates figure for this edit part. - * - * Body of this method does not depend on settings in generation model - * so you may safely remove <i>generated</i> tag and modify it. - * - * @generated - */ - @Override - protected NodeFigure createMainFigure() { - NodeFigure figure = createNodePlate(); - figure.setLayoutManager(new StackLayout()); - IFigure shape = createNodeShape(); - figure.add(shape); - contentPane = setupContentPane(shape); - return figure; - - } - - /** - * Default implementation treats passed figure as content pane. - * Respects layout one may have set for generated figure. - * - * @param nodeShape - * instance of generated figure class - * @generated - */ - protected IFigure setupContentPane(IFigure nodeShape) { - return nodeShape; // use nodeShape itself as contentPane - } - - /** - * @generated - */ - @Override - public IFigure getContentPane() { - if (contentPane != null) { - return contentPane; - } - return super.getContentPane(); - } - - /** - * @generated - */ - @Override - protected void setForegroundColor(Color color) { - if (primaryShape != null) { - primaryShape.setForegroundColor(color); - } - } - - /** - * @generated - */ - @Override - protected void setLineWidth(int width) { - super.setLineWidth(width); - } - - /** - * @generated - */ - @Override - protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); - } - } - - /** - * @generated - */ - @Override - public EditPart getPrimaryChildEditPart() { - return getChildBySemanticHint(UMLVisualIDRegistry.getType(DurationConstraintLabelEditPart.VISUAL_ID)); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageAppliedStereotypeEditPart.java deleted file mode 100644 index d397b27deb5..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageAppliedStereotypeEditPart.java +++ /dev/null @@ -1,856 +0,0 @@ - -/** - * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * CEA LIST - Initial API and implementation - */ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.RunnableWithResult; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.AccessibleEditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; -import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; -import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; -import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; -import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; -import org.eclipse.gmf.runtime.notation.FontStyle; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.extensionpoints.editors.Activator; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; -import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; -import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; -import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; -import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; -import org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeWrappingLabelFigure; -import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; -import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; -import org.eclipse.uml2.uml.Feature; - -/** - * @generated - */ -public class DurationConstraintInMessageAppliedStereotypeEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { - - /** - * @generated - */ - public static final String VISUAL_ID = "DurationConstraint_StereotypeLabel_CN"; - - /** - * @generated - */ - private DirectEditManager manager; - - /** - * @generated - */ - private IParser parser; - - /** - * @generated - */ - private List<?> parserElements; - - /** - * @generated - */ - private String defaultText; - - /** - * direct edition mode (default, undefined, registered editor, etc.) - * - * @generated - */ - protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; - - /** - * configuration from a registered edit dialog - * - * @generated - */ - protected IDirectEditorConfiguration configuration; - - /** - * @generated - */ - static { - registerSnapBackPosition(UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); - } - - /** - * @generated - */ - public DurationConstraintInMessageAppliedStereotypeEditPart(View view) { - super(view); - } - - /** - * @generated - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); - } - - /** - * @generated - */ - @Override - public IBorderItemLocator getBorderItemLocator() { - IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { - Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; - } - return null; - } - - /** - * @generated - */ - @Override - public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); - getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); - } - - /** - * @generated - */ - protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); - } else { - return ((Label) figure).getText(); - } - } - - /** - * @generated - */ - protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); - } else { - ((Label) figure).setText(text); - } - } - - /** - * @generated - */ - protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); - } else { - return ((Label) figure).getIcon(); - } - } - - /** - * @generated - */ - protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); - } else { - ((Label) figure).setIcon(icon); - } - } - - /** - * @generated - */ - public void setLabel(IFigure figure) { - unregisterVisuals(); - setFigure(figure); - defaultText = getLabelTextHelper(figure); - registerVisuals(); - refreshVisuals(); - } - - /** - * @generated - */ - @Override - protected List<?> getModelChildren() { - return Collections.EMPTY_LIST; - } - - /** - * @generated - */ - @Override - public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { - return null; - } - - /** - * @generated - */ - public void setParser(IParser parser) { - this.parser = parser; - } - - /** - * @generated - */ - protected EObject getParserElement() { - return resolveSemanticElement(); - } - - /** - * @generated - */ - protected Image getLabelIcon() { - return DiagramEditPartsUtil.getIcon(getParserElement(), getViewer()); - } - - /** - * @generated - */ - protected String getLabelText() { - String text = null; - EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); - } - if (text == null || text.length() == 0) { - text = defaultText; - } - return text; - } - - /** - * @generated - */ - @Override - public void setLabelText(String text) { - setLabelTextHelper(getFigure(), text); - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - /** - * @generated - */ - @Override - public String getEditText() { - if (getParserElement() == null || getParser() == null) { - return ""; //$NON-NLS-1$ - } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); - } - - /** - * @generated - */ - protected boolean isEditable() { - return false; - } - - /** - * @generated - */ - @Override - public ICellEditorValidator getEditTextValidator() { - return new ICellEditorValidator() { - - @Override - public String isValid(final Object value) { - if (value instanceof String) { - final EObject element = getParserElement(); - final IParser parser = getParser(); - try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - DurationConstraintInMessageAppliedStereotypeEditPart.this), - (String) value)); - } - }); - return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - } - - // shouldn't get here - return null; - } - }; - } - - /** - * @generated - */ - @Override - public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { - return null; - } - return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); - } - - /** - * @generated - */ - @Override - public ParserOptions getParserOptions() { - return ParserOptions.NONE; - } - - /** - * @generated - */ - @Override - public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.DurationConstraint_Shape_CN, getParserElement(), this, - VISUAL_ID); - } - return parser; - } - - /** - * @generated - */ - protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); - } - return manager; - } - - /** - * @generated - */ - protected void setManager(DirectEditManager manager) { - this.manager = manager; - } - - /** - * @generated - */ - protected void performDirectEdit() { - BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() { - - @Override - public void run() { - getManager().show(); - } - }); - } - - /** - * @generated - */ - protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); - } - } - - /** - * @generated - */ - protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); - } else { - performDirectEdit(); - } - } - - /** - * @generated - */ - @Override - protected void performDirectEditRequest(Request request) { - - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { - directEditionMode = getDirectEditionType(); - } - switch (directEditionMode) { - case IDirectEdition.NO_DIRECT_EDITION: - // no direct edition mode => does nothing - return; - case IDirectEdition.EXTENDED_DIRECT_EDITOR: - updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { - // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); - performDefaultDirectEditorEdit(theRequest); - } else { - configuration.preEditAction(resolveSemanticElement()); - Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); - initializeDirectEditManager(theRequest); - return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); - helper.showEditor(); - return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); - } else { - return; - } - final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { - TransactionalEditingDomain domain = getEditingDomain(); - RecordingCommand command = new RecordingCommand(domain, "Edit Label") { - - @Override - protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - - } - }; - domain.getCommandStack().execute(command); - } - } - break; - case IDirectEdition.DEFAULT_DIRECT_EDITOR: - initializeDirectEditManager(theRequest); - break; - default: - break; - } - } - - /** - * @generated - */ - protected void initializeDirectEditManager(final Request request) { - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - @Override - public void run() { - if (isActive() && isEditable()) { - if (request.getExtendedData() - .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character) request.getExtendedData() - .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); - performDirectEdit(initialChar.charValue()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * @generated - */ - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshLabel(); - refreshFont(); - refreshFontColor(); - refreshUnderline(); - refreshStrikeThrough(); - } - - /** - * @generated - */ - protected void refreshLabel() { - EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { - maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); - } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { - setLabelTextHelper(getFigure(), getLabelText()); - setLabelIconHelper(getFigure(), getLabelIcon()); - } else { - setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$ - setLabelIconHelper(getFigure(), null); - } - } - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - /** - * @generated - */ - protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); - } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); - } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); - } - } - } - - /** - * @generated - */ - protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); - } - } - - /** - * @generated - */ - @Override - protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); - setFont(fontData); - } - } - - /** - * @generated - */ - @Override - protected void setFontColor(Color color) { - getFigure().setForegroundColor(color); - } - - /** - * @generated - */ - @Override - protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { - EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ - } - } else { - super.addSemanticListeners(); - } - } - - /** - * @generated - */ - @Override - protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { - removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ - } - } else { - super.removeSemanticListeners(); - } - } - - /** - * @generated - */ - @Override - protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { - accessibleEP = new AccessibleGraphicalEditPart() { - - @Override - public void getName(AccessibleEvent e) { - e.result = getLabelTextHelper(getFigure()); - } - }; - } - return accessibleEP; - } - - /** - * @generated - */ - private View getFontStyleOwnerView() { - return getPrimaryView(); - } - - /** - * Returns the kind of associated editor for direct edition. - * - * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition - * @generated - */ - public int getDirectEditionType() { - // The label is read-only (defined in GMFGen model) - return IDirectEdition.NO_DIRECT_EDITION; - } - - /** - * Checks if an extended editor is present. - * - * @return <code>true</code> if an extended editor is present. - * @generated - */ - protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { - return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); - } - return false; - } - - /** - * Checks if a default direct edition is available - * - * @return <code>true</code> if a default direct edition is available - * @generated - */ - protected boolean checkDefaultEdition() { - return (getParser() != null); - } - - /** - * Initializes the extended editor configuration - * - * @generated - */ - protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); - } - } - } - - /** - * Updates the preference configuration - * - * @generated - */ - protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { - configuration = null; - } - } - - /** - * Performs the direct edit usually used by GMF editors. - * - * @param theRequest - * the direct edit request that starts the direct edit system - * @generated - */ - protected void performDefaultDirectEditorEdit(final Request theRequest) { - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @Override - public void run() { - if (isActive() && isEditable()) { - if (theRequest.getExtendedData() - .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character) theRequest.getExtendedData() - .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) - && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * @generated - */ - @Override - protected void handleNotificationEvent(Notification event) { - Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); - setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { - refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { - refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { - refreshFont(); - } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { - refreshLabel(); - } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { - removeSemanticListeners(); - if (resolveSemanticElement() != null) { - addSemanticListeners(); - } - refreshLabel(); - } - } - } - super.handleNotificationEvent(event); - } - - /** - * @generated - */ - @Override - protected IFigure createFigure() { - IFigure label = createFigurePrim(); - defaultText = getLabelTextHelper(label); - return label; - } - - /** - * @generated - */ - protected IFigure createFigurePrim() { - return new AppliedStereotypeWrappingLabelFigure(); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageEditPart.java deleted file mode 100644 index a80f94c1fd9..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageEditPart.java +++ /dev/null @@ -1,317 +0,0 @@ - -/** - * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * CEA LIST - Initial API and implementation - */ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.LayoutEditPolicy; -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; -import org.eclipse.gef.handles.MoveHandle; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator; -import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; -import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure; -import org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MoveableNonResizableLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; -import org.eclipse.swt.graphics.Color; - -/** - * @generated - */ -public class DurationConstraintInMessageEditPart extends NodeEditPart { - - /** - * @generated - */ - public static final String VISUAL_ID = "DurationConstraint_Shape_CN"; - - /** - * @generated - */ - protected IFigure contentPane; - - /** - * @generated - */ - protected IFigure primaryShape; - - /** - * @generated - */ - public DurationConstraintInMessageEditPart(View view) { - super(view); - } - - /** - * @generated - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new MoveableNonResizableLabelEditPolicy()); - installEditPolicy(DeleteTimeElementWithoutEventPolicy.KEY, new DeleteTimeElementWithoutEventPolicy()); - // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies - // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); - } - - /** - * @generated - */ - protected LayoutEditPolicy createLayoutEditPolicy() { - org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { - - @Override - protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); - String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { - case DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID: - return new BorderItemSelectionEditPolicy() { - - @Override - protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); - mh.setBorder(null); - return Collections.singletonList(mh); - } - }; - } - } - EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { - result = new NonResizableEditPolicy(); - } - return result; - } - - @Override - protected Command getMoveChildrenCommand(Request request) { - return null; - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - }; - return lep; - } - - /** - * @generated - */ - @Override - protected IFigure createNodeShape() { - return primaryShape = new RoundedCompartmentFigure(); - } - - /** - * org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure - * - * @generated - */ - @Override - public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; - } - - /** - * @generated - */ - protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof DurationConstraintInMessageLabelEditPart) { - ((DurationConstraintInMessageLabelEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); - return true; - } - - return false; - } - - /** - * @generated - */ - protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof DurationConstraintInMessageLabelEditPart) { - return true; - } - return false; - } - - /** - * @generated - */ - @Override - protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { - return; - } - super.addChildVisual(childEditPart, -1); - } - - /** - * @generated - */ - @Override - protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { - return; - } - super.removeChildVisual(childEditPart); - } - - /** - * @generated - */ - @Override - protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if (editPart instanceof IBorderItemEditPart) { - return getBorderedFigure().getBorderItemContainer(); - } - return getContentPane(); - } - - /** - * @generated - */ - @Override - protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof DurationConstraintInMessageAppliedStereotypeEditPart) { - BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); - locator.setBorderItemOffset(new Dimension(-20, -20)); - borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else { - super.addBorderItem(borderItemContainer, borderItemEditPart); - } - } - - /** - * @generated - */ - @Override - protected NodeFigure createNodePlate() { - RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(40, 40); - return result; - } - - /** - * Creates figure for this edit part. - * - * Body of this method does not depend on settings in generation model - * so you may safely remove <i>generated</i> tag and modify it. - * - * @generated - */ - @Override - protected NodeFigure createMainFigure() { - return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - - } - - /** - * Default implementation treats passed figure as content pane. - * Respects layout one may have set for generated figure. - * - * @param nodeShape - * instance of generated figure class - * @generated - */ - @Override - protected IFigure setupContentPane(IFigure nodeShape) { - if (nodeShape.getLayoutManager() == null) { - ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); - layout.setSpacing(5); - nodeShape.setLayoutManager(layout); - } - return nodeShape; // use nodeShape itself as contentPane - } - - /** - * @generated - */ - @Override - public IFigure getContentPane() { - if (contentPane != null) { - return contentPane; - } - return super.getContentPane(); - } - - /** - * @generated - */ - @Override - protected void setForegroundColor(Color color) { - if (primaryShape != null) { - primaryShape.setForegroundColor(color); - } - } - - /** - * @generated - */ - @Override - protected void setLineWidth(int width) { - super.setLineWidth(width); - } - - /** - * @generated - */ - @Override - protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); - } - } - - /** - * @generated - */ - @Override - public EditPart getPrimaryChildEditPart() { - return getChildBySemanticHint(UMLVisualIDRegistry.getType(DurationConstraintInMessageLabelEditPart.VISUAL_ID)); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLabelEditPart.java deleted file mode 100644 index 3b437f5fd15..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLabelEditPart.java +++ /dev/null @@ -1,859 +0,0 @@ - -/** - * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * CEA LIST - Initial API and implementation - */ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.Label; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.transaction.RecordingCommand; -import org.eclipse.emf.transaction.RunnableWithResult; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.AccessibleEditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.Request; -import org.eclipse.gef.requests.DirectEditRequest; -import org.eclipse.gef.tools.DirectEditManager; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; -import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; -import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; -import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; -import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; -import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; -import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel; -import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser; -import org.eclipse.gmf.runtime.notation.FontStyle; -import org.eclipse.gmf.runtime.notation.NotationPackage; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.text.contentassist.IContentAssistProcessor; -import org.eclipse.jface.viewers.ICellEditorValidator; -import org.eclipse.jface.window.Window; -import org.eclipse.papyrus.extensionpoints.editors.Activator; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IAdvancedEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.ICustomDirectEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IDirectEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.configuration.IPopupEditorConfiguration; -import org.eclipse.papyrus.extensionpoints.editors.ui.ExtendedDirectEditionDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; -import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; -import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; -import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; -import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; -import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.MultilineLabelFigure; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; -import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; -import org.eclipse.swt.SWT; -import org.eclipse.swt.accessibility.AccessibleEvent; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.FontData; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; -import org.eclipse.uml2.uml.Feature; - -/** - * @generated - */ -public class DurationConstraintLabelEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { - - /** - * @generated - */ - public static final String VISUAL_ID = "DurationConstraint_BodyLabel"; - - /** - * @generated - */ - private DirectEditManager manager; - - /** - * @generated - */ - private IParser parser; - - /** - * @generated - */ - private List<?> parserElements; - - /** - * @generated - */ - private String defaultText; - - /** - * direct edition mode (default, undefined, registered editor, etc.) - * - * @generated - */ - protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; - - /** - * configuration from a registered edit dialog - * - * @generated - */ - protected IDirectEditorConfiguration configuration; - - /** - * @generated - */ - static { - registerSnapBackPosition( - UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLabelEditPart.VISUAL_ID), - new Point(0, 0)); - } - - /** - * @generated - */ - public DurationConstraintLabelEditPart(View view) { - super(view); - } - - /** - * @generated - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); - } - - /** - * @generated - */ - @Override - public IBorderItemLocator getBorderItemLocator() { - IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { - Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; - } - return null; - } - - /** - * @generated - */ - @Override - public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); - getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); - } - - /** - * @generated - */ - protected String getLabelTextHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getText(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getText(); - } else { - return ((Label) figure).getText(); - } - } - - /** - * @generated - */ - protected void setLabelTextHelper(IFigure figure, String text) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setText(text); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setText(text); - } else { - ((Label) figure).setText(text); - } - } - - /** - * @generated - */ - protected Image getLabelIconHelper(IFigure figure) { - if (figure instanceof WrappingLabel) { - return ((WrappingLabel) figure).getIcon(); - } else if (figure instanceof ILabelFigure) { - return ((ILabelFigure) figure).getIcon(); - } else { - return ((Label) figure).getIcon(); - } - } - - /** - * @generated - */ - protected void setLabelIconHelper(IFigure figure, Image icon) { - if (figure instanceof WrappingLabel) { - ((WrappingLabel) figure).setIcon(icon); - } else if (figure instanceof ILabelFigure) { - ((ILabelFigure) figure).setIcon(icon); - } else { - ((Label) figure).setIcon(icon); - } - } - - /** - * @generated - */ - public void setLabel(IFigure figure) { - unregisterVisuals(); - setFigure(figure); - defaultText = getLabelTextHelper(figure); - registerVisuals(); - refreshVisuals(); - } - - /** - * @generated - */ - @Override - protected List<?> getModelChildren() { - return Collections.EMPTY_LIST; - } - - /** - * @generated - */ - @Override - public IGraphicalEditPart getChildBySemanticHint(String semanticHint) { - return null; - } - - /** - * @generated - */ - public void setParser(IParser parser) { - this.parser = parser; - } - - /** - * @generated - */ - protected EObject getParserElement() { - return resolveSemanticElement(); - } - - /** - * @generated - */ - protected Image getLabelIcon() { - return null; - } - - /** - * @generated - */ - protected String getLabelText() { - String text = null; - EObject parserElement = getParserElement(); - if (parserElement != null && getParser() != null) { - text = getParser().getPrintString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); - } - if (text == null || text.length() == 0) { - text = defaultText; - } - return text; - } - - /** - * @generated - */ - @Override - public void setLabelText(String text) { - setLabelTextHelper(getFigure(), text); - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - /** - * @generated - */ - @Override - public String getEditText() { - if (getParserElement() == null || getParser() == null) { - return ""; //$NON-NLS-1$ - } - return getParser().getEditString(ParserUtil.getParserAdapter(getParserElement(), this), - getParserOptions().intValue()); - } - - /** - * @generated - */ - protected boolean isEditable() { - return getParser() != null; - } - - /** - * @generated - */ - @Override - public ICellEditorValidator getEditTextValidator() { - return new ICellEditorValidator() { - - @Override - public String isValid(final Object value) { - if (value instanceof String) { - final EObject element = getParserElement(); - final IParser parser = getParser(); - try { - IParserEditStatus valid = (IParserEditStatus) getEditingDomain() - .runExclusive(new RunnableWithResult.Impl<java.lang.Object>() { - - @Override - public void run() { - setResult( - parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), - DurationConstraintLabelEditPart.this), (String) value)); - } - }); - return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); - } catch (InterruptedException ie) { - ie.printStackTrace(); - } - } - - // shouldn't get here - return null; - } - }; - } - - /** - * @generated - */ - @Override - public IContentAssistProcessor getCompletionProcessor() { - if (getParserElement() == null || getParser() == null) { - return null; - } - return getParser().getCompletionProcessor(ParserUtil.getParserAdapter(getParserElement(), this)); - } - - /** - * @generated - */ - @Override - public ParserOptions getParserOptions() { - return ParserOptions.NONE; - } - - /** - * @generated - */ - @Override - public IParser getParser() { - if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.DurationConstraint_Shape, getParserElement(), this, - VISUAL_ID); - } - return parser; - } - - /** - * @generated - */ - protected DirectEditManager getManager() { - if (manager == null) { - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); - } - return manager; - } - - /** - * @generated - */ - protected void setManager(DirectEditManager manager) { - this.manager = manager; - } - - /** - * @generated - */ - protected void performDirectEdit() { - BusyIndicator.showWhile(Display.getDefault(), new java.lang.Runnable() { - - @Override - public void run() { - getManager().show(); - } - }); - } - - /** - * @generated - */ - protected void performDirectEdit(Point eventLocation) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(eventLocation.getSWTPoint()); - } - } - - /** - * @generated - */ - protected void performDirectEdit(char initialCharacter) { - if (getManager() instanceof TextDirectEditManager) { - ((TextDirectEditManager) getManager()).show(initialCharacter); - } else { - performDirectEdit(); - } - } - - /** - * @generated - */ - @Override - protected void performDirectEditRequest(Request request) { - - final Request theRequest = request; - - if (IDirectEdition.UNDEFINED_DIRECT_EDITOR == directEditionMode) { - directEditionMode = getDirectEditionType(); - } - switch (directEditionMode) { - case IDirectEdition.NO_DIRECT_EDITION: - // no direct edition mode => does nothing - return; - case IDirectEdition.EXTENDED_DIRECT_EDITOR: - updateExtendedEditorConfiguration(); - if (configuration == null || configuration.getLanguage() == null) { - // Create default edit manager - setManager(new MultilineLabelDirectEditManager(this, - MultilineLabelDirectEditManager.getTextCellEditorClass(this), - UMLEditPartFactory.getTextCellEditorLocator(this))); - performDefaultDirectEditorEdit(theRequest); - } else { - configuration.preEditAction(resolveSemanticElement()); - Dialog dialog = null; - if (configuration instanceof ICustomDirectEditorConfiguration) { - setManager(((ICustomDirectEditorConfiguration) configuration).createDirectEditManager(this)); - initializeDirectEditManager(theRequest); - return; - } else if (configuration instanceof IPopupEditorConfiguration) { - IPopupEditorHelper helper = ((IPopupEditorConfiguration) configuration) - .createPopupEditorHelper(this); - helper.showEditor(); - return; - } else if (configuration instanceof IAdvancedEditorConfiguration) { - dialog = ((IAdvancedEditorConfiguration) configuration).createDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement())); - } else if (configuration instanceof IDirectEditorConfiguration) { - dialog = new ExtendedDirectEditionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), resolveSemanticElement(), - configuration.getTextToEdit(resolveSemanticElement()), configuration); - } else { - return; - } - final Dialog finalDialog = dialog; - - if (Window.OK == dialog.open()) { - TransactionalEditingDomain domain = getEditingDomain(); - RecordingCommand command = new RecordingCommand(domain, "Edit Label") { - - @Override - protected void doExecute() { - configuration.postEditAction(resolveSemanticElement(), - ((ILabelEditorDialog) finalDialog).getValue()); - - } - }; - domain.getCommandStack().execute(command); - } - } - break; - case IDirectEdition.DEFAULT_DIRECT_EDITOR: - initializeDirectEditManager(theRequest); - break; - default: - break; - } - } - - /** - * @generated - */ - protected void initializeDirectEditManager(final Request request) { - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - @Override - public void run() { - if (isActive() && isEditable()) { - if (request.getExtendedData() - .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character) request.getExtendedData() - .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); - performDirectEdit(initialChar.charValue()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * @generated - */ - @Override - protected void refreshVisuals() { - super.refreshVisuals(); - refreshLabel(); - refreshFont(); - refreshFontColor(); - refreshUnderline(); - refreshStrikeThrough(); - } - - /** - * @generated - */ - protected void refreshLabel() { - EditPolicy maskLabelPolicy = getEditPolicy(IMaskManagedLabelEditPolicy.MASK_MANAGED_LABEL_EDIT_POLICY); - if (maskLabelPolicy == null) { - maskLabelPolicy = getEditPolicy(IndirectMaskLabelEditPolicy.INDRIRECT_MASK_MANAGED_LABEL); - } - if (maskLabelPolicy == null) { - View view = (View) getModel(); - if (view.isVisible()) { - setLabelTextHelper(getFigure(), getLabelText()); - setLabelIconHelper(getFigure(), getLabelIcon()); - } else { - setLabelTextHelper(getFigure(), ""); //$NON-NLS-1$ - setLabelIconHelper(getFigure(), null); - } - } - Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (pdEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) pdEditPolicy).refreshFeedback(); - } - Object sfEditPolicy = getEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE); - if (sfEditPolicy instanceof UMLTextSelectionEditPolicy) { - ((UMLTextSelectionEditPolicy) sfEditPolicy).refreshFeedback(); - } - } - - /** - * @generated - */ - protected void refreshUnderline() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextUnderline(style.isUnderline()); - } - if (resolveSemanticElement() instanceof Feature) { - if (((Feature) resolveSemanticElement()).isStatic()) { - ((WrappingLabel) getFigure()).setTextUnderline(true); - } else { - ((WrappingLabel) getFigure()).setTextUnderline(false); - } - } - } - - /** - * @generated - */ - protected void refreshStrikeThrough() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null && getFigure() instanceof WrappingLabel) { - ((WrappingLabel) getFigure()).setTextStrikeThrough(style.isStrikeThrough()); - } - } - - /** - * @generated - */ - @Override - protected void refreshFont() { - FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); - if (style != null) { - FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), - (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); - setFont(fontData); - } - } - - /** - * @generated - */ - @Override - protected void setFontColor(Color color) { - getFigure().setForegroundColor(color); - } - - /** - * @generated - */ - @Override - protected void addSemanticListeners() { - if (getParser() instanceof ISemanticParser) { - EObject element = resolveSemanticElement(); - parserElements = ((ISemanticParser) getParser()).getSemanticElementsBeingParsed(element); - for (int i = 0; i < parserElements.size(); i++) { - addListenerFilter("SemanticModel" + i, this, (EObject) parserElements.get(i)); //$NON-NLS-1$ - } - } else { - super.addSemanticListeners(); - } - } - - /** - * @generated - */ - @Override - protected void removeSemanticListeners() { - if (parserElements != null) { - for (int i = 0; i < parserElements.size(); i++) { - removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$ - } - } else { - super.removeSemanticListeners(); - } - } - - /** - * @generated - */ - @Override - protected AccessibleEditPart getAccessibleEditPart() { - if (accessibleEP == null) { - accessibleEP = new AccessibleGraphicalEditPart() { - - @Override - public void getName(AccessibleEvent e) { - e.result = getLabelTextHelper(getFigure()); - } - }; - } - return accessibleEP; - } - - /** - * @generated - */ - private View getFontStyleOwnerView() { - return getPrimaryView(); - } - - /** - * Returns the kind of associated editor for direct edition. - * - * @return an <code>int</code> corresponding to the kind of direct editor, @see org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition - * @generated - */ - public int getDirectEditionType() { - if (checkExtendedEditor()) { - initExtendedEditorConfiguration(); - return IDirectEdition.EXTENDED_DIRECT_EDITOR; - } - if (checkDefaultEdition()) { - return IDirectEdition.DEFAULT_DIRECT_EDITOR; - } - - // not a named element. no specific editor => do nothing - return IDirectEdition.NO_DIRECT_EDITION; - } - - /** - * Checks if an extended editor is present. - * - * @return <code>true</code> if an extended editor is present. - * @generated - */ - protected boolean checkExtendedEditor() { - if (resolveSemanticElement() != null) { - return DirectEditorsUtil.hasSpecificEditorConfiguration(resolveSemanticElement(), this); - } - return false; - } - - /** - * Checks if a default direct edition is available - * - * @return <code>true</code> if a default direct edition is available - * @generated - */ - protected boolean checkDefaultEdition() { - return (getParser() != null); - } - - /** - * Initializes the extended editor configuration - * - * @generated - */ - protected void initExtendedEditorConfiguration() { - if (configuration == null) { - final String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("")) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else { - configuration = DirectEditorsUtil.findEditorConfiguration(IDirectEditorsIds.UML_LANGUAGE, - resolveSemanticElement(), this); - } - } - } - - /** - * Updates the preference configuration - * - * @generated - */ - protected void updateExtendedEditorConfiguration() { - String languagePreferred = Activator.getDefault().getPreferenceStore().getString( - IDirectEditorsIds.EDITOR_FOR_ELEMENT + resolveSemanticElement().eClass().getInstanceClassName()); - if (languagePreferred != null && !languagePreferred.equals("") - && !languagePreferred.equals(configuration.getLanguage())) { - configuration = DirectEditorsUtil.findEditorConfiguration(languagePreferred, resolveSemanticElement(), - this); - } else if (IDirectEditorsIds.SIMPLE_DIRECT_EDITOR.equals(languagePreferred)) { - configuration = null; - } - } - - /** - * Performs the direct edit usually used by GMF editors. - * - * @param theRequest - * the direct edit request that starts the direct edit system - * @generated - */ - protected void performDefaultDirectEditorEdit(final Request theRequest) { - // initialize the direct edit manager - try { - getEditingDomain().runExclusive(new Runnable() { - - @Override - public void run() { - if (isActive() && isEditable()) { - if (theRequest.getExtendedData() - .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof Character) { - Character initialChar = (Character) theRequest.getExtendedData() - .get(RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR); - performDirectEdit(initialChar.charValue()); - } else if ((theRequest instanceof DirectEditRequest) - && (getEditText().equals(getLabelText()))) { - DirectEditRequest editRequest = (DirectEditRequest) theRequest; - performDirectEdit(editRequest.getLocation()); - } else { - performDirectEdit(); - } - } - } - }); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - /** - * @generated - */ - @Override - protected void handleNotificationEvent(Notification event) { - Object feature = event.getFeature(); - if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { - Integer c = (Integer) event.getNewValue(); - setFontColor(DiagramColorRegistry.getInstance().getColor(c)); - } else if (NotationPackage.eINSTANCE.getFontStyle_Underline().equals(feature)) { - refreshUnderline(); - } else if (NotationPackage.eINSTANCE.getFontStyle_StrikeThrough().equals(feature)) { - refreshStrikeThrough(); - } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_FontName().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) - || NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) { - refreshFont(); - } else { - if (getParser() != null && getParser().isAffectingEvent(event, getParserOptions().intValue())) { - refreshLabel(); - } - if (getParser() instanceof ISemanticParser) { - ISemanticParser modelParser = (ISemanticParser) getParser(); - if (modelParser.areSemanticElementsAffected(null, event)) { - removeSemanticListeners(); - if (resolveSemanticElement() != null) { - addSemanticListeners(); - } - refreshLabel(); - } - } - } - super.handleNotificationEvent(event); - } - - /** - * @generated - */ - @Override - protected IFigure createFigure() { - IFigure label = createFigurePrim(); - defaultText = getLabelTextHelper(label); - return label; - } - - /** - * @generated - */ - protected IFigure createFigurePrim() { - return new MultilineLabelFigure(); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkAppliedStereotypeEditPart.java index 7fa3a60a383..efe5bccb802 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkAppliedStereotypeEditPart.java @@ -1,15 +1,12 @@ - /** * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * 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.sequence.edit.parts; @@ -17,10 +14,10 @@ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; import java.util.Collections; import java.util.List; +import org.eclipse.draw2d.ConnectionLocator; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.RecordingCommand; @@ -34,11 +31,9 @@ import org.eclipse.gef.tools.DirectEditManager; import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; @@ -61,17 +56,15 @@ import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; +import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; -import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; -import org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeWrappingLabelFigure; import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; @@ -89,8 +82,8 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DurationConstraintAppliedStereotypeEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class DurationConstraintLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated @@ -136,53 +129,34 @@ public class DurationConstraintAppliedStereotypeEditPart extends PapyrusLabelEdi */ static { registerSnapBackPosition(UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintAppliedStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkAppliedStereotypeEditPart.VISUAL_ID), + new Point(1, -33)); } /** * @generated */ - public DurationConstraintAppliedStereotypeEditPart(View view) { + public DurationConstraintLinkAppliedStereotypeEditPart(View view) { super(view); } /** - * @generated + * @generated Papyrus Generation */ @Override protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); } /** * @generated */ @Override - public IBorderItemLocator getBorderItemLocator() { - IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { - Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; - } - return null; - } - - /** - * @generated - */ - @Override - public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); - getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); + public int getKeyPoint() { + return ConnectionLocator.MIDDLE; } /** @@ -267,6 +241,7 @@ public class DurationConstraintAppliedStereotypeEditPart extends PapyrusLabelEdi /** * @generated */ + @Override public void setParser(IParser parser) { this.parser = parser; } @@ -282,7 +257,7 @@ public class DurationConstraintAppliedStereotypeEditPart extends PapyrusLabelEdi * @generated */ protected Image getLabelIcon() { - return DiagramEditPartsUtil.getIcon(getParserElement(), getViewer()); + return null; } /** @@ -356,7 +331,7 @@ public class DurationConstraintAppliedStereotypeEditPart extends PapyrusLabelEdi public void run() { setResult(parser.isValidEditString( ParserUtil.getParserAdapter(getParserElement(), - DurationConstraintAppliedStereotypeEditPart.this), + DurationConstraintLinkAppliedStereotypeEditPart.this), (String) value)); } }); @@ -397,8 +372,7 @@ public class DurationConstraintAppliedStereotypeEditPart extends PapyrusLabelEdi @Override public IParser getParser() { if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.DurationConstraint_Shape, getParserElement(), this, - VISUAL_ID); + parser = ParserUtil.getParser(UMLElementTypes.DurationConstraint_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -833,6 +807,7 @@ public class DurationConstraintAppliedStereotypeEditPart extends PapyrusLabelEdi } } } + super.handleNotificationEvent(event); } @@ -841,16 +816,24 @@ public class DurationConstraintAppliedStereotypeEditPart extends PapyrusLabelEdi */ @Override protected IFigure createFigure() { - IFigure label = createFigurePrim(); - defaultText = getLabelTextHelper(label); - return label; + // Parent should assign one using setLabel() method + return null; + } + + /** + * @generated + */ + @Override + public String getLabelRole() { + return "Stereotype";//$NON-NLS-1$ } /** * @generated */ - protected IFigure createFigurePrim() { - return new AppliedStereotypeWrappingLabelFigure(); + @Override + public String getIconPathRole() { + return "platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Stereotype.gif";//$NON-NLS-1$ } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkEditPart.java new file mode 100644 index 00000000000..fc9afc13178 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkEditPart.java @@ -0,0 +1,123 @@ +/** + * Copyright (c) 2016 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.sequence.edit.parts; + +import org.eclipse.draw2d.Connection; +import org.eclipse.gef.EditPart; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure; + +/** + * @generated + */ +public class DurationConstraintLinkEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart { + + /** + * @generated + */ + public static final String VISUAL_ID = "DurationConstraint_Edge"; + + /** + * @generated + */ + public DurationConstraintLinkEditPart(View view) { + super(view); + } + + /** + * @generated + */ + @Override + protected void createDefaultEditPolicies() { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeLinkLabelDisplayEditPolicy()); + } + + /** + * @generated + */ + protected boolean addFixedChild(EditPart childEditPart) { + if (childEditPart instanceof DurationConstraintLinkNameEditPart) { + ((DurationConstraintLinkNameEditPart) childEditPart).setLabel(getPrimaryShape().getDurationLabelFigure()); + } + if (childEditPart instanceof DurationConstraintLinkAppliedStereotypeEditPart) { + ((DurationConstraintLinkAppliedStereotypeEditPart) childEditPart) + .setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + } + return false; + } + + /** + * @generated + */ + @Override + protected void addChildVisual(EditPart childEditPart, int index) { + if (addFixedChild(childEditPart)) { + return; + } + super.addChildVisual(childEditPart, -1); + } + + /** + * @generated + */ + protected boolean removeFixedChild(EditPart childEditPart) { + if (childEditPart instanceof DurationConstraintLinkNameEditPart) { + return true; + } + if (childEditPart instanceof DurationConstraintLinkAppliedStereotypeEditPart) { + return true; + } + return false; + } + + /** + * @generated + */ + @Override + protected void removeChildVisual(EditPart childEditPart) { + if (removeFixedChild(childEditPart)) { + return; + } + super.removeChildVisual(childEditPart); + } + + /** + * Creates figure for this edit part. + * + * Body of this method does not depend on settings in generation model + * so you may safely remove <i>generated</i> tag and modify it. + * + * @generated + */ + @Override + protected Connection createConnectionFigure() { + return new DurationLinkFigure(); + } + + /** + * @generated + */ + @Override + public DurationLinkFigure getPrimaryShape() { + return (DurationLinkFigure) getFigure(); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkNameEditPart.java index a4e841dd1ad..0c20c65da50 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkNameEditPart.java @@ -1,15 +1,12 @@ - /** * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * 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.sequence.edit.parts; @@ -17,6 +14,7 @@ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; import java.util.Collections; import java.util.List; +import org.eclipse.draw2d.ConnectionLocator; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.geometry.Point; @@ -59,15 +57,17 @@ import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; +import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; -import org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.policies.DefaultNodeLabelDragPolicy; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; +import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleEvent; @@ -82,13 +82,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DurationConstraintInMessageLabelEditPart extends PapyrusCompartmentEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class DurationConstraintLinkNameEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated */ - public static final String VISUAL_ID = "DurationConstraint_BodyLabel_CN"; + public static final String VISUAL_ID = "DurationConstraint_NameLabel"; /** * @generated @@ -113,7 +113,6 @@ public class DurationConstraintInMessageLabelEditPart extends PapyrusCompartment /** * direct edition mode (default, undefined, registered editor, etc.) * - * * @generated */ protected int directEditionMode = IDirectEdition.UNDEFINED_DIRECT_EDITOR; @@ -128,20 +127,36 @@ public class DurationConstraintInMessageLabelEditPart extends PapyrusCompartment /** * @generated */ - public DurationConstraintInMessageLabelEditPart(View view) { - super(view); + static { + registerSnapBackPosition(UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkNameEditPart.VISUAL_ID), + new Point(1, -13)); } /** * @generated */ + public DurationConstraintLinkNameEditPart(View view) { + super(view); + } + + /** + * @generated Papyrus Generation + */ @Override protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); + } + + /** + * @generated + */ + @Override + public int getKeyPoint() { + return ConnectionLocator.MIDDLE; } /** @@ -314,10 +329,11 @@ public class DurationConstraintInMessageLabelEditPart extends PapyrusCompartment @Override public void run() { - setResult(parser.isValidEditString( - ParserUtil.getParserAdapter(getParserElement(), - DurationConstraintInMessageLabelEditPart.this), - (String) value)); + setResult( + parser.isValidEditString( + ParserUtil.getParserAdapter(getParserElement(), + DurationConstraintLinkNameEditPart.this), + (String) value)); } }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); @@ -357,8 +373,7 @@ public class DurationConstraintInMessageLabelEditPart extends PapyrusCompartment @Override public IParser getParser() { if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.DurationConstraint_Shape_CN, getParserElement(), this, - VISUAL_ID); + parser = ParserUtil.getParser(UMLElementTypes.DurationConstraint_Edge, getParserElement(), this, VISUAL_ID); } return parser; } @@ -772,26 +787,7 @@ public class DurationConstraintInMessageLabelEditPart extends PapyrusCompartment * @generated */ @Override - protected void addNotationalListeners() { - super.addNotationalListeners(); - addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ - } - - /** - * @generated - */ - @Override - protected void removeNotationalListeners() { - super.removeNotationalListeners(); - removeListenerFilter("PrimaryView"); //$NON-NLS-1$ - } - - /** - * @generated - */ - @Override protected void handleNotificationEvent(Notification event) { - refreshLabel(); Object feature = event.getFeature(); if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { Integer c = (Integer) event.getNewValue(); @@ -820,6 +816,7 @@ public class DurationConstraintInMessageLabelEditPart extends PapyrusCompartment } } } + super.handleNotificationEvent(event); } @@ -835,41 +832,17 @@ public class DurationConstraintInMessageLabelEditPart extends PapyrusCompartment /** * @generated */ - private static final String ADD_PARENT_MODEL = "AddParentModel"; - - /** - * @generated - */ @Override - public void activate() { - super.activate(); - addOwnerElementListeners(); - } - - /** - * @generated - */ - protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); - + public String getLabelRole() { + return "Name";//$NON-NLS-1$ } /** * @generated */ @Override - public void deactivate() { - removeOwnerElementListeners(); - super.deactivate(); - - } - - /** - * @generated - */ - protected void removeOwnerElementListeners() { - removeListenerFilter(ADD_PARENT_MODEL); - + public String getIconPathRole() { + return "platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/label_role/name.png";//$NON-NLS-1$ } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationEditPart.java deleted file mode 100644 index 57abb7ed4a4..00000000000 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationEditPart.java +++ /dev/null @@ -1,317 +0,0 @@ - -/** - * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * CEA LIST - Initial API and implementation - */ -package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; - -import java.util.Collections; -import java.util.List; - -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.PositionConstants; -import org.eclipse.draw2d.geometry.Dimension; -import org.eclipse.gef.EditPart; -import org.eclipse.gef.EditPolicy; -import org.eclipse.gef.GraphicalEditPart; -import org.eclipse.gef.Request; -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.editpolicies.LayoutEditPolicy; -import org.eclipse.gef.editpolicies.NonResizableEditPolicy; -import org.eclipse.gef.handles.MoveHandle; -import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; -import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ListItemComponentEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator; -import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout; -import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.NodeEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SelectableBorderedNodeFigure; -import org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MoveableNonResizableLabelEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; -import org.eclipse.swt.graphics.Color; - -/** - * @generated - */ -public class DurationObservationEditPart extends NodeEditPart { - - /** - * @generated - */ - public static final String VISUAL_ID = "DurationObservation_Shape"; - - /** - * @generated - */ - protected IFigure contentPane; - - /** - * @generated - */ - protected IFigure primaryShape; - - /** - * @generated - */ - public DurationObservationEditPart(View view) { - super(view); - } - - /** - * @generated - */ - @Override - protected void createDefaultEditPolicies() { - super.createDefaultEditPolicies(); - installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - - installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); - - installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(EditPolicy.COMPONENT_ROLE, new ListItemComponentEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new MoveableNonResizableLabelEditPolicy()); - installEditPolicy(DeleteTimeElementWithoutEventPolicy.KEY, new DeleteTimeElementWithoutEventPolicy()); - // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies - // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); - } - - /** - * @generated - */ - protected LayoutEditPolicy createLayoutEditPolicy() { - org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy lep = new org.eclipse.gmf.runtime.diagram.ui.editpolicies.LayoutEditPolicy() { - - @Override - protected EditPolicy createChildEditPolicy(EditPart child) { - View childView = (View) child.getModel(); - String vid = UMLVisualIDRegistry.getVisualID(childView); - if (vid != null) { - switch (vid) { - case DurationObservationAppliedStereotypeEditPart.VISUAL_ID: - return new BorderItemSelectionEditPolicy() { - - @Override - protected List<?> createSelectionHandles() { - MoveHandle mh = new MoveHandle((GraphicalEditPart) getHost()); - mh.setBorder(null); - return Collections.singletonList(mh); - } - }; - } - } - EditPolicy result = child.getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE); - if (result == null) { - result = new NonResizableEditPolicy(); - } - return result; - } - - @Override - protected Command getMoveChildrenCommand(Request request) { - return null; - } - - @Override - protected Command getCreateCommand(CreateRequest request) { - return null; - } - }; - return lep; - } - - /** - * @generated - */ - @Override - protected IFigure createNodeShape() { - return primaryShape = new RoundedCompartmentFigure(); - } - - /** - * org.eclipse.papyrus.uml.diagram.common.figure.node.RoundedCompartmentFigure - * - * @generated - */ - @Override - public RoundedCompartmentFigure getPrimaryShape() { - return (RoundedCompartmentFigure) primaryShape; - } - - /** - * @generated - */ - protected boolean addFixedChild(EditPart childEditPart) { - if (childEditPart instanceof DurationObservationLabelEditPart) { - ((DurationObservationLabelEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel()); - return true; - } - - return false; - } - - /** - * @generated - */ - protected boolean removeFixedChild(EditPart childEditPart) { - if (childEditPart instanceof DurationObservationLabelEditPart) { - return true; - } - return false; - } - - /** - * @generated - */ - @Override - protected void addChildVisual(EditPart childEditPart, int index) { - if (addFixedChild(childEditPart)) { - return; - } - super.addChildVisual(childEditPart, -1); - } - - /** - * @generated - */ - @Override - protected void removeChildVisual(EditPart childEditPart) { - if (removeFixedChild(childEditPart)) { - return; - } - super.removeChildVisual(childEditPart); - } - - /** - * @generated - */ - @Override - protected IFigure getContentPaneFor(IGraphicalEditPart editPart) { - if (editPart instanceof IBorderItemEditPart) { - return getBorderedFigure().getBorderItemContainer(); - } - return getContentPane(); - } - - /** - * @generated - */ - @Override - protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof DurationObservationAppliedStereotypeEditPart) { - BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); - locator.setBorderItemOffset(new Dimension(-20, -20)); - borderItemContainer.add(borderItemEditPart.getFigure(), locator); - } else { - super.addBorderItem(borderItemContainer, borderItemEditPart); - } - } - - /** - * @generated - */ - @Override - protected NodeFigure createNodePlate() { - RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(40, 40); - return result; - } - - /** - * Creates figure for this edit part. - * - * Body of this method does not depend on settings in generation model - * so you may safely remove <i>generated</i> tag and modify it. - * - * @generated - */ - @Override - protected NodeFigure createMainFigure() { - return new SelectableBorderedNodeFigure(createMainFigureWithSVG()); - - } - - /** - * Default implementation treats passed figure as content pane. - * Respects layout one may have set for generated figure. - * - * @param nodeShape - * instance of generated figure class - * @generated - */ - @Override - protected IFigure setupContentPane(IFigure nodeShape) { - if (nodeShape.getLayoutManager() == null) { - ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(); - layout.setSpacing(5); - nodeShape.setLayoutManager(layout); - } - return nodeShape; // use nodeShape itself as contentPane - } - - /** - * @generated - */ - @Override - public IFigure getContentPane() { - if (contentPane != null) { - return contentPane; - } - return super.getContentPane(); - } - - /** - * @generated - */ - @Override - protected void setForegroundColor(Color color) { - if (primaryShape != null) { - primaryShape.setForegroundColor(color); - } - } - - /** - * @generated - */ - @Override - protected void setLineWidth(int width) { - super.setLineWidth(width); - } - - /** - * @generated - */ - @Override - protected void setLineType(int style) { - if (primaryShape instanceof IPapyrusNodeFigure) { - ((IPapyrusNodeFigure) primaryShape).setLineStyle(style); - } - } - - /** - * @generated - */ - @Override - public EditPart getPrimaryChildEditPart() { - return getChildBySemanticHint(UMLVisualIDRegistry.getType(DurationObservationLabelEditPart.VISUAL_ID)); - } - -} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkAppliedStereotypeEditPart.java index a4ab73622fd..9895e5a7d0f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkAppliedStereotypeEditPart.java @@ -1,15 +1,12 @@ - /** * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * 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.sequence.edit.parts; @@ -17,10 +14,10 @@ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; import java.util.Collections; import java.util.List; +import org.eclipse.draw2d.ConnectionLocator; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.geometry.Point; -import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.RecordingCommand; @@ -34,11 +31,9 @@ import org.eclipse.gef.tools.DirectEditManager; import org.eclipse.gmf.runtime.common.ui.services.parser.IParser; import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus; import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy; -import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants; import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager; @@ -61,17 +56,15 @@ import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; +import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; -import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; -import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy; -import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; -import org.eclipse.papyrus.uml.diagram.common.figure.node.AppliedStereotypeWrappingLabelFigure; import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; @@ -89,8 +82,8 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DurationObservationAppliedStereotypeEditPart extends PapyrusLabelEditPart - implements ITextAwareEditPart, IBorderItemEditPart { +public class DurationObservationLinkAppliedStereotypeEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated @@ -136,53 +129,34 @@ public class DurationObservationAppliedStereotypeEditPart extends PapyrusLabelEd */ static { registerSnapBackPosition(UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationAppliedStereotypeEditPart.VISUAL_ID), - new Point(0, 0)); + org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkAppliedStereotypeEditPart.VISUAL_ID), + new Point(1, -33)); } /** * @generated */ - public DurationObservationAppliedStereotypeEditPart(View view) { + public DurationObservationLinkAppliedStereotypeEditPart(View view) { super(view); } /** - * @generated + * @generated Papyrus Generation */ @Override protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); - installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, - new AppliedStereotypeExternalNodeEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ExternalLabelPrimaryDragRoleEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); } /** * @generated */ @Override - public IBorderItemLocator getBorderItemLocator() { - IFigure parentFigure = getFigure().getParent(); - if (parentFigure != null && parentFigure.getLayoutManager() != null) { - Object constraint = parentFigure.getLayoutManager().getConstraint(getFigure()); - return (IBorderItemLocator) constraint; - } - return null; - } - - /** - * @generated - */ - @Override - public void refreshBounds() { - int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); - int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); - int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); - int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); - getBorderItemLocator().setConstraint(new Rectangle(x, y, width, height)); + public int getKeyPoint() { + return ConnectionLocator.MIDDLE; } /** @@ -267,6 +241,7 @@ public class DurationObservationAppliedStereotypeEditPart extends PapyrusLabelEd /** * @generated */ + @Override public void setParser(IParser parser) { this.parser = parser; } @@ -282,7 +257,7 @@ public class DurationObservationAppliedStereotypeEditPart extends PapyrusLabelEd * @generated */ protected Image getLabelIcon() { - return DiagramEditPartsUtil.getIcon(getParserElement(), getViewer()); + return null; } /** @@ -356,7 +331,7 @@ public class DurationObservationAppliedStereotypeEditPart extends PapyrusLabelEd public void run() { setResult(parser.isValidEditString( ParserUtil.getParserAdapter(getParserElement(), - DurationObservationAppliedStereotypeEditPart.this), + DurationObservationLinkAppliedStereotypeEditPart.this), (String) value)); } }); @@ -397,7 +372,7 @@ public class DurationObservationAppliedStereotypeEditPart extends PapyrusLabelEd @Override public IParser getParser() { if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.DurationObservation_Shape, getParserElement(), this, + parser = ParserUtil.getParser(UMLElementTypes.DurationObservation_Edge, getParserElement(), this, VISUAL_ID); } return parser; @@ -833,6 +808,7 @@ public class DurationObservationAppliedStereotypeEditPart extends PapyrusLabelEd } } } + super.handleNotificationEvent(event); } @@ -841,16 +817,24 @@ public class DurationObservationAppliedStereotypeEditPart extends PapyrusLabelEd */ @Override protected IFigure createFigure() { - IFigure label = createFigurePrim(); - defaultText = getLabelTextHelper(label); - return label; + // Parent should assign one using setLabel() method + return null; + } + + /** + * @generated + */ + @Override + public String getLabelRole() { + return "Stereotype";//$NON-NLS-1$ } /** * @generated */ - protected IFigure createFigurePrim() { - return new AppliedStereotypeWrappingLabelFigure(); + @Override + public String getIconPathRole() { + return "platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/Stereotype.gif";//$NON-NLS-1$ } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkEditPart.java new file mode 100644 index 00000000000..05f1006d8da --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkEditPart.java @@ -0,0 +1,131 @@ +/** + * Copyright (c) 2016, 2018 CEA LIST, Christian W. Damus, 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 + * Christian W. Damus - bug 536486 + */ +package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; + +import org.eclipse.draw2d.Connection; +import org.eclipse.gef.EditPart; +import org.eclipse.gef.EditPolicy; +import org.eclipse.gmf.runtime.diagram.ui.editparts.ITreeBranchEditPart; +import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; +import org.eclipse.gmf.runtime.notation.View; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editparts.UMLConnectionNodeEditPart; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.figures.DurationLinkFigure; + +/** + * @generated + */ +public class DurationObservationLinkEditPart extends UMLConnectionNodeEditPart implements ITreeBranchEditPart { + + /** + * @generated + */ + public static final String VISUAL_ID = "DurationObservation_Edge"; + + /** + * @generated + */ + public DurationObservationLinkEditPart(View view) { + super(view); + } + + /** + * @generated + */ + protected void createDefaultEditPoliciesGen() { + super.createDefaultEditPolicies(); + installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); + installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, + new AppliedStereotypeLinkLabelDisplayEditPolicy()); + } + + @Override + protected void createDefaultEditPolicies() { + createDefaultEditPoliciesGen(); + + removeEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE); + } + + /** + * @generated + */ + protected boolean addFixedChild(EditPart childEditPart) { + if (childEditPart instanceof DurationObservationLinkNameEditPart) { + ((DurationObservationLinkNameEditPart) childEditPart).setLabel(getPrimaryShape().getDurationLabelFigure()); + } + if (childEditPart instanceof DurationObservationLinkAppliedStereotypeEditPart) { + ((DurationObservationLinkAppliedStereotypeEditPart) childEditPart) + .setLabel(getPrimaryShape().getAppliedStereotypeLabel()); + } + return false; + } + + /** + * @generated + */ + @Override + protected void addChildVisual(EditPart childEditPart, int index) { + if (addFixedChild(childEditPart)) { + return; + } + super.addChildVisual(childEditPart, -1); + } + + /** + * @generated + */ + protected boolean removeFixedChild(EditPart childEditPart) { + if (childEditPart instanceof DurationObservationLinkNameEditPart) { + return true; + } + if (childEditPart instanceof DurationObservationLinkAppliedStereotypeEditPart) { + return true; + } + return false; + } + + /** + * @generated + */ + @Override + protected void removeChildVisual(EditPart childEditPart) { + if (removeFixedChild(childEditPart)) { + return; + } + super.removeChildVisual(childEditPart); + } + + /** + * Creates figure for this edit part. + * + * Body of this method does not depend on settings in generation model + * so you may safely remove <i>generated</i> tag and modify it. + * + * @generated + */ + @Override + protected Connection createConnectionFigure() { + return new DurationLinkFigure(); + } + + /** + * @generated + */ + @Override + public DurationLinkFigure getPrimaryShape() { + return (DurationLinkFigure) getFigure(); + } + +} diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkNameEditPart.java index 523f2e4d845..46c326bdcf3 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkNameEditPart.java @@ -1,15 +1,12 @@ - /** * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * 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.sequence.edit.parts; @@ -17,6 +14,7 @@ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; import java.util.Collections; import java.util.List; +import org.eclipse.draw2d.ConnectionLocator; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.geometry.Point; @@ -61,16 +59,18 @@ import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit; -import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusCompartmentEditPart; +import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.PapyrusLinkLabelDragPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; -import org.eclipse.papyrus.infra.gmfdiag.tooling.runtime.edit.policies.DefaultNodeLabelDragPolicy; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; +import org.eclipse.papyrus.uml.diagram.common.editparts.ILabelRoleProvider; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; import org.eclipse.swt.SWT; import org.eclipse.swt.accessibility.AccessibleEvent; @@ -85,8 +85,8 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class DurationObservationLabelEditPart extends PapyrusCompartmentEditPart - implements ITextAwareEditPart, IControlParserForDirectEdit { +public class DurationObservationLinkNameEditPart extends PapyrusLabelEditPart + implements ITextAwareEditPart, IControlParserForDirectEdit, ILabelRoleProvider { /** * @generated @@ -130,20 +130,36 @@ public class DurationObservationLabelEditPart extends PapyrusCompartmentEditPart /** * @generated */ - public DurationObservationLabelEditPart(View view) { - super(view); + static { + registerSnapBackPosition(UMLVisualIDRegistry.getType( + org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkNameEditPart.VISUAL_ID), + new Point(1, -13)); } /** * @generated */ + public DurationObservationLinkNameEditPart(View view) { + super(view); + } + + /** + * @generated Papyrus Generation + */ @Override protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); - installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy()); - installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new DefaultNodeLabelDragPolicy()); installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, new UMLTextSelectionEditPolicy()); + installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new PapyrusLinkLabelDragPolicy()); + } + + /** + * @generated + */ + @Override + public int getKeyPoint() { + return ConnectionLocator.MIDDLE; } /** @@ -319,7 +335,7 @@ public class DurationObservationLabelEditPart extends PapyrusCompartmentEditPart setResult( parser.isValidEditString( ParserUtil.getParserAdapter(getParserElement(), - DurationObservationLabelEditPart.this), + DurationObservationLinkNameEditPart.this), (String) value)); } }); @@ -360,7 +376,7 @@ public class DurationObservationLabelEditPart extends PapyrusCompartmentEditPart @Override public IParser getParser() { if (parser == null) { - parser = ParserUtil.getParser(UMLElementTypes.DurationObservation_Shape, getParserElement(), this, + parser = ParserUtil.getParser(UMLElementTypes.DurationObservation_Edge, getParserElement(), this, VISUAL_ID); } return parser; @@ -775,26 +791,7 @@ public class DurationObservationLabelEditPart extends PapyrusCompartmentEditPart * @generated */ @Override - protected void addNotationalListeners() { - super.addNotationalListeners(); - addListenerFilter("PrimaryView", this, getPrimaryView()); //$NON-NLS-1$ - } - - /** - * @generated - */ - @Override - protected void removeNotationalListeners() { - super.removeNotationalListeners(); - removeListenerFilter("PrimaryView"); //$NON-NLS-1$ - } - - /** - * @generated - */ - @Override protected void handleNotificationEvent(Notification event) { - refreshLabel(); Object feature = event.getFeature(); if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(feature)) { Integer c = (Integer) event.getNewValue(); @@ -823,6 +820,7 @@ public class DurationObservationLabelEditPart extends PapyrusCompartmentEditPart } } } + if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON .equals(((EAnnotation) event.getNewValue()).getSource())) { refreshLabel(); @@ -842,41 +840,17 @@ public class DurationObservationLabelEditPart extends PapyrusCompartmentEditPart /** * @generated */ - private static final String ADD_PARENT_MODEL = "AddParentModel"; - - /** - * @generated - */ @Override - public void activate() { - super.activate(); - addOwnerElementListeners(); - } - - /** - * @generated - */ - protected void addOwnerElementListeners() { - addListenerFilter(ADD_PARENT_MODEL, this, ((View) getParent().getModel())); - + public String getLabelRole() { + return "Name";//$NON-NLS-1$ } /** * @generated */ @Override - public void deactivate() { - removeOwnerElementListeners(); - super.deactivate(); - - } - - /** - * @generated - */ - protected void removeOwnerElementListeners() { - removeListenerFilter(ADD_PARENT_MODEL); - + public String getIconPathRole() { + return "platform:/plugin/org.eclipse.papyrus.uml.diagram.common/icons/label_role/name.png";//$NON-NLS-1$ } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java index 38ecb782eae..e5411a37e5d 100755..100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java @@ -123,10 +123,9 @@ public class LifelineEditPart extends RoundedCompartmentEditPart { if (vid != null) { switch (vid) { case StateInvariantEditPart.VISUAL_ID: - case TimeConstraintEditPart.VISUAL_ID: - case TimeObservationEditPart.VISUAL_ID: - case DurationConstraintEditPart.VISUAL_ID: case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + case TimeObservationBorderNodeEditPart.VISUAL_ID: return new BorderItemResizableEditPolicy(); } } @@ -188,9 +187,6 @@ public class LifelineEditPart extends RoundedCompartmentEditPart { return true; } - - - // Papyrus Gencode :Specific locator for the itemBorder of the lifeline. if (childEditPart instanceof StateInvariantEditPart) { IBorderItemLocator locator = new CenterLocator(getMainFigure(), PositionConstants.NONE); @@ -198,47 +194,29 @@ public class LifelineEditPart extends RoundedCompartmentEditPart { return true; } - - - - // Papyrus Gencode :Affixed locator for Lifelines to place element with a time bar - if (childEditPart instanceof TimeConstraintEditPart) { - IBorderItemLocator locator = new CenterLocator(getMainFigure(), PositionConstants.NONE); - getBorderedFigure().getBorderItemContainer().add(((TimeConstraintEditPart) childEditPart).getFigure(), locator); - return true; - } - - - - - // Papyrus Gencode :Affixed locator for Lifelines to place element with a time bar - if (childEditPart instanceof TimeObservationEditPart) { - IBorderItemLocator locator = new CenterLocator(getMainFigure(), PositionConstants.NONE); - getBorderedFigure().getBorderItemContainer().add(((TimeObservationEditPart) childEditPart).getFigure(), locator); + // Papyrus Gencode :Specific locator for the itemBorder of the lifeline. + if (childEditPart instanceof DestructionOccurrenceSpecificationEditPart) { + IBorderItemLocator locator = new CenterLocator(getMainFigure(), PositionConstants.SOUTH); + getBorderedFigure().getBorderItemContainer().add(((DestructionOccurrenceSpecificationEditPart) childEditPart).getFigure(), locator); return true; } - - - - // Papyrus Gencode :Affixed locator for Lifelines to place element with a time bar - if (childEditPart instanceof DurationConstraintEditPart) { + // Papyrus Gencode :Specific locator for the itemBorder of the lifeline. + if (childEditPart instanceof TimeConstraintBorderNodeEditPart) { IBorderItemLocator locator = new CenterLocator(getMainFigure(), PositionConstants.NONE); - getBorderedFigure().getBorderItemContainer().add(((DurationConstraintEditPart) childEditPart).getFigure(), locator); + getBorderedFigure().getBorderItemContainer() + .add(((TimeConstraintBorderNodeEditPart) childEditPart).getFigure(), locator); return true; } - - - // Papyrus Gencode :Specific locator for the itemBorder of the lifeline. - if (childEditPart instanceof DestructionOccurrenceSpecificationEditPart) { - IBorderItemLocator locator = new CenterLocator(getMainFigure(), PositionConstants.SOUTH); - getBorderedFigure().getBorderItemContainer().add(((DestructionOccurrenceSpecificationEditPart) childEditPart).getFigure(), locator); + if (childEditPart instanceof TimeObservationBorderNodeEditPart) { + IBorderItemLocator locator = new CenterLocator(getMainFigure(), PositionConstants.NONE); + getBorderedFigure().getBorderItemContainer() + .add(((TimeObservationBorderNodeEditPart) childEditPart).getFigure(), locator); return true; } - return false; } @@ -253,20 +231,18 @@ public class LifelineEditPart extends RoundedCompartmentEditPart { getBorderedFigure().getBorderItemContainer().remove(((StateInvariantEditPart) childEditPart).getFigure()); return true; } - if (childEditPart instanceof TimeConstraintEditPart) { - getBorderedFigure().getBorderItemContainer().remove(((TimeConstraintEditPart) childEditPart).getFigure()); - return true; - } - if (childEditPart instanceof TimeObservationEditPart) { - getBorderedFigure().getBorderItemContainer().remove(((TimeObservationEditPart) childEditPart).getFigure()); + if (childEditPart instanceof DestructionOccurrenceSpecificationEditPart) { + getBorderedFigure().getBorderItemContainer().remove(((DestructionOccurrenceSpecificationEditPart) childEditPart).getFigure()); return true; } - if (childEditPart instanceof DurationConstraintEditPart) { - getBorderedFigure().getBorderItemContainer().remove(((DurationConstraintEditPart) childEditPart).getFigure()); + if (childEditPart instanceof TimeConstraintBorderNodeEditPart) { + getBorderedFigure().getBorderItemContainer() + .remove(((TimeConstraintBorderNodeEditPart) childEditPart).getFigure()); return true; } - if (childEditPart instanceof DestructionOccurrenceSpecificationEditPart) { - getBorderedFigure().getBorderItemContainer().remove(((DestructionOccurrenceSpecificationEditPart) childEditPart).getFigure()); + if (childEditPart instanceof TimeObservationBorderNodeEditPart) { + getBorderedFigure().getBorderItemContainer() + .remove(((TimeObservationBorderNodeEditPart) childEditPart).getFigure()); return true; } return false; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageAsyncEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageAsyncEditPart.java index bdeb6910644..7c38576948d 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageAsyncEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageAsyncEditPart.java @@ -9,7 +9,6 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageConnectionLineSegEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageAsync; @@ -37,7 +36,6 @@ public class MessageAsyncEditPart extends AbstractMessageEditPart implements ITr protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationOnMessageEditPolicy()); installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new MessageConnectionLineSegEditPolicy()); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageCreateEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageCreateEditPart.java index 7094d8cc2e9..c0be7d4284e 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageCreateEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageCreateEditPart.java @@ -9,7 +9,6 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageConnectionLineSegEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageCreate; @@ -37,7 +36,6 @@ public class MessageCreateEditPart extends AbstractMessageEditPart implements IT protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationOnMessageEditPolicy()); installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new MessageConnectionLineSegEditPolicy()); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageDeleteEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageDeleteEditPart.java index 01dd8949833..ca65318fddc 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageDeleteEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageDeleteEditPart.java @@ -9,7 +9,6 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageConnectionLineSegEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageDelete; @@ -37,7 +36,6 @@ public class MessageDeleteEditPart extends AbstractMessageEditPart implements IT protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationOnMessageEditPolicy()); installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new MessageConnectionLineSegEditPolicy()); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundAppliedStereotypeEditPart.java index c18c7217092..6fccbc19c37 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundAppliedStereotypeEditPart.java @@ -22,7 +22,6 @@ import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.Label; import org.eclipse.draw2d.geometry.Point; import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.RecordingCommand; import org.eclipse.emf.transaction.RunnableWithResult; @@ -60,7 +59,6 @@ import org.eclipse.papyrus.extensionpoints.editors.ui.ILabelEditorDialog; import org.eclipse.papyrus.extensionpoints.editors.ui.IPopupEditorHelper; import org.eclipse.papyrus.extensionpoints.editors.utils.DirectEditorsUtil; import org.eclipse.papyrus.extensionpoints.editors.utils.IDirectEditorsIds; -import org.eclipse.papyrus.infra.emf.appearance.helper.VisualInformationPapyrusConstants; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IControlParserForDirectEdit; import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; @@ -814,10 +812,6 @@ public class MessageFoundAppliedStereotypeEditPart extends PapyrusLabelEditPart } } - if (event.getNewValue() instanceof EAnnotation && VisualInformationPapyrusConstants.DISPLAY_NAMELABELICON - .equals(((EAnnotation) event.getNewValue()).getSource())) { - refreshLabel(); - } super.handleNotificationEvent(event); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundEditPart.java index 1bdb2b93bd3..cd2d5bf0c2e 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundEditPart.java @@ -9,7 +9,6 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageConnectionLineSegEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageFound; @@ -37,7 +36,6 @@ public class MessageFoundEditPart extends AbstractMessageEditPart implements ITr protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationOnMessageEditPolicy()); installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new MessageConnectionLineSegEditPolicy()); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageLostEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageLostEditPart.java index 276c1243f4a..82d9becff6a 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageLostEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageLostEditPart.java @@ -9,7 +9,6 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageConnectionLineSegEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageLost; @@ -37,7 +36,6 @@ public class MessageLostEditPart extends AbstractMessageEditPart implements ITre protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationOnMessageEditPolicy()); installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new MessageConnectionLineSegEditPolicy()); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageReplyEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageReplyEditPart.java index 1178fb6f0dc..31699dd348f 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageReplyEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageReplyEditPart.java @@ -9,7 +9,6 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageConnectionLineSegEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageReply; @@ -37,7 +36,6 @@ public class MessageReplyEditPart extends AbstractMessageEditPart implements ITr protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationOnMessageEditPolicy()); installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new MessageConnectionLineSegEditPolicy()); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageSyncEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageSyncEditPart.java index fad1c89937c..45e7fe2403f 100755 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageSyncEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageSyncEditPart.java @@ -9,7 +9,6 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLinkLabelDisplayEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.CreationOnMessageEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.MessageConnectionLineSegEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.MessageSync; @@ -37,7 +36,6 @@ public class MessageSyncEditPart extends AbstractMessageEditPart implements ITre protected void createDefaultEditPolicies() { super.createDefaultEditPolicies(); installEditPolicy(EditPolicyRoles.SEMANTIC_ROLE, new DefaultSemanticEditPolicy()); - installEditPolicy(EditPolicyRoles.CREATION_ROLE, new CreationOnMessageEditPolicy()); installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new AppliedStereotypeLinkLabelDisplayEditPolicy()); installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new MessageConnectionLineSegEditPolicy()); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintAppliedStereotypeEditPart.java index 13831b6fdbb..2f093e81fea 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintAppliedStereotypeEditPart.java @@ -1,15 +1,12 @@ - /** * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * 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.sequence.edit.parts; @@ -66,7 +63,6 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimar import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; -import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; @@ -282,7 +278,7 @@ public class TimeConstraintAppliedStereotypeEditPart extends PapyrusLabelEditPar * @generated */ protected Image getLabelIcon() { - return DiagramEditPartsUtil.getIcon(getParserElement(), getViewer()); + return null; } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintBorderNodeEditPart.java index e9e95bc2419..5558d8d104f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintBorderNodeEditPart.java @@ -1,15 +1,12 @@ - /** * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * 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.sequence.edit.parts; @@ -21,6 +18,9 @@ import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.StackLayout; import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.draw2d.geometry.Rectangle; +import org.eclipse.emf.common.notify.Notification; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPolicy; import org.eclipse.gef.GraphicalEditPart; @@ -30,25 +30,28 @@ import org.eclipse.gef.editpolicies.LayoutEditPolicy; import org.eclipse.gef.editpolicies.NonResizableEditPolicy; import org.eclipse.gef.handles.MoveHandle; import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator; import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; +import org.eclipse.gmf.runtime.notation.BasicCompartment; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; -import org.eclipse.papyrus.uml.diagram.sequence.figures.TimeMarkElementFigure; +import org.eclipse.papyrus.uml.diagram.common.editparts.BorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.figures.TimeConstraintFigure; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.swt.graphics.Color; /** * @generated */ -public class TimeConstraintEditPart extends BorderedBorderItemEditPart { +public class TimeConstraintBorderNodeEditPart extends BorderNodeEditPart { /** * @generated @@ -68,7 +71,7 @@ public class TimeConstraintEditPart extends BorderedBorderItemEditPart { /** * @generated */ - public TimeConstraintEditPart(View view) { + public TimeConstraintBorderNodeEditPart(View view) { super(view); } @@ -100,7 +103,7 @@ public class TimeConstraintEditPart extends BorderedBorderItemEditPart { String vid = UMLVisualIDRegistry.getVisualID(childView); if (vid != null) { switch (vid) { - case TimeConstraintLabelEditPart.VISUAL_ID: + case TimeConstraintNameEditPart.VISUAL_ID: case TimeConstraintAppliedStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @@ -134,19 +137,66 @@ public class TimeConstraintEditPart extends BorderedBorderItemEditPart { } /** + * Papyrus codeGen + * + * @generated + **/ + @Override + protected void handleNotificationEvent(Notification event) { + /* + * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart + * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! + */ + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + Object notifier = event.getNotifier(); + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { + return; + } + } + } + super.handleNotificationEvent(event); + + } + + /** * @generated */ protected IFigure createNodeShape() { - return primaryShape = new TimeMarkElementFigure(); + return primaryShape = new TimeConstraintFigure(); + } + + @Override + public void refreshVisuals() { + super.refreshVisuals(); + } + + @Override + protected void refreshBounds() { + if (getBorderItemLocator() != null) { + int x = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_X())).intValue(); + int y = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getLocation_Y())).intValue(); + Point loc = new Point(x, y); + + int width = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Width())).intValue(); + int height = ((Integer) getStructuralFeatureValue(NotationPackage.eINSTANCE.getSize_Height())).intValue(); + Dimension size = new Dimension(width, height); + + getBorderItemLocator().setConstraint(new Rectangle(loc, size)); + } else { + super.refreshBounds(); + } } /** - * org.eclipse.papyrus.uml.diagram.sequence.figures.TimeMarkElementFigure + * org.eclipse.papyrus.uml.diagram.sequence.figures.TimeConstraintFigure * * @generated */ - public TimeMarkElementFigure getPrimaryShape() { - return (TimeMarkElementFigure) primaryShape; + @Override + public TimeConstraintFigure getPrimaryShape() { + return (TimeConstraintFigure) primaryShape; } /** @@ -154,7 +204,7 @@ public class TimeConstraintEditPart extends BorderedBorderItemEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof TimeConstraintLabelEditPart + if (borderItemEditPart instanceof TimeConstraintNameEditPart || borderItemEditPart instanceof TimeConstraintAppliedStereotypeEditPart) { BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); locator.setBorderItemOffset(new Dimension(-20, -20)); @@ -168,7 +218,7 @@ public class TimeConstraintEditPart extends BorderedBorderItemEditPart { * @generated */ protected NodeFigure createNodePlate() { - RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(40, 40); + RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(40, 1); return result; } @@ -247,7 +297,7 @@ public class TimeConstraintEditPart extends BorderedBorderItemEditPart { */ @Override public EditPart getPrimaryChildEditPart() { - return getChildBySemanticHint(UMLVisualIDRegistry.getType(TimeConstraintLabelEditPart.VISUAL_ID)); + return getChildBySemanticHint(UMLVisualIDRegistry.getType(TimeConstraintNameEditPart.VISUAL_ID)); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintNameEditPart.java index 62ed3a1bd6e..a9617d040ec 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintNameEditPart.java @@ -1,15 +1,12 @@ - /** * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: + * + * 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.sequence.edit.parts; @@ -65,12 +62,13 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.MultilineLabelFigure; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; import org.eclipse.swt.SWT; @@ -86,13 +84,13 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class TimeConstraintLabelEditPart extends PapyrusLabelEditPart +public class TimeConstraintNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** * @generated */ - public static final String VISUAL_ID = "TimeConstraint_ConstraintLabel"; + public static final String VISUAL_ID = "TimeConstraint_NameLabel"; /** * @generated @@ -134,14 +132,14 @@ public class TimeConstraintLabelEditPart extends PapyrusLabelEditPart static { registerSnapBackPosition( UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintLabelEditPart.VISUAL_ID), + org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintNameEditPart.VISUAL_ID), new Point(0, 0)); } /** * @generated */ - public TimeConstraintLabelEditPart(View view) { + public TimeConstraintNameEditPart(View view) { super(view); } @@ -278,7 +276,7 @@ public class TimeConstraintLabelEditPart extends PapyrusLabelEditPart * @generated */ protected Image getLabelIcon() { - return null; + return DiagramEditPartsUtil.getIcon(getParserElement(), getViewer()); } /** @@ -351,7 +349,7 @@ public class TimeConstraintLabelEditPart extends PapyrusLabelEditPart @Override public void run() { setResult(parser.isValidEditString(ParserUtil.getParserAdapter( - getParserElement(), TimeConstraintLabelEditPart.this), (String) value)); + getParserElement(), TimeConstraintNameEditPart.this), (String) value)); } }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); @@ -851,7 +849,7 @@ public class TimeConstraintLabelEditPart extends PapyrusLabelEditPart * @generated */ protected IFigure createFigurePrim() { - return new MultilineLabelFigure(); + return new PapyrusWrappingLabel(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationAppliedStereotypeEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationAppliedStereotypeEditPart.java index cc247589c05..eb45c84afe8 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationAppliedStereotypeEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationAppliedStereotypeEditPart.java @@ -1,16 +1,15 @@ - /** - * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * CEA LIST - Initial API and implementation + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation */ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; @@ -66,7 +65,6 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimar import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; -import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeExternalNodeEditPolicy; import org.eclipse.papyrus.uml.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy; @@ -282,7 +280,7 @@ public class TimeObservationAppliedStereotypeEditPart extends PapyrusLabelEditPa * @generated */ protected Image getLabelIcon() { - return DiagramEditPartsUtil.getIcon(getParserElement(), getViewer()); + return null; } /** diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationBorderNodeEditPart.java index 3b583838440..dc8ed111e72 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationBorderNodeEditPart.java @@ -1,16 +1,15 @@ - /** - * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * CEA LIST - Initial API and implementation + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation */ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; @@ -21,6 +20,7 @@ import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.StackLayout; import org.eclipse.draw2d.geometry.Dimension; +import org.eclipse.emf.common.notify.Notification; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPolicy; import org.eclipse.gef.GraphicalEditPart; @@ -30,26 +30,28 @@ import org.eclipse.gef.editpolicies.LayoutEditPolicy; import org.eclipse.gef.editpolicies.NonResizableEditPolicy; import org.eclipse.gef.handles.MoveHandle; import org.eclipse.gef.requests.CreateRequest; -import org.eclipse.gmf.runtime.diagram.ui.editparts.BorderedBorderItemEditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IBorderItemEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.BorderItemSelectionEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles; import org.eclipse.gmf.runtime.diagram.ui.figures.BorderItemLocator; import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure; +import org.eclipse.gmf.runtime.notation.BasicCompartment; +import org.eclipse.gmf.runtime.notation.Edge; +import org.eclipse.gmf.runtime.notation.NotationPackage; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultGraphicalNodeEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.DefaultSemanticEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; -import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.DeleteTimeElementWithoutEventPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.TimeMarkElementFigure; +import org.eclipse.papyrus.uml.diagram.common.editparts.BorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.figures.TimeObservationFigure; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.swt.graphics.Color; /** * @generated */ -public class TimeObservationEditPart extends BorderedBorderItemEditPart { +public class TimeObservationBorderNodeEditPart extends BorderNodeEditPart { /** * @generated @@ -69,7 +71,7 @@ public class TimeObservationEditPart extends BorderedBorderItemEditPart { /** * @generated */ - public TimeObservationEditPart(View view) { + public TimeObservationBorderNodeEditPart(View view) { super(view); } @@ -85,7 +87,6 @@ public class TimeObservationEditPart extends BorderedBorderItemEditPart { installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new DefaultGraphicalNodeEditPolicy()); installEditPolicy(EditPolicy.LAYOUT_ROLE, createLayoutEditPolicy()); - installEditPolicy(DeleteTimeElementWithoutEventPolicy.KEY, new DeleteTimeElementWithoutEventPolicy()); // XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies // removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE); } @@ -102,7 +103,7 @@ public class TimeObservationEditPart extends BorderedBorderItemEditPart { String vid = UMLVisualIDRegistry.getVisualID(childView); if (vid != null) { switch (vid) { - case TimeObservationLabelEditPart.VISUAL_ID: + case TimeObservationNameEditPart.VISUAL_ID: case TimeObservationAppliedStereotypeEditPart.VISUAL_ID: return new BorderItemSelectionEditPolicy() { @@ -136,19 +137,44 @@ public class TimeObservationEditPart extends BorderedBorderItemEditPart { } /** + * Papyrus codeGen + * + * @generated + **/ + @Override + protected void handleNotificationEvent(Notification event) { + /* + * when a node have external node labels, the methods refreshChildren() remove the EditPart corresponding to the Label from the EditPart + * Registry. After that, we can't reset the visibility to true (using the Show/Hide Label Action)! + */ + if (NotationPackage.eINSTANCE.getView_Visible().equals(event.getFeature())) { + Object notifier = event.getNotifier(); + List<?> modelChildren = ((View) getModel()).getChildren(); + if (false == notifier instanceof Edge && false == notifier instanceof BasicCompartment) { + if (modelChildren.contains(event.getNotifier())) { + return; + } + } + } + super.handleNotificationEvent(event); + + } + + /** * @generated */ protected IFigure createNodeShape() { - return primaryShape = new TimeMarkElementFigure(); + return primaryShape = new TimeObservationFigure(); } /** - * org.eclipse.papyrus.uml.diagram.sequence.figures.TimeMarkElementFigure + * org.eclipse.papyrus.uml.diagram.sequence.figures.TimeObservationFigure * * @generated */ - public TimeMarkElementFigure getPrimaryShape() { - return (TimeMarkElementFigure) primaryShape; + @Override + public TimeObservationFigure getPrimaryShape() { + return (TimeObservationFigure) primaryShape; } /** @@ -156,7 +182,7 @@ public class TimeObservationEditPart extends BorderedBorderItemEditPart { */ @Override protected void addBorderItem(IFigure borderItemContainer, IBorderItemEditPart borderItemEditPart) { - if (borderItemEditPart instanceof TimeObservationLabelEditPart + if (borderItemEditPart instanceof TimeObservationNameEditPart || borderItemEditPart instanceof TimeObservationAppliedStereotypeEditPart) { BorderItemLocator locator = new BorderItemLocator(getMainFigure(), PositionConstants.SOUTH); locator.setBorderItemOffset(new Dimension(-20, -20)); @@ -170,7 +196,7 @@ public class TimeObservationEditPart extends BorderedBorderItemEditPart { * @generated */ protected NodeFigure createNodePlate() { - RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(40, 40); + RoundedRectangleNodePlateFigure result = new RoundedRectangleNodePlateFigure(40, 1); return result; } @@ -249,7 +275,7 @@ public class TimeObservationEditPart extends BorderedBorderItemEditPart { */ @Override public EditPart getPrimaryChildEditPart() { - return getChildBySemanticHint(UMLVisualIDRegistry.getType(TimeObservationLabelEditPart.VISUAL_ID)); + return getChildBySemanticHint(UMLVisualIDRegistry.getType(TimeObservationNameEditPart.VISUAL_ID)); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationLabelEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationNameEditPart.java index 93a0e40b094..a0be8507a9e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationLabelEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationNameEditPart.java @@ -1,16 +1,15 @@ - /** - * Copyright (c) 2016 CEA LIST. - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * CEA LIST - Initial API and implementation + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation */ package org.eclipse.papyrus.uml.diagram.sequence.edit.parts; @@ -65,12 +64,13 @@ import org.eclipse.papyrus.infra.gmfdiag.common.editpart.PapyrusLabelEditPart; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IMaskManagedLabelEditPolicy; import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.IndirectMaskLabelEditPolicy; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel; import org.eclipse.papyrus.infra.gmfdiag.common.parsers.ParserUtil; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil; import org.eclipse.papyrus.uml.diagram.common.directedit.MultilineLabelDirectEditManager; import org.eclipse.papyrus.uml.diagram.common.editpolicies.IDirectEdition; import org.eclipse.papyrus.uml.diagram.common.figure.node.ILabelFigure; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLTextSelectionEditPolicy; -import org.eclipse.papyrus.uml.diagram.sequence.figures.MultilineLabelFigure; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; import org.eclipse.swt.SWT; @@ -86,7 +86,7 @@ import org.eclipse.uml2.uml.Feature; /** * @generated */ -public class TimeObservationLabelEditPart extends PapyrusLabelEditPart +public class TimeObservationNameEditPart extends PapyrusLabelEditPart implements ITextAwareEditPart, IBorderItemEditPart { /** @@ -134,14 +134,14 @@ public class TimeObservationLabelEditPart extends PapyrusLabelEditPart static { registerSnapBackPosition( UMLVisualIDRegistry.getType( - org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart.VISUAL_ID), + org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationNameEditPart.VISUAL_ID), new Point(0, 0)); } /** * @generated */ - public TimeObservationLabelEditPart(View view) { + public TimeObservationNameEditPart(View view) { super(view); } @@ -278,7 +278,7 @@ public class TimeObservationLabelEditPart extends PapyrusLabelEditPart * @generated */ protected Image getLabelIcon() { - return null; + return DiagramEditPartsUtil.getIcon(getParserElement(), getViewer()); } /** @@ -350,9 +350,8 @@ public class TimeObservationLabelEditPart extends PapyrusLabelEditPart @Override public void run() { - setResult( - parser.isValidEditString(ParserUtil.getParserAdapter(getParserElement(), - TimeObservationLabelEditPart.this), (String) value)); + setResult(parser.isValidEditString(ParserUtil.getParserAdapter( + getParserElement(), TimeObservationNameEditPart.this), (String) value)); } }); return valid.getCode() == IParserEditStatus.EDITABLE ? null : valid.getMessage(); @@ -852,7 +851,7 @@ public class TimeObservationLabelEditPart extends PapyrusLabelEditPart * @generated */ protected IFigure createFigurePrim() { - return new MultilineLabelFigure(); + return new PapyrusWrappingLabel(); } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/UMLEditPartFactory.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/UMLEditPartFactory.java index 995453e3a29..91b9940ef2c 100755..100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/UMLEditPartFactory.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/UMLEditPartFactory.java @@ -82,33 +82,6 @@ public class UMLEditPartFactory implements EditPartFactory { case StateInvariantLabelEditPart.VISUAL_ID: return new StateInvariantLabelEditPart(view); - case TimeConstraintEditPart.VISUAL_ID: - return new TimeConstraintEditPart(view); - - case TimeConstraintLabelEditPart.VISUAL_ID: - return new TimeConstraintLabelEditPart(view); - - case TimeConstraintAppliedStereotypeEditPart.VISUAL_ID: - return new TimeConstraintAppliedStereotypeEditPart(view); - - case TimeObservationEditPart.VISUAL_ID: - return new TimeObservationEditPart(view); - - case TimeObservationLabelEditPart.VISUAL_ID: - return new TimeObservationLabelEditPart(view); - - case TimeObservationAppliedStereotypeEditPart.VISUAL_ID: - return new TimeObservationAppliedStereotypeEditPart(view); - - case DurationConstraintEditPart.VISUAL_ID: - return new DurationConstraintEditPart(view); - - case DurationConstraintLabelEditPart.VISUAL_ID: - return new DurationConstraintLabelEditPart(view); - - case DurationConstraintAppliedStereotypeEditPart.VISUAL_ID: - return new DurationConstraintAppliedStereotypeEditPart(view); - case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: return new DestructionOccurrenceSpecificationEditPart(view); @@ -127,29 +100,29 @@ public class UMLEditPartFactory implements EditPartFactory { case CommentBodyEditPart.VISUAL_ID: return new CommentBodyEditPart(view); - case DurationConstraintInMessageEditPart.VISUAL_ID: - return new DurationConstraintInMessageEditPart(view); + case GateEditPart.VISUAL_ID: + return new GateEditPart(view); - case DurationConstraintInMessageLabelEditPart.VISUAL_ID: - return new DurationConstraintInMessageLabelEditPart(view); + case GateNameEditPart.VISUAL_ID: + return new GateNameEditPart(view); - case DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID: - return new DurationConstraintInMessageAppliedStereotypeEditPart(view); + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + return new TimeConstraintBorderNodeEditPart(view); - case DurationObservationEditPart.VISUAL_ID: - return new DurationObservationEditPart(view); + case TimeConstraintNameEditPart.VISUAL_ID: + return new TimeConstraintNameEditPart(view); - case DurationObservationLabelEditPart.VISUAL_ID: - return new DurationObservationLabelEditPart(view); + case TimeConstraintAppliedStereotypeEditPart.VISUAL_ID: + return new TimeConstraintAppliedStereotypeEditPart(view); - case DurationObservationAppliedStereotypeEditPart.VISUAL_ID: - return new DurationObservationAppliedStereotypeEditPart(view); + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return new TimeObservationBorderNodeEditPart(view); - case GateEditPart.VISUAL_ID: - return new GateEditPart(view); + case TimeObservationNameEditPart.VISUAL_ID: + return new TimeObservationNameEditPart(view); - case GateNameEditPart.VISUAL_ID: - return new GateNameEditPart(view); + case TimeObservationAppliedStereotypeEditPart.VISUAL_ID: + return new TimeObservationAppliedStereotypeEditPart(view); case InteractionInteractionCompartmentEditPart.VISUAL_ID: return new InteractionInteractionCompartmentEditPart(view); @@ -238,6 +211,24 @@ public class UMLEditPartFactory implements EditPartFactory { case ConstraintContextAppliedStereotypeEditPart.VISUAL_ID: return new ConstraintContextAppliedStereotypeEditPart(view); + case DurationConstraintLinkEditPart.VISUAL_ID: + return new DurationConstraintLinkEditPart(view); + + case DurationConstraintLinkNameEditPart.VISUAL_ID: + return new DurationConstraintLinkNameEditPart(view); + + case DurationConstraintLinkAppliedStereotypeEditPart.VISUAL_ID: + return new DurationConstraintLinkAppliedStereotypeEditPart(view); + + case DurationObservationLinkEditPart.VISUAL_ID: + return new DurationObservationLinkEditPart(view); + + case DurationObservationLinkNameEditPart.VISUAL_ID: + return new DurationObservationLinkNameEditPart(view); + + case DurationObservationLinkAppliedStereotypeEditPart.VISUAL_ID: + return new DurationObservationLinkAppliedStereotypeEditPart(view); + } } return createUnrecognizedEditPart(context, model); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UMLBaseItemSemanticEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UMLBaseItemSemanticEditPolicy.java index e6a3ae04104..b9545365740 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UMLBaseItemSemanticEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UMLBaseItemSemanticEditPolicy.java @@ -58,13 +58,17 @@ import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; import org.eclipse.uml2.uml.Comment; import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.DurationConstraint; +import org.eclipse.uml2.uml.DurationObservation; import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.GeneralOrdering; import org.eclipse.uml2.uml.Interaction; import org.eclipse.uml2.uml.InteractionFragment; import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.Namespace; import org.eclipse.uml2.uml.OccurrenceSpecification; +import org.eclipse.uml2.uml.Package; import org.eclipse.uml2.uml.UMLPackage; /** @@ -475,6 +479,20 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { /** * @generated */ + public boolean canCreateDurationConstraint_Edge(Namespace container, Element source, Element target) { + return canExistDurationConstraint_Edge(container, null, source, target); + } + + /** + * @generated + */ + public boolean canCreateDurationObservation_Edge(Package container, NamedElement source, NamedElement target) { + return canExistDurationObservation_Edge(container, null, source, target); + } + + /** + * @generated + */ public boolean canExistMessage_SynchEdge(Interaction container, Message linkInstance, Element source, Element target) { try { @@ -745,6 +763,22 @@ public class UMLBaseItemSemanticEditPolicy extends SemanticEditPolicy { public boolean canExistConstraint_ContextEdge(Constraint source, Namespace target) { return true; } + + /** + * @generated + */ + public boolean canExistDurationConstraint_Edge(Namespace container, DurationConstraint linkInstance, + Element source, Element target) { + return true; + } + + /** + * @generated + */ + public boolean canExistDurationObservation_Edge(Package container, DurationObservation linkInstance, + NamedElement source, NamedElement target) { + return true; + } } } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/Messages.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/Messages.java index 5c750bf205a..a0bd11969ba 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/Messages.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/Messages.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 CEA LIST. + * Copyright (c) 2016, 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * CEA LIST - Initial API and implementation + * Christian W. Damus - bug 536486 */ package org.eclipse.papyrus.uml.diagram.sequence.part; @@ -254,292 +255,292 @@ public class Messages extends NLS { public static String ValidateActionMessage; /** - * @generated + * @generated not */ public static String Nodes1Group_title; /** - * @generated + * @generated not */ public static String Nodes1Group_desc; /** - * @generated + * @generated not */ public static String Edges2Group_title; /** - * @generated + * @generated not */ public static String Edges2Group_desc; /** - * @generated + * @generated not */ public static String Lifeline1CreationTool_title; /** - * @generated + * @generated not */ public static String Lifeline1CreationTool_desc; /** - * @generated + * @generated not */ public static String ActionExecutionSpecification2CreationTool_title; /** - * @generated + * @generated not */ public static String ActionExecutionSpecification2CreationTool_desc; /** - * @generated + * @generated not */ public static String BehaviorExecutionSpecification3CreationTool_title; /** - * @generated + * @generated not */ public static String BehaviorExecutionSpecification3CreationTool_desc; /** - * @generated + * @generated not */ public static String InteractionUse4CreationTool_title; /** - * @generated + * @generated not */ public static String InteractionUse4CreationTool_desc; /** - * @generated + * @generated not */ public static String CombinedFragment5CreationTool_title; /** - * @generated + * @generated not */ public static String CombinedFragment5CreationTool_desc; /** - * @generated + * @generated not */ public static String InteractionOperand6CreationTool_title; /** - * @generated + * @generated not */ public static String InteractionOperand6CreationTool_desc; /** - * @generated + * @generated not */ public static String Continuation7CreationTool_title; /** - * @generated + * @generated not */ public static String Continuation7CreationTool_desc; /** - * @generated + * @generated not */ public static String StateInvariant8CreationTool_title; /** - * @generated + * @generated not */ public static String StateInvariant8CreationTool_desc; /** - * @generated + * @generated not */ public static String Comment9CreationTool_title; /** - * @generated + * @generated not */ public static String Comment9CreationTool_desc; /** - * @generated + * @generated not */ public static String Constraint10CreationTool_title; /** - * @generated + * @generated not */ public static String Constraint10CreationTool_desc; /** - * @generated + * @generated not */ public static String DurationObservation11CreationTool_title; /** - * @generated + * @generated not */ public static String DurationObservation11CreationTool_desc; /** - * @generated + * @generated not */ public static String TimeConstraint12CreationTool_title; /** - * @generated + * @generated not */ public static String TimeConstraint12CreationTool_desc; /** - * @generated + * @generated not */ public static String TimeObservation13CreationTool_title; /** - * @generated + * @generated not */ public static String TimeObservation13CreationTool_desc; /** - * @generated + * @generated not */ public static String DurationConstraint14CreationTool_title; /** - * @generated + * @generated not */ public static String DurationConstraint14CreationTool_desc; /** - * @generated + * @generated not */ public static String NEWGateCreationTool_title; /** - * @generated + * @generated not */ public static String NEWGateCreationTool_desc; /** - * @generated + * @generated not */ public static String ConsiderIgnoreFragment16CreationTool_title; /** - * @generated + * @generated not */ public static String ConsiderIgnoreFragment16CreationTool_desc; /** - * @generated + * @generated not */ public static String MessageSync1CreationTool_title; /** - * @generated + * @generated not */ public static String MessageSync1CreationTool_desc; /** - * @generated + * @generated not */ public static String MessageAsync2CreationTool_title; /** - * @generated + * @generated not */ public static String MessageAsync2CreationTool_desc; /** - * @generated + * @generated not */ public static String MessageReply3CreationTool_title; /** - * @generated + * @generated not */ public static String MessageReply3CreationTool_desc; /** - * @generated + * @generated not */ public static String MessageCreate4CreationTool_title; /** - * @generated + * @generated not */ public static String MessageCreate4CreationTool_desc; /** - * @generated + * @generated not */ public static String MessageDelete5CreationTool_title; /** - * @generated + * @generated not */ public static String MessageDelete5CreationTool_desc; /** - * @generated + * @generated not */ public static String MessageLost6CreationTool_title; /** - * @generated + * @generated not */ public static String MessageLost6CreationTool_desc; /** - * @generated + * @generated not */ public static String MessageFound7CreationTool_title; /** - * @generated + * @generated not */ public static String MessageFound7CreationTool_desc; /** - * @generated + * @generated not */ public static String GeneralOrdering8CreationTool_title; /** - * @generated + * @generated not */ public static String GeneralOrdering8CreationTool_desc; /** - * @generated + * @generated not */ public static String Commentlink9CreationTool_title; /** - * @generated + * @generated not */ public static String Commentlink9CreationTool_desc; /** - * @generated + * @generated not */ public static String Constraintlink10CreationTool_title; /** - * @generated + * @generated not */ public static String Constraintlink10CreationTool_desc; /** - * @generated + * @generated not */ public static String ContextLink11CreationTool_title; /** - * @generated + * @generated not */ public static String ContextLink11CreationTool_desc; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditor.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditor.java index 6930fea96d3..d5552fa9e14 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditor.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditor.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016 CEA LIST. + * Copyright (c) 2016, 2018 CEA LIST, Christian W. Damus, and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * CEA LIST - Initial API and implementation + * Christian W. Damus - bug 536486 */ package org.eclipse.papyrus.uml.diagram.sequence.part; @@ -127,7 +128,7 @@ public class UMLDiagramEditor extends UmlGmfDiagramEditor implements IProviderCh } /** - * @generated + * @generated NOT */ @Override protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditorUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditorUtil.java index 7c83ae7baa4..2c7f284fdbd 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditorUtil.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditorUtil.java @@ -189,7 +189,7 @@ public class UMLDiagramEditorUtil { * Create a new instance of domain element associated with canvas. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * + * * @generated */ private static Package createInitialModel() { @@ -200,7 +200,7 @@ public class UMLDiagramEditorUtil { * Store model element in the resource. * <!-- begin-user-doc --> * <!-- end-user-doc --> - * + * * @generated */ private static void attachModelToResource(Package model, Resource resource) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramUpdater.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramUpdater.java index 952d248d15c..2ffba826292 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramUpdater.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramUpdater.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2009, 2014 Atos Origin, CEA, and others. + * Copyright (c) 2009, 2018 Atos Origin, CEA, Christian W. Damus, and others. * * * All rights reserved. This program and the accompanying materials @@ -12,6 +12,7 @@ * Contributors: * Atos Origin - Initial API and implementation * Christian W. Damus (CEA) - bug 410909 + * Christian W. Damus - bug 536486 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.part; @@ -27,9 +28,6 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.gmf.runtime.emf.core.util.CrossReferenceAdapter; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.updater.DiagramUpdater; -import org.eclipse.papyrus.uml.diagram.common.helper.DurationConstraintHelper; -import org.eclipse.papyrus.uml.diagram.common.helper.TimeConstraintHelper; -import org.eclipse.papyrus.uml.diagram.common.helper.TimeObservationHelper; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ActionExecutionSpecificationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.BehaviorExecutionSpecificationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CCombinedCompartmentEditPart; @@ -43,9 +41,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContextLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart; @@ -62,8 +59,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageReplyEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.SequenceDiagramEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintBorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationBorderNodeEditPart; import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes; import org.eclipse.uml2.uml.ActionExecutionSpecification; import org.eclipse.uml2.uml.BehaviorExecutionSpecification; @@ -84,6 +81,7 @@ import org.eclipse.uml2.uml.InteractionOperand; import org.eclipse.uml2.uml.InteractionUse; import org.eclipse.uml2.uml.Lifeline; import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.Namespace; import org.eclipse.uml2.uml.OccurrenceSpecification; import org.eclipse.uml2.uml.Package; @@ -130,6 +128,12 @@ public class UMLDiagramUpdater implements DiagramUpdater { return getInteractionUse_Shape_SemanticChildren(view); case LifelineEditPart.VISUAL_ID: return getLifeline_Shape_SemanticChildren(view); + case ActionExecutionSpecificationEditPart.VISUAL_ID: + return getActionExecutionSpecification_Shape_SemanticChildren(view); + case BehaviorExecutionSpecificationEditPart.VISUAL_ID: + return getBehaviorExecutionSpecification_Shape_SemanticChildren(view); + case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: + return getDestructionOccurrenceSpecification_Shape_SemanticChildren(view); case InteractionInteractionCompartmentEditPart.VISUAL_ID: return getInteraction_SubfragmentCompartment_SemanticChildren(view); case CombinedFragmentCombinedFragmentCompartmentEditPart.VISUAL_ID: @@ -301,10 +305,10 @@ public class UMLDiagramUpdater implements DiagramUpdater { */ public static List<UMLNodeDescriptor> getInteraction_Shape_SemanticChildren(View view) { if (!view.isSetElement()) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } Interaction modelElement = (Interaction) view.getElement(); - List result = new LinkedList(); + List<UMLNodeDescriptor> result = new LinkedList<>(); // remove fake children for messages (DurationConstraintInMessageEditPart/DurationObservationEditPart) return result; } @@ -331,7 +335,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated NOT (update at each lifeline modification) Added code for manage ExecutionSpecification, handle TimeConstraintEditPart and - * DurationConstraintEditPart children, handle TimeObservationEditPart children + * handle TimeObservationEditPart children */ public static List<UMLNodeDescriptor> getLifeline_Shape_SemanticChildren(View view) { if (!view.isSetElement()) { @@ -366,44 +370,78 @@ public class UMLDiagramUpdater implements DiagramUpdater { } } } - /* - * Autogenerated code not valid for (Iterator it = modelElement.getFragments().iterator(); - * it.hasNext();) { InteractionFragment childElement = (InteractionFragment) it.next(); int - * visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); if (visualID == - * BehaviorExecutionSpecificationEditPart.VISUAL_ID) { result.add(new - * UMLNodeDescriptor(childElement, visualID)); continue; } } - */ - // handle TimeConstraintEditPart and DurationConstraintEditPart children - if (modelElement instanceof Lifeline) { - for (InteractionFragment covering : modelElement.getCoveredBys()) { - for (TimeConstraint childElement : TimeConstraintHelper.getTimeConstraintsOn(covering)) { - // block from generated code - String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (TimeConstraintEditPart.VISUAL_ID.equals(visualID)) { - result.add(new UMLNodeDescriptor(childElement, visualID)); - continue; - } - } - for (DurationConstraint childElement : DurationConstraintHelper.getDurationConstraintsOn(covering)) { - // block from generated code - String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (DurationConstraintEditPart.VISUAL_ID.equals(visualID)) { - result.add(new UMLNodeDescriptor(childElement, visualID)); - continue; - } - } + return result; + } + + /** + * @generated NOT + */ + public List<UMLNodeDescriptor> getActionExecutionSpecification_Shape_SemanticChildren(View view) { + if (!view.isSetElement()) { + return Collections.emptyList(); + } + ActionExecutionSpecification modelElement = (ActionExecutionSpecification) view.getElement(); + LinkedList<UMLNodeDescriptor> result = new LinkedList<>(); + Interaction interaction = modelElement.getEnclosingInteraction(); + if (interaction == null) { + return Collections.emptyList(); + } + for (Iterator<?> it = interaction.getOwnedRules().iterator(); it.hasNext();) { + Constraint childElement = (Constraint) it.next(); + String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); + if (TimeConstraintBorderNodeEditPart.VISUAL_ID.equals(visualID)) { + result.add(new UMLNodeDescriptor(childElement, visualID)); + continue; } } - // handle TimeObservationEditPart children - if (modelElement instanceof Lifeline) { - for (InteractionFragment covering : modelElement.getCoveredBys()) { - for (TimeObservation childElement : TimeObservationHelper.getTimeObservations(covering)) { - // block from generated code - String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); - if (TimeObservationEditPart.VISUAL_ID.equals(visualID)) { - result.add(new UMLNodeDescriptor(childElement, visualID)); - continue; - } + return result; + } + + /** + * @generated NOT + */ + public List<UMLNodeDescriptor> getBehaviorExecutionSpecification_Shape_SemanticChildren(View view) { + if (!view.isSetElement()) { + return Collections.emptyList(); + } + BehaviorExecutionSpecification modelElement = (BehaviorExecutionSpecification) view.getElement(); + LinkedList<UMLNodeDescriptor> result = new LinkedList<>(); + Interaction interaction = modelElement.getEnclosingInteraction(); + if (interaction == null) { + return Collections.emptyList(); + } + for (Iterator<?> it = interaction.getOwnedRules().iterator(); it.hasNext();) { + Constraint childElement = (Constraint) it.next(); + String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); + if (TimeConstraintBorderNodeEditPart.VISUAL_ID.equals(visualID)) { + result.add(new UMLNodeDescriptor(childElement, visualID)); + continue; + } + } + return result; + } + + /** + * @generated NOT + */ + public List<UMLNodeDescriptor> getDestructionOccurrenceSpecification_Shape_SemanticChildren(View view) { + if (!view.isSetElement()) { + return Collections.emptyList(); + } + DestructionOccurrenceSpecification modelElement = (DestructionOccurrenceSpecification) view.getElement(); + Interaction interaction = modelElement.getEnclosingInteraction(); + if (interaction == null) { + return Collections.emptyList(); + } + LinkedList<UMLNodeDescriptor> result = new LinkedList<>(); + for (Iterator<?> it = interaction.getOwnedRules().iterator(); it.hasNext();) { + Constraint childElement = (Constraint) it.next(); + // Does it constrain this destruction occurrence? + if (childElement.getConstrainedElements().contains(modelElement)) { + String visualID = UMLVisualIDRegistry.getNodeVisualID(view, childElement); + if (TimeConstraintBorderNodeEditPart.VISUAL_ID.equals(visualID)) { + result.add(new UMLNodeDescriptor(childElement, visualID)); + continue; } } } @@ -440,24 +478,18 @@ public class UMLDiagramUpdater implements DiagramUpdater { return getBehaviorExecutionSpecification_Shape_ContainedLinks(view); case StateInvariantEditPart.VISUAL_ID: return getStateInvariant_Shape_ContainedLinks(view); - case TimeConstraintEditPart.VISUAL_ID: - return getTimeConstraint_Shape_ContainedLinks(view); - case TimeObservationEditPart.VISUAL_ID: - return getTimeObservation_Shape_ContainedLinks(view); - case DurationConstraintEditPart.VISUAL_ID: - return getDurationConstraint_Shape_ContainedLinks(view); case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: return getDestructionOccurrenceSpecification_Shape_ContainedLinks(view); case ConstraintEditPart.VISUAL_ID: return getConstraint_Shape_ContainedLinks(view); case CommentEditPart.VISUAL_ID: return getComment_Shape_ContainedLinks(view); - case DurationConstraintInMessageEditPart.VISUAL_ID: - return getDurationConstraint_Shape_CN_ContainedLinks(view); - case DurationObservationEditPart.VISUAL_ID: - return getDurationObservation_Shape_ContainedLinks(view); case GateEditPart.VISUAL_ID: return getGate_Shape_ContainedLinks(view); + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + return getTimeConstraint_Shape_ContainedLinks(view); + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return getTimeObservation_Shape_ContainedLinks(view); case MessageSyncEditPart.VISUAL_ID: return getMessage_SynchEdge_ContainedLinks(view); case MessageAsyncEditPart.VISUAL_ID: @@ -474,6 +506,10 @@ public class UMLDiagramUpdater implements DiagramUpdater { return getMessage_FoundEdge_ContainedLinks(view); case GeneralOrderingEditPart.VISUAL_ID: return getGeneralOrdering_Edge_ContainedLinks(view); + case DurationConstraintLinkEditPart.VISUAL_ID: + return getDurationConstraint_Edge_ContainedLinks(view); + case DurationObservationLinkEditPart.VISUAL_ID: + return getDurationObservation_Edge_ContainedLinks(view); } } return Collections.emptyList(); @@ -507,24 +543,18 @@ public class UMLDiagramUpdater implements DiagramUpdater { return getBehaviorExecutionSpecification_Shape_IncomingLinks(view); case StateInvariantEditPart.VISUAL_ID: return getStateInvariant_Shape_IncomingLinks(view); - case TimeConstraintEditPart.VISUAL_ID: - return getTimeConstraint_Shape_IncomingLinks(view); - case TimeObservationEditPart.VISUAL_ID: - return getTimeObservation_Shape_IncomingLinks(view); - case DurationConstraintEditPart.VISUAL_ID: - return getDurationConstraint_Shape_IncomingLinks(view); case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: return getDestructionOccurrenceSpecification_Shape_IncomingLinks(view); case ConstraintEditPart.VISUAL_ID: return getConstraint_Shape_IncomingLinks(view); case CommentEditPart.VISUAL_ID: return getComment_Shape_IncomingLinks(view); - case DurationConstraintInMessageEditPart.VISUAL_ID: - return getDurationConstraint_Shape_CN_IncomingLinks(view); - case DurationObservationEditPart.VISUAL_ID: - return getDurationObservation_Shape_IncomingLinks(view); case GateEditPart.VISUAL_ID: return getGate_Shape_IncomingLinks(view); + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + return getTimeConstraint_Shape_IncomingLinks(view); + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return getTimeObservation_Shape_IncomingLinks(view); case MessageSyncEditPart.VISUAL_ID: return getMessage_SynchEdge_IncomingLinks(view); case MessageAsyncEditPart.VISUAL_ID: @@ -541,6 +571,10 @@ public class UMLDiagramUpdater implements DiagramUpdater { return getMessage_FoundEdge_IncomingLinks(view); case GeneralOrderingEditPart.VISUAL_ID: return getGeneralOrdering_Edge_IncomingLinks(view); + case DurationConstraintLinkEditPart.VISUAL_ID: + return getDurationConstraint_Edge_IncomingLinks(view); + case DurationObservationLinkEditPart.VISUAL_ID: + return getDurationObservation_Edge_IncomingLinks(view); } } return Collections.emptyList(); @@ -574,24 +608,18 @@ public class UMLDiagramUpdater implements DiagramUpdater { return getBehaviorExecutionSpecification_Shape_OutgoingLinks(view); case StateInvariantEditPart.VISUAL_ID: return getStateInvariant_Shape_OutgoingLinks(view); - case TimeConstraintEditPart.VISUAL_ID: - return getTimeConstraint_Shape_OutgoingLinks(view); - case TimeObservationEditPart.VISUAL_ID: - return getTimeObservation_Shape_OutgoingLinks(view); - case DurationConstraintEditPart.VISUAL_ID: - return getDurationConstraint_Shape_OutgoingLinks(view); case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: return getDestructionOccurrenceSpecification_Shape_OutgoingLinks(view); case ConstraintEditPart.VISUAL_ID: return getConstraint_Shape_OutgoingLinks(view); case CommentEditPart.VISUAL_ID: return getComment_Shape_OutgoingLinks(view); - case DurationConstraintInMessageEditPart.VISUAL_ID: - return getDurationConstraint_Shape_CN_OutgoingLinks(view); - case DurationObservationEditPart.VISUAL_ID: - return getDurationObservation_Shape_OutgoingLinks(view); case GateEditPart.VISUAL_ID: return getGate_Shape_OutgoingLinks(view); + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + return getTimeConstraint_Shape_OutgoingLinks(view); + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return getTimeObservation_Shape_OutgoingLinks(view); case MessageSyncEditPart.VISUAL_ID: return getMessage_SynchEdge_OutgoingLinks(view); case MessageAsyncEditPart.VISUAL_ID: @@ -608,6 +636,10 @@ public class UMLDiagramUpdater implements DiagramUpdater { return getMessage_FoundEdge_OutgoingLinks(view); case GeneralOrderingEditPart.VISUAL_ID: return getGeneralOrdering_Edge_OutgoingLinks(view); + case DurationConstraintLinkEditPart.VISUAL_ID: + return getDurationConstraint_Edge_OutgoingLinks(view); + case DurationObservationLinkEditPart.VISUAL_ID: + return getDurationObservation_Edge_OutgoingLinks(view); } } return Collections.emptyList(); @@ -617,7 +649,11 @@ public class UMLDiagramUpdater implements DiagramUpdater { * @generated */ public List<UMLLinkDescriptor> getPackage_SequenceDiagram_ContainedLinks(View view) { - return Collections.emptyList(); + Package modelElement = (Package) view.getElement(); + LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); + result.addAll(getContainedTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getContainedTypeModelFacetLinks_DurationObservation_Edge(modelElement)); + return result; } /** @@ -634,6 +670,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getContainedTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getContainedTypeModelFacetLinks_Message_FoundEdge(modelElement)); result.addAll(getContainedTypeModelFacetLinks_GeneralOrdering_Edge(modelElement)); + result.addAll(getContainedTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); return result; } @@ -664,6 +701,7 @@ public class UMLDiagramUpdater implements DiagramUpdater { InteractionOperand modelElement = (InteractionOperand) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getContainedTypeModelFacetLinks_GeneralOrdering_Edge(modelElement)); + result.addAll(getContainedTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); return result; } @@ -727,35 +765,6 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - public List<UMLLinkDescriptor> getTimeConstraint_Shape_ContainedLinks(View view) { - TimeConstraint modelElement = (TimeConstraint) view.getElement(); - LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); - return result; - } - - /** - * @generated - */ - public List<UMLLinkDescriptor> getTimeObservation_Shape_ContainedLinks(View view) { - return Collections.emptyList(); - } - - /** - * @generated - */ - public List<UMLLinkDescriptor> getDurationConstraint_Shape_ContainedLinks(View view) { - DurationConstraint modelElement = (DurationConstraint) view.getElement(); - LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); - return result; - } - - /** - * @generated - */ public List<UMLLinkDescriptor> getDestructionOccurrenceSpecification_Shape_ContainedLinks(View view) { DestructionOccurrenceSpecification modelElement = (DestructionOccurrenceSpecification) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -787,25 +796,25 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ - public List<UMLLinkDescriptor> getDurationConstraint_Shape_CN_ContainedLinks(View view) { - DurationConstraint modelElement = (DurationConstraint) view.getElement(); - LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); - return result; + public List<UMLLinkDescriptor> getGate_Shape_ContainedLinks(View view) { + return Collections.emptyList(); } /** * @generated */ - public List<UMLLinkDescriptor> getDurationObservation_Shape_ContainedLinks(View view) { - return Collections.emptyList(); + public List<UMLLinkDescriptor> getTimeConstraint_Shape_ContainedLinks(View view) { + TimeConstraint modelElement = (TimeConstraint) view.getElement(); + LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); + result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); + result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); + return result; } /** * @generated */ - public List<UMLLinkDescriptor> getGate_Shape_ContainedLinks(View view) { + public List<UMLLinkDescriptor> getTimeObservation_Shape_ContainedLinks(View view) { return Collections.emptyList(); } @@ -868,6 +877,24 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ + public List<UMLLinkDescriptor> getDurationConstraint_Edge_ContainedLinks(View view) { + DurationConstraint modelElement = (DurationConstraint) view.getElement(); + LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); + result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); + result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); + return result; + } + + /** + * @generated + */ + public List<UMLLinkDescriptor> getDurationObservation_Edge_ContainedLinks(View view) { + return Collections.emptyList(); + } + + /** + * @generated + */ public List<UMLLinkDescriptor> getInteraction_Shape_IncomingLinks(View view) { Interaction modelElement = (Interaction) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter @@ -884,6 +911,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -905,6 +934,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -926,6 +957,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -948,6 +981,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); result.addAll(getIncomingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -969,6 +1004,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -990,6 +1027,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -1011,6 +1050,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -1032,6 +1073,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -1053,6 +1096,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -1074,35 +1119,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getTimeConstraint_Shape_IncomingLinks(View view) { - TimeConstraint modelElement = (TimeConstraint) view.getElement(); - CrossReferenceAdapter crossReferencer = CrossReferenceAdapter - .getCrossReferenceAdapter(view.eResource().getResourceSet()); - LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); - result.addAll(getIncomingTypeModelFacetLinks_Message_SynchEdge(modelElement, crossReferencer)); - result.addAll(getIncomingTypeModelFacetLinks_Message_AsynchEdge(modelElement, crossReferencer)); - result.addAll(getIncomingTypeModelFacetLinks_Message_ReplyEdge(modelElement, crossReferencer)); - result.addAll(getIncomingTypeModelFacetLinks_Message_CreateEdge(modelElement, crossReferencer)); - result.addAll(getIncomingTypeModelFacetLinks_Message_DeleteEdge(modelElement, crossReferencer)); - result.addAll(getIncomingTypeModelFacetLinks_Message_LostEdge(modelElement, crossReferencer)); - result.addAll(getIncomingTypeModelFacetLinks_Message_FoundEdge(modelElement, crossReferencer)); - result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); - result.addAll( - getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); - return result; - } - - /** - * @generated - */ - public List<UMLLinkDescriptor> getTimeObservation_Shape_IncomingLinks(View view) { - TimeObservation modelElement = (TimeObservation) view.getElement(); + public List<UMLLinkDescriptor> getDestructionOccurrenceSpecification_Shape_IncomingLinks(View view) { + DestructionOccurrenceSpecification modelElement = (DestructionOccurrenceSpecification) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1116,14 +1142,17 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_GeneralOrdering_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getDurationConstraint_Shape_IncomingLinks(View view) { - DurationConstraint modelElement = (DurationConstraint) view.getElement(); + public List<UMLLinkDescriptor> getConstraint_Shape_IncomingLinks(View view) { + Constraint modelElement = (Constraint) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1137,14 +1166,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getDestructionOccurrenceSpecification_Shape_IncomingLinks(View view) { - DestructionOccurrenceSpecification modelElement = (DestructionOccurrenceSpecification) view.getElement(); + public List<UMLLinkDescriptor> getComment_Shape_IncomingLinks(View view) { + Comment modelElement = (Comment) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1158,15 +1189,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); - result.addAll(getIncomingTypeModelFacetLinks_GeneralOrdering_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getConstraint_Shape_IncomingLinks(View view) { - Constraint modelElement = (Constraint) view.getElement(); + public List<UMLLinkDescriptor> getGate_Shape_IncomingLinks(View view) { + Gate modelElement = (Gate) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1180,14 +1211,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getComment_Shape_IncomingLinks(View view) { - Comment modelElement = (Comment) view.getElement(); + public List<UMLLinkDescriptor> getTimeConstraint_Shape_IncomingLinks(View view) { + TimeConstraint modelElement = (TimeConstraint) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1201,14 +1234,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getDurationConstraint_Shape_CN_IncomingLinks(View view) { - DurationConstraint modelElement = (DurationConstraint) view.getElement(); + public List<UMLLinkDescriptor> getTimeObservation_Shape_IncomingLinks(View view) { + TimeObservation modelElement = (TimeObservation) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1222,14 +1257,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getDurationObservation_Shape_IncomingLinks(View view) { - DurationObservation modelElement = (DurationObservation) view.getElement(); + public List<UMLLinkDescriptor> getMessage_SynchEdge_IncomingLinks(View view) { + Message modelElement = (Message) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1243,14 +1280,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getGate_Shape_IncomingLinks(View view) { - Gate modelElement = (Gate) view.getElement(); + public List<UMLLinkDescriptor> getMessage_AsynchEdge_IncomingLinks(View view) { + Message modelElement = (Message) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1264,13 +1303,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_SynchEdge_IncomingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_ReplyEdge_IncomingLinks(View view) { Message modelElement = (Message) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); @@ -1285,13 +1326,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_AsynchEdge_IncomingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_CreateEdge_IncomingLinks(View view) { Message modelElement = (Message) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); @@ -1306,13 +1349,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_ReplyEdge_IncomingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_DeleteEdge_IncomingLinks(View view) { Message modelElement = (Message) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); @@ -1327,13 +1372,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_CreateEdge_IncomingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_LostEdge_IncomingLinks(View view) { Message modelElement = (Message) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); @@ -1348,13 +1395,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_DeleteEdge_IncomingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_FoundEdge_IncomingLinks(View view) { Message modelElement = (Message) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); @@ -1369,14 +1418,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_LostEdge_IncomingLinks(View view) { - Message modelElement = (Message) view.getElement(); + public List<UMLLinkDescriptor> getGeneralOrdering_Edge_IncomingLinks(View view) { + GeneralOrdering modelElement = (GeneralOrdering) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1390,14 +1441,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_FoundEdge_IncomingLinks(View view) { - Message modelElement = (Message) view.getElement(); + public List<UMLLinkDescriptor> getDurationConstraint_Edge_IncomingLinks(View view) { + DurationConstraint modelElement = (DurationConstraint) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1411,14 +1464,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getGeneralOrdering_Edge_IncomingLinks(View view) { - GeneralOrdering modelElement = (GeneralOrdering) view.getElement(); + public List<UMLLinkDescriptor> getDurationObservation_Edge_IncomingLinks(View view) { + DurationObservation modelElement = (DurationObservation) view.getElement(); CrossReferenceAdapter crossReferencer = CrossReferenceAdapter .getCrossReferenceAdapter(view.eResource().getResourceSet()); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -1432,6 +1487,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getIncomingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement, crossReferencer)); result.addAll( getIncomingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationConstraint_Edge(modelElement, crossReferencer)); + result.addAll(getIncomingTypeModelFacetLinks_DurationObservation_Edge(modelElement, crossReferencer)); return result; } @@ -1448,6 +1505,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -1464,6 +1523,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -1480,6 +1541,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -1496,6 +1559,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -1512,6 +1577,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -1528,6 +1595,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -1544,6 +1613,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -1560,6 +1631,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -1576,6 +1649,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -1592,32 +1667,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getTimeConstraint_Shape_OutgoingLinks(View view) { - TimeConstraint modelElement = (TimeConstraint) view.getElement(); - LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); - result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); - result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); - result.addAll(getOutgoingTypeModelFacetLinks_Message_ReplyEdge(modelElement)); - result.addAll(getOutgoingTypeModelFacetLinks_Message_CreateEdge(modelElement)); - result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); - result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); - result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); - return result; - } - - /** - * @generated - */ - public List<UMLLinkDescriptor> getTimeObservation_Shape_OutgoingLinks(View view) { - TimeObservation modelElement = (TimeObservation) view.getElement(); + public List<UMLLinkDescriptor> getDestructionOccurrenceSpecification_Shape_OutgoingLinks(View view) { + DestructionOccurrenceSpecification modelElement = (DestructionOccurrenceSpecification) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1626,14 +1685,17 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_GeneralOrdering_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getDurationConstraint_Shape_OutgoingLinks(View view) { - DurationConstraint modelElement = (DurationConstraint) view.getElement(); + public List<UMLLinkDescriptor> getConstraint_Shape_OutgoingLinks(View view) { + Constraint modelElement = (Constraint) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1644,14 +1706,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getDestructionOccurrenceSpecification_Shape_OutgoingLinks(View view) { - DestructionOccurrenceSpecification modelElement = (DestructionOccurrenceSpecification) view.getElement(); + public List<UMLLinkDescriptor> getComment_Shape_OutgoingLinks(View view) { + Comment modelElement = (Comment) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1660,15 +1724,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); - result.addAll(getOutgoingTypeModelFacetLinks_GeneralOrdering_Edge(modelElement)); + result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getConstraint_Shape_OutgoingLinks(View view) { - Constraint modelElement = (Constraint) view.getElement(); + public List<UMLLinkDescriptor> getGate_Shape_OutgoingLinks(View view) { + Gate modelElement = (Gate) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1677,16 +1742,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getComment_Shape_OutgoingLinks(View view) { - Comment modelElement = (Comment) view.getElement(); + public List<UMLLinkDescriptor> getTimeConstraint_Shape_OutgoingLinks(View view) { + TimeConstraint modelElement = (TimeConstraint) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1695,15 +1760,18 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Comment_AnnotatedElementEdge(modelElement)); + result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); + result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getDurationConstraint_Shape_CN_OutgoingLinks(View view) { - DurationConstraint modelElement = (DurationConstraint) view.getElement(); + public List<UMLLinkDescriptor> getTimeObservation_Shape_OutgoingLinks(View view) { + TimeObservation modelElement = (TimeObservation) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1712,16 +1780,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); - result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getDurationObservation_Shape_OutgoingLinks(View view) { - DurationObservation modelElement = (DurationObservation) view.getElement(); + public List<UMLLinkDescriptor> getMessage_SynchEdge_OutgoingLinks(View view) { + Message modelElement = (Message) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1730,14 +1798,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getGate_Shape_OutgoingLinks(View view) { - Gate modelElement = (Gate) view.getElement(); + public List<UMLLinkDescriptor> getMessage_AsynchEdge_OutgoingLinks(View view) { + Message modelElement = (Message) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1746,13 +1816,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_SynchEdge_OutgoingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_ReplyEdge_OutgoingLinks(View view) { Message modelElement = (Message) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); @@ -1762,13 +1834,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_AsynchEdge_OutgoingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_CreateEdge_OutgoingLinks(View view) { Message modelElement = (Message) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); @@ -1778,13 +1852,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_ReplyEdge_OutgoingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_DeleteEdge_OutgoingLinks(View view) { Message modelElement = (Message) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); @@ -1794,13 +1870,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_CreateEdge_OutgoingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_LostEdge_OutgoingLinks(View view) { Message modelElement = (Message) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); @@ -1810,13 +1888,15 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_DeleteEdge_OutgoingLinks(View view) { + public List<UMLLinkDescriptor> getMessage_FoundEdge_OutgoingLinks(View view) { Message modelElement = (Message) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); @@ -1826,14 +1906,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_LostEdge_OutgoingLinks(View view) { - Message modelElement = (Message) view.getElement(); + public List<UMLLinkDescriptor> getGeneralOrdering_Edge_OutgoingLinks(View view) { + GeneralOrdering modelElement = (GeneralOrdering) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1842,14 +1924,16 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getMessage_FoundEdge_OutgoingLinks(View view) { - Message modelElement = (Message) view.getElement(); + public List<UMLLinkDescriptor> getDurationConstraint_Edge_OutgoingLinks(View view) { + DurationConstraint modelElement = (DurationConstraint) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1858,14 +1942,18 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ConstrainedElementEdge(modelElement)); + result.addAll(getOutgoingFeatureModelFacetLinks_Constraint_ContextEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } /** * @generated */ - public List<UMLLinkDescriptor> getGeneralOrdering_Edge_OutgoingLinks(View view) { - GeneralOrdering modelElement = (GeneralOrdering) view.getElement(); + public List<UMLLinkDescriptor> getDurationObservation_Edge_OutgoingLinks(View view) { + DurationObservation modelElement = (DurationObservation) view.getElement(); LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); result.addAll(getOutgoingTypeModelFacetLinks_Message_SynchEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_AsynchEdge(modelElement)); @@ -1874,6 +1962,8 @@ public class UMLDiagramUpdater implements DiagramUpdater { result.addAll(getOutgoingTypeModelFacetLinks_Message_DeleteEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_LostEdge(modelElement)); result.addAll(getOutgoingTypeModelFacetLinks_Message_FoundEdge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(modelElement)); + result.addAll(getOutgoingTypeModelFacetLinks_DurationObservation_Edge(modelElement)); return result; } @@ -2092,6 +2182,72 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ + protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_DurationConstraint_Edge( + Namespace container) { + LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); + for (Iterator<?> links = container.getOwnedRules().iterator(); links.hasNext();) { + EObject linkObject = (EObject) links.next(); + if (false == linkObject instanceof DurationConstraint) { + continue; + } + DurationConstraint link = (DurationConstraint) linkObject; + if (!DurationConstraintLinkEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + continue; + } + List<?> targets = link.getConstrainedElements(); + Object theTarget = targets.size() == 1 ? targets.get(0) : null; + if (false == theTarget instanceof Element) { + continue; + } + Element dst = (Element) theTarget; + List<?> sources = link.getConstrainedElements(); + Object theSource = sources.size() == 1 ? sources.get(0) : null; + if (false == theSource instanceof Element) { + continue; + } + Element src = (Element) theSource; + result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.DurationConstraint_Edge, + DurationConstraintLinkEditPart.VISUAL_ID)); + } + return result; + } + + /** + * @generated + */ + protected Collection<UMLLinkDescriptor> getContainedTypeModelFacetLinks_DurationObservation_Edge( + Package container) { + LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); + for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) { + EObject linkObject = (EObject) links.next(); + if (false == linkObject instanceof DurationObservation) { + continue; + } + DurationObservation link = (DurationObservation) linkObject; + if (!DurationObservationLinkEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + continue; + } + List<?> targets = link.getEvents(); + Object theTarget = targets.size() == 1 ? targets.get(0) : null; + if (false == theTarget instanceof NamedElement) { + continue; + } + NamedElement dst = (NamedElement) theTarget; + List<?> sources = link.getEvents(); + Object theSource = sources.size() == 1 ? sources.get(0) : null; + if (false == theSource instanceof NamedElement) { + continue; + } + NamedElement src = (NamedElement) theSource; + result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.DurationObservation_Edge, + DurationObservationLinkEditPart.VISUAL_ID)); + } + return result; + } + + /** + * @generated + */ protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_Message_SynchEdge(Element target, CrossReferenceAdapter crossReferencer) { LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); @@ -2325,6 +2481,62 @@ public class UMLDiagramUpdater implements DiagramUpdater { /** * @generated */ + protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_DurationConstraint_Edge(Element target, + CrossReferenceAdapter crossReferencer) { + LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); + Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target); + for (EStructuralFeature.Setting setting : settings) { + if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getConstraint_ConstrainedElement() + || false == setting.getEObject() instanceof DurationConstraint) { + continue; + } + DurationConstraint link = (DurationConstraint) setting.getEObject(); + if (!DurationConstraintLinkEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + continue; + } + List<?> sources = link.getConstrainedElements(); + Object theSource = sources.size() == 1 ? sources.get(0) : null; + if (false == theSource instanceof Element) { + continue; + } + Element src = (Element) theSource; + result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.DurationConstraint_Edge, + DurationConstraintLinkEditPart.VISUAL_ID)); + } + return result; + } + + /** + * @generated + */ + protected Collection<UMLLinkDescriptor> getIncomingTypeModelFacetLinks_DurationObservation_Edge(NamedElement target, + CrossReferenceAdapter crossReferencer) { + LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); + Collection<EStructuralFeature.Setting> settings = crossReferencer.getInverseReferences(target); + for (EStructuralFeature.Setting setting : settings) { + if (setting.getEStructuralFeature() != UMLPackage.eINSTANCE.getDurationObservation_Event() + || false == setting.getEObject() instanceof DurationObservation) { + continue; + } + DurationObservation link = (DurationObservation) setting.getEObject(); + if (!DurationObservationLinkEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + continue; + } + List<?> sources = link.getEvents(); + Object theSource = sources.size() == 1 ? sources.get(0) : null; + if (false == theSource instanceof NamedElement) { + continue; + } + NamedElement src = (NamedElement) theSource; + result.add(new UMLLinkDescriptor(src, target, link, UMLElementTypes.DurationObservation_Edge, + DurationObservationLinkEditPart.VISUAL_ID)); + } + return result; + } + + /** + * @generated + */ protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_Message_SynchEdge(Element source) { Interaction container = null; // Find container element for the link. @@ -2697,4 +2909,99 @@ public class UMLDiagramUpdater implements DiagramUpdater { return result; } + /** + * @generated + */ + protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_DurationConstraint_Edge(Element source) { + Namespace container = null; + // Find container element for the link. + // Climb up by containment hierarchy starting from the source + // and return the first element that is instance of the container class. + for (EObject element = source; element != null && container == null; element = element.eContainer()) { + if (element instanceof Namespace) { + container = (Namespace) element; + } + } + if (container == null) { + return Collections.emptyList(); + } + LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); + for (Iterator<?> links = container.getOwnedRules().iterator(); links.hasNext();) { + EObject linkObject = (EObject) links.next(); + if (false == linkObject instanceof DurationConstraint) { + continue; + } + DurationConstraint link = (DurationConstraint) linkObject; + if (!DurationConstraintLinkEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + continue; + } + List<?> targets = link.getConstrainedElements(); + Object theTarget = targets.size() == 1 ? targets.get(0) : null; + if (false == theTarget instanceof Element) { + continue; + } + Element dst = (Element) theTarget; + List<?> sources = link.getConstrainedElements(); + Object theSource = sources.size() == 1 ? sources.get(0) : null; + if (false == theSource instanceof Element) { + continue; + } + Element src = (Element) theSource; + if (src != source) { + continue; + } + result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.DurationConstraint_Edge, + DurationConstraintLinkEditPart.VISUAL_ID)); + } + return result; + } + + /** + * @generated + */ + protected Collection<UMLLinkDescriptor> getOutgoingTypeModelFacetLinks_DurationObservation_Edge( + NamedElement source) { + Package container = null; + // Find container element for the link. + // Climb up by containment hierarchy starting from the source + // and return the first element that is instance of the container class. + for (EObject element = source; element != null && container == null; element = element.eContainer()) { + if (element instanceof Package) { + container = (Package) element; + } + } + if (container == null) { + return Collections.emptyList(); + } + LinkedList<UMLLinkDescriptor> result = new LinkedList<>(); + for (Iterator<?> links = container.getPackagedElements().iterator(); links.hasNext();) { + EObject linkObject = (EObject) links.next(); + if (false == linkObject instanceof DurationObservation) { + continue; + } + DurationObservation link = (DurationObservation) linkObject; + if (!DurationObservationLinkEditPart.VISUAL_ID.equals(UMLVisualIDRegistry.getLinkWithClassVisualID(link))) { + continue; + } + List<?> targets = link.getEvents(); + Object theTarget = targets.size() == 1 ? targets.get(0) : null; + if (false == theTarget instanceof NamedElement) { + continue; + } + NamedElement dst = (NamedElement) theTarget; + List<?> sources = link.getEvents(); + Object theSource = sources.size() == 1 ? sources.get(0) : null; + if (false == theSource instanceof NamedElement) { + continue; + } + NamedElement src = (NamedElement) theSource; + if (src != source) { + continue; + } + result.add(new UMLLinkDescriptor(src, dst, link, UMLElementTypes.DurationObservation_Edge, + DurationObservationLinkEditPart.VISUAL_ID)); + } + return result; + } + } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLVisualIDRegistry.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLVisualIDRegistry.java index 5d7aef810ba..6b28e436e29 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLVisualIDRegistry.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLVisualIDRegistry.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2009 Atos Origin. + * Copyright (c) 2009, 2018 Atos Origin, Christian W. Damus, CEA LIST, and others. * * * All rights reserved. This program and the accompanying materials @@ -11,6 +11,7 @@ * * Contributors: * Atos Origin - Initial API and implementation + * Christian W. Damus - bug 536486 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.part; @@ -35,15 +36,12 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContextLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLabelEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkAppliedStereotypeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkNameEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkAppliedStereotypeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingAppliedStereotypeEditPart; @@ -83,11 +81,11 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPar import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantLabelEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintLabelEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintBorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationBorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.expressions.UMLOCLFactory; import org.eclipse.uml2.uml.Message; import org.eclipse.uml2.uml.Package; @@ -193,9 +191,6 @@ public class UMLVisualIDRegistry { } break; case InteractionEditPart.VISUAL_ID: - if (UMLPackage.eINSTANCE.getDurationConstraint().isSuperTypeOf(domainElement.eClass())) { - return DurationConstraintInMessageEditPart.VISUAL_ID; - } if (UMLPackage.eINSTANCE.getGate().isSuperTypeOf(domainElement.eClass())) { return GateEditPart.VISUAL_ID; } @@ -234,18 +229,39 @@ public class UMLVisualIDRegistry { if (UMLPackage.eINSTANCE.getStateInvariant().isSuperTypeOf(domainElement.eClass())) { return StateInvariantEditPart.VISUAL_ID; } + if (UMLPackage.eINSTANCE.getDestructionOccurrenceSpecification() + .isSuperTypeOf(domainElement.eClass())) { + return DestructionOccurrenceSpecificationEditPart.VISUAL_ID; + } if (UMLPackage.eINSTANCE.getTimeConstraint().isSuperTypeOf(domainElement.eClass())) { - return TimeConstraintEditPart.VISUAL_ID; + return TimeConstraintBorderNodeEditPart.VISUAL_ID; } if (UMLPackage.eINSTANCE.getTimeObservation().isSuperTypeOf(domainElement.eClass())) { - return TimeObservationEditPart.VISUAL_ID; + return TimeObservationBorderNodeEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getDurationConstraint().isSuperTypeOf(domainElement.eClass())) { - return DurationConstraintEditPart.VISUAL_ID; + break; + case ActionExecutionSpecificationEditPart.VISUAL_ID: + if (UMLPackage.eINSTANCE.getTimeConstraint().isSuperTypeOf(domainElement.eClass())) { + return TimeConstraintBorderNodeEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getDestructionOccurrenceSpecification() - .isSuperTypeOf(domainElement.eClass())) { - return DestructionOccurrenceSpecificationEditPart.VISUAL_ID; + if (UMLPackage.eINSTANCE.getTimeObservation().isSuperTypeOf(domainElement.eClass())) { + return TimeObservationBorderNodeEditPart.VISUAL_ID; + } + break; + case BehaviorExecutionSpecificationEditPart.VISUAL_ID: + if (UMLPackage.eINSTANCE.getTimeConstraint().isSuperTypeOf(domainElement.eClass())) { + return TimeConstraintBorderNodeEditPart.VISUAL_ID; + } + if (UMLPackage.eINSTANCE.getTimeObservation().isSuperTypeOf(domainElement.eClass())) { + return TimeObservationBorderNodeEditPart.VISUAL_ID; + } + break; + case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: + if (UMLPackage.eINSTANCE.getTimeConstraint().isSuperTypeOf(domainElement.eClass())) { + return TimeConstraintBorderNodeEditPart.VISUAL_ID; + } + if (UMLPackage.eINSTANCE.getTimeObservation().isSuperTypeOf(domainElement.eClass())) { + return TimeObservationBorderNodeEditPart.VISUAL_ID; } break; case InteractionInteractionCompartmentEditPart.VISUAL_ID: @@ -267,9 +283,6 @@ public class UMLVisualIDRegistry { if (UMLPackage.eINSTANCE.getComment().isSuperTypeOf(domainElement.eClass())) { return CommentEditPart.VISUAL_ID; } - if (UMLPackage.eINSTANCE.getDurationObservation().isSuperTypeOf(domainElement.eClass())) { - return DurationObservationEditPart.VISUAL_ID; - } break; case CombinedFragmentCombinedFragmentCompartmentEditPart.VISUAL_ID: if (UMLPackage.eINSTANCE.getInteractionOperand().isSuperTypeOf(domainElement.eClass())) { @@ -315,9 +328,6 @@ public class UMLVisualIDRegistry { if (InteractionInteractionCompartmentEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (DurationConstraintInMessageEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } if (GateEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } @@ -373,48 +383,45 @@ public class UMLVisualIDRegistry { if (StateInvariantEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (TimeConstraintEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (TimeObservationEditPart.VISUAL_ID.equals(nodeVisualID)) { + if (DestructionOccurrenceSpecificationEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (DurationConstraintEditPart.VISUAL_ID.equals(nodeVisualID)) { + if (TimeConstraintBorderNodeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (DestructionOccurrenceSpecificationEditPart.VISUAL_ID.equals(nodeVisualID)) { + if (TimeObservationBorderNodeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; - case StateInvariantEditPart.VISUAL_ID: - if (StateInvariantNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + case ActionExecutionSpecificationEditPart.VISUAL_ID: + if (TimeConstraintBorderNodeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (StateInvariantLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + if (TimeObservationBorderNodeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; - case TimeConstraintEditPart.VISUAL_ID: - if (TimeConstraintLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + case BehaviorExecutionSpecificationEditPart.VISUAL_ID: + if (TimeConstraintBorderNodeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (TimeConstraintAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if (TimeObservationBorderNodeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; - case TimeObservationEditPart.VISUAL_ID: - if (TimeObservationLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + case StateInvariantEditPart.VISUAL_ID: + if (StateInvariantNameEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (TimeObservationAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if (StateInvariantLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; - case DurationConstraintEditPart.VISUAL_ID: - if (DurationConstraintLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: + if (TimeConstraintBorderNodeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (DurationConstraintAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if (TimeObservationBorderNodeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; @@ -431,24 +438,24 @@ public class UMLVisualIDRegistry { return true; } break; - case DurationConstraintInMessageEditPart.VISUAL_ID: - if (DurationConstraintInMessageLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } - if (DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + case GateEditPart.VISUAL_ID: + if (GateNameEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; - case DurationObservationEditPart.VISUAL_ID: - if (DurationObservationLabelEditPart.VISUAL_ID.equals(nodeVisualID)) { + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + if (TimeConstraintNameEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (DurationObservationAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + if (TimeConstraintAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; - case GateEditPart.VISUAL_ID: - if (GateNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + case TimeObservationBorderNodeEditPart.VISUAL_ID: + if (TimeObservationNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + return true; + } + if (TimeObservationAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } break; @@ -471,9 +478,6 @@ public class UMLVisualIDRegistry { if (CommentEditPart.VISUAL_ID.equals(nodeVisualID)) { return true; } - if (DurationObservationEditPart.VISUAL_ID.equals(nodeVisualID)) { - return true; - } break; case CombinedFragmentCombinedFragmentCompartmentEditPart.VISUAL_ID: if (InteractionOperandEditPart.VISUAL_ID.equals(nodeVisualID)) { @@ -546,6 +550,22 @@ public class UMLVisualIDRegistry { return true; } break; + case DurationConstraintLinkEditPart.VISUAL_ID: + if (DurationConstraintLinkNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + return true; + } + if (DurationConstraintLinkAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + return true; + } + break; + case DurationObservationLinkEditPart.VISUAL_ID: + if (DurationObservationLinkNameEditPart.VISUAL_ID.equals(nodeVisualID)) { + return true; + } + if (DurationObservationLinkAppliedStereotypeEditPart.VISUAL_ID.equals(nodeVisualID)) { + return true; + } + break; } } return false; @@ -589,6 +609,12 @@ public class UMLVisualIDRegistry { if (UMLPackage.eINSTANCE.getGeneralOrdering().isSuperTypeOf(domainElement.eClass())) { return GeneralOrderingEditPart.VISUAL_ID; } + if (UMLPackage.eINSTANCE.getDurationConstraint().isSuperTypeOf(domainElement.eClass())) { + return DurationConstraintLinkEditPart.VISUAL_ID; + } + if (UMLPackage.eINSTANCE.getDurationObservation().isSuperTypeOf(domainElement.eClass())) { + return DurationObservationLinkEditPart.VISUAL_ID; + } return ""; } @@ -696,19 +722,13 @@ public class UMLVisualIDRegistry { switch (visualID) { case SequenceDiagramEditPart.VISUAL_ID: return false; - case BehaviorExecutionSpecificationEditPart.VISUAL_ID: - case ActionExecutionSpecificationEditPart.VISUAL_ID: case ConsiderIgnoreFragmentEditPart.VISUAL_ID: case ConstraintEditPart.VISUAL_ID: case CommentEditPart.VISUAL_ID: case ContinuationEditPart.VISUAL_ID: case StateInvariantEditPart.VISUAL_ID: - case TimeConstraintEditPart.VISUAL_ID: - case TimeObservationEditPart.VISUAL_ID: - case DurationConstraintEditPart.VISUAL_ID: - case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: - case DurationConstraintInMessageEditPart.VISUAL_ID: - case DurationObservationEditPart.VISUAL_ID: + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + case TimeObservationBorderNodeEditPart.VISUAL_ID: case GateEditPart.VISUAL_ID: return true; } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/ElementInitializers.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/ElementInitializers.java index e17be236cf6..8f5f9698425 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/ElementInitializers.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/ElementInitializers.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2009 Atos Origin. + * Copyright (c) 2009, 2018 Atos Origin, Christian W. Damus, CEA LIST, and others. * * * All rights reserved. This program and the accompanying materials @@ -11,6 +11,7 @@ * * Contributors: * Atos Origin - Initial API and implementation + * Christian W. Damus - bug 536486 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.providers; @@ -154,29 +155,11 @@ public class ElementInitializers { } /** - * @generated NOT init Time Interval - */ - public void init_TimeConstraint_Shape(TimeConstraint instance) { - try { - TimeInterval newInstance_0_0 = UMLFactory.eINSTANCE.createTimeInterval(); - instance.setSpecification(newInstance_0_0); - Object value_0_0_0 = name_specification_TimeConstraint_Shape(newInstance_0_0); - newInstance_0_0.setName((String) value_0_0_0); - // init Time Interval - init_TimeInterval(newInstance_0_0); - Object value_1 = name_TimeConstraint_Shape(instance); - instance.setName((String) value_1); - } catch (RuntimeException e) { - UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ - } - } - - /** * @generated */ - public void init_TimeObservation_Shape(TimeObservation instance) { + public void init_DestructionOccurrenceSpecification_Shape(DestructionOccurrenceSpecification instance) { try { - Object value_0 = name_TimeObservation_Shape(instance); + Object value_0 = name_DestructionOccurrenceSpecification_Shape(instance); if (value_0 != null) { instance.setName((String) value_0); } @@ -186,18 +169,16 @@ public class ElementInitializers { } /** - * @generated NOT init Duration Interval + * @generated */ - public void init_DurationConstraint_Shape(DurationConstraint instance) { + public void init_Constraint_Shape(Constraint instance) { try { - DurationInterval newInstance_0_0 = UMLFactory.eINSTANCE.createDurationInterval(); + LiteralString newInstance_0_0 = UMLFactory.eINSTANCE.createLiteralString(); instance.setSpecification(newInstance_0_0); - Object value_0_0_0 = name_specification_DurationConstraint_Shape(newInstance_0_0); - newInstance_0_0.setName((String) value_0_0_0); - // init Duration Interval - init_DurationInterval(newInstance_0_0); - Object value_1 = name_DurationConstraint_Shape(instance); - instance.setName((String) value_1); + Object value_0_0_0 = value_specification_Constraint_Shape(newInstance_0_0); + if (value_0_0_0 != null) { + newInstance_0_0.setValue((String) value_0_0_0); + } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ } @@ -206,11 +187,11 @@ public class ElementInitializers { /** * @generated */ - public void init_DestructionOccurrenceSpecification_Shape(DestructionOccurrenceSpecification instance) { + public void init_Comment_Shape(Comment instance) { try { - Object value_0 = name_DestructionOccurrenceSpecification_Shape(instance); + Object value_0 = UMLOCLFactory.getExpression(0, UMLPackage.eINSTANCE.getComment(), null).evaluate(instance); if (value_0 != null) { - instance.setName((String) value_0); + instance.setBody((String) value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -220,13 +201,11 @@ public class ElementInitializers { /** * @generated */ - public void init_Constraint_Shape(Constraint instance) { + public void init_TimeConstraint_Shape(TimeConstraint instance) { try { - LiteralString newInstance_0_0 = UMLFactory.eINSTANCE.createLiteralString(); - instance.setSpecification(newInstance_0_0); - Object value_0_0_0 = value_specification_Constraint_Shape(newInstance_0_0); - if (value_0_0_0 != null) { - newInstance_0_0.setValue((String) value_0_0_0); + Object value_0 = name_TimeConstraint_Shape(instance); + if (value_0 != null) { + instance.setName((String) value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -236,11 +215,11 @@ public class ElementInitializers { /** * @generated */ - public void init_Comment_Shape(Comment instance) { + public void init_TimeObservation_Shape(TimeObservation instance) { try { - Object value_0 = UMLOCLFactory.getExpression(0, UMLPackage.eINSTANCE.getComment(), null).evaluate(instance); + Object value_0 = name_TimeObservation_Shape(instance); if (value_0 != null) { - instance.setBody((String) value_0); + instance.setName((String) value_0); } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ @@ -294,18 +273,14 @@ public class ElementInitializers { } /** - * @generated NOT init Duration Interval + * @generated */ - public void init_DurationConstraint_Shape_CN(DurationConstraint instance) { + public void init_GeneralOrdering_Edge(GeneralOrdering instance) { try { - DurationInterval newInstance_0_0 = UMLFactory.eINSTANCE.createDurationInterval(); - instance.setSpecification(newInstance_0_0); - Object value_0_0_0 = name_specification_DurationConstraint_Shape_CN(newInstance_0_0); - newInstance_0_0.setName((String) value_0_0_0); - // init Duration Interval - init_DurationInterval(newInstance_0_0); - Object value_1 = name_DurationConstraint_Shape_CN(instance); - instance.setName((String) value_1); + Object value_0 = name_GeneralOrdering_Edge(instance); + if (value_0 != null) { + instance.setName((String) value_0); + } } catch (RuntimeException e) { UMLDiagramEditorPlugin.getInstance().logError("Element initialization failed", e); //$NON-NLS-1$ } @@ -314,9 +289,9 @@ public class ElementInitializers { /** * @generated */ - public void init_DurationObservation_Shape(DurationObservation instance) { + public void init_DurationConstraint_Edge(DurationConstraint instance) { try { - Object value_0 = name_DurationObservation_Shape(instance); + Object value_0 = name_DurationConstraint_Edge(instance); if (value_0 != null) { instance.setName((String) value_0); } @@ -328,9 +303,9 @@ public class ElementInitializers { /** * @generated */ - public void init_GeneralOrdering_Edge(GeneralOrdering instance) { + public void init_DurationObservation_Edge(DurationObservation instance) { try { - Object value_0 = name_GeneralOrdering_Edge(instance); + Object value_0 = name_DurationObservation_Edge(instance); if (value_0 != null) { instance.setName((String) value_0); } @@ -391,77 +366,49 @@ public class ElementInitializers { /** * @generated */ - private String name_TimeConstraint_Shape(TimeConstraint it) { - return getNamedElement(it, "", it.eClass().getName(), ""); - } - - /** - * @generated - */ - private String name_specification_TimeConstraint_Shape(TimeInterval it) { + private String name_DestructionOccurrenceSpecification_Shape(DestructionOccurrenceSpecification it) { return getNamedElement(it, "", it.eClass().getName(), ""); } /** * @generated */ - private String name_TimeObservation_Shape(TimeObservation it) { - return getNamedElement(it, "", "t", ""); - } - - /** - * @generated - */ - private String name_DurationConstraint_Shape(DurationConstraint it) { - return getNamedElement(it, "", it.eClass().getName(), ""); + private String value_specification_Constraint_Shape(LiteralString it) { + return ""; } /** * @generated */ - private String name_specification_DurationConstraint_Shape(DurationInterval it) { + private String name_TimeConstraint_Shape(TimeConstraint it) { return getNamedElement(it, "", it.eClass().getName(), ""); } /** * @generated */ - private String name_DestructionOccurrenceSpecification_Shape(DestructionOccurrenceSpecification it) { + private String name_TimeObservation_Shape(TimeObservation it) { return getNamedElement(it, "", it.eClass().getName(), ""); } /** * @generated */ - private String value_specification_Constraint_Shape(LiteralString it) { - return ""; - } - - /** - * @generated - */ - private String name_DurationConstraint_Shape_CN(DurationConstraint it) { + private String name_GeneralOrdering_Edge(GeneralOrdering it) { return getNamedElement(it, "", it.eClass().getName(), ""); } /** * @generated */ - private String name_specification_DurationConstraint_Shape_CN(DurationInterval it) { + private String name_DurationConstraint_Edge(DurationConstraint it) { return getNamedElement(it, "", it.eClass().getName(), ""); } /** * @generated */ - private String name_DurationObservation_Shape(DurationObservation it) { - return getNamedElement(it, "", "d", ""); - } - - /** - * @generated - */ - private String name_GeneralOrdering_Edge(GeneralOrdering it) { + private String name_DurationObservation_Edge(DurationObservation it) { return getNamedElement(it, "", it.eClass().getName(), ""); } diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLElementTypes.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLElementTypes.java index 66b5edf531c..b3a0df15d68 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLElementTypes.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLElementTypes.java @@ -37,9 +37,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContextLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionEditPart; @@ -55,8 +54,8 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageReplyEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.SequenceDiagramEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintBorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationBorderNodeEditPart; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin; import org.eclipse.swt.graphics.Image; import org.eclipse.uml2.uml.UMLPackage; @@ -146,21 +145,6 @@ public class UMLElementTypes { /** * @generated */ - public static final IElementType TimeConstraint_Shape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.TimeConstraint_Shape"); //$NON-NLS-1$ - /** - * @generated - */ - public static final IElementType TimeObservation_Shape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.TimeObservation_Shape"); //$NON-NLS-1$ - /** - * @generated - */ - public static final IElementType DurationConstraint_Shape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.DurationConstraint_Shape"); //$NON-NLS-1$ - /** - * @generated - */ public static final IElementType DestructionOccurrenceSpecification_Shape = getElementTypeByUniqueId( "org.eclipse.papyrus.umldi.DestructionOccurrenceSpecification_Shape"); //$NON-NLS-1$ /** @@ -176,17 +160,19 @@ public class UMLElementTypes { /** * @generated */ - public static final IElementType DurationConstraint_Shape_CN = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.DurationConstraint_Shape_CN"); //$NON-NLS-1$ + public static final IElementType Gate_Shape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Gate_Shape"); //$NON-NLS-1$ + /** * @generated */ - public static final IElementType DurationObservation_Shape = getElementTypeByUniqueId( - "org.eclipse.papyrus.umldi.DurationObservation_Shape"); //$NON-NLS-1$ + public static final IElementType TimeConstraint_Shape = getElementTypeByUniqueId( + "org.eclipse.papyrus.umldi.TimeConstraint_Shape"); //$NON-NLS-1$ + /** * @generated */ - public static final IElementType Gate_Shape = getElementTypeByUniqueId("org.eclipse.papyrus.umldi.Gate_Shape"); //$NON-NLS-1$ + public static final IElementType TimeObservation_Shape = getElementTypeByUniqueId( + "org.eclipse.papyrus.umldi.TimeObservation_Shape"); //$NON-NLS-1$ /** * @generated @@ -247,6 +233,18 @@ public class UMLElementTypes { /** * @generated */ + public static final IElementType DurationConstraint_Edge = getElementTypeByUniqueId( + "org.eclipse.papyrus.umldi.DurationConstraint_Edge"); //$NON-NLS-1$ + + /** + * @generated + */ + public static final IElementType DurationObservation_Edge = getElementTypeByUniqueId( + "org.eclipse.papyrus.umldi.DurationObservation_Edge"); //$NON-NLS-1$ + + /** + * @generated + */ public static ImageDescriptor getImageDescriptor(ENamedElement element) { return elementTypeImages.getImageDescriptor(element); } @@ -305,12 +303,6 @@ public class UMLElementTypes { elements.put(StateInvariant_Shape, UMLPackage.eINSTANCE.getStateInvariant()); - elements.put(TimeConstraint_Shape, UMLPackage.eINSTANCE.getTimeConstraint()); - - elements.put(TimeObservation_Shape, UMLPackage.eINSTANCE.getTimeObservation()); - - elements.put(DurationConstraint_Shape, UMLPackage.eINSTANCE.getDurationConstraint()); - elements.put(DestructionOccurrenceSpecification_Shape, UMLPackage.eINSTANCE.getDestructionOccurrenceSpecification()); @@ -318,11 +310,11 @@ public class UMLElementTypes { elements.put(Comment_Shape, UMLPackage.eINSTANCE.getComment()); - elements.put(DurationConstraint_Shape_CN, UMLPackage.eINSTANCE.getDurationConstraint()); + elements.put(Gate_Shape, UMLPackage.eINSTANCE.getGate()); - elements.put(DurationObservation_Shape, UMLPackage.eINSTANCE.getDurationObservation()); + elements.put(TimeConstraint_Shape, UMLPackage.eINSTANCE.getTimeConstraint()); - elements.put(Gate_Shape, UMLPackage.eINSTANCE.getGate()); + elements.put(TimeObservation_Shape, UMLPackage.eINSTANCE.getTimeObservation()); elements.put(Message_SynchEdge, UMLPackage.eINSTANCE.getMessage()); @@ -345,6 +337,10 @@ public class UMLElementTypes { elements.put(GeneralOrdering_Edge, UMLPackage.eINSTANCE.getGeneralOrdering()); elements.put(Constraint_ContextEdge, UMLPackage.eINSTANCE.getConstraint_Context()); + + elements.put(DurationConstraint_Edge, UMLPackage.eINSTANCE.getDurationConstraint()); + + elements.put(DurationObservation_Edge, UMLPackage.eINSTANCE.getDurationObservation()); } return elements.get(type); } @@ -373,15 +369,12 @@ public class UMLElementTypes { KNOWN_ELEMENT_TYPES.add(ActionExecutionSpecification_Shape); KNOWN_ELEMENT_TYPES.add(BehaviorExecutionSpecification_Shape); KNOWN_ELEMENT_TYPES.add(StateInvariant_Shape); - KNOWN_ELEMENT_TYPES.add(TimeConstraint_Shape); - KNOWN_ELEMENT_TYPES.add(TimeObservation_Shape); - KNOWN_ELEMENT_TYPES.add(DurationConstraint_Shape); KNOWN_ELEMENT_TYPES.add(DestructionOccurrenceSpecification_Shape); KNOWN_ELEMENT_TYPES.add(Constraint_Shape); KNOWN_ELEMENT_TYPES.add(Comment_Shape); - KNOWN_ELEMENT_TYPES.add(DurationConstraint_Shape_CN); - KNOWN_ELEMENT_TYPES.add(DurationObservation_Shape); KNOWN_ELEMENT_TYPES.add(Gate_Shape); + KNOWN_ELEMENT_TYPES.add(TimeConstraint_Shape); + KNOWN_ELEMENT_TYPES.add(TimeObservation_Shape); KNOWN_ELEMENT_TYPES.add(Message_SynchEdge); KNOWN_ELEMENT_TYPES.add(Message_AsynchEdge); KNOWN_ELEMENT_TYPES.add(Message_ReplyEdge); @@ -393,6 +386,8 @@ public class UMLElementTypes { KNOWN_ELEMENT_TYPES.add(Constraint_ConstrainedElementEdge); KNOWN_ELEMENT_TYPES.add(GeneralOrdering_Edge); KNOWN_ELEMENT_TYPES.add(Constraint_ContextEdge); + KNOWN_ELEMENT_TYPES.add(DurationConstraint_Edge); + KNOWN_ELEMENT_TYPES.add(DurationObservation_Edge); } boolean result = KNOWN_ELEMENT_TYPES.contains(elementType); @@ -435,24 +430,18 @@ public class UMLElementTypes { return BehaviorExecutionSpecification_Shape; case StateInvariantEditPart.VISUAL_ID: return StateInvariant_Shape; - case TimeConstraintEditPart.VISUAL_ID: - return TimeConstraint_Shape; - case TimeObservationEditPart.VISUAL_ID: - return TimeObservation_Shape; - case DurationConstraintEditPart.VISUAL_ID: - return DurationConstraint_Shape; case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: return DestructionOccurrenceSpecification_Shape; case ConstraintEditPart.VISUAL_ID: return Constraint_Shape; case CommentEditPart.VISUAL_ID: return Comment_Shape; - case DurationConstraintInMessageEditPart.VISUAL_ID: - return DurationConstraint_Shape_CN; - case DurationObservationEditPart.VISUAL_ID: - return DurationObservation_Shape; case GateEditPart.VISUAL_ID: return Gate_Shape; + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + return TimeConstraint_Shape; + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return TimeObservation_Shape; case MessageSyncEditPart.VISUAL_ID: return Message_SynchEdge; case MessageAsyncEditPart.VISUAL_ID: @@ -475,6 +464,10 @@ public class UMLElementTypes { return GeneralOrdering_Edge; case ContextLinkEditPart.VISUAL_ID: return Constraint_ContextEdge; + case DurationConstraintLinkEditPart.VISUAL_ID: + return DurationConstraint_Edge; + case DurationObservationLinkEditPart.VISUAL_ID: + return DurationObservation_Edge; } } return null; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLParserProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLParserProvider.java index 803f55f7f11..f2e454b174c 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLParserProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLParserProvider.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2009 Atos Origin. + * Copyright (c) 2009, 2018 Atos Origin, Christian W. Damus, CEA LIST, and others. * * * All rights reserved. This program and the accompanying materials @@ -11,6 +11,7 @@ * * Contributors: * Atos Origin - Initial API and implementation + * Christian W. Damus - bug 536486 * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.providers; @@ -29,17 +30,16 @@ import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.uml.diagram.common.parser.CommentParser; import org.eclipse.papyrus.uml.diagram.common.parser.ConstraintParser; +import org.eclipse.papyrus.uml.diagram.common.parser.ObservationParser; import org.eclipse.papyrus.uml.diagram.common.parser.stereotype.AppliedStereotypeParser; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentBodyEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.Constraint2EditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationNameEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLabelEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkAppliedStereotypeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkNameEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkAppliedStereotypeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingAppliedStereotypeEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionNameEditPart; @@ -63,15 +63,12 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.MessageSyncNameEditPa import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantLabelEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintLabelEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.parser.custom.DurationObservationParser; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.parser.custom.InteractionUseCustomParsers; import org.eclipse.papyrus.uml.diagram.sequence.parser.custom.LifelineCustomParsers; import org.eclipse.papyrus.uml.diagram.sequence.parser.custom.MessageCustomParser; -import org.eclipse.papyrus.uml.diagram.sequence.parser.custom.TimeConstraintParser; -import org.eclipse.papyrus.uml.diagram.sequence.parser.custom.TimeObservationParser; import org.eclipse.papyrus.uml.diagram.sequence.parsers.MessageFormatParser; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.uml2.uml.UMLPackage; @@ -203,96 +200,6 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid /** * @generated */ - private TimeConstraintParser timeConstraint_ConstraintLabel_Parser; - - /** - * @generated - */ - private IParser getTimeConstraint_ConstraintLabel_Parser() { - if (timeConstraint_ConstraintLabel_Parser == null) { - timeConstraint_ConstraintLabel_Parser = new TimeConstraintParser(); - } - return timeConstraint_ConstraintLabel_Parser; - } - - /** - * @generated - */ - private AppliedStereotypeParser timeConstraint_StereotypeLabel_Parser; - - /** - * @generated - */ - private IParser getTimeConstraint_StereotypeLabel_Parser() { - if (timeConstraint_StereotypeLabel_Parser == null) { - timeConstraint_StereotypeLabel_Parser = new AppliedStereotypeParser(); - } - return timeConstraint_StereotypeLabel_Parser; - } - - /** - * @generated - */ - private TimeObservationParser timeObservation_NameLabel_Parser; - - /** - * @generated - */ - private IParser getTimeObservation_NameLabel_Parser() { - if (timeObservation_NameLabel_Parser == null) { - timeObservation_NameLabel_Parser = new TimeObservationParser(); - } - return timeObservation_NameLabel_Parser; - } - - /** - * @generated - */ - private AppliedStereotypeParser timeObservation_StereotypeLabel_Parser; - - /** - * @generated - */ - private IParser getTimeObservation_StereotypeLabel_Parser() { - if (timeObservation_StereotypeLabel_Parser == null) { - timeObservation_StereotypeLabel_Parser = new AppliedStereotypeParser(); - } - return timeObservation_StereotypeLabel_Parser; - } - - /** - * @generated - */ - private TimeConstraintParser durationConstraint_BodyLabel_Parser; - - /** - * @generated - */ - private IParser getDurationConstraint_BodyLabel_Parser() { - if (durationConstraint_BodyLabel_Parser == null) { - durationConstraint_BodyLabel_Parser = new TimeConstraintParser(); - } - return durationConstraint_BodyLabel_Parser; - } - - /** - * @generated - */ - private AppliedStereotypeParser durationConstraint_StereotypeLabel_Parser; - - /** - * @generated - */ - private IParser getDurationConstraint_StereotypeLabel_Parser() { - if (durationConstraint_StereotypeLabel_Parser == null) { - durationConstraint_StereotypeLabel_Parser = new AppliedStereotypeParser(); - } - return durationConstraint_StereotypeLabel_Parser; - } - - /** - * @generated - */ private IParser constraint_NameLabel_Parser; /** @@ -340,78 +247,78 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid /** * @generated */ - private TimeConstraintParser durationConstraint_BodyLabel_CN_Parser; + private IParser gate_NameLabel_Parser; /** * @generated */ - private IParser getDurationConstraint_BodyLabel_CN_Parser() { - if (durationConstraint_BodyLabel_CN_Parser == null) { - durationConstraint_BodyLabel_CN_Parser = new TimeConstraintParser(); + private IParser getGate_NameLabel_Parser() { + if (gate_NameLabel_Parser == null) { + EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; + MessageFormatParser parser = new MessageFormatParser(features); + gate_NameLabel_Parser = parser; } - return durationConstraint_BodyLabel_CN_Parser; + return gate_NameLabel_Parser; } /** * @generated */ - private AppliedStereotypeParser durationConstraint_StereotypeLabel_CN_Parser; + private ConstraintParser timeConstraint_NameLabel_Parser; /** * @generated */ - private IParser getDurationConstraint_StereotypeLabel_CN_Parser() { - if (durationConstraint_StereotypeLabel_CN_Parser == null) { - durationConstraint_StereotypeLabel_CN_Parser = new AppliedStereotypeParser(); + private IParser getTimeConstraint_NameLabel_Parser() { + if (timeConstraint_NameLabel_Parser == null) { + timeConstraint_NameLabel_Parser = new ConstraintParser(); } - return durationConstraint_StereotypeLabel_CN_Parser; + return timeConstraint_NameLabel_Parser; } /** * @generated */ - private DurationObservationParser durationObservation_NameLabel_Parser; + private AppliedStereotypeParser timeConstraint_StereotypeLabel_Parser; /** * @generated */ - private IParser getDurationObservation_NameLabel_Parser() { - if (durationObservation_NameLabel_Parser == null) { - durationObservation_NameLabel_Parser = new DurationObservationParser(); + private IParser getTimeConstraint_StereotypeLabel_Parser() { + if (timeConstraint_StereotypeLabel_Parser == null) { + timeConstraint_StereotypeLabel_Parser = new AppliedStereotypeParser(); } - return durationObservation_NameLabel_Parser; + return timeConstraint_StereotypeLabel_Parser; } /** * @generated */ - private AppliedStereotypeParser durationObservation_StereotypeLabel_Parser; + private ObservationParser timeObservation_NameLabel_Parser; /** * @generated */ - private IParser getDurationObservation_StereotypeLabel_Parser() { - if (durationObservation_StereotypeLabel_Parser == null) { - durationObservation_StereotypeLabel_Parser = new AppliedStereotypeParser(); + private IParser getTimeObservation_NameLabel_Parser() { + if (timeObservation_NameLabel_Parser == null) { + timeObservation_NameLabel_Parser = new ObservationParser(); } - return durationObservation_StereotypeLabel_Parser; + return timeObservation_NameLabel_Parser; } /** * @generated */ - private IParser gate_NameLabel_Parser; + private AppliedStereotypeParser timeObservation_StereotypeLabel_Parser; /** * @generated */ - private IParser getGate_NameLabel_Parser() { - if (gate_NameLabel_Parser == null) { - EAttribute[] features = new EAttribute[] { UMLPackage.eINSTANCE.getNamedElement_Name() }; - MessageFormatParser parser = new MessageFormatParser(features); - gate_NameLabel_Parser = parser; + private IParser getTimeObservation_StereotypeLabel_Parser() { + if (timeObservation_StereotypeLabel_Parser == null) { + timeObservation_StereotypeLabel_Parser = new AppliedStereotypeParser(); } - return gate_NameLabel_Parser; + return timeObservation_StereotypeLabel_Parser; } /** @@ -642,6 +549,66 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid /** * @generated */ + private ConstraintParser durationConstraint_NameLabel_Parser; + + /** + * @generated + */ + private IParser getDurationConstraint_NameLabel_Parser() { + if (durationConstraint_NameLabel_Parser == null) { + durationConstraint_NameLabel_Parser = new ConstraintParser(); + } + return durationConstraint_NameLabel_Parser; + } + + /** + * @generated + */ + private AppliedStereotypeParser durationConstraint_StereotypeLabel_Parser; + + /** + * @generated + */ + private IParser getDurationConstraint_StereotypeLabel_Parser() { + if (durationConstraint_StereotypeLabel_Parser == null) { + durationConstraint_StereotypeLabel_Parser = new AppliedStereotypeParser(); + } + return durationConstraint_StereotypeLabel_Parser; + } + + /** + * @generated + */ + private ObservationParser durationObservation_NameLabel_Parser; + + /** + * @generated + */ + private IParser getDurationObservation_NameLabel_Parser() { + if (durationObservation_NameLabel_Parser == null) { + durationObservation_NameLabel_Parser = new ObservationParser(); + } + return durationObservation_NameLabel_Parser; + } + + /** + * @generated + */ + private AppliedStereotypeParser durationObservation_StereotypeLabel_Parser; + + /** + * @generated + */ + private IParser getDurationObservation_StereotypeLabel_Parser() { + if (durationObservation_StereotypeLabel_Parser == null) { + durationObservation_StereotypeLabel_Parser = new AppliedStereotypeParser(); + } + return durationObservation_StereotypeLabel_Parser; + } + + /** + * @generated + */ protected IParser getParser(String visualID) { if (visualID != null) { switch (visualID) { @@ -664,21 +631,6 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid case StateInvariantLabelEditPart.VISUAL_ID: return getStateInvariant_ConstraintLabel_Parser(); - case TimeConstraintLabelEditPart.VISUAL_ID: - return getTimeConstraint_ConstraintLabel_Parser(); - case TimeConstraintAppliedStereotypeEditPart.VISUAL_ID: - return getTimeConstraint_StereotypeLabel_Parser(); - - case TimeObservationLabelEditPart.VISUAL_ID: - return getTimeObservation_NameLabel_Parser(); - case TimeObservationAppliedStereotypeEditPart.VISUAL_ID: - return getTimeObservation_StereotypeLabel_Parser(); - - case DurationConstraintLabelEditPart.VISUAL_ID: - return getDurationConstraint_BodyLabel_Parser(); - case DurationConstraintAppliedStereotypeEditPart.VISUAL_ID: - return getDurationConstraint_StereotypeLabel_Parser(); - case ConstraintNameEditPart.VISUAL_ID: return getConstraint_NameLabel_Parser(); case Constraint2EditPart.VISUAL_ID: @@ -687,19 +639,19 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid case CommentBodyEditPart.VISUAL_ID: return getComment_BodyLabel_Parser(); - case DurationConstraintInMessageLabelEditPart.VISUAL_ID: - return getDurationConstraint_BodyLabel_CN_Parser(); - case DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID: - return getDurationConstraint_StereotypeLabel_CN_Parser(); - - case DurationObservationLabelEditPart.VISUAL_ID: - return getDurationObservation_NameLabel_Parser(); - case DurationObservationAppliedStereotypeEditPart.VISUAL_ID: - return getDurationObservation_StereotypeLabel_Parser(); - case GateNameEditPart.VISUAL_ID: return getGate_NameLabel_Parser(); + case TimeConstraintNameEditPart.VISUAL_ID: + return getTimeConstraint_NameLabel_Parser(); + case TimeConstraintAppliedStereotypeEditPart.VISUAL_ID: + return getTimeConstraint_StereotypeLabel_Parser(); + + case TimeObservationNameEditPart.VISUAL_ID: + return getTimeObservation_NameLabel_Parser(); + case TimeObservationAppliedStereotypeEditPart.VISUAL_ID: + return getTimeObservation_StereotypeLabel_Parser(); + case MessageSyncNameEditPart.VISUAL_ID: return getMessage_SynchNameLabel_Parser(); case MessageSyncAppliedStereotypeEditPart.VISUAL_ID: @@ -738,6 +690,16 @@ public class UMLParserProvider extends AbstractProvider implements IParserProvid case GeneralOrderingAppliedStereotypeEditPart.VISUAL_ID: return getGeneralOrdering_StereotypeLabel_Parser(); + case DurationConstraintLinkNameEditPart.VISUAL_ID: + return getDurationConstraint_NameLabel_Parser(); + case DurationConstraintLinkAppliedStereotypeEditPart.VISUAL_ID: + return getDurationConstraint_StereotypeLabel_Parser(); + + case DurationObservationLinkNameEditPart.VISUAL_ID: + return getDurationObservation_NameLabel_Parser(); + case DurationObservationLinkAppliedStereotypeEditPart.VISUAL_ID: + return getDurationObservation_StereotypeLabel_Parser(); + } } return null; diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java index c9fc0ca2ef7..a790e212465 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2009 Atos Origin. + * Copyright (c) 2009, 2018 Atos Origin, Christian W. Damus, CEA LIST, and others. * * * All rights reserved. This program and the accompanying materials @@ -12,6 +12,7 @@ * Contributors: * Atos Origin - Initial API and implementation * Vincent Lorenzo - vincent.lorenzo@cea.fr - CEA - LIST + * Christian W. Damus - bug 536486 *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.sequence.providers; @@ -77,15 +78,12 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContextLinkEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ContinuationNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DestructionOccurrenceSpecificationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintInMessageLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLabelEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLabelEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkAppliedStereotypeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationConstraintLinkNameEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkAppliedStereotypeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.DurationObservationLinkNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GateNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.GeneralOrderingAppliedStereotypeEditPart; @@ -125,11 +123,11 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantEditPar import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantLabelEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.StateInvariantNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintLabelEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintBorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeConstraintNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationAppliedStereotypeEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart; -import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationLabelEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationBorderNodeEditPart; +import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationNameEditPart; import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.FontData; @@ -202,7 +200,7 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { * <p> * This method can be overloaded when diagram editor inherits from another one, but should never be <code>null</code> * </p> - * + * * @return the unique identifier of the diagram for which views are provided. */ return SequenceDiagramEditPart.MODEL_ID; @@ -266,15 +264,12 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { case ActionExecutionSpecificationEditPart.VISUAL_ID: case BehaviorExecutionSpecificationEditPart.VISUAL_ID: case StateInvariantEditPart.VISUAL_ID: - case TimeConstraintEditPart.VISUAL_ID: - case TimeObservationEditPart.VISUAL_ID: - case DurationConstraintEditPart.VISUAL_ID: case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: case ConstraintEditPart.VISUAL_ID: case CommentEditPart.VISUAL_ID: - case DurationObservationEditPart.VISUAL_ID: case GateEditPart.VISUAL_ID: - case DurationConstraintInMessageEditPart.VISUAL_ID: + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + case TimeObservationBorderNodeEditPart.VISUAL_ID: if (domainElement == null || !visualID .equals(UMLVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement))) { return false; // visual id in semantic hint should match visual id for domain element @@ -366,12 +361,6 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { preferencesHint); case StateInvariantEditPart.VISUAL_ID: return createStateInvariant_Shape(domainElement, containerView, index, persisted, preferencesHint); - case TimeConstraintEditPart.VISUAL_ID: - return createTimeConstraint_Shape(domainElement, containerView, index, persisted, preferencesHint); - case TimeObservationEditPart.VISUAL_ID: - return createTimeObservation_Shape(domainElement, containerView, index, persisted, preferencesHint); - case DurationConstraintEditPart.VISUAL_ID: - return createDurationConstraint_Shape(domainElement, containerView, index, persisted, preferencesHint); case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: return createDestructionOccurrenceSpecification_Shape(domainElement, containerView, index, persisted, preferencesHint); @@ -379,13 +368,12 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { return createConstraint_Shape(domainElement, containerView, index, persisted, preferencesHint); case CommentEditPart.VISUAL_ID: return createComment_Shape(domainElement, containerView, index, persisted, preferencesHint); - case DurationConstraintInMessageEditPart.VISUAL_ID: - return createDurationConstraint_Shape_CN(domainElement, containerView, index, persisted, - preferencesHint); - case DurationObservationEditPart.VISUAL_ID: - return createDurationObservation_Shape(domainElement, containerView, index, persisted, preferencesHint); case GateEditPart.VISUAL_ID: return createGate_Shape(domainElement, containerView, index, persisted, preferencesHint); + case TimeConstraintBorderNodeEditPart.VISUAL_ID: + return createTimeConstraint_Shape(domainElement, containerView, index, persisted, preferencesHint); + case TimeObservationBorderNodeEditPart.VISUAL_ID: + return createTimeObservation_Shape(domainElement, containerView, index, persisted, preferencesHint); } } // can't happen, provided #provides(CreateNodeViewOperation) is correct @@ -433,6 +421,12 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { preferencesHint); case ContextLinkEditPart.VISUAL_ID: return createConstraint_ContextEdge(containerView, index, persisted, preferencesHint); + case DurationConstraintLinkEditPart.VISUAL_ID: + return createDurationConstraint_Edge(getSemanticElement(semanticAdapter), containerView, index, + persisted, preferencesHint); + case DurationObservationLinkEditPart.VISUAL_ID: + return createDurationObservation_Edge(getSemanticElement(semanticAdapter), containerView, index, + persisted, preferencesHint); } } // can never happen, provided #provides(CreateEdgeViewOperation) is correct @@ -633,97 +627,6 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createTimeConstraint_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(TimeConstraintEditPart.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "TimeConstraint"); - Node timeConstraint_ConstraintLabel = createLabel(node, - UMLVisualIDRegistry.getType(TimeConstraintLabelEditPart.VISUAL_ID)); - timeConstraint_ConstraintLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location timeConstraint_ConstraintLabel_Location = (Location) timeConstraint_ConstraintLabel - .getLayoutConstraint(); - timeConstraint_ConstraintLabel_Location.setX(0); - timeConstraint_ConstraintLabel_Location.setY(15); - Node timeConstraint_StereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(TimeConstraintAppliedStereotypeEditPart.VISUAL_ID)); - timeConstraint_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location timeConstraint_StereotypeLabel_Location = (Location) timeConstraint_StereotypeLabel - .getLayoutConstraint(); - timeConstraint_StereotypeLabel_Location.setX(0); - timeConstraint_StereotypeLabel_Location.setY(-22); - return node; - } - - /** - * @generated - */ - public Node createTimeObservation_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(TimeObservationEditPart.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "TimeObservation"); - Node timeObservation_NameLabel = createLabel(node, - UMLVisualIDRegistry.getType(TimeObservationLabelEditPart.VISUAL_ID)); - timeObservation_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location timeObservation_NameLabel_Location = (Location) timeObservation_NameLabel.getLayoutConstraint(); - timeObservation_NameLabel_Location.setX(0); - timeObservation_NameLabel_Location.setY(15); - Node timeObservation_StereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(TimeObservationAppliedStereotypeEditPart.VISUAL_ID)); - timeObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location timeObservation_StereotypeLabel_Location = (Location) timeObservation_StereotypeLabel - .getLayoutConstraint(); - timeObservation_StereotypeLabel_Location.setX(0); - timeObservation_StereotypeLabel_Location.setY(-22); - return node; - } - - /** - * @generated - */ - public Node createDurationConstraint_Shape(EObject domainElement, View containerView, int index, boolean persisted, - PreferencesHint preferencesHint) { - Shape node = NotationFactory.eINSTANCE.createShape(); - node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(DurationConstraintEditPart.VISUAL_ID)); - ViewUtil.insertChildView(containerView, node, index, persisted); - node.setElement(domainElement); - // initializeFromPreferences - final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DurationConstraint"); - Node durationConstraint_BodyLabel = createLabel(node, - UMLVisualIDRegistry.getType(DurationConstraintLabelEditPart.VISUAL_ID)); - durationConstraint_BodyLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location durationConstraint_BodyLabel_Location = (Location) durationConstraint_BodyLabel.getLayoutConstraint(); - durationConstraint_BodyLabel_Location.setX(0); - durationConstraint_BodyLabel_Location.setY(15); - Node durationConstraint_StereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(DurationConstraintAppliedStereotypeEditPart.VISUAL_ID)); - durationConstraint_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location durationConstraint_StereotypeLabel_Location = (Location) durationConstraint_StereotypeLabel - .getLayoutConstraint(); - durationConstraint_StereotypeLabel_Location.setX(0); - durationConstraint_StereotypeLabel_Location.setY(-22); - return node; - } - - /** - * @generated - */ public Node createDestructionOccurrenceSpecification_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); @@ -779,75 +682,83 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ - public Node createDurationConstraint_Shape_CN(EObject domainElement, View containerView, int index, - boolean persisted, PreferencesHint preferencesHint) { + public Node createGate_Shape(EObject domainElement, View containerView, int index, boolean persisted, + PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(DurationConstraintInMessageEditPart.VISUAL_ID)); + node.setType(UMLVisualIDRegistry.getType(GateEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DurationConstraint"); - Node durationConstraint_BodyLabel_CN = createLabel(node, - UMLVisualIDRegistry.getType(DurationConstraintInMessageLabelEditPart.VISUAL_ID)); - Node durationConstraint_StereotypeLabel_CN = createLabel(node, - UMLVisualIDRegistry.getType(DurationConstraintInMessageAppliedStereotypeEditPart.VISUAL_ID)); - durationConstraint_StereotypeLabel_CN.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location durationConstraint_StereotypeLabel_CN_Location = (Location) durationConstraint_StereotypeLabel_CN - .getLayoutConstraint(); - durationConstraint_StereotypeLabel_CN_Location.setX(0); - durationConstraint_StereotypeLabel_CN_Location.setY(-22); + PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Gate"); + Node gate_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(GateNameEditPart.VISUAL_ID)); + gate_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + Location gate_NameLabel_Location = (Location) gate_NameLabel.getLayoutConstraint(); + gate_NameLabel_Location.setX(25); + gate_NameLabel_Location.setY(3); + PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(node, prefStore, "Gate"); return node; } /** * @generated */ - public Node createDurationObservation_Shape(EObject domainElement, View containerView, int index, boolean persisted, + public Node createTimeConstraint_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(DurationObservationEditPart.VISUAL_ID)); + node.setType(UMLVisualIDRegistry.getType(TimeConstraintBorderNodeEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "DurationObservation"); - Node durationObservation_NameLabel = createLabel(node, - UMLVisualIDRegistry.getType(DurationObservationLabelEditPart.VISUAL_ID)); - Node durationObservation_StereotypeLabel = createLabel(node, - UMLVisualIDRegistry.getType(DurationObservationAppliedStereotypeEditPart.VISUAL_ID)); - durationObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location durationObservation_StereotypeLabel_Location = (Location) durationObservation_StereotypeLabel + PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "TimeConstraint"); + Node timeConstraint_NameLabel = createLabel(node, + UMLVisualIDRegistry.getType(TimeConstraintNameEditPart.VISUAL_ID)); + timeConstraint_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + Location timeConstraint_NameLabel_Location = (Location) timeConstraint_NameLabel.getLayoutConstraint(); + timeConstraint_NameLabel_Location.setX(25); + timeConstraint_NameLabel_Location.setY(3); + Node timeConstraint_StereotypeLabel = createLabel(node, + UMLVisualIDRegistry.getType(TimeConstraintAppliedStereotypeEditPart.VISUAL_ID)); + timeConstraint_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + Location timeConstraint_StereotypeLabel_Location = (Location) timeConstraint_StereotypeLabel .getLayoutConstraint(); - durationObservation_StereotypeLabel_Location.setX(0); - durationObservation_StereotypeLabel_Location.setY(-22); + timeConstraint_StereotypeLabel_Location.setX(0); + timeConstraint_StereotypeLabel_Location.setY(-22); return node; } /** * @generated */ - public Node createGate_Shape(EObject domainElement, View containerView, int index, boolean persisted, + public Node createTimeObservation_Shape(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); - node.setType(UMLVisualIDRegistry.getType(GateEditPart.VISUAL_ID)); + node.setType(UMLVisualIDRegistry.getType(TimeObservationBorderNodeEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); - PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "Gate"); - Node gate_NameLabel = createLabel(node, UMLVisualIDRegistry.getType(GateNameEditPart.VISUAL_ID)); - gate_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); - Location gate_NameLabel_Location = (Location) gate_NameLabel.getLayoutConstraint(); - gate_NameLabel_Location.setX(25); - gate_NameLabel_Location.setY(3); - PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(node, prefStore, "Gate"); + PreferenceInitializerForElementHelper.initFontStyleFromPrefs(node, prefStore, "TimeObservation"); + Node timeObservation_NameLabel = createLabel(node, + UMLVisualIDRegistry.getType(TimeObservationNameEditPart.VISUAL_ID)); + timeObservation_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + Location timeObservation_NameLabel_Location = (Location) timeObservation_NameLabel.getLayoutConstraint(); + timeObservation_NameLabel_Location.setX(25); + timeObservation_NameLabel_Location.setY(3); + Node timeObservation_StereotypeLabel = createLabel(node, + UMLVisualIDRegistry.getType(TimeObservationAppliedStereotypeEditPart.VISUAL_ID)); + timeObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + Location timeObservation_StereotypeLabel_Location = (Location) timeObservation_StereotypeLabel + .getLayoutConstraint(); + timeObservation_StereotypeLabel_Location.setX(0); + timeObservation_StereotypeLabel_Location.setY(-22); return node; } @@ -1266,6 +1177,91 @@ public class UMLViewProvider extends AbstractProvider implements IViewProvider { /** * @generated */ + public Edge createDurationConstraint_Edge(EObject domainElement, View containerView, int index, boolean persisted, + PreferencesHint preferencesHint) { + Connector edge = NotationFactory.eINSTANCE.createConnector(); + edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); + RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); + List<RelativeBendpoint> points = new ArrayList<>(2); + points.add(new RelativeBendpoint()); + points.add(new RelativeBendpoint()); + bendpoints.setPoints(points); + edge.setBendpoints(bendpoints); + ViewUtil.insertChildView(containerView, edge, index, persisted); + edge.setType(UMLVisualIDRegistry.getType(DurationConstraintLinkEditPart.VISUAL_ID)); + edge.setElement(domainElement); + // initializePreferences + final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); + + PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "DurationConstraint"); + // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); + // if (routing != null) { + // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); + // } + Node durationConstraint_NameLabel = createLabel(edge, + UMLVisualIDRegistry.getType(DurationConstraintLinkNameEditPart.VISUAL_ID)); + durationConstraint_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + Location durationConstraint_NameLabel_Location = (Location) durationConstraint_NameLabel.getLayoutConstraint(); + durationConstraint_NameLabel_Location.setX(1); + durationConstraint_NameLabel_Location.setY(-13); + Node durationConstraint_StereotypeLabel = createLabel(edge, + UMLVisualIDRegistry.getType(DurationConstraintLinkAppliedStereotypeEditPart.VISUAL_ID)); + durationConstraint_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + Location durationConstraint_StereotypeLabel_Location = (Location) durationConstraint_StereotypeLabel + .getLayoutConstraint(); + durationConstraint_StereotypeLabel_Location.setX(1); + durationConstraint_StereotypeLabel_Location.setY(-33); + + PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "DurationConstraint"); + return edge; + } + + /** + * @generated + */ + public Edge createDurationObservation_Edge(EObject domainElement, View containerView, int index, boolean persisted, + PreferencesHint preferencesHint) { + Connector edge = NotationFactory.eINSTANCE.createConnector(); + edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); + RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); + List<RelativeBendpoint> points = new ArrayList<>(2); + points.add(new RelativeBendpoint()); + points.add(new RelativeBendpoint()); + bendpoints.setPoints(points); + edge.setBendpoints(bendpoints); + ViewUtil.insertChildView(containerView, edge, index, persisted); + edge.setType(UMLVisualIDRegistry.getType(DurationObservationLinkEditPart.VISUAL_ID)); + edge.setElement(domainElement); + // initializePreferences + final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); + + PreferenceInitializerForElementHelper.initFontStyleFromPrefs(edge, prefStore, "DurationObservation"); + // org.eclipse.gmf.runtime.notation.Routing routing = org.eclipse.gmf.runtime.notation.Routing.get(prefStore.getInt(org.eclipse.gmf.runtime.diagram.ui.preferences.IPreferenceConstants.PREF_LINE_STYLE)); + // if (routing != null) { + // org.eclipse.gmf.runtime.diagram.core.util.ViewUtil.setStructuralFeatureValue(edge, org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); + // } + Node durationObservation_NameLabel = createLabel(edge, + UMLVisualIDRegistry.getType(DurationObservationLinkNameEditPart.VISUAL_ID)); + durationObservation_NameLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + Location durationObservation_NameLabel_Location = (Location) durationObservation_NameLabel + .getLayoutConstraint(); + durationObservation_NameLabel_Location.setX(1); + durationObservation_NameLabel_Location.setY(-13); + Node durationObservation_StereotypeLabel = createLabel(edge, + UMLVisualIDRegistry.getType(DurationObservationLinkAppliedStereotypeEditPart.VISUAL_ID)); + durationObservation_StereotypeLabel.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); + Location durationObservation_StereotypeLabel_Location = (Location) durationObservation_StereotypeLabel + .getLayoutConstraint(); + durationObservation_StereotypeLabel_Location.setX(1); + durationObservation_StereotypeLabel_Location.setY(-33); + + PreferenceInitializerForElementHelper.initLabelVisibilityFromPrefs(edge, prefStore, "DurationObservation"); + return edge; + } + + /** + * @generated + */ protected void stampShortcut(View containerView, Node target) { if (!SequenceDiagramEditPart.MODEL_ID.equals(UMLVisualIDRegistry.getModelID(containerView))) { EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations b/plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations index cf3f14cc273..5d9fe034be2 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations @@ -1155,6 +1155,9 @@ <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_RDj3kHOtEeer__BSotNaQg" identifier="org.eclipse.papyrus.uml.advice.CombinedFragment" target="org.eclipse.papyrus.uml.CombinedFragment" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.CombinedFragmentEditHelperAdvice"/> <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_U6DhsETXEeimO7ZhVBpjkg" identifier="org.eclipse.papyrus.uml.advice.InteractionOperand" target="org.eclipse.papyrus.uml.InteractionOperand" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionOperandEditHelperAdvice"/> <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_VVC0kETXEeimO7ZhVBpjkg" identifier="org.eclipse.papyrus.uml.advice.Interaction" target="org.eclipse.papyrus.uml.Interaction" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionFragmentContainerEditHelperAdvice"/> - <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_MTDR4FeqEeiIM8M4fGXWTg" identifier="org.eclipse.papyrus.uml.advice.StateInvariant" target="org.eclipse.papyrus.uml.StateInvariant" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionFragmentEditHelperAdvice"/> - <adviceBindingsConfigurations xsi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_M02-cFeqEeiIM8M4fGXWTg" identifier="org.eclipse.papyrus.uml.advice.InteractionUse" target="org.eclipse.papyrus.uml.InteractionUse" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionFragmentEditHelperAdvice"/> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_MTDR4FeqEeiIM8M4fGXWTg" identifier="org.eclipse.papyrus.uml.advice.StateInvariant" target="org.eclipse.papyrus.uml.StateInvariant" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionFragmentEditHelperAdvice"/> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_M02-cFeqEeiIM8M4fGXWTg" identifier="org.eclipse.papyrus.uml.advice.InteractionUse" target="org.eclipse.papyrus.uml.InteractionUse" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.InteractionFragmentEditHelperAdvice"/> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_zgVlQH4AEeiKffoiPArZXg" identifier="org.eclipse.papyrus.uml.advice.DurationObservation" target="org.eclipse.papyrus.uml.DurationObservation" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.DurationObservationEditHelperAdvice"/> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_aR9tYLXcEeifBoIyyarpjQ" identifier="org.eclipse.papyrus.uml.advice.DestructionOccurrenceSpecification" target="org.eclipse.papyrus.uml.DestructionOccurrenceSpecification" inheritance="all" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.DestructionOccurrenceSpecificationEditHelperAdvice"/> + <adviceBindingsConfigurations xmi:type="elementtypesconfigurations:AdviceBindingConfiguration" xmi:id="_Gik8YLYCEeifBoIyyarpjQ" description="This advice configures the event (occurrence specification) for a time observation" identifier="org.eclipse.papyrus.uml.service.types.helper.advice.TimeObservation" target="org.eclipse.papyrus.uml.TimeObservation" editHelperAdviceClassName="org.eclipse.papyrus.uml.service.types.helper.advice.TimeObservationEditHelperAdvice"/> </elementtypesconfigurations:ElementTypeSetConfiguration> diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations b/plugins/uml/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations index 48295fcf7c9..96ab693e99e 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations @@ -1033,6 +1033,10 @@ <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_r7U8ENx2EeWVxMf7SXAfhg" iconPath="/icons/full/obj16/DurationConstraint.gif" bundleId="org.eclipse.uml2.uml.edit"/> <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationConstraint"/> </elementTypeConfigurations> + <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="_zZRfUH3REeiyRednYY2ROQ" description="A Duration Constraint, represented as an Edge between its first (duration start) and its second (duration finish) constrained element" identifier="org.eclipse.papyrus.umldi.DurationConstraint_Edge" name="DurationConstraint Edge" hint="DurationConstraint_Edge" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"> + <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_JszLwH3SEeiyRednYY2ROQ" iconPath="/icons/full/obj16/DurationConstraint.gif" bundleId="org.eclipse.uml2.uml.edit"/> + <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationConstraint"/> + </elementTypeConfigurations> <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.umldi.DurationInterval_Shape" identifier="org.eclipse.papyrus.umldi.DurationInterval_Shape" name="Duration Interval Shape" hint="DurationInterval_Shape" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"> <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_sAjaUNx2EeWVxMf7SXAfhg" iconPath="/icons/full/obj16/DurationInterval.gif" bundleId="org.eclipse.uml2.uml.edit"/> <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationInterval"/> @@ -1041,12 +1045,16 @@ <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_sXQDENx2EeWVxMf7SXAfhg" iconPath="/icons/full/obj16/DurationObservation.gif" bundleId="org.eclipse.uml2.uml.edit"/> <specializedTypes xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationObservation.Event"/> </elementTypeConfigurations> + <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.umldi.DurationObservation_Shape_CN" identifier="org.eclipse.papyrus.umldi.DurationObservation_Shape_CN" name="Duration Observation Shape CN" hint="DurationObservation_Shape_CN" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"> + <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_r8CGsNx2EeWVxMf7SXAfhg" iconPath="/icons/full/obj16/DurationObservation.gif" bundleId="org.eclipse.uml2.uml.edit"/> + <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationObservation"/> + </elementTypeConfigurations> <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.umldi.DurationObservation_Shape" identifier="org.eclipse.papyrus.umldi.DurationObservation_Shape" name="Duration Observation Shape" hint="DurationObservation_Shape" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"> <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_r4UEUNx2EeWVxMf7SXAfhg" iconPath="/icons/full/obj16/DurationObservation.gif" bundleId="org.eclipse.uml2.uml.edit"/> <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationObservation"/> </elementTypeConfigurations> - <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.umldi.DurationObservation_Shape_CN" identifier="org.eclipse.papyrus.umldi.DurationObservation_Shape_CN" name="Duration Observation Shape CN" hint="DurationObservation_Shape_CN" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"> - <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="_r8CGsNx2EeWVxMf7SXAfhg" iconPath="/icons/full/obj16/DurationObservation.gif" bundleId="org.eclipse.uml2.uml.edit"/> + <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="__qpi0H38EeiKffoiPArZXg" description="A Duration Observation, represented as an Edge between its first (duration start) and its second (duration finish) events" identifier="org.eclipse.papyrus.umldi.DurationObservation_Edge" name="DurationObservation Edge" hint="DurationObservation_Edge" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"> + <iconEntry xmi:type="elementtypesconfigurations:IconEntry" xmi:id="__qpi0X38EeiKffoiPArZXg" iconPath="/icons/full/obj16/DurationObservation.gif" bundleId="org.eclipse.uml2.uml.edit"/> <specializedTypes xmi:type="elementtypesconfigurations:MetamodelTypeConfiguration" href="platform:/plugin/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations#org.eclipse.papyrus.uml.DurationObservation"/> </elementTypeConfigurations> <elementTypeConfigurations xmi:type="elementtypesconfigurations:SpecializationTypeConfiguration" xmi:id="org.eclipse.papyrus.umldi.Duration_Shape" identifier="org.eclipse.papyrus.umldi.Duration_Shape" name="Duration Shape" hint="Duration_Shape" kind="org.eclipse.gmf.runtime.emf.type.core.IHintedType"> diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java index a10276a43ea..4f7aa873948 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java @@ -1,6 +1,6 @@ /***************************************************************************** * Copyright (c) 2015 CEA LIST and others. - * + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,11 +10,16 @@ * * Contributors: * CEA LIST - Initial API and implementation - * + * *****************************************************************************/ package org.eclipse.papyrus.uml.service.types.helper; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.IdentityCommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.papyrus.infra.gmfdiag.common.commands.CreateRelationshipCommandEx; import org.eclipse.uml2.uml.UMLFactory; import org.eclipse.uml2.uml.ValueSpecification; @@ -24,5 +29,30 @@ public class DurationConstraintEditHelper extends ConstraintEditHelper { protected ValueSpecification createSpecification() { return UMLFactory.eINSTANCE.createDurationInterval(); } - + + /** + * <p> + * Unlike other constraints, a DurationConstraint is a Constraint between two elements; so we support + * creation as a Link. In the sequence diagram, this is currently (2018/07) the only supported way. + * In the future, we may add support for DurationConstraints targetting a single element (The UML + * spec supports that; the multiplicity is [1..2]). + * </p> + */ + @Override + protected ICommand getCreateRelationshipCommand(CreateRelationshipRequest req) { + EObject source = req.getSource(); + EObject target = req.getTarget(); + + boolean noSourceOrTarget = (source == null || target == null); + boolean noSourceAndTarget = (source == null && target == null); + + if (noSourceOrTarget && !noSourceAndTarget) { + // The request isn't complete yet. Return the identity command so + // that the create relationship gesture is enabled. + return IdentityCommand.INSTANCE; + } + + return new CreateRelationshipCommandEx(req); + } + } diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationObservationEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationObservationEditHelper.java new file mode 100644 index 00000000000..acbd1124c00 --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationObservationEditHelper.java @@ -0,0 +1,49 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.uml.service.types.helper; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.IdentityCommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.papyrus.infra.gmfdiag.common.commands.CreateRelationshipCommandEx; + +public class DurationObservationEditHelper extends ElementEditHelper { + + /** + * <p> + * A DurationObservation is an Observation between two named elements; so we support + * creation as a Link. In the sequence diagram, this is currently (2018/07) the only supported way. + * In the future, we may add support for DurationObservations targetting a single named element (The UML + * spec supports that; the multiplicity is [1..2]). + * </p> + */ + @Override + protected ICommand getCreateRelationshipCommand(CreateRelationshipRequest req) { + EObject source = req.getSource(); + EObject target = req.getTarget(); + + boolean noSourceOrTarget = (source == null || target == null); + boolean noSourceAndTarget = (source == null && target == null); + + if (noSourceOrTarget && !noSourceAndTarget) { + // The request isn't complete yet. Return the identity command so + // that the create relationship gesture is enabled. + return IdentityCommand.INSTANCE; + } + + return new CreateRelationshipCommandEx(req); + } + +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java index f2a2dece90e..6aa1b806648 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java @@ -60,7 +60,7 @@ public class LifelineEditHelper extends ElementEditHelper { IElementType elementtype = createRequest.getElementType(); - if (UMLPackage.eINSTANCE.getExecutionSpecification().isSuperTypeOf(elementtype.getEClass())) { + if (elementtype.getEClass() != null && UMLPackage.eINSTANCE.getExecutionSpecification().isSuperTypeOf(elementtype.getEClass())) { Object containerParam = request.getParameters().get(SequenceRequestConstant.INTERACTIONFRAGMENT_CONTAINER); if (containerParam instanceof Interaction || containerParam instanceof InteractionOperand) { diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractOccurrenceLinkEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractOccurrenceLinkEditHelperAdvice.java new file mode 100644 index 00000000000..89de0b2ef90 --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractOccurrenceLinkEditHelperAdvice.java @@ -0,0 +1,231 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.service.types.helper.advice; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.common.core.command.UnexecutableCommand; +import org.eclipse.gmf.runtime.emf.type.core.commands.GetEditContextCommand; +import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; +import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest; +import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant; +import org.eclipse.uml2.uml.DurationConstraint; +import org.eclipse.uml2.uml.DurationObservation; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.ExecutionSpecification; +import org.eclipse.uml2.uml.GeneralOrdering; +import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.OccurrenceSpecification; + +/** + * <p> + * Abstract advice for links connecting {@link OccurrenceSpecification} + * ({@link DurationConstraint}, {@link DurationObservation}, {@link GeneralOrdering}) + * </p> + */ +public abstract class AbstractOccurrenceLinkEditHelperAdvice extends AbstractEditHelperAdvice { + + /** + * <p> + * Retrieve the Source Element from a request (Either a {@link CreateRelationshipRequest}, or a + * related request, e.g. a {@link ConfigureRequest} occurring after a {@link CreateRelationshipRequest}). + * </p> + * + * <p> + * The source element may correspond to the element on which the relationship is created, + * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification}, + * this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}). + * </p> + * + * @param request + * The Edit Request (Typically a {@link CreateRelationshipRequest} or {@link ConfigureRequest}) + * @return + * The source element for this request, or <code>null</code> if no such element can be found + */ + protected Element getSourceElement(AbstractEditCommandRequest request) { + if (request instanceof CreateRelationshipRequest) { + return getSourceElement((CreateRelationshipRequest) request); + } + return getSourceOrTarget(request.getParameter(CreateRelationshipRequest.SOURCE), request.getParameter(SequenceRequestConstant.SOURCE_OCCURRENCE)); + } + + /** + * <p> + * Retrieve the Target Element from a request (Either a {@link CreateRelationshipRequest}, or a + * related request, e.g. a {@link ConfigureRequest} occurring after a {@link CreateRelationshipRequest}). + * </p> + * + * <p> + * The target element may correspond to the element on which the relationship is created, + * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification}, + * this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}). + * </p> + * + * @param request + * The Edit Request (Typically a {@link CreateRelationshipRequest} or {@link ConfigureRequest}) + * @return + * The target element for this request, or <code>null</code> if no such element can be found + */ + protected Element getTargetElement(AbstractEditCommandRequest request) { + if (request instanceof CreateRelationshipRequest) { + return getTargetElement((CreateRelationshipRequest) request); + } + return getSourceOrTarget(request.getParameter(CreateRelationshipRequest.TARGET), request.getParameter(SequenceRequestConstant.TARGET_OCCURRENCE)); + } + + /** + * <p> + * Retrieve the Source Element from a {@link CreateRelationshipRequest} + * </p> + * + * <p> + * The source element may correspond to the element on which the relationship is created, + * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification}, + * this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}). + * </p> + * + * @param request + * The Edit Request (Typically a {@link CreateRelationshipRequest} or {@link ConfigureRequest}) + * @return + * The source element for this request, or <code>null</code> if no such element can be found + */ + protected Element getSourceElement(CreateRelationshipRequest request) { + return getSourceOrTarget(request.getSource(), request.getParameter(SequenceRequestConstant.SOURCE_OCCURRENCE)); + } + + /** + * <p> + * Retrieve the Target Element from a {@link CreateRelationshipRequest} + * </p> + * + * <p> + * The target element may correspond to the element on which the relationship is created, + * or a specific occurrence specification (For example, when creating a link on an {@link ExecutionSpecification}, + * this method may return the specific start or finish {@link OccurrenceSpecification} instead of the {@link ExecutionSpecification}). + * </p> + * + * @param request + * The Edit Request (Typically a {@link CreateRelationshipRequest} or {@link ConfigureRequest}) + * @return + * The source element for this request, or <code>null</code> if no such element can be found + */ + protected Element getTargetElement(CreateRelationshipRequest request) { + return getSourceOrTarget(request.getTarget(), request.getParameter(SequenceRequestConstant.TARGET_OCCURRENCE)); + } + + /** + * <p> + * For Links connecting {@link OccurrenceSpecification}s, the {@link CreateRelationshipRequest} will typically contain two distinct parameters + * for their source, and two for their target. The first one will represent the source/target visual element, + * and the second will represent the real event ({@link OccurrenceSpecification}); typically the start/finish + * {@link OccurrenceSpecification} of the graphical element. + * </p> + * <p> + * This method will take these two values (Which may or may not be valid {@link Element} or {@link OccurrenceSpecification}, + * thus the {@link Object} type), and will return the one that should be used as the source/target of the new Link + * </p> + * + * @param rawElement + * The element that is the source or target of a {@link CreateRelationshipRequest}. (Typically the UML Element + * represented in a Diagram, i.e. an {@link ExecutionSpecification} or a {@link Message}. It may also be + * an {@link OccurrenceSpecification}, e.g. if the Link is created directly from the Model Explorer). + * @param occurrenceParam + * The specific {@link OccurrenceSpecification} referenced by the {@link CreateRelationshipRequest}. Typical values + * may be <code>null</code> (The request doesn't specify which event should be used), an {@link OccurrenceSpecification} + * referenced by the <code>rawElement</code> (Start/Finish occurrence, or Send/Receive event), or the same object as + * <code>rawElement</code>. + * @return + * The source or target semantic element for a Link (Which may be different from + * the graphical element, since {@link OccurrenceSpecification} are not displayed on diagrams) + * + * @see CreateRelationshipRequest#getSource() + * @see CreateRelationshipRequest#getTarget() + * @see SequenceRequestConstant#SOURCE_OCCURRENCE + * @see SequenceRequestConstant#TARGET_OCCURRENCE + * @see CreateRelationshipRequest#SOURCE + * @see CreateRelationshipRequest#TARGET + */ + protected Element getSourceOrTarget(Object rawElement, Object occurrenceParam) { + OccurrenceSpecification occurrence; + if (occurrenceParam instanceof OccurrenceSpecification) { + occurrence = (OccurrenceSpecification) occurrenceParam; + } else if (rawElement instanceof Element) { + return (Element) rawElement; + } else { + return null; + } + + Element element; + if (rawElement instanceof Element) { + element = (Element) rawElement; + } else { + element = null; + } + + // If both the element and occurrence are set, make sure the occurrence belongs to the element + // That's required, because the occurrence parameter might have been added to the request + // when its owner was hovered, and then it wasn't removed when we hovered a different element. + if (element instanceof ExecutionSpecification) { + ExecutionSpecification execSpec = (ExecutionSpecification) element; + if (execSpec.getStart() == occurrence || execSpec.getFinish() == occurrence) { + return occurrence; + } + } else if (element instanceof Message) { + Message message = (Message) element; + if (message.getSendEvent() == occurrence || message.getReceiveEvent() == occurrence) { + return occurrence; + } + } else if (element == occurrence) { + return occurrence; + } + + return element; + } + + @Override + protected ICommand getBeforeEditContextCommand(GetEditContextRequest request) { + if (request.getEditCommandRequest() instanceof CreateRelationshipRequest) { + CreateRelationshipRequest createRequest = (CreateRelationshipRequest) request.getEditCommandRequest(); + EObject source = getSourceElement(createRequest); + EObject target = getTargetElement(createRequest); + if (createRequest.getSource() != null && !isValid(source)) { + return UnexecutableCommand.INSTANCE; + } + if (createRequest.getTarget() != null && !isValid(target)) { + return UnexecutableCommand.INSTANCE; + } + if (source != null && target != null) { + Object editContext = request.getEditContext(); + if (editContext instanceof Element) { + Element creationContainer = getCreationContainer((Element) editContext); + if (creationContainer != null) { + GetEditContextCommand command = new GetEditContextCommand(request); + command.setEditContext(creationContainer); + return command; + } + } + } + } + return super.getBeforeEditContextCommand(request); + } + + protected boolean isValid(EObject sourceOrTarget) { + return sourceOrTarget instanceof OccurrenceSpecification; + } + + protected abstract Element getCreationContainer(Element targetElement); + +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DestructionOccurrenceSpecificationEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DestructionOccurrenceSpecificationEditHelperAdvice.java new file mode 100644 index 00000000000..eb718f7733c --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DestructionOccurrenceSpecificationEditHelperAdvice.java @@ -0,0 +1,201 @@ +/***************************************************************************** + * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christian W. Damus - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.service.types.helper.advice; + +import static java.util.stream.Collectors.toList; +import static org.eclipse.papyrus.uml.service.types.utils.ElementUtil.isTypeOf; + +import java.util.Collection; +import java.util.stream.Stream; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.gmf.runtime.common.core.command.ICommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.uml2.common.util.CacheAdapter; +import org.eclipse.uml2.uml.Component; +import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.DestructionOccurrenceSpecification; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification; +import org.eclipse.uml2.uml.Interaction; +import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.Namespace; +import org.eclipse.uml2.uml.OccurrenceSpecification; +import org.eclipse.uml2.uml.TimeConstraint; +import org.eclipse.uml2.uml.TimeObservation; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Advice for the editing of {@link DestructionOccurrenceSpecification}s. + */ +public class DestructionOccurrenceSpecificationEditHelperAdvice extends InteractionFragmentEditHelperAdvice { + + @Override + public void configureRequest(IEditCommandRequest request) { + super.configureRequest(request); + + if (request instanceof CreateElementRequest) { + configureCreateRequest((CreateElementRequest) request); + } + } + + protected void configureCreateRequest(CreateElementRequest request) { + if (isTypeOf(request.getElementType(), UMLElementTypes.TIME_CONSTRAINT) + && (request.getContainer() instanceof DestructionOccurrenceSpecification)) { + + DestructionOccurrenceSpecification destruction = (DestructionOccurrenceSpecification) request.getContainer(); + + // These constraints can only plausibly be owned by the nearest namespace + Namespace owner = destruction.getEnclosingInteraction(); + if (owner == null) { + owner = destruction.getEnclosingOperand(); + } + if (owner != null) { + // These constraints can only plausibly be owned by the nearest namespace + request.setContainer(owner); + } + } else if (isTypeOf(request.getElementType(), UMLElementTypes.TIME_OBSERVATION) + && (request.getContainer() instanceof DestructionOccurrenceSpecification)) { + + DestructionOccurrenceSpecification destruction = (DestructionOccurrenceSpecification) request.getContainer(); + + // These observations can only plausibly be owned by the nearest package or + // component + Namespace owner = destruction.getNearestPackage(); + Component component = getNearestComponent(destruction); + if (component != null && EcoreUtil.isAncestor(owner, component)) { + owner = component; + } + + if (owner != null) { + // These constraints can only plausibly be owned by the nearest namespace + request.setContainer(owner); + } + } + } + + /** + * Get the nearest {@link Component} containing an {@code element}, recursively. + * + * @param element + * an element + * @return the nearest component containing it, or {@code null} if none + */ + protected Component getNearestComponent(Element element) { + Component result = null; + + for (Element next = element; element != null && result == null; next = next.getOwner()) { + if (next instanceof Component) { + result = (Component) next; + } + } + + return result; + } + + /** + * <pre> + * Add a command to associated {@link OccurrenceSpecification} and {@link Message}. + * This command is only added if the start - finish referenced {@link OccurrenceSpecification} is not + * referenced by another element or the start/finish references are of type {@link ExecutionOccurrenceSpecification}. + * </pre> + * + * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeDestroyDependentsCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest) + * + * @param request + * the request + * @return the command to execute before the edit helper work is done + */ + @Override + protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) { + // Destroy any associated time constraints and time observations + DestructionOccurrenceSpecification destruction = (DestructionOccurrenceSpecification) request.getElementToDestroy(); + Interaction interaction = getInteraction(destruction); + + Stream<TimeConstraint> timeConstraints = getTimeConstraints(interaction, destruction); + Stream<TimeObservation> timeObservations = getTimeObservations(interaction, destruction); + + Collection<? extends EObject> dependentsToDestroy = Stream.concat(timeConstraints, timeObservations).collect(toList()); + return dependentsToDestroy.isEmpty() + ? null + : request.getDestroyDependentsCommand(dependentsToDestroy); + } + + protected Interaction getInteraction(Element element) { + Interaction result = null; + + for (Element next = element; next != null && result == null; next = next.getOwner()) { + if (next instanceof Interaction) { + result = (Interaction) next; + } + } + + return result; + } + + /** + * Get time constraints in the contextual {@code interaction} that constrain only + * the {@code constrained} element and no others. + * + * @param interaction + * the contextual interaction + * @param constrained + * the constrained element + * + * @return its unique time constraints + */ + protected Stream<TimeConstraint> getTimeConstraints(Interaction interaction, Element constrained) { + if (interaction == null) { + return Stream.empty(); + } + + return CacheAdapter.getCacheAdapter(constrained).getNonNavigableInverseReferences(constrained) + .stream() + .filter(setting -> setting.getEStructuralFeature() == UMLPackage.Literals.CONSTRAINT__CONSTRAINED_ELEMENT) + .map(setting -> (Constraint) setting.getEObject()) + .filter(TimeConstraint.class::isInstance) + .filter(c -> c.getConstrainedElements().size() == 1) + .filter(c -> getInteraction(c) == interaction) + .map(TimeConstraint.class::cast); + } + + /** + * Get time observations in the contextual {@code interaction} that reference the given + * {@code observed} element. + * + * @param interaction + * the contextual interaction + * @param observed + * the observed element + * + * @return its unique time constraints + */ + protected Stream<TimeObservation> getTimeObservations(Interaction interaction, Element observed) { + if (interaction == null) { + return Stream.empty(); + } + + // These observations are contained by packages, so the interaction context isn't + // actually useful. It is specified for API consistency with other cases + return CacheAdapter.getCacheAdapter(observed).getNonNavigableInverseReferences(observed) + .stream() + .filter(setting -> setting.getEStructuralFeature() == UMLPackage.Literals.TIME_OBSERVATION__EVENT) + .map(setting -> (TimeObservation) setting.getEObject()); + } +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java index 1fb1fa298d8..d4b658f6e17 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java @@ -1,6 +1,6 @@ /***************************************************************************** - * Copyright (c) 2017 CEA LIST and others. - * + * Copyright (c) 2017 - 2018 CEA LIST, EclipseSource and others. + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -11,10 +11,13 @@ * Contributors: * CEA LIST - Initial API and implementation * Vincent Lorenzo (CEA LIST) - vincent.lorenzo@cea.fr - bug 527259 + * EclipseSource - Bug 536488, 536489 *****************************************************************************/ - package org.eclipse.papyrus.uml.service.types.helper.advice; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; @@ -23,26 +26,31 @@ 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.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; +import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil; import org.eclipse.uml2.uml.Duration; import org.eclipse.uml2.uml.DurationConstraint; import org.eclipse.uml2.uml.DurationInterval; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.Interaction; +import org.eclipse.uml2.uml.OccurrenceSpecification; import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.UMLPackage.Literals; /** * @since 3.0 * */ -public class DurationConstraintEditHelperAdvice extends AbstractEditHelperAdvice { +public class DurationConstraintEditHelperAdvice extends AbstractOccurrenceLinkEditHelperAdvice { /** * Add Duration value to the created Duration Interval * Set name with prefix - * + * * @param durationInterval */ private void initDurationInterval(final DurationInterval durationInterval) { @@ -65,47 +73,124 @@ public class DurationConstraintEditHelperAdvice extends AbstractEditHelperAdvice maxDuration.setExpr(UMLFactory.eINSTANCE.createLiteralInteger()); } - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getAfterEditCommand(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) + * <p> + * Configure the new DurationConstraint with + * </p> * - * @param request * @return */ @Override - public ICommand getAfterEditCommand(final IEditCommandRequest request) { - - ICommand composite = new CompositeCommand("After Edit Command of DurationConstraint");// $NON-NLS-0$ + protected ICommand getAfterConfigureCommand(ConfigureRequest request) { + ICommand composite = new CompositeCommand("After Configure Command of DurationConstraint");// $NON-NLS-0$ + ICommand afterConfigureCommand = super.getAfterConfigureCommand(request); + if (null != afterConfigureCommand && afterConfigureCommand.canExecute()) { + composite.compose(afterConfigureCommand); + } - if (null != super.getAfterEditCommand(request) && super.getAfterEditCommand(request).canExecute()) { - composite.compose(super.getAfterEditCommand(request)); + EObject toConfigure = request.getElementToConfigure(); + if (false == toConfigure instanceof DurationConstraint) { + return composite; } + DurationConstraint constraint = (DurationConstraint) toConfigure; + // Create the command to initialize Duration Interval in case of Duration Constraint - final ICommand command = new AbstractTransactionalCommand(request.getEditingDomain(), "Init DurationConstraint", null) {// $NON-NLS-0$ + final ICommand initInterval = new AbstractTransactionalCommand(request.getEditingDomain(), "Init DurationConstraint Specification", null) { //$NON-NLS-1$ @Override protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { - if (request instanceof ConfigureRequest) { - ConfigureRequest configRequest = (ConfigureRequest) request; - EObject element = configRequest.getElementToConfigure(); - if (element instanceof DurationConstraint) { - if (((DurationConstraint) element).getSpecification() instanceof DurationInterval) { - // initialize Duration Interval - initDurationInterval((DurationInterval) ((DurationConstraint) element).getSpecification()); - } - } + if (constraint.getSpecification() instanceof DurationInterval) { + // initialize Duration Interval + initDurationInterval((DurationInterval) constraint.getSpecification()); } return CommandResult.newOKCommandResult(); - } }; + composite.compose(initInterval); + + // Create the command to initialize the ConstrainedElement (Multiplicity [1..2] + Element source = getSourceElement(request); + Element target = getTargetElement(request); + + if (source != null && target != null) { + final ICommand initConstrainedElements = new AbstractTransactionalCommand(request.getEditingDomain(), "Init DurationConstraint constrained elements", null) { - if (command.canExecute()) { - composite.compose(command); + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + constraint.getConstrainedElements().add(0, source); + if (target != source) { + constraint.getConstrainedElements().add(1, target); + } + return CommandResult.newOKCommandResult(); + } + }; + + composite.compose(initConstrainedElements); } + return composite; } + @Override + protected ICommand getAfterReorientRelationshipCommand(ReorientRelationshipRequest request) { + EObject relationship = request.getRelationship(); + if (relationship instanceof DurationConstraint) { + DurationConstraint constraint = (DurationConstraint) relationship; + EObject newEnd = request.getNewRelationshipEnd(); + if (newEnd instanceof OccurrenceSpecification) { + OccurrenceSpecification newOccurrence = (OccurrenceSpecification) newEnd; + List<Element> values = new ArrayList<>(constraint.getConstrainedElements()); + if (request.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE) { + if (values.isEmpty()) { + values.add(newOccurrence); + } else if (values.size() == 1) { + values.add(0, newOccurrence); + } else if (values.get(0) == newOccurrence) { + return null; + } else { + values.set(0, newOccurrence); + } + } else { // Reorient Target + if (values.isEmpty()) { + values.add(newOccurrence); + } else if (values.size() == 1) { + values.add(newOccurrence); + } else if (values.get(1) == newOccurrence) { + return null; + } else { + values.set(1, newOccurrence); + } + } + + SetRequest setRequest = new SetRequest(constraint, Literals.CONSTRAINT__CONSTRAINED_ELEMENT, values); + return new SetValueCommand(setRequest); + } + } + return super.getAfterReorientRelationshipCommand(request); + } + + /** + * @see org.eclipse.papyrus.uml.service.types.helper.advice.AbstractDurationEditHelperAdvice#getCreationContainer(org.eclipse.uml2.uml.Element) + * + * @param targetElement + * @return + */ + @Override + protected Element getCreationContainer(Element targetElement) { + return findInteraction(targetElement); + } + + protected Interaction findInteraction(Element source) { + Element element = source; + while (element != null) { + if (element instanceof Interaction) { + return (Interaction) element; + } + element = element.getOwner(); + } + return null; + } + } diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java new file mode 100644 index 00000000000..6e448bcf446 --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java @@ -0,0 +1,131 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST, EclipseSource 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: + * EclipseSource - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.uml.service.types.helper.advice; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; +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.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; +import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; +import org.eclipse.uml2.uml.DurationObservation; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.OccurrenceSpecification; +import org.eclipse.uml2.uml.UMLPackage.Literals; + +public class DurationObservationEditHelperAdvice extends AbstractOccurrenceLinkEditHelperAdvice { + + @Override + protected ICommand getAfterConfigureCommand(ConfigureRequest request) { + ICommand composite = new CompositeCommand("After Configure Command of DurationObservation");// $NON-NLS-0$ + ICommand afterConfigureCommand = super.getAfterConfigureCommand(request); + if (null != afterConfigureCommand && afterConfigureCommand.canExecute()) { + composite.compose(afterConfigureCommand); + } + + EObject toConfigure = request.getElementToConfigure(); + if (false == toConfigure instanceof DurationObservation) { + return composite; + } + + DurationObservation observation = (DurationObservation) toConfigure; + + // Create the command to initialize the Events (Multiplicity [1..2] + NamedElement source = getSourceElement(request); + NamedElement target = getTargetElement(request); + + if (source != null && target != null) { + final ICommand initConstrainedElements = new AbstractTransactionalCommand(request.getEditingDomain(), "Init DurationObservation events", null) { + + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + observation.getEvents().add(0, source); + if (target != source) { + observation.getEvents().add(1, target); + } + return CommandResult.newOKCommandResult(); + } + }; + + composite.compose(initConstrainedElements); + } + + return composite; + } + + @Override + protected ICommand getAfterReorientRelationshipCommand(ReorientRelationshipRequest request) { + EObject relationship = request.getRelationship(); + if (relationship instanceof DurationObservation) { + DurationObservation observation = (DurationObservation) relationship; + EObject newEnd = request.getNewRelationshipEnd(); + if (newEnd instanceof OccurrenceSpecification) { + OccurrenceSpecification newOccurrence = (OccurrenceSpecification) newEnd; + List<Element> values = new ArrayList<>(observation.getEvents()); + if (request.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE) { + if (values.isEmpty()) { + values.add(newOccurrence); + } else if (values.size() == 1) { + values.add(0, newOccurrence); + } else if (values.get(0) == newOccurrence) { + return null; + } else { + values.set(0, newOccurrence); + } + } else { // Reorient Target + if (values.isEmpty()) { + values.add(newOccurrence); + } else if (values.size() == 1) { + values.add(newOccurrence); + } else if (values.get(1) == newOccurrence) { + return null; + } else { + values.set(1, newOccurrence); + } + } + + SetRequest setRequest = new SetRequest(observation, Literals.DURATION_OBSERVATION__EVENT, values); + return new SetValueCommand(setRequest); + } + } + return super.getAfterReorientRelationshipCommand(request); + } + + @Override + protected NamedElement getSourceElement(AbstractEditCommandRequest request) { + Element source = super.getSourceElement(request); + return source instanceof NamedElement ? (NamedElement) source : null; + } + + @Override + protected NamedElement getTargetElement(AbstractEditCommandRequest request) { + Element target = super.getTargetElement(request); + return target instanceof NamedElement ? (NamedElement) target : null; + } + + @Override + protected Element getCreationContainer(Element targetElement) { + return targetElement.getNearestPackage(); + } + +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java index 8e10935741c..3c405b583e1 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java @@ -31,13 +31,18 @@ import org.eclipse.gmf.runtime.common.core.command.CommandResult; 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.requests.ConfigureRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest; +import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; import org.eclipse.papyrus.infra.emf.utils.EMFHelper; +import org.eclipse.papyrus.uml.service.types.element.UMLElementTypes; +import org.eclipse.papyrus.uml.service.types.utils.ElementUtil; import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant; import org.eclipse.uml2.uml.Association; import org.eclipse.uml2.uml.ExecutionOccurrenceSpecification; import org.eclipse.uml2.uml.ExecutionSpecification; import org.eclipse.uml2.uml.Interaction; +import org.eclipse.uml2.uml.InteractionOperand; import org.eclipse.uml2.uml.Lifeline; import org.eclipse.uml2.uml.Message; import org.eclipse.uml2.uml.MessageEnd; @@ -53,6 +58,34 @@ import com.google.common.collect.Iterables; */ public class ExecutionSpecificationHelperAdvice extends InteractionFragmentEditHelperAdvice { + @Override + public void configureRequest(IEditCommandRequest request) { + super.configureRequest(request); + + if (request instanceof CreateElementRequest) { + configureCreate((CreateElementRequest) request); + } + } + + private void configureCreate(CreateElementRequest request) { + if (ElementUtil.isTypeOf(request.getElementType(), UMLElementTypes.TIME_CONSTRAINT) + && (request.getContainer() instanceof ExecutionSpecification)) { + + ExecutionSpecification executionSpecification = (ExecutionSpecification) request.getContainer(); + Interaction interaction = executionSpecification.getEnclosingInteraction(); + if (interaction != null) { + request.setContainer(interaction); + } else { + InteractionOperand operand = executionSpecification.getEnclosingOperand(); + if (operand != null) { + request.setContainer(operand); + } + } + } + } + + + /** * Create an execution Occurrence * @@ -72,11 +105,11 @@ public class ExecutionSpecificationHelperAdvice extends InteractionFragmentEditH /** * <pre> * {@inheritDoc} - * + * * Complete the {@link Association} creation by: * adding its {@link Property} ends in the model * adding the UML Nature on the {@link Association}. - * + * * </pre> */ @Override @@ -121,19 +154,19 @@ public class ExecutionSpecificationHelperAdvice extends InteractionFragmentEditH } }; - + return (superResult != null) ? superResult.compose(result) : result; } /** * <pre> * Add a command to associated {@link OccurrenceSpecification} and {@link Message}. - * This command is only added if the start - finish referenced {@link OccurrenceSpecification} is not + * This command is only added if the start - finish referenced {@link OccurrenceSpecification} is not * referenced by another element or the start/finish references are of type {@link ExecutionOccurrenceSpecification}. * </pre> - * + * * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#getBeforeDestroyDependentsCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyDependentsRequest) - * + * * @param request * the request * @return the command to execute before the edit helper work is done @@ -141,50 +174,50 @@ public class ExecutionSpecificationHelperAdvice extends InteractionFragmentEditH @Override protected ICommand getBeforeDestroyDependentsCommand(DestroyDependentsRequest request) { - List<EObject> dependentsToDestroy = new ArrayList<EObject>(); + List<EObject> dependentsToDestroy = new ArrayList<>(); ExecutionSpecification es = (ExecutionSpecification) request.getElementToDestroy(); // Check whether start - finish referenced OccurrenceSpecification should be added to the dependents list OccurrenceSpecification osStart = es.getStart(); - if (shouldDestroyOccurrenceSpecification(es, osStart)&& (!(osStart instanceof MessageEnd))) { + if (shouldDestroyOccurrenceSpecification(es, osStart) && (!(osStart instanceof MessageEnd))) { dependentsToDestroy.add(osStart); } OccurrenceSpecification osFinish = es.getFinish(); - if (shouldDestroyOccurrenceSpecification(es, osFinish)&& (!(osFinish instanceof MessageEnd))) { + if (shouldDestroyOccurrenceSpecification(es, osFinish) && (!(osFinish instanceof MessageEnd))) { dependentsToDestroy.add(osFinish); } - Set<Lifeline> coveredLifelines = new HashSet<Lifeline>(es.getCovereds()); + Set<Lifeline> coveredLifelines = new HashSet<>(es.getCovereds()); // find initiating MOS of a synch message -// InteractionFragment previousIft = InteractionFragmentHelper.findPreviousFragment(osStart, es.getOwner()); -// while (previousIft != null) { -// // keep the first ift with the same lifelines, and check it -// if (coveredLifelines.equals(new HashSet<Lifeline>(previousIft.getCovereds()))) { -// if (previousIft instanceof MessageOccurrenceSpecification) { -// Message msg = ((MessageOccurrenceSpecification) previousIft).getMessage(); -// if (msg != null && MessageSort.SYNCH_CALL_LITERAL.equals(msg.getMessageSort())) { -// dependentsToDestroy.add(previousIft); -// } -// } -// break; -// } -// previousIft = InteractionFragmentHelper.findPreviousFragment(previousIft, es.getOwner()); -// } -// -// // find MOS between the start and finish -// InteractionFragment fragment = osStart; -// while (fragment != null && !fragment.equals(osFinish)) { -// // remove MOS if it have the same covered lifelines as the ES -// if (fragment instanceof MessageOccurrenceSpecification && coveredLifelines.equals(new HashSet<Lifeline>(fragment.getCovereds()))) { -// dependentsToDestroy.add(fragment); -// } -// -// fragment = InteractionFragmentHelper.findNextFragment(fragment, es.getOwner()); -// } -// + // InteractionFragment previousIft = InteractionFragmentHelper.findPreviousFragment(osStart, es.getOwner()); + // while (previousIft != null) { + // // keep the first ift with the same lifelines, and check it + // if (coveredLifelines.equals(new HashSet<Lifeline>(previousIft.getCovereds()))) { + // if (previousIft instanceof MessageOccurrenceSpecification) { + // Message msg = ((MessageOccurrenceSpecification) previousIft).getMessage(); + // if (msg != null && MessageSort.SYNCH_CALL_LITERAL.equals(msg.getMessageSort())) { + // dependentsToDestroy.add(previousIft); + // } + // } + // break; + // } + // previousIft = InteractionFragmentHelper.findPreviousFragment(previousIft, es.getOwner()); + // } + // + // // find MOS between the start and finish + // InteractionFragment fragment = osStart; + // while (fragment != null && !fragment.equals(osFinish)) { + // // remove MOS if it have the same covered lifelines as the ES + // if (fragment instanceof MessageOccurrenceSpecification && coveredLifelines.equals(new HashSet<Lifeline>(fragment.getCovereds()))) { + // dependentsToDestroy.add(fragment); + // } + // + // fragment = InteractionFragmentHelper.findNextFragment(fragment, es.getOwner()); + // } + // // return command to destroy dependents if (!dependentsToDestroy.isEmpty()) { return request.getDestroyDependentsCommand(dependentsToDestroy); @@ -197,12 +230,12 @@ public class ExecutionSpecificationHelperAdvice extends InteractionFragmentEditH * <pre> * Check that given {@link OccurrenceSpecification} should be destroyed along with {@link ExecutionSpecification} which references it. * It should be destroyed in case: - * It is of type {@link ExecutionOccurrenceSpecification} (since the opposite reference + * It is of type {@link ExecutionOccurrenceSpecification} (since the opposite reference * 'ExecutionOccurrenceSpecification::execution[1]' which designates given {@link ExecutionSpecification} is mandatory). * or * It is not used by another element. * </pre> - * + * * @param es * {@link ExecutionSpecification} which references {@link OccurrenceSpecification} (by means of #start/#finish references) * @param os diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java index 9365736569e..059ccef0a45 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java @@ -1,7 +1,6 @@ /***************************************************************************** - * Copyright (c) 2010 CEA LIST. + * Copyright (c) 2010, 2018 CEA LIST, EclipseSource and others. * - * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,8 +9,8 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation + * EclipseSource - Bug 537562 * *****************************************************************************/ package org.eclipse.papyrus.uml.service.types.helper.advice; @@ -20,132 +19,97 @@ package org.eclipse.papyrus.uml.service.types.helper.advice; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.ecore.EObject; 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.common.core.command.UnexecutableCommand; -import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; -import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; +import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; +import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand; import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.GetEditContextRequest; -import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest; import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest; -import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils; -import org.eclipse.papyrus.infra.services.edit.service.IElementEditService; +import org.eclipse.uml2.uml.Element; import org.eclipse.uml2.uml.GeneralOrdering; +import org.eclipse.uml2.uml.Interaction; import org.eclipse.uml2.uml.OccurrenceSpecification; -import org.eclipse.uml2.uml.UMLPackage; +import org.eclipse.uml2.uml.UMLPackage.Literals; /** - * This advice add automatically the constrained element (occurrence specification) for a time constraint * @since 3.0 */ -public class GeneralOrderingHelperAdvice extends AbstractEditHelperAdvice { +public class GeneralOrderingHelperAdvice extends AbstractOccurrenceLinkEditHelperAdvice { - /** - * {@inheritDoc} - */ @Override - protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) { - return new ConfigureElementCommand(request) { + protected ICommand getAfterConfigureCommand(ConfigureRequest request) { + ICommand composite = new CompositeCommand("After Configure Command of GeneralOrdering");// $NON-NLS-0$ + ICommand afterConfigureCommand = super.getAfterConfigureCommand(request); + if (null != afterConfigureCommand && afterConfigureCommand.canExecute()) { + composite.compose(afterConfigureCommand); + } + + EObject toConfigure = request.getElementToConfigure(); + if (false == toConfigure instanceof GeneralOrdering) { + return composite; + } - protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { + GeneralOrdering generalOrdering = (GeneralOrdering) toConfigure; + // Create the command to initialize the Before and After values + Element source = getSourceElement(request); + Element target = getTargetElement(request); - final GeneralOrdering generalOrdering = (GeneralOrdering) request.getElementToConfigure(); - {//set Before - Object paramObject = this.getRequest().getParameter(CreateRelationshipRequest.SOURCE); - if (paramObject instanceof OccurrenceSpecification) { - generalOrdering.setBefore((OccurrenceSpecification)paramObject); - } - } - {//set After + if (source instanceof OccurrenceSpecification && target instanceof OccurrenceSpecification) { + final ICommand initOrderedElements = new AbstractTransactionalCommand(request.getEditingDomain(), "Init GeneralOrdering ordered elements", null) { - Object paramObject = this.getRequest().getParameter(CreateRelationshipRequest.TARGET); - if (paramObject instanceof OccurrenceSpecification) { - generalOrdering.setAfter((OccurrenceSpecification)paramObject); - } + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { + generalOrdering.setBefore((OccurrenceSpecification) source); + generalOrdering.setAfter((OccurrenceSpecification) target); + return CommandResult.newOKCommandResult(); } + }; - return CommandResult.newOKCommandResult(generalOrdering); - } - }; + composite.compose(initOrderedElements); + } + + return composite; } - /** - * <pre> - * {@inheritDoc} - * - * Add a command to related association end during re-orient. - * - * </pre> - */ @Override - protected ICommand getBeforeReorientRelationshipCommand(ReorientRelationshipRequest request) { - - ICommand gmfCommand = super.getBeforeReorientRelationshipCommand(request); - final GeneralOrdering generalOrdering = (GeneralOrdering) request.getRelationship(); - - SetRequest setTypeRequest = null; - - if (request.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE) { - Object paramObject =request.getNewRelationshipEnd(); - System.out.println(paramObject); - if (paramObject instanceof OccurrenceSpecification) { - setTypeRequest = new SetRequest((OccurrenceSpecification)paramObject, UMLPackage.eINSTANCE.getGeneralOrdering_Before(), generalOrdering); - } - else{ - return UnexecutableCommand.INSTANCE; - } - } - else{ - Object paramObject =request.getNewRelationshipEnd(); - if (paramObject instanceof OccurrenceSpecification) { - setTypeRequest = new SetRequest((OccurrenceSpecification)paramObject, UMLPackage.eINSTANCE.getGeneralOrdering_After(), generalOrdering); - } - else{ - return UnexecutableCommand.INSTANCE; - } - - if (setTypeRequest != null) { - // Propagate parameters to the set request - //setTypeRequest.addParameters(request.getParameters()); + protected Element getCreationContainer(Element targetElement) { + return findInteraction(targetElement); + } - IElementEditService provider = ElementEditServiceUtils.getCommandProvider(generalOrdering); - if (provider != null) { - ICommand setTypeCommand = provider.getEditCommand(setTypeRequest); - gmfCommand = CompositeCommand.compose(gmfCommand, setTypeCommand); + @Override + protected ICommand getAfterReorientRelationshipCommand(ReorientRelationshipRequest request) { + EObject relationship = request.getRelationship(); + if (relationship instanceof GeneralOrdering) { + GeneralOrdering ordering = (GeneralOrdering) relationship; + EObject newEnd = request.getNewRelationshipEnd(); + if (newEnd instanceof OccurrenceSpecification) { + SetRequest setRequest; + if (request.getDirection() == ReorientRelationshipRequest.REORIENT_SOURCE) { + setRequest = new SetRequest(ordering, Literals.GENERAL_ORDERING__BEFORE, newEnd); + } else { + setRequest = new SetRequest(ordering, Literals.GENERAL_ORDERING__AFTER, newEnd); } + + return new SetValueCommand(setRequest); } } - return gmfCommand; + return super.getAfterReorientRelationshipCommand(request); } - /** - * @see org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice#approveRequest(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest) - * - * @param request - * @return - */ - @Override - public boolean approveRequest(IEditCommandRequest request) { - if (request instanceof GetEditContextRequest){ - GetEditContextRequest contextRequest= (GetEditContextRequest)request; - IEditCommandRequest editCommandRequest=contextRequest.getEditCommandRequest(); - if(editCommandRequest instanceof CreateRelationshipRequest){ - CreateRelationshipRequest relationshipRequest= (CreateRelationshipRequest)editCommandRequest; - if (relationshipRequest.getSource() == null && relationshipRequest.getTarget() == null) { - return false; - } - if (relationshipRequest.getSource() != null && false == relationshipRequest.getSource() instanceof OccurrenceSpecification) { - return false; - } - if (relationshipRequest.getTarget() != null && false == relationshipRequest.getTarget() instanceof OccurrenceSpecification) { - return false; - } + + protected Interaction findInteraction(Element source) { + Element element = source; + while (element != null) { + if (element instanceof Interaction) { + return (Interaction) element; } + element = element.getOwner(); } - return super.approveRequest(request); + return null; } + + } diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java index ec5f5e2e065..fc3733f1a07 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java @@ -1,7 +1,7 @@ /***************************************************************************** - * Copyright (c) 2010 CEA LIST. + * Copyright (c) 2010, 2018 CEA LIST, Christian W. Damus, and others. + * * - * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,8 @@ * SPDX-License-Identifier: EPL-2.0 * * Contributors: - * + Christian W. Damus - bug 536486 + * * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation * *****************************************************************************/ @@ -33,12 +34,12 @@ import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant; import org.eclipse.uml2.uml.Message; import org.eclipse.uml2.uml.MessageOccurrenceSpecification; import org.eclipse.uml2.uml.MessageSort; -import org.eclipse.uml2.uml.NamedElement; import org.eclipse.uml2.uml.OccurrenceSpecification; import org.eclipse.uml2.uml.TimeConstraint; /** - * This advice add automatically the constrained element (occurrence specification) for a time constraint + * This advice add automatically the constrained element (occurrence specification) for a time constraint + * * @since 3.0 */ public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice { @@ -50,19 +51,20 @@ public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice { protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) { return new ConfigureElementCommand(request) { + @SuppressWarnings("unlikely-arg-type") + @Override protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { - NamedElement element = (NamedElement)request.getElementToConfigure(); - - TimeConstraint newElement = (TimeConstraint)request.getElementToConfigure(); + TimeConstraint newElement = (TimeConstraint) request.getElementToConfigure(); // assign the occurrence specification Object paramOccurrence = getRequest().getParameter(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION); - List<OccurrenceSpecification> occList =getAsOccSpecList(paramOccurrence); + List<OccurrenceSpecification> occList = getAsOccSpecList(paramOccurrence); if (!occList.isEmpty()) { for (OccurrenceSpecification occurrence : occList) { if (occurrence instanceof MessageOccurrenceSpecification) { Message mess = ((MessageOccurrenceSpecification) occurrence).getMessage(); - if (mess != null && occurrence.equals(mess.getReceiveEvent()) && MessageSort.SYNCH_CALL_LITERAL.equals(mess.getMessageSort())) { + if (mess != null && occurrence.equals(mess.getReceiveEvent()) && MessageSort.SYNCH_CALL_LITERAL.equals(mess.getMessageSort()) + && occList.contains(mess.getSendEvent())) { // filter receive event, we prefer the corresponding start event at the same location continue; } @@ -72,11 +74,12 @@ public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice { break; } } - return CommandResult.newOKCommandResult(element); + + return CommandResult.newOKCommandResult(newElement); } }; } - + /** * Get the object safely casted as a list of OccurrenceSpecification * @@ -87,7 +90,7 @@ public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice { if (occurrenceSpecificationList instanceof List<?>) { List<?> list = (List<?>) occurrenceSpecificationList; if (!list.isEmpty()) { - List<OccurrenceSpecification> newList = new ArrayList<OccurrenceSpecification>(list.size()); + List<OccurrenceSpecification> newList = new ArrayList<>(list.size()); for (Object elt : list) { if (elt instanceof OccurrenceSpecification) { newList.add((OccurrenceSpecification) elt); @@ -98,4 +101,5 @@ public class TimeConstraintHelperAdvice extends AbstractEditHelperAdvice { } return Collections.emptyList(); } + } diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeObservationEditHelperAdvice.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeObservationEditHelperAdvice.java new file mode 100644 index 00000000000..5edae94718f --- /dev/null +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeObservationEditHelperAdvice.java @@ -0,0 +1,76 @@ +/***************************************************************************** + * Copyright (c) 2010, 2018 CEA LIST, Christian W. Damus, and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * CEA LIST - Initial API and implementation + * Christian W. Damus - bug 536486 + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.service.types.helper.advice; + + +import static org.eclipse.papyrus.uml.service.types.helper.advice.TimeConstraintHelperAdvice.getAsOccSpecList; + +import java.util.List; + +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.ICommand; +import org.eclipse.gmf.runtime.emf.type.core.commands.ConfigureElementCommand; +import org.eclipse.gmf.runtime.emf.type.core.edithelper.AbstractEditHelperAdvice; +import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest; +import org.eclipse.papyrus.uml.service.types.utils.SequenceRequestConstant; +import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.MessageOccurrenceSpecification; +import org.eclipse.uml2.uml.MessageSort; +import org.eclipse.uml2.uml.OccurrenceSpecification; +import org.eclipse.uml2.uml.TimeObservation; + +/** + * Advice for configuration and editing of {@link TimeObservation}s. + */ +public class TimeObservationEditHelperAdvice extends AbstractEditHelperAdvice { + + @Override + protected ICommand getBeforeConfigureCommand(final ConfigureRequest request) { + return new ConfigureElementCommand(request) { + + @SuppressWarnings("unlikely-arg-type") + @Override + protected CommandResult doExecuteWithResult(IProgressMonitor progressMonitor, IAdaptable info) throws ExecutionException { + TimeObservation newElement = (TimeObservation) request.getElementToConfigure(); + + // assign the occurrence specification + Object paramOccurrence = getRequest().getParameter(SequenceRequestConstant.NEAREST_OCCURRENCE_SPECIFICATION); + List<OccurrenceSpecification> occList = getAsOccSpecList(paramOccurrence); + if (!occList.isEmpty()) { + for (OccurrenceSpecification occurrence : occList) { + if (occurrence instanceof MessageOccurrenceSpecification) { + Message mess = ((MessageOccurrenceSpecification) occurrence).getMessage(); + if (mess != null && occurrence.equals(mess.getReceiveEvent()) && MessageSort.SYNCH_CALL_LITERAL.equals(mess.getMessageSort()) + && occList.contains(mess.getSendEvent())) { + // filter receive event, we prefer the corresponding start event at the same location + continue; + } + } + // otherwise, first occ is just fine + newElement.setEvent(occurrence); + break; + } + } + + return CommandResult.newOKCommandResult(newElement); + } + }; + } + +} diff --git a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java index 4ed605dd3e6..db66deafb1b 100644 --- a/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java +++ b/plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java @@ -17,10 +17,13 @@ package org.eclipse.papyrus.uml.service.types.utils; import org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest; +import org.eclipse.uml2.uml.ExecutionSpecification; +import org.eclipse.uml2.uml.Message; +import org.eclipse.uml2.uml.OccurrenceSpecification; /** * Constants used in the sequence diagram - * + * * @since 3.0 */ public interface SequenceRequestConstant { @@ -33,7 +36,7 @@ public interface SequenceRequestConstant { /** * Add in the request that a element cover another element. - * + * * @deprecated Since version 3.1, use the {@link #COVERED_LIFELINES}, instead. * @see RequestParameterUtils#getCoveredLifelines(IEditCommandRequest) * @see RequestParameterUtils#setCoveredLifelines(IEditCommandRequest, Iterable) @@ -43,7 +46,7 @@ public interface SequenceRequestConstant { /** * Hint providing a collection of covered lifelines ({@code {@literal Collection<Lifeline>}}). - * + * * @since 4.0 * @see RequestParameterUtils#getCoveredLifelines(IEditCommandRequest) * @see RequestParameterUtils#setCoveredLifelines(IEditCommandRequest, Iterable) @@ -63,4 +66,30 @@ public interface SequenceRequestConstant { /** the finish of Execution specification can be replace by an event of a message */ public static final String REPLACE_EXECUTION_SPECIFICATION_FINISH = "REPLACE_EXECUTION_SPECIFICATION_FINISH"; //$NON-NLS-1$ + /** + * <p> + * When creating a Relationship to an {@link ExecutionSpecification} or a {@link Message}, + * this parameter represents the target {@link OccurrenceSpecification}. It may be the start or finish + * occurrence of an {@link ExecutionSpecification}, or the send or receive event of a {@link Message}. + * </p> + * + * <p> + * If this parameter is set, the source of the relationship should reference the {@link OccurrenceSpecification} rather than the original {@link Message} or {@link ExecutionSpecification}. + * </p> + */ + public static final String SOURCE_OCCURRENCE = "Source Occurrence"; + + /** + * <p> + * When creating a Relationship to an {@link ExecutionSpecification} or a {@link Message}, + * this parameter represents the source {@link OccurrenceSpecification}. It may be the start or finish + * occurrence of an {@link ExecutionSpecification}, or the send or receive event of a {@link Message}. + * </p> + * + * <p> + * If this parameter is set, the target of the relationship should reference the {@link OccurrenceSpecification} rather than the original {@link Message} or {@link ExecutionSpecification}. + * </p> + */ + public static final String TARGET_OCCURRENCE = "Target Occurrence"; + } diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/.settings/.api_filters b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/.settings/.api_filters deleted file mode 100644 index 5c64599690b..00000000000 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/.settings/.api_filters +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<component id="org.eclipse.papyrus.uml.properties" version="2"> - <resource path="src/org/eclipse/papyrus/uml/properties/constraints/HasStereotypeConstraint.java" type="org.eclipse.papyrus.uml.properties.constraints.HasStereotypeConstraint"> - <filter comment="Change type (& visibility) of a memory-leak field that should no longer be used" id="388018290"> - <message_arguments> - <message_argument value="org.eclipse.papyrus.uml.properties.constraints.HasStereotypeConstraint"/> - <message_argument value="umlElement"/> - </message_arguments> - </filter> - </resource> -</component> diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt index 2c29867de9c..daedfcded32 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt @@ -1,7 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> -<Composite xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets" +<Composite xmlns="http://www.eclipse.org/xwt/presentation" + xmlns:j="clr-namespace:java.lang" + xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets" xmlns:ppel="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets.layout" - xmlns="http://www.eclipse.org/xwt/presentation" xmlns:j="clr-namespace:java.lang" xmlns:x="http://www.eclipse.org/xwt"> <Composite.layout> <ppel:PropertiesLayout></ppel:PropertiesLayout> @@ -10,6 +11,16 @@ <Composite.layout> <ppel:PropertiesLayout></ppel:PropertiesLayout> </Composite.layout> - <ppe:EnumCombo input="{Binding}" property="UML:NamedElement:visibility"></ppe:EnumCombo> + <ppe:EnumCombo input="{Binding}" + property="UML:NamedElement:visibility"></ppe:EnumCombo> </Composite> -</Composite> + <Composite> + <Composite.layout> + <ppel:PropertiesLayout numColumns="2"></ppel:PropertiesLayout> + </Composite.layout> + <ppe:ReferenceDialog input="{Binding}" + property="UML:GeneralOrdering:before"></ppe:ReferenceDialog> + <ppe:ReferenceDialog input="{Binding}" + property="UML:GeneralOrdering:after"></ppe:ReferenceDialog> + </Composite> +</Composite>
\ No newline at end of file diff --git a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt index 5e73f3ed24b..9f5f9fb262e 100644 --- a/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt +++ b/plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt @@ -1,7 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<Composite xmlns:ppel="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets.layout" - xmlns:j="clr-namespace:java.lang" xmlns:x="http://www.eclipse.org/xwt" - xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets" xmlns="http://www.eclipse.org/xwt/presentation"> +<Composite xmlns="http://www.eclipse.org/xwt/presentation" + xmlns:j="clr-namespace:java.lang" + xmlns:ppe="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets" + xmlns:ppel="clr-namespace:org.eclipse.papyrus.infra.properties.ui.widgets.layout" + xmlns:x="http://www.eclipse.org/xwt"> <Composite.layout> <ppel:PropertiesLayout></ppel:PropertiesLayout> </Composite.layout> @@ -9,13 +11,20 @@ <Composite.layout> <ppel:PropertiesLayout></ppel:PropertiesLayout> </Composite.layout> - <ppe:StringEditor input="{Binding}" property="UML:NamedElement:name"></ppe:StringEditor> - <ppe:StringEditor input="{Binding}" property="UML:NamedElement:label"></ppe:StringEditor> + <ppe:StringEditor input="{Binding}" + property="UML:NamedElement:name"></ppe:StringEditor> + <ppe:StringEditor input="{Binding}" + property="UML:NamedElement:label"></ppe:StringEditor> + <ppe:EnumCombo input="{Binding}" + property="UML:NamedElement:visibility"></ppe:EnumCombo> </Composite> <Composite> <Composite.layout> - <ppel:PropertiesLayout></ppel:PropertiesLayout> + <ppel:PropertiesLayout numColumns="2"></ppel:PropertiesLayout> </Composite.layout> - <ppe:EnumCombo input="{Binding}" property="UML:NamedElement:visibility"></ppe:EnumCombo> + <ppe:ReferenceDialog input="{Binding}" + property="UML:GeneralOrdering:before"></ppe:ReferenceDialog> + <ppe:ReferenceDialog input="{Binding}" + property="UML:GeneralOrdering:after"></ppe:ReferenceDialog> </Composite> -</Composite> +</Composite>
\ No newline at end of file |