Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 471139

Summary: Edge creation with its border nodes: difference between feedback and result
Product: [Modeling] Sirius Reporter: Laurent Redor <laurent.redor>
Component: DiagramAssignee: Laurent Redor <laurent.redor>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: florian.barbin, maxime.porhel
Version: 2.0.0Keywords: triaged
Target Milestone: 3.1.0   
Hardware: PC   
OS: Linux   
See Also: https://git.eclipse.org/r/51757
https://git.eclipse.org/r/51759
https://git.eclipse.org/r/53383
https://git.eclipse.org/r/53382
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=08d4a2628b1b9e7f01d4f18635168f07e0b7e4e9
https://git.eclipse.org/c/sirius/org.eclipse.sirius.git/commit/?id=d5f85c079265745f40f599aee3689c611768ec68
Whiteboard:
Attachments:
Description Flags
borderedNode.zip
none
edgeCreationFeedback.png
none
edgeCreationResult.png
none
borderedNode.zip none

Description Laurent Redor CLA 2015-06-26 10:16:13 EDT
Created attachment 254751 [details]
borderedNode.zip

When we create an edge with its associated border nodes, there is sometimes a difference between the feedback and the result.

Steps to reproduce:
* Import the project "borderedNode" from borderedNode.zip (this data has been inspired from /org.eclipse.sirius.tests.swtbot/data/unit/tools/creation/borderedNode).
* Open the diagram "diagWithEdgeOnBorderNode" from this project
* Check that:
** The snap to grid is enabled
** The grid spacing is set to 2 pixels
* Use the tool "Create 2 inherited interfaces" from "P5-2", point {150, 205}, to "P5-3", point {160, 306}. The feedback is straight (edgeCreationFeedback.png), but the result is an oblique edge (edgeCreationResul.png).
Comment 1 Laurent Redor CLA 2015-06-26 10:16:32 EDT
Created attachment 254752 [details]
edgeCreationFeedback.png
Comment 2 Laurent Redor CLA 2015-06-26 10:16:46 EDT
Created attachment 254753 [details]
edgeCreationResult.png
Comment 3 Laurent Redor CLA 2015-06-30 11:31:48 EDT
Technical analysis:
The feedback is shown by org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy.showCreationFeedback(CreateConnectionRequest).
The command is build through org.eclipse.sirius.diagram.ui.graphical.edit.policies.SiriusGraphicalNodeEditPolicy.buildSiriusConnectionCreationCmd(CreateConnectionRequest).

The feedback figure is straightened by the router that consider a "margin" for that (org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor.STRAIGHT_LINE_TOLERANCE used indirectly in org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ObliqueRouter.resetEndPointsToEdge(Connection, PointList) during the showCreationFeedback).

But the command is build from the data of the request (that currently completely ignores the magic of the router).
Comment 4 Laurent Redor CLA 2015-07-01 03:08:31 EDT
The SiriusGraphicalNodeEditPolicy used to build the command has not access to the feedback. Indeed, the feedback is created by the SiriusGraphicalNodeEditPolicy of the source of the edge and the command is build by the SiriusGraphicalNodeEditPolicy of the target of the edge.
Comment 5 Laurent Redor CLA 2015-07-01 05:03:19 EDT
Created attachment 254871 [details]
borderedNode.zip

In fact, the problem is the same without the border nodes. I updated the use case.

Steps to reproduce:
* Import the project "borderedNode" from borderedNode.zip (this data has been inspired from /org.eclipse.sirius.tests.swtbot/data/unit/tools/creation/borderedNode).
* Open the diagram "diagWithEdgeOnBorderNode" from this project
* Check that:
** The snap to grid is enabled
** The grid spacing is set to 2 pixels
* Use the tool "Reference" from "C1", point {650, 205}, to "C2", point {659, 307}. The feedback is straight, but the result is an oblique edge.
Comment 6 Laurent Redor CLA 2015-07-10 13:23:52 EDT
Here is the status of my current analysis. I'm in holiday until the 31/07/2015 so I cannot finalize this bug.

1- The source feedback is shown (but with a deffered update for the figure)
*******org.eclipse.sirius.diagram.ui.tools.internal.part.SiriusDiagramGraphicalViewer$ToggleUpdateManager.sendUpdateRequest(SiriusDiagramGraphicalViewer.java:176)
org.eclipse.draw2d.DeferredUpdateManager.queueWork(DeferredUpdateManager.java:247)
org.eclipse.sirius.diagram.ui.tools.internal.part.SiriusDiagramGraphicalViewer$ToggleUpdateManager.queueWork(SiriusDiagramGraphicalViewer.java:285)
org.eclipse.draw2d.DeferredUpdateManager.addInvalidFigure(DeferredUpdateManager.java:133)
org.eclipse.draw2d.Figure.revalidate(Figure.java:1448)
org.eclipse.draw2d.Figure.revalidate(Figure.java:1450)
org.eclipse.draw2d.Figure.revalidate(Figure.java:1450)
org.eclipse.draw2d.Figure.revalidate(Figure.java:1450)
org.eclipse.draw2d.Figure.revalidate(Figure.java:1450)
org.eclipse.draw2d.PolylineConnection.revalidate(PolylineConnection.java:224)
org.eclipse.draw2d.PolylineConnection.setTargetAnchor(PolylineConnection.java:314)
org.eclipse.gef.editpolicies.FeedbackHelper.setAnchor(FeedbackHelper.java:85)
org.eclipse.gef.editpolicies.FeedbackHelper.update(FeedbackHelper.java:99)
******org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy.showCreationFeedback(GraphicalNodeEditPolicy.java:287)
org.eclipse.sirius.diagram.ui.graphical.edit.policies.SiriusGraphicalNodeEditPolicy.showCreationFeedback(SiriusGraphicalNodeEditPolicy.java:1395)
org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy.showSourceFeedback(GraphicalNodeEditPolicy.java:298)
org.eclipse.gef.editparts.AbstractEditPart.showSourceFeedback(AbstractEditPart.java:1093)
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.showSourceFeedback(GraphicalEditPart.java:1380)
******org.eclipse.gef.tools.AbstractConnectionCreationTool.showSourceFeedback(AbstractConnectionCreationTool.java:377)
org.eclipse.gef.tools.AbstractConnectionCreationTool.handleMove(AbstractConnectionCreationTool.java:319)

2- The target feedback is shown and the command is constructed (but not always with the real data about edge feedback because of the deffered update of the figure)
org.eclipse.sirius.diagram.ui.graphical.edit.policies.SiriusGraphicalNodeEditPolicy.buildSiriusConnectionCreationCmd(CreateConnectionRequest)
org.eclipse.sirius.diagram.ui.graphical.edit.policies.SiriusGraphicalNodeEditPolicy.getConnectionCompleteCommand(SiriusGraphicalNodeEditPolicy.java:708)
...
******org.eclipse.gef.tools.AbstractConnectionCreationTool.showTargetFeedback(AbstractConnectionCreationTool.java:377)
org.eclipse.gef.tools.AbstractConnectionCreationTool.handleMove(AbstractConnectionCreationTool.java:319)

3-The edge feedback is really drawn
org.eclipse.gmf.runtime.draw2d.ui.figures.BaseSlidableAnchor.normalizeToStraightlineTolerance(Point, Point, int)
...
org.eclipse.gmf.runtime.draw2d.ui.internal.routers.RouterHelper.resetEndPointsToEdge(RouterHelper.java:479)
org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ObliqueRouter.resetEndPointsToEdge(ObliqueRouter.java:997)
org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ObliqueRouter.routeLine(ObliqueRouter.java:502)
org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ObliqueRouter.routeBendpoints(ObliqueRouter.java:210)
org.eclipse.gmf.runtime.draw2d.ui.internal.routers.ObliqueRouter.route(ObliqueRouter.java:195)
org.eclipse.draw2d.AutomaticRouter.route(AutomaticRouter.java:151)
org.eclipse.gmf.runtime.draw2d.ui.internal.routers.FanRouter.routeBendpoints(FanRouter.java:55)
org.eclipse.gmf.runtime.draw2d.ui.internal.routers.FanRouter.route(FanRouter.java:39)
org.eclipse.draw2d.PolylineConnection.layout(PolylineConnection.java:176)
org.eclipse.draw2d.Figure.validate(Figure.java:1896)
org.eclipse.draw2d.Figure.validate(Figure.java:1898)
...

After this analysis, the only solution that I imagine is to pass the figure to the request in ExtendedMetaData. And compute the EdgeLayoutData from this edge only during the execution of the command. At this moment, the feedback figure will be the last one (after deffered update). But I did not think this is a "clean solution".
Comment 7 Eclipse Genie CLA 2015-07-10 13:25:24 EDT
New Gerrit change created: https://git.eclipse.org/r/51757
Comment 8 Laurent Redor CLA 2015-07-10 13:33:35 EDT
The above gerrit corresponds to my analysis of comment 6.
Comment 9 Eclipse Genie CLA 2015-07-10 13:58:39 EDT
New Gerrit change created: https://git.eclipse.org/r/51759
Comment 10 Laurent Redor CLA 2015-07-10 14:00:56 EDT
I finally quickly tried the solution with edge figure passes to the request. It seems to work... Do not hesitate to comment the above gerrit.
Comment 11 Eclipse Genie CLA 2015-08-07 04:57:28 EDT
New Gerrit change created: https://git.eclipse.org/r/53383
Comment 12 Eclipse Genie CLA 2015-08-07 04:57:32 EDT
New Gerrit change created: https://git.eclipse.org/r/53382
Comment 15 Laurent Redor CLA 2015-08-07 08:37:05 EDT
Resolved with above commits.
Comment 16 Florian Barbin CLA 2015-09-23 08:52:01 EDT
Verified with 3.1.0.201509211006
Comment 17 Pierre-Charles David CLA 2015-10-16 09:10:14 EDT
Available in Sirius 3.1.0.