Menu

#1 IExecutableExtension aware extension factory

open
nobody
None
5
2006-07-12
2006-07-12
Anonymous
No

Several Eclipse classes, such as ViewPart, implement
the IExecutableExtension.setInitializationData() method
that allows instances of the class to be configured
with data from the extension definition in the
plugin.xml file.

When using the Spring RCP Spring support plugin, this
method is not called on classes like ViewPart.
Therefore, configuration of things like tab titles must
be done programtically.

The Spring Extension factory should become a bit more
aware of this and should attempt to call
setInitializationData().

Below is a sample class I created to do this:

public class ConfigAwareExtensionFactory extends
SpringExtensionFactory{

private IConfigurationElement config = null;
private String propertyName = null;
private Object data = null;

public void
setInitializationData(IConfigurationElement config,
String propertyName, Object data) throws CoreException {
super.setInitializationData(config, propertyName, data);

this.config = config;
this.propertyName = propertyName;
this.data = data;
}

public Object create() throws CoreException {
Object obj = super.create();

if(obj instanceof IExecutableExtension) {

((IExecutableExtension)obj).setInitializationData(config,
propertyName, data);
}

return obj;
}

}

By using this class, instead of the normal
SpringExtensionFactory, in the plugin.xml, components
like ViewPart can be created fully configured from the
plugin.xml.

Seems like this functionality should probably be part
of the SpringExtensionFactory class itself.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.