Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2018-07-30 09:03:31 -0400
committerCamille Letavernier2018-07-30 09:03:31 -0400
commita3d9740ab7f30c7de801a88b9eeb95701f6132d7 (patch)
tree6447ac7a33e16c35df445fa9b3cb64d14565e488
parent78a564067d676695afb081339d2c686b42ed8cb0 (diff)
downloadorg.eclipse.papyrus-a3d9740ab7f30c7de801a88b9eeb95701f6132d7.tar.gz
org.eclipse.papyrus-a3d9740ab7f30c7de801a88b9eeb95701f6132d7.tar.xz
org.eclipse.papyrus-a3d9740ab7f30c7de801a88b9eeb95701f6132d7.zip
Bug 536639: [Sequence Diagram] Forbid reconnect on Duration edit parts
https://bugs.eclipse.org/bugs/show_bug.cgi?id=536639 Change-Id: If1406571fb6220c948afe2c0a353c35cc8ba564c Signed-off-by: Camille Letavernier <cletavernier@eclipsesource.com>
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/DestructionOccurrenceGraphicalNodeEditPolicy.java21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/ExecutionSpecificationGraphicalNodeEditPolicy.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/MessageGraphicalNodeEditPolicy.java30
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/DurationLinkUtil.java18
4 files changed, 95 insertions, 4 deletions
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
index 16167d4838a..b7db8caeb91 100644
--- 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
@@ -17,7 +17,10 @@ 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.commands.UnexecutableCommand;
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;
@@ -38,6 +41,24 @@ public class DestructionOccurrenceGraphicalNodeEditPolicy extends DefaultGraphic
}
@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();
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
index 19b20d395d1..cf5c53a774b 100644
--- 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
@@ -12,12 +12,16 @@
*****************************************************************************/
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.commands.UnexecutableCommand;
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;
@@ -49,7 +53,9 @@ public class ExecutionSpecificationGraphicalNodeEditPolicy extends ElementCreati
} else {
sourceOccurrence = execSpec.getFinish();
}
- request.getExtendedData().put(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> extendedData = request.getExtendedData();
+ extendedData.put(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
createRequest.setParameter(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
}
}
@@ -79,7 +85,9 @@ public class ExecutionSpecificationGraphicalNodeEditPolicy extends ElementCreati
} else {
targetOccurrence = execSpec.getFinish();
}
- request.getExtendedData().put(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> extendedData = request.getExtendedData();
+ extendedData.put(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
createRequest.setParameter(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
}
}
@@ -88,6 +96,24 @@ public class ExecutionSpecificationGraphicalNodeEditPolicy extends ElementCreati
}
@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();
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
index 3639bc05476..2a7a2f0b09d 100644
--- 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
@@ -12,12 +12,16 @@
*****************************************************************************/
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.commands.UnexecutableCommand;
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;
@@ -41,7 +45,9 @@ public class MessageGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
if (message != null) {
sourceOccurrence = DurationLinkUtil.isSource(getHostFigure(), request) ? message.getSendEvent() : message.getReceiveEvent();
if (sourceOccurrence instanceof OccurrenceSpecification) {
- request.getExtendedData().put(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> extendedData = request.getExtendedData();
+ extendedData.put(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
createRequest.setParameter(SequenceRequestConstant.SOURCE_OCCURRENCE, sourceOccurrence);
}
}
@@ -61,7 +67,9 @@ public class MessageGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
if (message != null) {
targetOccurrence = DurationLinkUtil.isSource(getHostFigure(), request) ? message.getSendEvent() : message.getReceiveEvent();
if (targetOccurrence instanceof OccurrenceSpecification) {
- request.getExtendedData().put(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> extendedData = request.getExtendedData();
+ extendedData.put(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
createRequest.setParameter(SequenceRequestConstant.TARGET_OCCURRENCE, targetOccurrence);
}
}
@@ -70,6 +78,24 @@ public class MessageGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy {
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;
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
index 47d186427ac..09e3876e2f5 100644
--- 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
@@ -23,6 +23,7 @@ import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.requests.CreateConnectionRequest;
import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
import org.eclipse.gmf.runtime.diagram.core.edithelpers.CreateElementRequestAdapter;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.GraphicalNodeEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest;
@@ -150,4 +151,21 @@ public class DurationLinkUtil {
return true;
}
+
+ /**
+ * <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;
+ }
+
}

Back to the top