Reputation: 4103
I want to open a help URL inside the tray of an wizard. That's what I came up with:
import org.eclipse.help.ui.internal.views.*;
public static void openHelpInWizard(Shell activeShell, String href) {
if (HelpTray.isAppropriateFor(activeShell)) {
TrayDialog dialog = (TrayDialog) activeShell.getData();
DialogTray tray = dialog.getTray();
if (tray == null) {
tray = new HelpTray();
dialog.openTray(tray);
}
if (tray instanceof HelpTray) {
ReusableHelpPart helpPart = ((HelpTray) tray).getHelpPart();
helpPart.showURL(href);
}
}
}
For modularization it's bad that this code has dependencies to org.eclipse.help.ui
(the help is inside another plug-in), but it might be tolerable as an optional dependency. Even worse is that the code has to use internal classes.
So what is the correct way to do this?
Upvotes: 1
Views: 87
Reputation: 4103
This was really hard to find: If the IContext
implementation returns null
via getText()
and has exactly one IHelpResource
when getRelatedTopics
is called the "href" of the one help resource is displayed.
So if you want to do what I did, you can implement IContext
with the above mentioned properties, or use the extension point org.eclipse.help.contexts
with a context.xml like this:
<contexts>
<context id="my_id">
<topic href="html/help_topic.html" label="My Help Topic"/>
</context>
</contexts>
(I think the "label" attribute is not necessary.)
And then of course use the context ID like this (which doesn't even have a dependency to the help plug-ins):
PlatformUI.getWorkbench().getHelpSystem().displayHelp("my_id");
Upvotes: 1