From version 3.x XNap will provide Sun's JavaHelp framework to support online help and documentation.
Here are the necessary calls you need to add to your code to enable context help:
import javax.help.*; JPanel jp = new JPanel(); CSH.setHelpIDString(jp, "id-string");
The id string is one of the id strings found in the docbook file xnap-manual.xml in a chapter tag.
<chapter id="introduction-id"> <title>Introduction</title> </chapter>
In this case "introduction-id" would be the id string denoting the chapter titled "Introduction".
If your GUI elements and settings are not documented in XNap's own docbook file and you have written your own documentation you have to set the proper helpset for your components:
import xnap.gui.util.HelpManager; import javax.help.*; JPanel jp = new JPanel(); CSH.setHelpIDString(jp, "id-string"); CSH.setHelpSet(jp, MyPlugin.getInstance().getHelpSet());
To make this work you have to register your helpset with the HelpManager
when startGUI()
is called:
public void startGUI() { HelpManager.add(myHelpSet); }
And remove it after your plugin has been unloaded:
public void stopGUI() { HelpManager.remove(myHelpSet); }
If you implement your own dialogs you might want to activate the F1 and the context help key for these dialogs. This can be done as follows:
import xnap.gui.util.HelpManager; import xnap.gui.component.DefaultDialog; public class SpecialSettingsDialog extends DefaultDialog { // the constructor public SpecialSettingsDialog() { // set up components here // ... HelpManager.enableHelpKeys(getRootPane(), "special-settings-dialog", MyPlugin.getInstance().getHelpSet()); } }