I like to use the navigation history provided by Eclipse in my RCP Application. Unfortunately this feature isn’t well documented. In fact I only found this Wiki entry: http://wiki.eclipse.org/FAQ_How_do_I_hook_my_editor_to_the_Back_and_Forward_buttons%3F
It mentions that every editor can be marked in the navigation history, without having to specify a location. This is exactly what I want.
Regardless of whether the specific editor has any support for navigation history, markLocation will work. If the editor doesn’t implement INavigationLocationProvider, a history entry will be added, allowing the user to jump back to that editor but without returning to any particular location.
I added the following lines of code to my application in order to add a navigation entry each time a new Editor is opened.
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = page.openEditor( input, MyEditor.ID );
page.getNavigationHistory().markLocation( editor );
My problem is that the code doesn’t work. The toolbar icons for the commands org.eclipse.ui.navigate.backwardHistory and org.eclipse.ui.navigate.forwardHistory stay grayed out.
I have found the solution. In order to use the Navigation History in your Eclipse RCP application you have to add the following lines of code to your
ApplicationActionBarAdvisor.