5

Now can I register contextual help in an Eclipse WizardDialog/Editor.

1) I created a help_contexts.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
   <context  id="my.plugin.help.general" >
        <description>test</description>
        <topic label="test" href="http://domain.com/help.html"/>
   </context>
</contexts>

2) I referenced this file in my plugin.xml

  <extension
         point="org.eclipse.help.contexts">
         <contexts file="help_contexts.xml" plugin="my.plugin.MainEditor">
         </contexts>
   </extension>

3) I added a line in my build.properties to include this file in the bin directory (bin.includes = help_contexts.xml, ... )

4) When running my GEF-based plugin, I see "No match found for "my.plugin.MainEditor"" under dynamic help.

I know I need to create something like this somewhere, but I don't know where to set this up for my WizardDialog or at least for my whole editor:

  public void createPartControl(Composite parent) {
      ...
      PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, 
         "my.plugin.help.general");
   }

Note: This question originally contained two questions. I have removed the first (unanswered part) to be posted elsewhere.

skaffman
  • 398,947
  • 96
  • 818
  • 769
Jason Kealey
  • 7,988
  • 11
  • 42
  • 55
  • Note to self: 1) Using a contextual ID that includes periods is a recipe for disaster. my.plugin.help.general does not work. you must use my.plugin.help_general when referencing help_general. 2) Must not specify the plugin name in the help_contexsts.xml file. Use help_general. – Jason Kealey Jun 18 '09 at 22:05
  • @Jason: if you have managed to answer (part of) your question, you could post an actual answer (and even select your own post as the official answer - no rep gain involved in this case) – VonC Jun 19 '09 at 05:33
  • @VonC answered it and created my original question more directly here http://stackoverflow.com/questions/1021719/eclipse-gef-editpart-contextual-help – Jason Kealey Jun 20 '09 at 14:28

2 Answers2

10

Here is how you do it: 1) I created a help_contexts.xml file. Don't have periods in the context id. Don't include your plugin name in there.

<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
   <context  id="help_general" >
        <description>test</description>
        <topic label="test" href="http://domain.com/help.html"/>
   </context>
</contexts>

2) I referenced this file in my plugin.xml Don't include the plugin-id if you are referencing your own plugin.

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

3) I added a line in my build.properties to include this file in the bin directory (bin.includes = help_contexts.xml, ... ). Note your Bundle-SymbolicName in your Manifest.MF (also visible in your plugin.xml editor). Example: my.plugin

4) Set the context id in the WizardPage (credit goes to @VonC)

public class MyWizardPage extends WizardPage
    public void createControl(Composite parent) {
        PlatformUI.getWorkbench.getHelpSystem.setHelp(parent, "my.plugin.help_general");
    }
}
Jason Kealey
  • 7,988
  • 11
  • 42
  • 55
3

For the main question, I am not sure about your setHelp second parameter. See this thread:

In the method call

PlatformUI.getWorkbench().getHelpSystem().setHelp()

second parameter is the contextID.
It should be prefixed with the pluginID like : "pluginID.contextID".
Now I was not sure where to find the plug-in ID for my plug-in.
So I used the value of this property : Bundle-Name Bundle-Symbolic-Name from MANIFEST.MF as the plug-in ID.
Now it works.


For the sidenote (help for WizardDialog), this thread might help (from David Kyle and his blog "Eclipse RCP"):

We set the context id in our wizard page.

public class MyWizardPage extends WizardPage
    public void createControl(Composite parent) {
        PlatformUI.getWorkbench.getHelpSystem.setHelp(parent, 
MyPluginActivator.ID + ".mycontexthelpid");
    }
}

and we set help for the wizard dialog.

WizardDialog dialog = new WizardDialog(.....);
PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), 
"mycontexthelp.id");

We don't override performHelp().

As for the help context id. Define a context xml file in your plugin.

<?xml version="1.0" encoding="UTF-8"?>
<?NLS TYPE="org.eclipse.help.contexts"?>
<contexts>
    <context id="mycontexthelpid" >
        <description>My wizard help.</description>
        <topic label="Wizard help" href="reference/wizard/help.xhtml"/>
    </context>
</contexts>

in your plugin

<plugin>
    <extension point="org.eclipse.help.contexts">
        <contexts file="mywizard.xml" plugin="com.mypluginid"/>
    </extension>
</plugin>

A common problem is messing up the plugin and context help ids. You can set a couple of break points to see which context id is being requested.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • For the first part, I entered a bogus string in there by accident, but I still am not sure how to apply this to GEF EditParts. For the second part, the key was adding the reference in the WizardPage. Thanks! – Jason Kealey Jun 18 '09 at 19:28
  • Note: You want to use Bundle-SymbolicName and not Bundle-Name. – Jason Kealey Jun 18 '09 at 22:06
  • @Jason: thank you for the feedback. I have updated my answer accordingly – VonC Jun 19 '09 at 05:32