Adding Help to Dialogs

I’m in the process of updating the help text for my RCP and have found that some of the dialogs that I’m invoking don’t have the ability to directly add help context id’s.

After a bit of digging, I found it’s not that difficult to add help to an object that extends Dialog.

For this example, I’m going to add a help id to the InputDialog class.

[code lang=”java”]
InputDialog dialog = new InputDialog(getShell(), "Title", "Question", value, validator) {

* @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
protected Control createContents(Composite parent) {
Control contents = super.createContents(parent);

IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();

helpSystem.setHelp(contents , "help_id");
return contents;


Basically, we’re creating an anonymous inner class that subclasses InputDialog and overriding the createContents method. In this method we’re invoking the superclass’s createContents method and assigning the help id to the created control.

Leave a Reply

Your email address will not be published. Required fields are marked *