diff options
author | Vincent Lorenzo | 2014-06-04 11:51:44 +0000 |
---|---|---|
committer | Vincent Lorenzo | 2014-06-04 11:51:44 +0000 |
commit | 301b28822bce80d4c1af8d88a796041e19fc038a (patch) | |
tree | bb67abddaa1be40a6bf7786ce73fdfee572b0765 | |
parent | 58f9a9441b4124fe6f5d69a944a863b4e285a53a (diff) | |
download | org.eclipse.papyrus-301b28822bce80d4c1af8d88a796041e19fc038a.tar.gz org.eclipse.papyrus-301b28822bce80d4c1af8d88a796041e19fc038a.tar.xz org.eclipse.papyrus-301b28822bce80d4c1af8d88a796041e19fc038a.zip |
Fix reconnect bug
2 files changed, 55 insertions, 39 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/PapyrusConnectionEndEditPolicy.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/PapyrusConnectionEndEditPolicy.java index 4f8f1d7070c..96836a53393 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/PapyrusConnectionEndEditPolicy.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/editpolicies/PapyrusConnectionEndEditPolicy.java @@ -40,6 +40,7 @@ import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer; import org.eclipse.gmf.runtime.draw2d.ui.figures.IAnchorableFigure;
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.CustomFeedbackHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.helper.IdentityAnchorHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.snap.PapyrusConnectionEndpointHandle;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.DiagramEditPartsUtil;
import org.eclipse.papyrus.infra.gmfdiag.common.utils.Util;
@@ -123,13 +124,30 @@ public class PapyrusConnectionEndEditPolicy extends ConnectionEndpointEditPolicy request.setLocation(location);
Map<Object, Object> param = request.getExtendedData();
final PointList copy = getConnection().getPoints().getCopy();
- final String sourceID = ((IAnchorableFigure)getConnection().getSourceAnchor().getOwner()).getConnectionAnchorTerminal(getConnection().getSourceAnchor());
- final String targetID = ((IAnchorableFigure)getConnection().getTargetAnchor().getOwner()).getConnectionAnchorTerminal(getConnection().getTargetAnchor());
+ IFigure sourceOwner = getConnection().getSourceAnchor().getOwner();
+ final String sourceID;
+ if(sourceOwner == null) {
+ //we need to put a value
+ sourceID = IdentityAnchorHelper.createNewAnchorIdValue(0.0, 0.0);
+ } else {
+ sourceID = ((IAnchorableFigure)sourceOwner).getConnectionAnchorTerminal(getConnection().getSourceAnchor());
+ }
+
+
+ IFigure targetOwner = getConnection().getTargetAnchor().getOwner();
+
+
+ final String targetID;
+ if(targetOwner == null) {
+ targetID = IdentityAnchorHelper.createNewAnchorIdValue(0.0, 0.0);
+ } else {
+ targetID = ((IAnchorableFigure)targetOwner).getConnectionAnchorTerminal(getConnection().getTargetAnchor());
+ }
param.put(Util.FEEDBACK_BENDPOINTS, copy);
param.put(Util.FEEDBACK_SOURCE_TERMINAL, sourceID);
param.put(Util.FEEDBKACK_TARGET_TERMINAL, targetID);
- System.out.println("sourceTerm" + sourceID);
- System.out.println("targetRer" + targetID);
+// System.out.println("sourceTerm" + sourceID);
+// System.out.println("targetRer" + targetID);
}
@@ -154,11 +172,9 @@ public class PapyrusConnectionEndEditPolicy extends ConnectionEndpointEditPolicy List<RelativeBendpoint> result = new ArrayList<RelativeBendpoint>();
if(value instanceof Collection<?>) {
final Iterator<?> iter = ((Collection<?>)value).iterator();
- System.out.println("initial bendpoints");
while(iter.hasNext()) {
final Object current = iter.next();
if(current instanceof RelativeBendpoint) {
- // System.out.println("bendpoints" + ((RelativeBendpoint)current).getLocation() + " " + current);
result.add((RelativeBendpoint)current);
}
}
@@ -166,15 +182,6 @@ public class PapyrusConnectionEndEditPolicy extends ConnectionEndpointEditPolicy }
result = Util.copyRelatedBendpointList(result, getConnection());
- Iterator<RelativeBendpoint> iter = result.iterator();
- while(iter.hasNext()) {
- final Object current = iter.next();
- // if(current instanceof RelativeBendpoint) {
- System.out.println("bendpoints" + ((RelativeBendpoint)current).getLocation() + " " + current);
- // result.add((RelativeBendpoint)current);
- // }
- }
-
return result;
}
diff --git a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/DefaultGraphicalNodeEditPolicy.java b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/DefaultGraphicalNodeEditPolicy.java index 30e3054b5e4..27057739365 100644 --- a/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/DefaultGraphicalNodeEditPolicy.java +++ b/plugins/sysml/diagram/org.eclipse.papyrus.sysml.diagram.common/src-common-gmf/org/eclipse/papyrus/gmf/diagram/common/edit/policy/DefaultGraphicalNodeEditPolicy.java @@ -42,7 +42,6 @@ import org.eclipse.gmf.runtime.diagram.ui.internal.commands.SetConnectionBendpoi import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewAndElementRequest; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateConnectionViewRequest; -import org.eclipse.gmf.runtime.draw2d.ui.figures.IAnchorableFigure; import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter; import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest; import org.eclipse.gmf.runtime.notation.Diagram; @@ -248,30 +247,40 @@ public class DefaultGraphicalNodeEditPolicy extends GraphicalNodeEditPolicy { final IFigure fig = request.getConnectionEditPart().getFigure(); if(fig instanceof Connection) { - //2.1 get the points list of the figure - final Connection connection = (Connection)fig; - final PointList points = connection.getPoints(); - - //2.2 save bendpoints - SetConnectionBendpointsCommand connectionBendpoints = new SetConnectionBendpointsCommand(getEditingDomain()); - connectionBendpoints.setNewPointList(points, points.getFirstPoint(), points.getLastPoint()); - connectionBendpoints.setEdgeAdapter(request.getConnectionEditPart()); - cc.add(connectionBendpoints); - - //2.3 save connection anchor - final SetConnectionAnchorsCommand setConnectionAnchorsCommand = new SetConnectionAnchorsCommand(getEditingDomain(), "Set Anchors Command"); - final ConnectionAnchor sourceAnchor = ((IAnchorableFigure)connection.getSourceAnchor().getOwner()).getSourceConnectionAnchorAt(points.getFirstPoint()); - final ConnectionAnchor targetAnchor = ((IAnchorableFigure)node.getFigure()).getTargetConnectionAnchorAt(points.getLastPoint()); - - final String newSourceTerminal = ((IAnchorableFigure)connection.getSourceAnchor().getOwner()).getConnectionAnchorTerminal(sourceAnchor); - final String newTargetTerminal = ((IAnchorableFigure)node.getFigure()).getConnectionAnchorTerminal(targetAnchor); - - setConnectionAnchorsCommand.setEdgeAdaptor(new EObjectAdapter((View)request.getConnectionEditPart().getModel())); - setConnectionAnchorsCommand.setNewSourceTerminal(newSourceTerminal); - setConnectionAnchorsCommand.setNewTargetTerminal(newTargetTerminal); - cc.add(setConnectionAnchorsCommand); - } + Map<?, ?> param = request.getExtendedData(); + if(param.get(Util.FEEDBACK_SOURCE_TERMINAL) != null) {//TODO : use a boolean or a wrapper for these information! + final String newSourceTerminal = (String)param.get(Util.FEEDBACK_SOURCE_TERMINAL); + final String newTargetTerminal = (String)param.get(Util.FEEDBKACK_TARGET_TERMINAL); + final PointList points = (PointList)param.get(Util.FEEDBACK_BENDPOINTS); + //2.1 get the points list of the figure + final Connection connection = (Connection)fig; + // final PointList points = connection.getPoints(); + + //2.2 save bendpoints + SetConnectionBendpointsCommand connectionBendpoints = new SetConnectionBendpointsCommand(getEditingDomain()); + connectionBendpoints.setNewPointList(points, points.getFirstPoint(), points.getLastPoint()); + connectionBendpoints.setEdgeAdapter(request.getConnectionEditPart()); + cc.add(connectionBendpoints); + + //2.3 save connection anchor + final SetConnectionAnchorsCommand setConnectionAnchorsCommand = new SetConnectionAnchorsCommand(getEditingDomain(), "Set Anchors Command"); + // final ConnectionAnchor sourceAnchor = ((IAnchorableFigure)node.getFigure()).getSourceConnectionAnchorAt(points.getFirstPoint()); + // final ConnectionAnchor targetAnchor = ((IAnchorableFigure)connection.getTargetAnchor().getOwner()).getTargetConnectionAnchorAt(points.getLastPoint()); + // final String newSourceTerminal = ((IAnchorableFigure)node.getFigure()).getConnectionAnchorTerminal(sourceAnchor); + // final String newTargetTerminal = ((IAnchorableFigure)connection.getTargetAnchor().getOwner()).getConnectionAnchorTerminal(targetAnchor); + + setConnectionAnchorsCommand.setEdgeAdaptor(new EObjectAdapter((View)request.getConnectionEditPart().getModel())); + setConnectionAnchorsCommand.setNewSourceTerminal(newSourceTerminal); + setConnectionAnchorsCommand.setNewTargetTerminal(newTargetTerminal); + cc.add(setConnectionAnchorsCommand); + + } else { + + //TODO : extract the calculus from PapyrusConnectionEndEditPolicy and put it here! + + } + } return new ICommandProxy(cc); } |