Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Dynamically add context help in Eclipse 3.4
Dynamically add context help in Eclipse 3.4 [message #334113] Wed, 21 January 2009 12:13 Go to next message
Marcus Ludvigson is currently offline Marcus LudvigsonFriend
Messages: 6
Registered: July 2009
Junior Member
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 13:14 Go to previous message
Marcus Ludvigson is currently offline Marcus LudvigsonFriend
Messages: 6
Registered: July 2009
Junior Member
>
> 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
Previous Topic:[Databinding] Not validate a form when it is first opened
Next Topic:javadoc cannot be showed correctly
Goto Forum:
  


Current Time: Tue Nov 12 22:18:57 GMT 2024

Powered by FUDForum. Page generated in 0.03026 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top