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

Bug 444009

Summary: Revise FXChopBoxHelper-mechanism.
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: GEF FXAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: 3.10.0 (Mars) M2   
Hardware: All   
OS: All   
Whiteboard:

Description Alexander Nyßen CLA 2014-09-13 04:16:36 EDT
An FXChopBoxAnchor requires a reference point for computation of the anchorage points. 

Up to now, the API does not provide any mechanism for an IFXAnchor to request such kind of information directly. Instead, it expects that the reference point for each AnchorKey gets passed in externally (via setReferencePoint()).

Because of this, each connection currently has to be equipped with an FXChopBoxHelper, which listens to changes in the connection and 'pushes' the reference point information to the connected FXChopBoxAnchors. This is a rather implicit API, which might be hard for clients to adopt.

We should thus revise this mechanism, so that the FXChopBoxAnchor rather 'pulls' the reference information. I would propose the following refactoring:

1) Provide a means so that an IFXAnchor can request additional information when an AnchorKey is being attached to it, by extending the IFXAnchor#attach(AnchorKey) method to take an additional IAdaptable argument (which may be null; as within IUndoableOperation#execute(), #undo(), or #redo()). The FXChopBoxAnchor could use this IAdaptable parameter to obtain a reference to an FXChopBoxHelper. 

2) As the computation of a reference points in the context of an FXConnection is driven from changes of the connection, the FXChopBoxHelper will have to listen to changes of the FXConnection and compute reference points dependent on it, as it currently does. However, rather than updating the reference position of an FXChopBoxAnchor directly, it could provide a local reference point map property (map from AnchorKey to reference point) to store the reference point information.

3) The FXChopBoxAnchor could add its reference point listener to the respective map property of the FXChopBoxHelper within attach(), or it could cache the reference point information and simply bind its local reference point property to the map entry within the FXChopBoxHelpers reference point map property.
Comment 1 Alexander Nyßen CLA 2014-09-13 05:58:12 EDT
Performed the following changes:
- Changed IFXAnchor#attach() and #detach() to take an additional IAdaptable argument.
- Removed referencePointProperty from FXChopBoxAnchor; instead pass in an FXChopBoxHelper in attach() and detach() to obtain the reference points from.
- Ensured an FXChopBoxHelper is already registered at the curve by default (making use of an AdapterStore).
- Adjusted examples to no longer construct FXChopBoxAnchors explicitly.

Resolving as fixed in 3.10.0M2.
Comment 2 Alexander Nyßen CLA 2014-09-13 11:42:06 EDT
We should extract an interface from FXChopBoxAnchor, so the base concept can also be used without connections. Also, the FXConnection should either expose its AnchorStore to subclasses, or it should implement IAdaptable itself, so clients can exchange the implementation.
Comment 3 Alexander Nyßen CLA 2014-09-13 12:39:19 EDT
Provided hook within FXConnection to register anchor infos. Extracted FXChopBoxAnchor.ReferencePointProvider interface. Resolving as fixed.
Comment 4 Alexander Nyßen CLA 2014-09-13 12:39:50 EDT
Setting target milestone to 3.10.0M2
Comment 5 Alexander Nyßen CLA 2014-09-13 13:53:29 EDT
As FXChopBoxAnchor is no longer needed outside FXConnection, transferred it into a nested class of FXConnection.