Added support to search extension by extension point id + extension id. Enhance search of "class" attribute.

This commit is contained in:
Heng Sin Low 2010-10-26 19:07:40 +08:00
parent 836c789066
commit 9a3b1f3a4c
1 changed files with 24 additions and 7 deletions

View File

@ -59,10 +59,16 @@ public class ExtensionList<T> implements Iterable<T>{
private boolean accept(IConfigurationElement element) {
for (String name : filters.keySet()) {
String expected = filters.get(name);
if (name.equals("Extension.ID")) {
String id = element.getDeclaringExtension().getUniqueIdentifier();
if (!expected.equals(id))
return false;
} else {
String actual = element.getAttribute(name);
if (!expected.equals(actual))
return false;
}
}
return true;
}
@ -70,6 +76,17 @@ public class ExtensionList<T> implements Iterable<T>{
public T next() {
iterateUntilAccepted();
IConfigurationElement e = elements[index++];
if (e.getAttribute("class") == null) {
IConfigurationElement[] childs = e.getChildren();
if (childs != null && childs.length > 0) {
for(IConfigurationElement child : childs) {
if (child.getAttribute("class") != null) {
e = child;
break;
}
}
}
}
try {
return (T) e.createExecutableExtension("class");
} catch (CoreException ex) {