Hi
i have a problem with an extension point definition.
I defined an extension point which is used by two other plug ins (Developer: one extension "Workspace"; Administrator: two extensions "Users" and "User Groups"). Each PlugIn has its own extension handler that ensures by the means of an ID (extension.getSimpleIdentifier()) that only the correct extensions are processed. That works fine so far.
Unfortunatly the code below (registry.getConfigurationElementsFor(NavigationViewExtesionHandler.EXTENSION_POINT_ID) as well as extensionPoint.getExtensions() only works on "Workspace" and "Users". "User Groups" is not available in extensionPoint.getExtensions() and registry.getConfigurationElementsFor(NavigationViewExtesionHandler.EXTENSION_POINT_ID) contains "Users" two times.
What did i do wrong?
Below is the code:
Thanks
Matthias
Handler code:
public NavigationViewExtesionHandler(final NavigationViewContentProvider contentProvider, final String id) {
this.id = id;
initializeExtensions();
}
private void initializeExtensions() {
final IExtensionRegistry registry = RegistryFactory.getRegistry();
final IExtensionPoint extensionPoint = registry.getExtensionPoint(NavigationViewExtesionHandler.EXTENSION_POINT_ID);
tracker = new ExtensionTracker(registry);
final IConfigurationElement[] configurationElementsFor = registry
.getConfigurationElementsFor(NavigationViewExtesionHandler.EXTENSION_POINT_ID);
for (final IConfigurationElement extension : configurationElementsFor) {
final IExtension declaringExtension = extension.getDeclaringExtension();
addExtension(tracker, declaringExtension);
//returns "workspace", "users" and "users"
}
for (final IExtension extension : extensionPoint.getExtensions()) {
addExtension(tracker, extension);
//returns "workspace", "users"
}
tracker.registerHandler(this, ExtensionTracker.createExtensionPointFilter(extensionPoint));
}
/** {@inheritDoc} */
@Override
public void addExtension(final IExtensionTracker tracker, final IExtension extension) {
if (id.equals(extension.getSimpleIdentifier())) {
final IConfigurationElement configurationElement = extension.getConfigurationElements()[0];
try {
final Object createExecutableExtension = configurationElement.createExecutableExtension("class");
System.out.println(createExecutableExtension);
} catch (final CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Extension Point definition:
<element name="extension">
<complexType>
<sequence>
<element ref="RootElement" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required"/>
<attribute name="id" type="string"/>
<attribute name="name" type="string"/>
</complexType>
</element>
<element name="RootElement">
<complexType>
<attribute name="ID" type="string" use="required"/>
<attribute name="name" type="string" use="required"/>
<attribute name="class" type="string" use="required">
<annotation>
<appinfo>
<meta.attribute kind="java" basedOn=":navigationview.treeelements.IRootElemet"/>
</appinfo>
</annotation>
</attribute>
<attribute name="handler" type="string" use="required">
<annotation>
<appinfo>
<meta.attribute kind="java"/>
</appinfo>
</annotation>
</attribute>
<attribute name="isVisible" type="boolean" use="default" value="true"/>
</complexType>
</element>
In addition i have to PlugIns that use this extension point:
Developer:
<extension
id="Developer"
point="NavigationView.RootElements">
<RootElement
ID="Workspace"
class="developerui.Workspace"
handler="developerui.RootElement1"
isVisible="true"
name="Workspace">
</RootElement>
</extension>
Administrator:
<extension
id="Administrator"
point="NavigationView.RootElements">
<RootElement
ID="Users"
class="administrationui.treeelements.users.Users"
handler="administrationui.RootElement2"
isVisible="true"
name="Users">
</RootElement>
<RootElement
ID="UserGroups"
class="administrationui.treeelements.usergroups.UserGroups"
handler="administrationui.RootElement3"
isVisible="true"
name="UserGroups">
</RootElement>
</extension>