Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2018-09-18 07:53:00 -0400
committerPatrick Tessier2018-10-19 03:39:40 -0400
commit94e017428e887c22c9a3ff100cbb5dbc61cd50ad (patch)
tree9ba25ff100522f587f81f9dba15f53a8a213b259
parent353489b4cc8f511882f97c38f98772ddd710df53 (diff)
downloadorg.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>
-rwxr-xr-xplugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/FixAnchorHelper.java22
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/IdentityAnchorHelper.java59
-rw-r--r--plugins/toolsmiths/org.eclipse.papyrus.gmf.figureview/src/org/eclipse/papyrus/gmf/figureview/view/FigureHierarchyView.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editpolicies/BorderItemResizableEditPolicy.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/parser/ObservationParser.java27
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.css/theme/uml.css20
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.restrictions/META-INF/MANIFEST.MF4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.options3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/.settings/.api_filters10
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/META-INF/MANIFEST.MF15
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/LifelineNodePlate.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/AnchorConstants.java72
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/CenterAnchor.java36
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/ConnectionSourceAnchor.java38
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/ConnectionTargetAnchor.java39
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/NodeBottomAnchor.java36
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/anchors/NodeTopAnchor.java36
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/CustomTimeObservationCreateCommand.java105
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/command/RestoreDurationConstraintLinkCommand.java144
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/draw2d/routers/DurationConstraintAutomaticRouter.java90
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/AbstractDurationLinkAdvice.java87
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DurationConstraintLinkAdvice.java31
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/DurationObservationLinkAdvice.java31
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/helpers/advice/GeneralOrderingLinkHelperAdvice.java79
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java126
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractMessageEditPart.java202
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CDestructionOccurrenceSpecificationEditPart.java110
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CInteractionInteractionCompartmentEditPart.java14
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CLifeLineEditPart.java83
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomCommentAnnotatedElementEditPart.java113
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDestructionOccurrenceSpecificationEditPart.java97
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintAppliedStereotypeEditPart.java73
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintEditPart.java926
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintInMessageAppliedStereotypeEditPart.java43
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintInMessageEditPart.java130
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationConstraintLinkEditPart.java77
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationAppliedStereotypeEditPart.java78
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationEditPart.java147
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomDurationObservationLinkEditPart.java78
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomGeneralOrderingEditPart.java53
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintAppliedStereotypeEditPart.java80
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintBorderNodeEditPart.java61
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintEditPart.java168
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeConstraintLabelEditPart.java62
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationAppliedStereotypeEditPart.java86
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationBorderNodeEditPart.java60
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationEditPart.java199
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CustomTimeObservationLabelEditPart.java298
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ITimeElementBorderNodeEditPart.java37
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ObservationLinkEditPart.java72
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeElementEditPartHelper.java216
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkEndEditPolicy.java54
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AnnotatedLinkStartEditPolicy.java11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/AppliedStereotypeCommentCreationEditPolicyEx.java7
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CreationOnMessageEditPolicy.java150
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDestructionOccurrenceSpecificationSemanticEditPolicy.java51
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomDiagramDragDropEditPolicy.java475
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomExecutionSpecificationSemanticEditPolicy.java59
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/CustomLifelineSemanticEditPolicy.java76
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DeleteTimeElementWithoutEventPolicy.java89
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java70
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DurationLinkSelectionHandlesEditPolicy.java294
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationAffixedChildAlignmentPolicy.java169
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java126
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineChildGraphicalNodeEditPolicy.java74
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java112
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OLDSequenceGraphicalNodeEditPolicy.java5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ObservationLinkPolicy.java638
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/OccurenceSemanticEditPolicy.java145
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeElementCreationFeedbackEditPolicy.java202
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/TimeRelatedSelectionEditPolicy.java152
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/CustomGeneralOrderingDescriptor.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventFigure.java53
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DestructionEventNodePlate.java57
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationConstraintFigure.java119
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/DurationLinkFigure.java433
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/ExecutionSpecificationNodePlate.java47
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/FigureHitTestUtil.java140
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineFigure.java101
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/LifelineNodeFigure.java17
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/MessageFigure.java29
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/TimeConstraintFigure.java70
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/TimeObservationFigure.java23
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/figures/doc-files/DurationLinkFigure.pngbin0 -> 3150 bytes
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/CenterLocator.java11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/DurationConstraintLocator.java127
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/IntersectionPointSelectionLocator.java54
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/locator/TimeElementLocator.java229
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/parser/custom/DurationObservationParser.java125
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomDestructionOccurrenceSpecificationEditPolicyProvider.java58
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPartProvider.java49
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomEditPolicyProvider.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomExecutionSpecificationEditPolicyProvider.java19
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomLifelineEditPolicyProvider.java70
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/CustomViewProvider.java197
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/DurationConstraintContributionItem.java319
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/PostEditPolicyProvider.java9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/providers/SemanticOccurrenceEditPolicyProvider.java60
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/ConnectRectangleToGridEditPolicy.java35
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomDestructionOccurrenceSpecificationCreationEditPolicy.java45
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/CustomExecutionSpecificationCreationEditPolicy.java265
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifeLineGraphicalNodeEditPolicy.java9
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/LifelineCreationEditPolicy.java8
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveArrowRequest.java46
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/requests/MoveSeparatorRequest.java51
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/service/DurationCreationTool.java41
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java163
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/GeneralOrderingUtil.java146
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LinkRouteModelElementFactory.java176
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationMoveHelper.java170
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/OccurrenceSpecificationUtil.java268
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java137
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceUtil.java125
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/PapyrusUMLSequenceDiagram.paletteconfiguration27
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/SequenceDiagram.elementtypesconfigurations21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/model/sequenceDiagram.gmfgen956
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/plugin.xml48
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java30
-rw-r--r--[-rwxr-xr-x]plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ContextLinkEditPart.java3
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DestructionOccurrenceSpecificationEditPart.java33
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintEditPart.java256
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageAppliedStereotypeEditPart.java856
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageEditPart.java317
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLabelEditPart.java859
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkAppliedStereotypeEditPart.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintAppliedStereotypeEditPart.java)93
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkEditPart.java123
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintLinkNameEditPart.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationConstraintInMessageLabelEditPart.java)119
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationEditPart.java317
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkAppliedStereotypeEditPart.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationAppliedStereotypeEditPart.java)92
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkEditPart.java131
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLinkNameEditPart.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/DurationObservationLabelEditPart.java)108
-rw-r--r--[-rwxr-xr-x]plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java68
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageAsyncEditPart.java2
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageCreateEditPart.java2
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageDeleteEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundAppliedStereotypeEditPart.java6
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageFoundEditPart.java2
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageLostEditPart.java2
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageReplyEditPart.java2
-rwxr-xr-xplugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/MessageSyncEditPart.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintAppliedStereotypeEditPart.java20
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintBorderNodeEditPart.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintEditPart.java)94
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintNameEditPart.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeConstraintLabelEditPart.java)34
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationAppliedStereotypeEditPart.java26
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationBorderNodeEditPart.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationEditPart.java)78
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationNameEditPart.java (renamed from plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/TimeObservationLabelEditPart.java)41
-rw-r--r--[-rwxr-xr-x]plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/UMLEditPartFactory.java77
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UMLBaseItemSemanticEditPolicy.java34
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/Messages.java119
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditor.java5
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramEditorUtil.java4
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLDiagramUpdater.java741
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/part/UMLVisualIDRegistry.java158
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/ElementInitializers.java131
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLElementTypes.java91
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLParserProvider.java270
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src-gen/org/eclipse/papyrus/uml/diagram/sequence/providers/UMLViewProvider.java306
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/model/uml.elementtypesconfigurations7
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/model/umldi.elementtypesconfigurations12
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationConstraintEditHelper.java36
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/DurationObservationEditHelper.java49
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/LifelineEditHelper.java2
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/AbstractOccurrenceLinkEditHelperAdvice.java231
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DestructionOccurrenceSpecificationEditHelperAdvice.java201
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationConstraintEditHelperAdvice.java141
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/DurationObservationEditHelperAdvice.java131
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/ExecutionSpecificationHelperAdvice.java109
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/GeneralOrderingHelperAdvice.java164
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeConstraintHelperAdvice.java30
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/helper/advice/TimeObservationEditHelperAdvice.java76
-rw-r--r--plugins/uml/org.eclipse.papyrus.uml.service.types/src/org/eclipse/papyrus/uml/service/types/utils/SequenceRequestConstant.java35
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/.settings/.api_filters11
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/MultipleGeneralOrdering.xwt19
-rw-r--r--plugins/uml/properties/org.eclipse.papyrus.uml.properties/Model/UML/ui/SingleGeneralOrdering.xwt25
-rw-r--r--tests/junit/framework/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/PapyrusEditorFixture.java122
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/META-INF/MANIFEST.MF3
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug536631-durationLinks.di2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug536631-durationLinks.notation607
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug536631-durationLinks.uml112
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug536631-durationLinksCreation.di2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug536631-durationLinksCreation.notation116
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug536631-durationLinksCreation.uml32
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug537571-times.di2
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug537571-times.notation497
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/resource/bugs/bug537571-times.uml98
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/AbstractOccurrenceLinkCreationTest.java311
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/AbstractOccurrenceLinkTest.java320
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests.java10
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/BugTests2.java21
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/DurationConstraintCreationTest.java43
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/DurationObservationCreationTest.java43
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/GeneralOrderingCreationTest.java43
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraintDisplay.java82
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationConstraints_384596.java228
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestDurationObservationDisplay.java83
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TestGeneralOrderingDisplay.java76
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TimeElementCreationTest.java451
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/bug/TimeElementMoveTest.java195
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramChildNode.java59
-rw-r--r--tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence.tests/src/org/eclipse/papyrus/uml/diagram/sequence/tests/canonical/TestSequenceDiagramInsideInteraction.java19
202 files changed, 11900 insertions, 11479 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/FixAnchorHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/FixAnchorHelper.java
index 5de99a35d5d..6e6b7d6ea23 100755
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/FixAnchorHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/FixAnchorHelper.java
@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.AbstractPointListShape;
+import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.PositionConstants;
@@ -38,6 +39,7 @@ 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.INodeEditPart;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor;
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
@@ -141,6 +143,22 @@ public class FixAnchorHelper {
protected Point getRealAnchorPoint(final AbstractConnectionEditPart edgeEP, final boolean sourcePoint) {
final IFigure figure = edgeEP.getFigure();
Point point = null;
+ if (figure instanceof Connection) {
+ // Bug 536638: We now have specific Anchors that are dynamically computed, and not based on a X/Y Ratio
+ // We *don't* want to "fix" these!
+ Connection connection = (Connection) figure;
+ if (sourcePoint && connection.getSourceAnchor() != null) {
+ ConnectionAnchor sourceAnchor = connection.getSourceAnchor();
+ if (false == sourceAnchor instanceof BaseSlidableAnchor) {
+ return null;
+ }
+ } else if (!sourcePoint && connection.getTargetAnchor() != null) {
+ ConnectionAnchor targetAnchor = connection.getTargetAnchor();
+ if (false == targetAnchor instanceof BaseSlidableAnchor) {
+ return null;
+ }
+ }
+ }
if (figure instanceof AbstractPointListShape) {
if (sourcePoint) {
point = ((AbstractPointListShape) figure).getStart().getCopy();
@@ -345,12 +363,12 @@ public class FixAnchorHelper {
/**
* Return the side of the point on the included Rectangle
- *
+ *
* @since 3.1
* @param pt
* Point with absolute position
* @return integer representing the position from PositionConstants.
- *
+ *
*/
protected int getSideFromRectangle(Point pt) {
while (getIncludedRect().contains(pt)) {
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/IdentityAnchorHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/IdentityAnchorHelper.java
index 73cb24315aa..d7138f8c37b 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/IdentityAnchorHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/IdentityAnchorHelper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2014 CEA LIST.
+ * Copyright (c) 2014, 2018 CEA LIST, EclipseSource and others.
*
*
* All rights reserved. This program and the accompanying materials
@@ -11,10 +11,13 @@
*
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * EclipseSource - Bug 536638
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.helper;
+import org.eclipse.draw2d.geometry.PrecisionPoint;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor;
import org.eclipse.gmf.runtime.notation.IdentityAnchor;
/**
@@ -43,7 +46,7 @@ public class IdentityAnchorHelper {
/**
* the char separating percentage as string in ids of {@link IdentityAnchor}
*/
- public static final String X_Y_SEPARATOR_AS_STRING = new String(new char[] { X_Y_SEPARATOR });
+ public static final String X_Y_SEPARATOR_AS_STRING = Character.toString(X_Y_SEPARATOR);
/**
*
@@ -57,14 +60,21 @@ public class IdentityAnchorHelper {
/**
*
* @param anchor
- * an anchor
+ * an {@link IdentityAnchor} representing a {@link BaseSlidableAnchor}
* @return
- * the value of x percentage
+ * the value of x percentage
+ * @deprecated
+ * This method only supports {@link IdentityAnchor IdentityAnchors} representing a {@link BaseSlidableAnchor}. Other
+ * anchors would cause an exception. Use {@link BaseSlidableAnchor#parseTerminalString(String)} instead; and check if the
+ * resulting point is != null (If null, then the {@link IdentityAnchor} doesn't represent a {@link BaseSlidableAnchor})
*/
+ @Deprecated
public static final double getXPercentage(final IdentityAnchor anchor) {
- String id = anchor.getId();
- id = id.substring(1, id.indexOf(X_Y_SEPARATOR_AS_STRING));
- return Double.parseDouble(id);
+ PrecisionPoint point = BaseSlidableAnchor.parseTerminalString(anchor.getId());
+ if (point == null) {
+ throw new IllegalArgumentException("Anchor " + anchor.getId() + " is not a valid BaseSlidableAnchor");
+ }
+ return point.preciseX();
}
/**
@@ -72,18 +82,19 @@ public class IdentityAnchorHelper {
* @param anchor
* an anchor
* @return
- * the value of y percentage
+ * the value of y percentage
+ * @deprecated
+ * This method only supports {@link IdentityAnchor IdentityAnchors} representing a {@link BaseSlidableAnchor}. Other
+ * anchors would cause an exception. Use {@link BaseSlidableAnchor#parseTerminalString(String)} instead; and check if the
+ * resulting point is != null (If null, then the {@link IdentityAnchor} doesn't represent a {@link BaseSlidableAnchor})
*/
+ @Deprecated
public static final double getYPercentage(final IdentityAnchor anchor) {
- String id = anchor.getId();
- if(id.indexOf(X_Y_SEPARATOR_AS_STRING)==-1) {
- return 0;
- }
- id = id.substring(id.indexOf(X_Y_SEPARATOR_AS_STRING) + 1, id.length() - 1);
- if(id.indexOf(END_ID)!=-1){
- id = id.substring(0, id.indexOf(END_ID));
+ PrecisionPoint point = BaseSlidableAnchor.parseTerminalString(anchor.getId());
+ if (point == null) {
+ throw new IllegalArgumentException("Anchor " + anchor.getId() + " is not a valid BaseSlidableAnchor");
}
- return Double.parseDouble(id);
+ return point.preciseY();
}
@@ -94,15 +105,15 @@ public class IdentityAnchorHelper {
* @param percentageOnY
* the percentage on y
* @return
- * the string representing the new id for an anchor
+ * the string representing the new id for an anchor
*/
public static final String createNewAnchorIdValue(final double percentageOnX, final double percentageOnY) {
- final StringBuffer buffer = new StringBuffer();
- buffer.append(START_ID);
- buffer.append(Double.toString(percentageOnX));
- buffer.append(X_Y_SEPARATOR_AS_STRING);
- buffer.append(Double.toString(percentageOnY));
- buffer.append(END_ID);
- return buffer.toString();
+ final StringBuilder builder = new StringBuilder();
+ builder.append(START_ID);
+ builder.append(Double.toString(percentageOnX));
+ builder.append(X_Y_SEPARATOR_AS_STRING);
+ builder.append(Double.toString(percentageOnY));
+ builder.append(END_ID);
+ return builder.toString();
}
}
diff --git a/plugins/toolsmiths/org.eclipse.papyrus.gmf.figureview/src/org/eclipse/papyrus/gmf/figureview/view/FigureHierarchyView.java b/plugins/toolsmiths/org.eclipse.papyrus.gmf.figureview/src/org/eclipse/papyrus/gmf/figureview/view/FigureHierarchyView.java
index 41cbc6e0bdf..df8dd843427 100644
--- a/plugins/toolsmiths/org.eclipse.papyrus.gmf.figureview/src/org/eclipse/papyrus/gmf/figureview/view/FigureHierarchyView.java
+++ b/plugins/toolsmiths/org.eclipse.papyrus.gmf.figureview/src/org/eclipse/papyrus/gmf/figureview/view/FigureHierarchyView.java
@@ -97,7 +97,7 @@ public class FigureHierarchyView extends ViewPart {
Object selectedobject = ((IStructuredSelection) selection).getFirstElement();
if (selectedobject instanceof GraphicalEditPart) {
GraphicalEditPart graphicalEP = ((GraphicalEditPart) selectedobject);
- IFigure figure = graphicalEP.getContentPane();
+ IFigure figure = graphicalEP.getFigure();
if (viewer != null) {
viewer.setInput(new Object[] { figure });
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
new 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
Binary files differ
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;