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

Bug 342874

Summary: CreateConnectionCommand overwriting "sourceLocation" with "targetLocation" on creation of a Connection
Product: [Modeling] Graphiti Reporter: Craig Petre <cpetre>
Component: CoreAssignee: Michael Wenz <michael.wenz>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: michael.wenz, tim.kaiser
Version: 0.8.0Flags: michael.wenz: indigo+
Target Milestone: 0.8.0   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=324859
Whiteboard: Indigo M7 theme_bug

Description Craig Petre CLA 2011-04-14 14:20:21 EDT
Build Identifier: 20110218-0911

Graphiti version in question:  Nightly build 04/13/2011

A diff of org.eclipse.graphiti.ui.internal.command:CreateConnectionCommand.java revisions 1.5 and 1.6 what looks to be an issue with the integrity of private variable "sourceLocation"

"sourceLocation" is set in the private method "createContext" which is called by "canStartConnection" and "getFeaturesAndContexts".  After a little debugging, it seems "canStartConnection" is called when a FreeFormConnection is started, as expected, and then upon anchoring the FreeFormConnection to the destination "getFeaturesAndContexts" is called (resetting sourceLocation to the current location again and in effect losing the original "sourceLocation"), followed by "execute".  

This results in a "CreateConnectionContext" being passed down to child classes which has an ILocation sourceLocation and ILocation targetLocation with matching x,y coordinates.

Note:  This behavior was not present in a nightly Graphiti build from 04/07/2011

Reproducible: Always

Steps to Reproduce:
1. Create a Connection Feature class extending AbstractConnectionPattern or some equivalent.
2. In the overridden "create" method, place a debug break point or print statement to observe the contents of the "ICreateConnectionContext"'s sourceLocation and targetLocation coordinates.
3. Attempt to draw a FreeFormConnection and upon anchoring the connection to the target, observe the source/target ILocation coordinates passed into the "create" via the "ICreateConnectionContext" parameter.  I would expect the sourceLocation coordinates to be representative of where the connection started and the targetLocation coordinates to represent where the connection ended, but this is not the case.
Comment 1 Michael Wenz CLA 2011-04-15 04:05:12 EDT
This is indeed a regression introduced by the enablement of non-EMF undo/redo (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=324859).
I fixed this in head, now the sourceLocation variable is only set on calling canStartConnection as it was before.

Thanks for pointing this out!
Comment 2 Michael Wenz CLA 2011-06-24 09:14:49 EDT
Part of Graphiti Indigo 0.8.0