Dynamically add context help in Eclipse 3.4 [message #334113] |
Wed, 21 January 2009 07:13  |
Eclipse User |
|
|
|
Hi,
In my 3.2 based plugin I dynamically add context help by using the
(internal, yes I know) addContext method on ContextManager. That is
org.eclipse.help.internal.context.ContextManager.addContext( IContext
context)
When converting my plugin to use Eclipse 3.4 I noticed that my dynamic
help didn't work. Digging into the source of ContextManager I saw that I
now triggered a bugg:
public String addContext(IContext context) {
String plugin = HelpPlugin.PLUGIN_ID;
String id = (String)idsByContext.get(context);
if (id != null) {
// context already registered
} else {
// generate ID and register the context
id = "ID" + idCounter++; //$NON-NLS-1$
idsByContext.put(context, id);
contextsById.put(id, context);
}
return plugin + "." + id; //$NON-NLS-1$
}
public IContext getContext(String contextId, String locale) {
// code removed
Context dynamicContext = (Context)contextsById.get(contextId);
// code removed
}
A interface is used when putting things into the contextsById map and a
specific implementation is used when retrieving the value.
Do any one have any other suggestion on how to dynamically add context
help? Adding context info elements to the plugin.xml is not an option as
I need a more dynamic solution.
Regards,
Marcus Ludvigson
|
|
|
Re: Dynamically add context help in Eclipse 3.4 [message #334115 is a reply to message #334113] |
Wed, 21 January 2009 08:14  |
Eclipse User |
|
|
|
>
> Do any one have any other suggestion on how to dynamically add context
> help? Adding context info elements to the plugin.xml is not an option as
> I need a more dynamic solution.
>
The quick-and-dirty(TM) solution was to create a Context object with a
fake ID:
HelpPlugin.getContextManager().addContext(new Context(new
PropertyHelpContext(getProperty()), "NotUsed"));
PropertyHelpContext(getProperty()) is something I have written that
implements IContext.
The context ID returned from addContext is something that looks like
org.eclipse.help.ID58 ("org.eclipse.help" + generated ID). The help
lookup is done just using the ID part(another bugg imho) so you need to
use the generated ID when setting the context help id on a control, e.g
PlatformUI.getWorkbench().getHelpSystem().setHelp(control, "ID58");
Kids, stay away from the internal stuff. You will get burned.
/Marcus Ludvigson
|
|
|
Powered by
FUDForum. Page generated in 0.04371 seconds