| Summary: | Improve PropertySourceAdapterFactory | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Patrick Sodre <psodre> |
| Component: | GEF-Legacy GEF (MVC) | Assignee: | Alexander Nyßen <nyssen> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | evan38109, hudsonr, nyssen |
| Version: | unspecified | ||
| Target Milestone: | 3.8.0 (Juno) | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Patrick Sodre
The purpose of the org.eclipse.gef.internal.PropertySourceAdapter seems to be to redirect the creation of a IPropertySource from an AbstractEditPart to the edit part's model. However, it does this by examining the model and either: 1. If it is an IPropertySource, return the model directly; or, 2. If it is IAdaptable, calling it's getAdapter() method. The platform adapter manager is never queried. This means that in order to be an IPropertySource, GEF models must directly implement IAdaptable; registering an IAdapterFactory will not work. A proposed fix would be: change org.eclipse.gef.internal.PropertySourceAdapter, line 28 from: return ((IAdaptable)model).getAdapter(adapterType); to: Platform.getAdapterManager().getAdapter(model, adapterType); Re-scheduling to 3.8, as this is an enhancement that changes the current behavior, even if it is not API-visible. Changed implementation of getAdapter() within PropertySourceAdapterFactory to fall back to platform's adapter manager as follows:
public Object getAdapter(Object adaptableObject, Class adapterType) {
AbstractEditPart part = (AbstractEditPart) adaptableObject;
Object model = part.getModel();
// check if model is already of the desired adapter type
if (adapterType.isInstance(model)) {
return model;
}
// check if model is adaptable and does provide an adapter of the
// desired type
if (model instanceof IAdaptable) {
Object adapter = ((IAdaptable) model).getAdapter(adapterType);
if (adapter != null) {
return adapter;
}
}
// fall back to platform's adapter manager
return Platform.getAdapterManager().getAdapter(model, adapterType);
}
Committed changes to cvs HEAD (3.8). Resolving as fixed.
|