Displaying help in Wizards in Eclipse
I haven’t seen this full sequence written down anywhere (only in various partial fragments), so here it is for anyone who finds it useful. Here’s what you need to do if you want to add a Help button to your Eclipse wizard.
- In your wizard class, call
setHelpAvailable(true). - In your wizard page class, override
performHelp()with code like this:public void performHelp() { PlatformUI.getWorkbench().getHelpSystem() .displayHelp(CONTEXT_ID); } CONTEXT_IDshould be something like “.mywizardhelp”. - Add a help context extension to your plugin. It should look something like:
<extension id="com.wotsit.doodah.wizardhelp" point="org.eclipse.help.contexts"> <contexts file="helpContexts.xml" /> </extension> - Create that helpContexts.xml file in the root of your plug-in. (It can be localised in fragments, incidentally). It should contain something like:
<contexts> <context id="wizardhelp"> <description>Gets help about this wizard</description> <topic href="html/wizard.html" label="My wizard help"/> <topic href="html/toc.html" label="General help"/> </context> </contexts> - Finally, of course, create the help HTML itself (which you probably did already if you selected the easiest settings when creating your plug-in in the first place).
The bit I couldn’t find documented anywhere was the single line of code which ties it all together! So there might be a better way to do that, but it seems to work.
