Writing Context Help

From Bioclipse
Jump to: navigation, search

Write Context help for the Help System

This page will show how context help for the inbuild Help System can be written. The output will look somewhat like shown in this blog item: http://chem-bla-ics.blogspot.com/2006/07/context-help-in-bioclipse.html

The context help uses the default Help System, and how to write such help is described in here.

The contexts extension point

First step is to create a context extension point, and link this to an XML file like:

  <?xml version="1.0" encoding="UTF-8"?>
  <?NLS TYPE="org.eclipse.help.contexts"?>
  
  <contexts>
    <context id="scriptInputField">
      <description>Enter Jmol Script in the text field below the view.</description>
      <topic href="doc/script/help.html" label="Jmol Script Commands Reference"/>
    </context>
  </contexts>

This points to a HTML page created for the default Help System (see here). Save this file as, for example, 'contexts.xml'.

The Context Help extension point

Then comes the issue of connecting it to the connection point.

1. Add 'org.eclipse.help.[webapp|ui|appserver|base]' as dependencies

2. Add an extension 'org.eclipse.help.contexts' with this content:

a. File := your new contexts.xml file
b. plugin := leave that empty

This should give you the following content in the plugin.xml source:

  <extension point="org.eclipse.help.contexts">
    <contexts file="helpContexts.xml" />
  </extension>

Link the contex help to a SWT Control

Next step is to link the given context help to a GUI item, e.g. a SWT Control. For example, the bc_jmol plugin has this piece of code:

  //Add the Jmol composite to the top
  composite = new Composite(parent, SWT.EMBEDDED);
  layout = new GridLayout();
  composite.setLayout(layout);
  layoutData = new GridData(GridData.FILL_BOTH);
  composite.setLayoutData(layoutData);
  PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, "net.bioclipse.plugins.bc_jmol.scriptInputField");

Note that the setHelp() has two parameters: first is the Control object and the second is the String representation of the context help ID, composed of <pluginID>.<contextHelpID>, where pluginID is for this example "net.bioclipse.plugins.bc_jmol" and the contextHelpID is taken from the contexts.xml and is scriptInputField here.