diff options
author | ptessier | 2017-08-11 13:57:37 +0000 |
---|---|---|
committer | Patrick Tessier | 2017-08-25 15:25:17 +0000 |
commit | 3c89b9852b7234e251df4a74225a967d486162fe (patch) | |
tree | ee1c696a906e981890bf906a1f0ccde9137e463e /plugins | |
parent | ec4f46fe7a166e5bb0ef71b80210aa61e499bca0 (diff) | |
download | org.eclipse.papyrus-3c89b9852b7234e251df4a74225a967d486162fe.tar.gz org.eclipse.papyrus-3c89b9852b7234e251df4a74225a967d486162fe.tar.xz org.eclipse.papyrus-3c89b9852b7234e251df4a74225a967d486162fe.zip |
Bug 519891 - [SequenceDiagram] move an element can implies move of other
elements in the sequence diagram
update weak references
Change-Id: I4335ce56501ef6827175ba227882ed0cf4278789
Diffstat (limited to 'plugins')
22 files changed, 637 insertions, 76 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/XYLayoutWithConstrainedResizedEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/XYLayoutWithConstrainedResizedEditPolicy.java index 8e72e2ff9e2..cf0406e747a 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/XYLayoutWithConstrainedResizedEditPolicy.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/XYLayoutWithConstrainedResizedEditPolicy.java @@ -9,7 +9,7 @@ * Contributors:
*
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 520154
+ * C�line Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 520154
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.editpolicies;
@@ -209,7 +209,7 @@ public class XYLayoutWithConstrainedResizedEditPolicy extends XYLayoutEditPolicy /**
* @return the helper
- * @since 3.1.0
+ * @since 3.1
*/
public FixAnchorHelper getHelper() {
return helper;
@@ -218,7 +218,7 @@ public class XYLayoutWithConstrainedResizedEditPolicy extends XYLayoutEditPolicy /**
* @param helper
* the helper to set
- * @since 3.1.0
+ * @since 3.1
*/
public void setHelper(FixAnchorHelper helper) {
this.helper = helper;
@@ -249,7 +249,7 @@ public class XYLayoutWithConstrainedResizedEditPolicy extends XYLayoutEditPolicy * @param notBeingMovedConnections
* List of not being moved Connections
* @return The proxy Command to Fix the Edge Anchor
- * @since 3.1.0
+ * @since 3.1
*/
protected ICommandProxy getMoveChildrenFixEdgeAnchorCommand(Set<Object> notBeingMovedConnections) {
return new ICommandProxy(new FixEdgeAnchorsDeferredCommand(getEditingDomain(), (IGraphicalEditPart) getHost(), notBeingMovedConnections));
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 de2b33d718f..07b56a323f4 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 @@ -9,7 +9,7 @@ *
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 520154
+ * C�line Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 520154
*
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.helper;
@@ -344,7 +344,7 @@ public class FixAnchorHelper { /**
* Return the side of the point on the included Rectangle
*
- * @since 3.1.0
+ * @since 3.1
* @param pt
* Point with absolute position
* @return integer representing the position from PositionConstants.
@@ -361,7 +361,7 @@ public class FixAnchorHelper { /**
* @return the includedRect
- * @since 3.1.0
+ * @since 3.1
*/
public Rectangle getIncludedRect() {
return includedRect;
@@ -370,7 +370,7 @@ public class FixAnchorHelper { /**
* @param includedRect
* the includedRect to set
- * @since 3.1.0
+ * @since 3.1
*/
public void setIncludedRect(Rectangle includedRect) {
this.includedRect = includedRect;
diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF index 42a678d1641..8f3abd8cda0 100644 --- a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.papyrus.uml.architecture;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Localization: plugin Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.papyrus.uml.service.types;bundle-version="[3.0.0,4.0.0)", @@ -25,7 +25,7 @@ Require-Bundle: org.eclipse.papyrus.uml.service.types;bundle-version="[3.0.0,4.0 org.eclipse.papyrus.uml.diagram.deployment;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.uml.diagram.interactionoverview;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.uml.diagram.profile;bundle-version="[3.0.0,4.0.0)", - org.eclipse.papyrus.uml.diagram.sequence;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.uml.diagram.sequence;bundle-version="[4.0.0,5.0.0)", org.eclipse.papyrus.uml.diagram.statemachine;bundle-version="[3.0.0,4.0.0)", org.eclipse.papyrus.uml.diagram.stereotype.edition;bundle-version="[2.0.0,3.0.0)", org.eclipse.papyrus.uml.diagram.timing;bundle-version="[1.3.0,2.0.0)", diff --git a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/pom.xml b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/pom.xml index b0958eef33b..3c69d2d7496 100644 --- a/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/pom.xml +++ b/plugins/uml/architecture/org.eclipse.papyrus.uml.architecture/pom.xml @@ -7,6 +7,6 @@ <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>org.eclipse.papyrus.uml.architecture</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>1.1.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file 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 974be6f00c5..75845e76860 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 @@ -70,7 +70,7 @@ Require-Bundle: org.eclipse.ui.navigator;visibility:=reexport;bundle-version="[3 org.eclipse.draw2d;visibility:=reexport, org.eclipse.gmf.runtime.notation;visibility:=reexport Bundle-Vendor: %providerName -Bundle-Version: 3.0.0.qualifier +Bundle-Version: 4.0.0.qualifier Bundle-ManifestVersion: 2 Bundle-Activator: org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin Bundle-SymbolicName: org.eclipse.papyrus.uml.diagram.sequence; singleton:=true 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 a65de77c9fd..1401ff646b6 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 @@ -39,6 +39,7 @@ 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.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.providers.UMLElementTypes; import org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling.ConnectExecutionToGridEditPolicy; @@ -105,6 +106,7 @@ public abstract class AbstractExecutionSpecificationEditPart extends RoundedComp installEditPolicy(AppliedStereotypeCommentEditPolicy.APPLIED_STEREOTYPE_COMMENT, new AppliedStereotypeCommentCreationEditPolicyEx()); installEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE, new SequenceReferenceEditPolicy()); installEditPolicy(UpdateConnectionReferenceEditPolicy.UDPATE_CONNECTION_REFERENCE, new UpdateConnectionReferenceEditPolicy()); + installEditPolicy(UpdateWeakReferenceForExecSpecEditPolicy.UDPATE_WEAK_REFERENCE_FOR_EXECSPEC, new UpdateWeakReferenceForExecSpecEditPolicy()); } 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 f375a476775..c54ba0cf2e4 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 @@ -20,6 +20,7 @@ import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.uml.diagram.sequence.LifelineNodePlate; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifeLineRestorePositionEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateNodeReferenceEditPolicy; +import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UpdateWeakReferenceForMessageSpecEditPolicy; import org.eclipse.papyrus.uml.diagram.sequence.figures.ILifelineInternalFigure; import org.eclipse.papyrus.uml.diagram.sequence.figures.LifeLineLayoutManager; @@ -36,7 +37,11 @@ public class CLifeLineEditPart extends LifelineEditPart { /** The default width of the figure. */ public static int DEFAUT_WIDTH = 100; - /** The minimum height of the figure. */ + /** + * The minimum height of the figure. + * + * @since 4.0 + */ public static int MIN_HEIGHT = 100; @@ -71,7 +76,7 @@ public class CLifeLineEditPart extends LifelineEditPart { protected void createDefaultEditPolicies() { installEditPolicy(LifeLineRestorePositionEditPolicy.KEY, new LifeLineRestorePositionEditPolicy()); installEditPolicy(UpdateNodeReferenceEditPolicy.UDPATE_NODE_REFERENCE, new UpdateNodeReferenceEditPolicy()); - + installEditPolicy(UpdateWeakReferenceForMessageSpecEditPolicy.UDPATE_WEAK_REFERENCE_FOR_MESSAGE, new UpdateWeakReferenceForMessageSpecEditPolicy()); super.createDefaultEditPolicies(); } @@ -90,7 +95,7 @@ public class CLifeLineEditPart extends LifelineEditPart { /** * @return the size of the header height * if the layout is null return -1 - * @since 3.0 + * @since 4.0 */ public int getStickerHeight() { if (getPrimaryShape().getLifeLineLayoutManager() != null) { diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SenderRequestUtils.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SenderRequestUtils.java index f0f7d8edcc3..318d7aa74e5 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SenderRequestUtils.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SenderRequestUtils.java @@ -22,7 +22,7 @@ import org.eclipse.gef.Request; /**
* this class is used to add senders of request in the request
*
- * @since 3.0
+ * @since 4.0
*
*/
public class SenderRequestUtils {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java index dabcc912b91..58864a225c3 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/SequenceReferenceEditPolicy.java @@ -16,6 +16,7 @@ package org.eclipse.papyrus.uml.diagram.sequence.edit.policies; import java.util.HashMap;
import java.util.Iterator;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartViewer;
@@ -28,16 +29,18 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpec import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractMessageEditPart;
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.sequence.util.LogOptions;
+import org.eclipse.papyrus.uml.diagram.sequence.util.RedirectionCommandStackListener;
import org.eclipse.papyrus.uml.diagram.sequence.util.RedirectionContentAdapter;
+import org.eclipse.papyrus.uml.diagram.sequence.util.RedirectionOperationListener;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.ExecutionSpecification;
import org.eclipse.uml2.uml.Interaction;
+import org.eclipse.uml2.uml.InteractionFragment;
import org.eclipse.uml2.uml.Lifeline;
import org.eclipse.uml2.uml.Message;
import org.eclipse.uml2.uml.MessageEnd;
-import org.eclipse.uml2.uml.NamedElement;
+import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
import org.eclipse.uml2.uml.OccurrenceSpecification;
-import org.eclipse.uml2.uml.UMLPackage;
/**
* this class is used to manage strong and weak references to editPart in the sequence : all execution specification and all messages
@@ -45,7 +48,7 @@ import org.eclipse.uml2.uml.UMLPackage; * and the editpart of the execution specification.
* Two consecutive execution specifications on the same life-line means that a weak reference exists from the top exec to the bottom lifeline.
*
- * @since 3.0
+ * @since 4.0
*/
public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements NotificationListener {
@@ -59,6 +62,8 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements protected HashMap<EditPart, String> weakReferences = new HashMap<EditPart, String>();
protected HashMap<EditPart, String> strongReferences = new HashMap<EditPart, String>();
protected RedirectionContentAdapter redirectionContentAdapter;
+ protected RedirectionCommandStackListener redirectionCommandStackListener;
+ protected RedirectionOperationListener redirectionOperationListener;
/**
* @return the weakReferences
@@ -83,10 +88,8 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements super.activate();
updateStrongAndWeakReferences();
// add a listener to update weak and string references
- redirectionContentAdapter = new RedirectionContentAdapter(this);
- if (getInteraction() != null) {
- getInteraction().eAdapters().add(redirectionContentAdapter);
- }
+ redirectionOperationListener = new RedirectionOperationListener(this);
+ OperationHistoryFactory.getOperationHistory().addOperationHistoryListener(redirectionOperationListener);
}
/**
@@ -95,9 +98,7 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements */
@Override
public void deactivate() {
- if (getInteraction() != null) {
- getInteraction().eAdapters().remove(redirectionContentAdapter);
- }
+ OperationHistoryFactory.getOperationHistory().removeOperationHistoryListener(redirectionOperationListener);
super.deactivate();
}
@@ -105,7 +106,7 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements * compute strong a weak reference
*/
public void updateStrongAndWeakReferences() {
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+ Update String and weak ref " + getHost().getClass().getName());//$NON-NLS-1$ //$NON-NLS-2$
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+ Update Strong and weak ref " + getHost().getClass().getName());//$NON-NLS-1$ //$NON-NLS-2$
strongReferences.clear();
weakReferences.clear();
@@ -168,10 +169,12 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements */
protected void fillWeakReference(OccurrenceSpecification sourceEvent, Lifeline currentLifeline) {
Element nextEvent = getNextEventFromLifeline(currentLifeline, sourceEvent);
- if (nextEvent instanceof MessageEnd) {
- addMessageIntoReferences((MessageEnd) nextEvent, weakReferences, NO_ROLE);
- } else if (nextEvent instanceof OccurrenceSpecification) {
- addExecutionSpecIntoReferences((OccurrenceSpecification) nextEvent, weakReferences, NO_ROLE);
+ if (!isCoveredByStrinReference(nextEvent)) {
+ if (nextEvent instanceof MessageOccurrenceSpecification && isOnlyMessageEnd((MessageOccurrenceSpecification) nextEvent)) {
+ addMessageIntoReferences((MessageEnd) nextEvent, weakReferences, NO_ROLE);
+ } else if (nextEvent instanceof OccurrenceSpecification) {
+ addExecutionSpecIntoReferences((OccurrenceSpecification) nextEvent, weakReferences, NO_ROLE);
+ }
}
}
@@ -229,6 +232,32 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements return nextEvent;
}
+
+ public boolean isCoveredByStrinReference(Element event) {
+ for (Iterator<EditPart> iterator = getStrongReferences().keySet().iterator(); iterator.hasNext();) {
+ EditPart editPart = (EditPart) iterator.next();
+ if (editPart instanceof AbstractMessageEditPart) {
+ Message message = (Message) (((AbstractMessageEditPart) editPart)).resolveSemanticElement();
+ if (message.getSendEvent().equals(event)) {
+ return true;
+ }
+ if (message.getReceiveEvent().equals(event)) {
+ return true;
+ }
+ }
+ if (editPart instanceof AbstractExecutionSpecificationEditPart) {
+ ExecutionSpecification exec = (ExecutionSpecification) (((AbstractExecutionSpecificationEditPart) editPart)).resolveSemanticElement();
+ if (exec.getStart().equals(event)) {
+ return true;
+ }
+ if (exec.getFinish().equals(event)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
/**
* given a messageEnd, the corresponding editPart to a message is adding to the references list
*
@@ -241,11 +270,39 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements if (messageEnd.getMessage() != null) {
IGraphicalEditPart resultedEditPart = getEditPartFromSemantic(messageEnd.getMessage());
if (resultedEditPart != null) {
- referenceList.put(resultedEditPart, role);
+ if (referenceList.equals(strongReferences)) {
+ referenceList.put(resultedEditPart, role);
+ } else if (referenceList.equals(weakReferences) && !(strongReferences.containsKey(resultedEditPart))) {
+ referenceList.put(resultedEditPart, role);
+ }
}
}
}
+
+ /**
+ * test if this event is only use of a message not also for an executionSpecification
+ *
+ * @param messageEnd
+ * @return true if the message End is only used by a message
+ */
+ protected boolean isOnlyMessageEnd(MessageOccurrenceSpecification messageEnd) {
+ InteractionFragment owner = (InteractionFragment) messageEnd.getOwner();
+ if (owner != null) {
+ for (Element fragment : owner.getOwnedElements()) {
+ if (fragment instanceof ExecutionSpecification) {
+ if (messageEnd.equals(((ExecutionSpecification) (fragment)).getStart())) {
+ return false;
+ }
+ if (messageEnd.equals(((ExecutionSpecification) (fragment)).getFinish())) {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
/**
* given a messageEnd, the corresponding editPart to a ExecutionSpec is added to the references list
*
@@ -258,11 +315,21 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements ExecutionSpecification executionSpec = getExecutionSpecificationAssociatedToEvent(sourceEvent);
if (executionSpec != null) {
IGraphicalEditPart resultedEditPart = getEditPartFromSemantic(executionSpec);
- if (resultedEditPart != null) {
- if (executionSpec.getStart().equals(sourceEvent)) {
- referenceList.put(resultedEditPart, ROLE_START);
- } else {
- referenceList.put(resultedEditPart, ROLE_FINISH);
+ if (referenceList.equals(strongReferences)) {
+ if (resultedEditPart != null) {
+ if (executionSpec.getStart().equals(sourceEvent)) {
+ referenceList.put(resultedEditPart, ROLE_START);
+ } else {
+ referenceList.put(resultedEditPart, ROLE_FINISH);
+ }
+ }
+ } else if (referenceList.equals(weakReferences) && !(strongReferences.containsKey(resultedEditPart))) {
+ if (resultedEditPart != null) {
+ if (executionSpec.getStart().equals(sourceEvent)) {
+ referenceList.put(resultedEditPart, ROLE_START);
+ } else {
+ referenceList.put(resultedEditPart, ROLE_FINISH);
+ }
}
}
}
@@ -308,22 +375,7 @@ public class SequenceReferenceEditPolicy extends GraphicalEditPolicy implements */
@Override
public void notifyChanged(Notification notification) {
- if ((UMLPackage.eINSTANCE.getLifeline_CoveredBy().equals(notification.getFeature())) ||
- (UMLPackage.eINSTANCE.getInteractionFragment_Covered().equals(notification.getFeature()))) {
- return;
- }
- if (UMLPackage.eINSTANCE.getMessage_ReceiveEvent().equals(notification.getFeature())
- || UMLPackage.eINSTANCE.getMessage_ReceiveEvent().equals(notification.getFeature())
- || UMLPackage.eINSTANCE.getExecutionSpecification_Start().equals(notification.getFeature())
- || UMLPackage.eINSTANCE.getExecutionSpecification_Finish().equals(notification.getFeature())
- || Notification.CREATE == notification.getEventType()
- || Notification.REMOVE == notification.getEventType()) {
- updateStrongAndWeakReferences();
- if ((((IGraphicalEditPart) getHost()).resolveSemanticElement()) != null) {
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+ " + ((NamedElement) ((IGraphicalEditPart) getHost()).resolveSemanticElement()).getName() + " strongRef " + strongReferences.keySet().size());
- }
- }
-
+ updateStrongAndWeakReferences();
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateConnectionReferenceEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateConnectionReferenceEditPolicy.java index 282fe62413a..380e9015e5e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateConnectionReferenceEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateConnectionReferenceEditPolicy.java @@ -36,7 +36,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.util.LogOptions; * this editpolicy is to manage the movement of Execution specification and update move of messages
* It is like a graphical node
*
- * @since 3.0
+ * @since 4.0
*
*/
public class UpdateConnectionReferenceEditPolicy extends GraphicalEditPolicy {
@@ -76,7 +76,7 @@ public class UpdateConnectionReferenceEditPolicy extends GraphicalEditPolicy { for (Iterator<EditPart> iterator = references.getStrongReferences().keySet().iterator(); iterator.hasNext();) {
EditPart editPart = (EditPart) iterator.next();
if (!SenderRequestUtils.isASender(request, editPart)) {
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> try to Move " + editPart);//$NON-NLS-1$
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> try to Move " + editPart.getClass().getName());//$NON-NLS-1$
if (editPart instanceof ConnectionEditPart) {
ConnectionEditPart connectionEditPart = (ConnectionEditPart) editPart;
ArrayList<EditPart> senderList = SenderRequestUtils.getSenders(request);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java index 68841c550ea..1eb4bb9052a 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateNodeReferenceEditPolicy.java @@ -40,7 +40,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.util.LogOptions; * this editpolicy is to manage the movement of message on node as lifeline
* It is like a graphical node
*
- * @since 3.0
+ * @since 4.0
*
*/
public class UpdateNodeReferenceEditPolicy extends GraphicalEditPolicy {
@@ -57,9 +57,6 @@ public class UpdateNodeReferenceEditPolicy extends GraphicalEditPolicy { * <img src="../../../../../../../../../icons/sequenceScheme.png" width="250" />
* <UL>
* <LI>when move B (anchor of the message)-->
- * If B.y<C.y
- * Move E but not move F this is a resize of the execution specification
- * if B.y> C.y
* Move E and Move F this is a move of the execution specification
* <LI>when move C (anchor of the message)-->move F but not move E this is a resize of the execution specification
* <UL>
@@ -89,21 +86,15 @@ public class UpdateNodeReferenceEditPolicy extends GraphicalEditPolicy { changeBoundsRequest.setEditParts(editPart);
if (references.getStrongReferences().get(editPart).equals(SequenceReferenceEditPolicy.ROLE_START)) {
int delta = (locationOnDiagram.y() - GEPlocationOnDiagram.y());
- if (gEditPart.getFigure().getBounds().height > delta) {
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> Delta " + delta + " " + editPart.getClass().getName());// $NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$
- changeBoundsRequest.setMoveDelta(new Point(0, delta));
- changeBoundsRequest.setSizeDelta(new Dimension(0, -delta));
- } else {// make a move
- UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> Delta " + delta + " " + editPart.getClass().getName());// $NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$
- changeBoundsRequest.setMoveDelta(new Point(0, delta));
- changeBoundsRequest.setSizeDelta(new Dimension(0, 0));
- }
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> Delta " + delta + " " + editPart.getClass().getName());// $NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$
+ changeBoundsRequest.setMoveDelta(new Point(0, delta));
+ changeBoundsRequest.setSizeDelta(new Dimension(0, 0));
}
if (references.getStrongReferences().get(editPart).equals(SequenceReferenceEditPolicy.ROLE_FINISH)) {
int delta = (locationOnDiagram.y() - GEPlocationOnDiagram.y() - gEditPart.getFigure().getBounds().height);
UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> Delta " + delta + " " + editPart.getClass().getName());// $NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-2$
- changeBoundsRequest.setMoveDelta(new Point(0, 0));
- changeBoundsRequest.setSizeDelta(new Dimension(0, delta));
+ changeBoundsRequest.setMoveDelta(new Point(0, delta));
+ changeBoundsRequest.setSizeDelta(new Dimension(0, 0));
}
ArrayList<EditPart> senderList = SenderRequestUtils.getSenders(request);
SenderRequestUtils.addRequestSenders(changeBoundsRequest, senderList);
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceEditPolicy.java new file mode 100644 index 00000000000..05085b85c55 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceEditPolicy.java @@ -0,0 +1,162 @@ +/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+
+
+import java.util.ArrayList;
+
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gef.editpolicies.GraphicalEditPolicy;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
+import org.eclipse.papyrus.uml.diagram.sequence.keyboardlistener.IKeyPressState;
+import org.eclipse.papyrus.uml.diagram.sequence.keyboardlistener.KeyboardListener;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * the goal of this editpat is to propose a set of method and action by SHIFT key button to move messages and execution spec under the current editpart
+ *
+ * @since 4.0
+ *
+ */
+public abstract class UpdateWeakReferenceEditPolicy extends GraphicalEditPolicy implements IKeyPressState {
+
+ protected KeyboardListener SHIFTDown = new KeyboardListener(this, SWT.SHIFT, true);
+ protected KeyboardListener SHIFTUp = new KeyboardListener(this, SWT.SHIFT, false);
+ protected boolean mustMove = true;
+
+ /**
+ * Constructor.
+ *
+ */
+ public UpdateWeakReferenceEditPolicy() {
+ super();
+ }
+
+ @Override
+ public void activate() {
+ super.activate();
+ // activate listeners
+ PlatformUI.getWorkbench().getDisplay().addFilter(SWT.KeyDown, SHIFTDown);
+ PlatformUI.getWorkbench().getDisplay().addFilter(SWT.KeyUp, SHIFTUp);
+ }
+
+ @Override
+ public void deactivate() {
+ PlatformUI.getWorkbench().getDisplay().removeFilter(SWT.KeyDown, SHIFTDown);
+ PlatformUI.getWorkbench().getDisplay().removeFilter(SWT.KeyUp, SHIFTUp);
+ super.deactivate();
+ }
+
+
+ /**
+ * Add a command of reconnection of the given connection editpart at the location.
+ *
+ * @param hostEditpart
+ * the current editpart that is the origin of this impact
+ * @param connectionEditPart
+ * the given editpart to move
+ * @param location
+ * the next location of the anchor
+ * @param senderList
+ * the list of editpart that are origin of this request
+ * @param reconnectType
+ * the type of the reconnection see {@link RequestConstants}
+ * @return return a request of reconnection
+ */
+ protected static ReconnectRequest createReconnectRequest(EditPart hostEditpart, ConnectionEditPart connectionEditPart, Rectangle location, ArrayList<EditPart> senderList, String reconnectType) {
+ ReconnectRequest reconnectRequest = new ReconnectRequest();
+ reconnectRequest.setConnectionEditPart(connectionEditPart);
+ SenderRequestUtils.addRequestSenders(reconnectRequest, senderList);
+ SenderRequestUtils.addRequestSender(reconnectRequest, hostEditpart);
+ reconnectRequest.setLocation(new Point(100, location.y));
+ reconnectRequest.setType(reconnectType);
+ if (RequestConstants.REQ_RECONNECT_TARGET.equals(reconnectType)) {
+ reconnectRequest.setTargetEditPart(connectionEditPart.getTarget());
+ } else {
+ reconnectRequest.setTargetEditPart(connectionEditPart.getSource());
+ }
+ return reconnectRequest;
+ }
+
+ @Override
+ public void setKeyPressState(Boolean isPressed) {
+ mustMove = !isPressed;
+
+ }
+
+ /**
+ * Move the editPart to move at this location withe the move delta
+ *
+ * @param moveDelta
+ * the move delta (very important)
+ * @param compoundCommand
+ * the command that will contain the result of the request
+ * @param editPartToMove
+ * the editpart to move
+ */
+ protected static void moveRoundedEditPart(EditPart hostEditPart, Point moveDelta, CompoundCommand compoundCommand, EditPart editPartToMove, ArrayList<EditPart> senderList) {
+ ChangeBoundsRequest changeBoundsRequest = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
+ SenderRequestUtils.addRequestSenders(changeBoundsRequest, senderList);
+ SenderRequestUtils.addRequestSender(changeBoundsRequest, hostEditPart);
+ GraphicalEditPart gEditPart = (GraphicalEditPart) editPartToMove;
+ changeBoundsRequest.setLocation(new Point(gEditPart.getFigure().getBounds().getTopLeft().x, gEditPart.getFigure().getBounds().getTopLeft().x + moveDelta.y()));
+ changeBoundsRequest.setEditParts(editPartToMove);
+ changeBoundsRequest.setMoveDelta(moveDelta);
+ changeBoundsRequest.setSizeDelta(new Dimension(0, 0));
+ compoundCommand.add(editPartToMove.getCommand(changeBoundsRequest));
+ }
+
+ /**
+ * move the target anchor of the connection editpartPart
+ *
+ * @param hostEditPart
+ * the editpart that impacts the connection editpart
+ * @param moveDelta
+ * the delta to move the anchors
+ * @param compoundCommand
+ * the compound command that can have the result of the request
+ * @param connectionEditPart
+ * the editpart to move
+ * @param senderList
+ * the list of editpart that are origin of this move
+ */
+ protected static void moveTargetConnectionEditPart(EditPart hostEditPart, Point moveDelta, CompoundCommand compoundCommand, ConnectionEditPart connectionEditPart, ArrayList<EditPart> senderList) {
+ PolylineConnectionEx polyline = (PolylineConnectionEx) connectionEditPart.getFigure();
+ Rectangle newAnchorPositionOnScreen;
+ Point positiononScreen = polyline.getTargetAnchor().getReferencePoint();
+ newAnchorPositionOnScreen = new Rectangle(positiononScreen.x, positiononScreen.y + moveDelta.y, 0, 0);
+ ReconnectRequest reconnectTargetRequest = createReconnectRequest(hostEditPart, connectionEditPart, newAnchorPositionOnScreen, senderList, RequestConstants.REQ_RECONNECT_TARGET);
+ compoundCommand.add(connectionEditPart.getTarget().getCommand(reconnectTargetRequest));
+ }
+
+ protected static void moveSourceConnectionEditPart(EditPart hostEditPart, Point moveDelta, CompoundCommand compoundCommand, ConnectionEditPart connectionEditPart, ArrayList<EditPart> senderList) {
+ PolylineConnectionEx polyline = (PolylineConnectionEx) connectionEditPart.getFigure();
+ Point anchorPositionOnScreen = polyline.getSourceAnchor().getReferencePoint();
+ Rectangle newAnchorPositionOnScreen = new Rectangle(anchorPositionOnScreen.x, anchorPositionOnScreen.y + moveDelta.y, 0, 0);
+ ReconnectRequest reconnectSourceRequest = createReconnectRequest(hostEditPart, connectionEditPart, newAnchorPositionOnScreen, senderList, RequestConstants.REQ_RECONNECT_SOURCE);
+ compoundCommand.add(connectionEditPart.getSource().getCommand(reconnectSourceRequest));
+ }
+
+}
\ 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/UpdateWeakReferenceForExecSpecEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForExecSpecEditPolicy.java new file mode 100644 index 00000000000..54a2dc94906 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForExecSpecEditPolicy.java @@ -0,0 +1,110 @@ +/*****************************************************************************
+ * Copyright s(c) 2017 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PrecisionRectangle;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.diagram.sequence.util.LogOptions;
+
+/**
+ * this editpolicy is to manage the movement of Execution specification and update move of messages
+ * It is like a graphical node
+ *
+ * @since 4.0
+ *
+ */
+public class UpdateWeakReferenceForExecSpecEditPolicy extends UpdateWeakReferenceEditPolicy {
+ public static final String UDPATE_WEAK_REFERENCE_FOR_EXECSPEC = "UpdateWeakReferenceForExecSpecEditPolicy"; //$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#getCommand(org.eclipse.gef.Request)
+ *
+ * @param request
+ * @return
+ *
+ *
+ * <img src="../../../../../../../../../icons/sequenceScheme.png" width="250" />
+ * <UL>
+ * <LI>when move E --> move B on the coordinate Y of E and move A on the coordinate Y of E
+ * <LI>when Move F (execution specification) (resize)--> move C on the coordinate of C of F and move D on the coordinate of Y of F
+ * <LI>Move E and F (execution specification) move the execution--> move B on the coordinate of Y of E and move A on the coordinate of Y of E and move C on the coordinate of C of F and move D on the coordinate of Y of F
+ * <UL>
+ *
+ */
+ @Override
+ public Command getCommand(Request request) {
+ if (request instanceof ChangeBoundsRequest && (!org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants.REQ_AUTOSIZE.equals(request.getType()))) {
+ Point nextLocation = ((ChangeBoundsRequest) request).getLocation();
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+ MOVE at " + nextLocation + " of " + getHost());//$NON-NLS-1$ //$NON-NLS-2$
+ Rectangle locationAndSize = new PrecisionRectangle(getHostFigure().getBounds());
+ Point moveDelta = new Point(0, 0);
+ if (RequestConstants.REQ_MOVE.equals(request.getType())) {
+ moveDelta = ((ChangeBoundsRequest) request).getMoveDelta();
+ } else if (RequestConstants.REQ_RESIZE.equals(request.getType())) {
+ moveDelta = new Point(0, ((ChangeBoundsRequest) request).getSizeDelta().height + ((ChangeBoundsRequest) request).getMoveDelta().y);
+ }
+ if (moveDelta.y > 0 && mustMove) {
+ if (getHost() instanceof AbstractExecutionSpecificationEditPart) {
+ getHostFigure().translateToAbsolute(locationAndSize);
+ locationAndSize = ((ChangeBoundsRequest) request).getTransformedRectangle(locationAndSize);
+ }
+ if (getHost().getEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE) != null) {
+ SequenceReferenceEditPolicy references = (SequenceReferenceEditPolicy) getHost().getEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE);
+ if (!SenderRequestUtils.isASender(request, getHost())) {
+ CompoundCommand compoundCommand = new CompoundCommand();
+ for (Iterator<EditPart> iterator = references.getWeakReferences().keySet().iterator(); iterator.hasNext();) {
+ EditPart editPart = (EditPart) iterator.next();
+ if (!SenderRequestUtils.isASender(request, editPart)) {
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> try to Move " + editPart);//$NON-NLS-1$
+ ArrayList<EditPart> senderList = SenderRequestUtils.getSenders(request);
+
+ if (editPart instanceof ConnectionEditPart) {
+ ConnectionEditPart connectionEditPart = (ConnectionEditPart) editPart;
+ // create the request
+ UpdateWeakReferenceEditPolicy.moveSourceConnectionEditPart(getHost(), moveDelta, compoundCommand, connectionEditPart, senderList);
+ UpdateWeakReferenceEditPolicy.moveTargetConnectionEditPart(getHost(), moveDelta, compoundCommand, connectionEditPart, senderList);
+
+ }
+ if (editPart instanceof RoundedCompartmentEditPart) {
+ UpdateWeakReferenceEditPolicy.moveRoundedEditPart(getHost(), moveDelta, compoundCommand, editPart, senderList);
+ }
+ }
+ }
+ if (compoundCommand.size() == 0) {
+ // to avoid pb of non-executable command
+ return super.getCommand(request);
+ }
+
+ return compoundCommand;
+ }
+ }
+ }
+ }
+ return super.getCommand(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 new file mode 100644 index 00000000000..ac8d0995059 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/UpdateWeakReferenceForMessageSpecEditPolicy.java @@ -0,0 +1,113 @@ +/*****************************************************************************
+ * Copyright s(c) 2017 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.Request;
+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.draw2d.ui.figures.PolylineConnectionEx;
+import org.eclipse.papyrus.uml.diagram.common.editparts.RoundedCompartmentEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.diagram.sequence.util.CoordinateReferentialUtils;
+import org.eclipse.papyrus.uml.diagram.sequence.util.LogOptions;
+
+/**
+ * this editpolicy is to manage the movement of Execution specification and update move of messages
+ * It is like a graphical node
+ *
+ * @since 4.0
+ *
+ */
+public class UpdateWeakReferenceForMessageSpecEditPolicy extends UpdateWeakReferenceEditPolicy {
+ public static final String UDPATE_WEAK_REFERENCE_FOR_MESSAGE = "UpdateWeakReferenceForMessageSpecEditPolicy"; //$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.gef.editpolicies.AbstractEditPolicy#getCommand(org.eclipse.gef.Request)
+ *
+ * @param request
+ * @return
+ *
+ *
+ * <img src="../../../../../../../../../icons/sequenceScheme.png" width="250" />
+ * <UL>
+ * <LI>when move E --> move B on the coordinate Y of E and move A on the coordinate Y of E
+ * <LI>when Move F (execution specification) (resize)--> move C on the coordinate of C of F and move D on the coordinate of Y of F
+ * <LI>Move E and F (execution specification) move the execution--> move B on the coordinate of Y of E and move A on the coordinate of Y of E and move C on the coordinate of C of F and move D on the coordinate of Y of F
+ * <UL>
+ *
+ */
+ @Override
+ public Command getCommand(Request request) {
+ if (request instanceof ReconnectRequest && !(SenderRequestUtils.isASender(request, getHost()))) {
+ ReconnectRequest reconnectRequest = (ReconnectRequest) request;
+ ConnectionEditPart hostConnectionEditPart = reconnectRequest.getConnectionEditPart();
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+ MOVE ANCHORS of " + hostConnectionEditPart.getClass().getName());//$NON-NLS-1$
+ Point locationOnDiagram = CoordinateReferentialUtils.transformPointFromScreenToDiagramReferential(reconnectRequest.getLocation(), (GraphicalViewer) getHost().getViewer());
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+-- LocationOnDiagram " + locationOnDiagram);// $NON-NLS-2$ //$NON-NLS-1$
+ // compute Delta
+ Point moveDelta = new Point(0, 0);
+
+ PolylineConnectionEx polyline = (PolylineConnectionEx) hostConnectionEditPart.getFigure();
+
+ if (RequestConstants.REQ_RECONNECT_TARGET.equals(reconnectRequest.getType())) {
+ Point anchorPositionOnScreen = polyline.getSourceAnchor().getReferencePoint();
+ moveDelta.y = reconnectRequest.getLocation().y - anchorPositionOnScreen.y;
+ } else {
+ Point anchorPositionOnScreen = polyline.getSourceAnchor().getReferencePoint();
+ moveDelta.y = reconnectRequest.getLocation().y - anchorPositionOnScreen.y;
+ }
+ if (moveDelta.y > 0 && mustMove) {
+ if (hostConnectionEditPart.getEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE) != null) {
+ SequenceReferenceEditPolicy references = (SequenceReferenceEditPolicy) hostConnectionEditPart.getEditPolicy(SequenceReferenceEditPolicy.SEQUENCE_REFERENCE);
+ if (!SenderRequestUtils.isASender(request, getHost())) {
+ CompoundCommand compoundCommand = new CompoundCommand();
+ for (Iterator<EditPart> iterator = references.getWeakReferences().keySet().iterator(); iterator.hasNext();) {
+ EditPart editPart = (EditPart) iterator.next();
+ if (!SenderRequestUtils.isASender(request, editPart)) {
+ UMLDiagramEditorPlugin.log.trace(LogOptions.SEQUENCE_DEBUG, "+--> try to Move " + editPart);//$NON-NLS-1$
+ ArrayList<EditPart> senderList = SenderRequestUtils.getSenders(request);
+ if (editPart instanceof ConnectionEditPart) {
+ ConnectionEditPart connectionEditPart = (ConnectionEditPart) editPart;
+ // create the request
+ moveSourceConnectionEditPart(hostConnectionEditPart, moveDelta, compoundCommand, connectionEditPart, senderList);
+ moveTargetConnectionEditPart(hostConnectionEditPart, moveDelta, compoundCommand, connectionEditPart, senderList);
+ }
+ if (editPart instanceof RoundedCompartmentEditPart) {
+ moveRoundedEditPart(hostConnectionEditPart, moveDelta, compoundCommand, editPart, senderList);
+ }
+ }
+ }
+ if (compoundCommand.size() == 0) {
+ // to avoid pb of non-executable command
+ return super.getCommand(request);
+ }
+
+ return compoundCommand;
+ }
+ }
+ }
+ }
+ return super.getCommand(request);
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/keyboardlistener/IKeyPressState.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/keyboardlistener/IKeyPressState.java new file mode 100644 index 00000000000..6b5dd864e74 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/keyboardlistener/IKeyPressState.java @@ -0,0 +1,29 @@ +/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.keyboardlistener;
+
+/**
+ * This interface is used to set the status of a key pressed see also {@link KeyboardListener}
+ *
+ */
+public interface IKeyPressState {
+
+ /**
+ *
+ * @param isPressed
+ * true if the key has bee pressed
+ */
+ public void setKeyPressState(Boolean isPressed);
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/keyboardlistener/KeyboardListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/keyboardlistener/KeyboardListener.java new file mode 100644 index 00000000000..e05f395ab42 --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/keyboardlistener/KeyboardListener.java @@ -0,0 +1,45 @@ +/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.keyboardlistener;
+
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+
+/**
+ * This listener listen keyboard and affect the behavior of the grid
+ *
+ */
+public class KeyboardListener implements Listener {
+
+ protected IKeyPressState keyPressState;
+ protected boolean state;
+ protected int keyboard;
+
+ /**
+ * Constructor.
+ *
+ */
+ public KeyboardListener(IKeyPressState keyPressState, int keyboard, boolean state) {
+ this.keyPressState = keyPressState;
+ this.state = state;
+ this.keyboard = keyboard;
+ }
+
+ @Override
+ public void handleEvent(Event event) {
+ if (event.keyCode == keyboard) {
+ keyPressState.setKeyPressState(state);
+ }
+ }
+}
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 692db1fc52e..d79905f9e38 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 @@ -31,7 +31,6 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.SequenceDiagramEditPa import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.AnnotatedConnectionHandleEditPolicy;
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.InteractionFragmentsOrderingEditPolicy;
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;
@@ -85,7 +84,7 @@ public class CustomEditPolicyProvider implements IEditPolicyProvider { }
// Ordering fragments after moving and resizing, See https://bugs.eclipse.org/bugs/show_bug.cgi?id=403233
if (view.isSetElement() && (view.getElement() instanceof InteractionFragment)) {
- editPart.installEditPolicy(InteractionFragmentsOrderingEditPolicy.ORDERING_ROLE, new InteractionFragmentsOrderingEditPolicy());
+ // editPart.installEditPolicy(InteractionFragmentsOrderingEditPolicy.ORDERING_ROLE, new InteractionFragmentsOrderingEditPolicy());
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CoordinateReferentialUtils.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CoordinateReferentialUtils.java index 795574ebd8a..360c3e39078 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CoordinateReferentialUtils.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/CoordinateReferentialUtils.java @@ -24,7 +24,7 @@ import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart; /**
* The purpose of this class is to provide method to transform local coordinates to screen coordinate or absolute coordinate
*
- * @since 3.0
+ * @since 4.0
*/
public class CoordinateReferentialUtils {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java index 45e4e352d45..7af733340fa 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineEditPartUtil.java @@ -116,7 +116,7 @@ public class LifelineEditPartUtil { * @param editPart
* the remove {@link MessageCreateEditPart}
* @return the command when the last create message is remove to a lifeline to move it up and resize it.
- * @since 3.0
+ * @since 4.0
*
*/
public static Command getRestoreLifelinePositionOnMessageCreateRemovedCommand(final ConnectionEditPart editPart) {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/RedirectionCommandStackListener.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/RedirectionCommandStackListener.java new file mode 100644 index 00000000000..f394f87368d --- /dev/null +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/RedirectionCommandStackListener.java @@ -0,0 +1,53 @@ +/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Patrick Tessier (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.sequence.util;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.NotificationImpl;
+import org.eclipse.gef.commands.CommandStackEvent;
+import org.eclipse.gef.commands.CommandStackEventListener;
+import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
+
+/**
+ * this class is to delegate all notification in all trre of an eObject to a notofication listener
+ * for example an editpolicy
+ *
+ * @since 4.0
+ */
+public class RedirectionCommandStackListener implements CommandStackEventListener {
+
+
+ protected NotificationListener notificationListener;
+
+ /**
+ * Constructor.
+ *
+ */
+ public RedirectionCommandStackListener(NotificationListener notificationListener) {
+ this.notificationListener = notificationListener;
+ }
+
+
+
+ /**
+ * @see org.eclipse.gef.commands.CommandStackEventListener#stackChanged(org.eclipse.gef.commands.CommandStackEvent)
+ *
+ * @param event
+ */
+ @Override
+ public void stackChanged(CommandStackEvent event) {
+ notificationListener.notifyChanged(new NotificationImpl(Notification.SET, null, null));
+
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/RedirectionContentAdapter.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/RedirectionContentAdapter.java index bedf07370d4..7d9a4279dbb 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/RedirectionContentAdapter.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/RedirectionContentAdapter.java @@ -21,7 +21,7 @@ import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener; * this class is to delegate all notification in all trre of an eObject to a notofication listener
* for example an editpolicy
*
- * @since 3.0
+ * @since 4.0
*/
public class RedirectionContentAdapter extends EContentAdapter {
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/pom.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/pom.xml index bc183cfc72f..90c66309b9e 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/pom.xml +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/pom.xml @@ -7,6 +7,6 @@ <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.papyrus.uml.diagram.sequence</artifactId>
- <version>3.0.0-SNAPSHOT</version>
+ <version>4.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
\ No newline at end of file |