* to the renderer parameter.
*
* @return The closest renderexecutor for the renderer.
*/
private RenderExecutor locateClosestFit(Renderer r) {
Renderer ofInterest = r;
if (r instanceof RendererDecorator) {
ofInterest = ((RendererDecorator) r).getRenderer();
}
final Renderer renderer = ofInterest;
List<IConfigurationElement> list = new ArrayList<IConfigurationElement>();
for (Iterator<IConfigurationElement> iter = ExtensionPointList.getExtensionPointList(
RenderExecutor.EXTENSION_ID).iterator(); iter.hasNext();) {
IConfigurationElement elem = iter.next();
try {
Bundle bundle = Platform.getBundle(elem.getNamespaceIdentifier());
Class<?> rendererClass = bundle.loadClass(elem
.getAttribute(RenderExecutor.RENDERER_ATTR));
if (rendererClass.isAssignableFrom(renderer.getClass()))
list.add(elem);
} catch (Exception e) {
ProjectPlugin.log(null, e);
// do nothing
}
}
if (!list.isEmpty()) {
Collections.sort(list, new Comparator<IConfigurationElement>() {
public int compare(IConfigurationElement o1, IConfigurationElement o2) {
try {
Bundle bundle = Platform.getBundle(o1.getNamespaceIdentifier());
Class clazz1 = bundle.loadClass(o1
.getAttribute(RenderExecutor.RENDERER_ATTR));
bundle = Platform.getBundle(o2.getNamespaceIdentifier());
Class clazz2 = bundle.loadClass(o2
.getAttribute(RenderExecutor.RENDERER_ATTR));
int dist1 = getDistance(renderer.getClass(), clazz1);
int dist2 = getDistance(renderer.getClass(), clazz2);
if (dist1 == dist2)
return 0;
return dist1 < dist2 ? -1 : 1;
} catch (Exception e) {
ProjectPlugin.log(null, e);