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

Bug 493523

Summary: Enable transitive role-based adapter bindings.
Product: [Tools] GEF Reporter: Matthias Wienand <matthias.wienand>
Component: GEF MVCAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: nyssen
Version: 0.2.0   
Target Milestone: 5.0.0 (Oxygen) M4   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 509007    

Description Matthias Wienand CLA 2016-05-12 08:58:09 EDT
Currently, some behaviors are injected by default as adapters into the root part (ContentBehavior, FXGridBehavior, FXFocusBehavior). Each behavior depends on a viewer model (ContentModel, GridModel, FocusModel) that is injected as an adapter into the viewer. If the model is not present within the viewer, then the behaviors should not be injected either.

Therefore, the AdapterMapBinder mechanism should allow the specification of transitive role-based adapter bindings.

For example, the user should be able to obtain an adapter-map-binder that will only inject adapters into the adaptable if the adaptable itself was transitively injected as an adapter into another adaptable of a specific role.

Unfortunately, some situations cannot be resolved even with transitive role-based adapter bindings. For example, a SelectionBehavior does only need to be registered for an IContentPart if the IContentPart is visualized within an IViewer that provides a SelectionModel. However, the adapter-map chain does not reach from IViewer to IContentPart, therefore, the AdapterMapBinder mechanism cannot be utilized to determine if such adapters need to be injected.
Comment 1 Alexander Nyßen CLA 2016-10-21 07:39:06 EDT
The preliminary use case behind this is that different adapter bindings can be specified for the different root parts of content and palette viewer, without having to bind the root parts themselves with specific roles. 

That is, it would be nice if the viewer role could simply be used in the adapter bindings for the root part adapters without having to specify the role for the root part (currently the root part itself is bound with the viewer role as a workaround). It would require that the adapter injector walks up the adaptable-adaptable.bound hierarchy to search for the respective role and not only evaluates the adaptable into which adapters are injected (i.e. the root part in this case) alone.

Together with a correctly implemented transitive adaptable scoping (see bug #506330) this would cover most use cases, as soon as a whole graphical application is maintained as an adaptable-adaptable.bound hierarchy (see bug #506331).
Comment 2 Alexander Nyßen CLA 2016-12-13 10:29:11 EST
I pushed the following changes to origin/master:
- Enhanced that adapter map bindings can now be restricted by specifying a context through adapter keys. 
- Made AdapterMapImpl package visible, as static methods within AdapterMaps should be used by clients to create a map binder with a respective binding annotation..
- Adjusted bindings in modules to no longer register root part with the content viewer role (which was a workaround), but restrict the binding to the content viewer context.

Resolving as fixed in 5.0.0 (Oxygen) M4 (final contribution).