Monday, May 25, 2009

How to add context help to an editor?

Short Steps:
1. Create a context help file and add a context id to it.
2. Extend the o..e.help.contexts and point it to this file
3. Associate the editor to the context help by calling setHelpContextId

How to:

1. Create a context help file and add a context id to it.

Use File -> New and choose Context Help. Give it a meaning full name. In PDE contexts_PDE.xml (in o.e.pde.doc.user) contains contexts help ids for PDE UI stuff while api_contexts.xml for API Tooling.

Add a context to it and name it like editor_main_page. Give some description


Context Help Editor

2. Extend the o..e.help.contexts and point it to this file

Add an extension org.eclipse.help.contexts (this will add a dependency to o.e.help). Add a new contexts to it. In the details section, point it to the context file created above.



Extension page


3. Associate the editor to the context help by calling setHelpContextId

In your editor class call setHelpContextId to associate the editor to the context help editor_main_page.

public XMLEditor() {
super();
colorManager = new ColorManager();
setSourceViewerConfiguration(new XMLConfiguration(colorManager));
setDocumentProvider(new XMLDocumentProvider());
setHelpContextId("my.editor.sample.editor_context");
}

No comments:

Post a Comment