Dynamic context help

In addition to statically associating widgets and context Ids, it is possible to provide this information dynamically for a more dynamic context-sensitive help capability. Help system uses context Ids to locate the matching org.eclipse.help.IContext object. The new Help view tracks activation of the workbench parts (views and editors) and checks if they adapt to org.eclipse.help.IContextProvider interface. If they do, the view will use the context provider to locate the IContext object and get the required information from it. This object can be cached or created on the fly.

Workbench parts that want to create the context object dynamically should adapt to the IContextProvider.class object as a key:

public Object getAdapter(Class key) {
	if (key.equals(IContextProvider.class)) {
		return new MyContextProvider();
	return super.getAdapter(key);

The context provider interface requires implementation of three methods:

public class MyContextProvider implements IContextProvider {
	int getContextChangeMask() {
		return NONE;
	IContext getContext(Object target) {
		return myContext;
	String getSearchExpression(Object target) {
		return null;

If context change mask returns NONE, context object will need to be provided when the workbench part is activated. If SELECTION is returned, you will need to provide context object that is sensitive to the current selection in the part. Each time part selection provider fires a selection change event, the context provider will be asked to provide context object.

Optionally, search expression for the dynamic help can be provided. Otherwise, a combination of the part name and perspective name will be used with good results in most cases.

Note: In addition to using context providers (or alternatively), you can use XML annotations to filter topics in context help.