Accessing component data using Eclipse APIs 
|
|
In this topic we show how you can access the component data using only Eclipse APIs. Why would you want to do this? Say your component may live in an Eclipse only environment - this method allows your component to install in an Eclipse only platform and no having a binary dependency on Expeditor API's. Another reason to use this approach is that Lotus Sametime doesn't have the Topology Handler API so if you want your component to run in Notes 8 and Sametime do not make your component depend on com.ibm.rcp.topologyhandler or com.ibm.pvc.sharedBundle.
The method shown here is a helper method were you would pass in the secondary identifier of the ViewPart. Remember, ViewParts have an identifier in the format :. It is the part that gets stored in the Eclipse extenion registry. This method attempts to lookup the components data in the Eclipse extension registry - it always returns an initialized Map so if your component is not in a composite application you will simply get an empty Map.
private Map getComponentAttributes(String secondaryViewId) {
IExtensionRegistry reg = RegistryFactory.getRegistry();
IExtension ext = reg.getExtension("com.ibm.rcp.topologyhandler" + "." + secondaryViewId);
if (ext == null)
return new HashMap();;
IConfigurationElement ce = ext.getConfigurationElements()[0];
Map map = new HashMap();
List keys = Arrays.asList(ce.getAttributeNames());
Iterator i = keys.iterator();
while (i.hasNext()) {
String key = (String )i.next();
String val = ce.getAttribute(key);
map.put(key, val);
}
return map;
}
The secondary id is easily obtained from the view site so if you have a ViewPart you get the view site and then the secondary id.
ViewPart viewpart = ...;
String secondaryId = viewpart.getViewSite().getSecondaryId();
|
|
|
|
| Version 3 |
July 19, 2010 |
4:32:19 PM |
by Neal A Timpe  |
|
|