I have a properly functioning Eclipse RCP program which opens the org.eclipse.ui.intro extension to a home-page-id of root.xhtml. Inside of the root.xhtml home page, there are links to other XHTML pages to offer help.
I am trying to create buttons throuhout my GUI which, when you click them, they would take you to the correct XHTML documentation page. All I can figure out so far is how to get the buttons to take me to the root.xhtml page, but I cannot figure out how to tell the intro page to navigate to a different page. Here is the code I am using now to open the intro page:
help_button.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent event)
{
ActionFactory.INTRO.create(DataStore.getInstance().getCurrentWorkbenchPage().getWorkbenchWindow()).run();
}
})
For example, I am trying to do something like this where the hyperlink string in quotes is exactly the same as the hyperlink in the root.xhtml file:
ActionFactory.INTRO.create(DataStore.getInstance().getCurrentWorkbenchPage().getWorkbenchWindow()).run().navigateTo("http://org.eclipse.ui.intro/showPage?id=setuplogging");
I was able to figure this out, it was rather time consuming and painful to do so – hopefully it helps someone out. At least the answer is a few lines of code.
You have to show the intro site getIntroSite() first before changing the URL otherwise you will get a null pointer exception in IntroURL. If you get the null pointer exception when calling createIntroURL(), it may have to do with an intro site not being already open in your GUI, not necessarily that your link is bad. Also, if the intro is already open, don’t try to reopen it because it will change the page to the home page rather than your page identified with page_id. So, for this class, I made the help button a toggle button meaning if the intro window is open, then the button is pressed. In some cases I close the intro site if it is already open when the button is pressed (example below), in other cases I just don’t update the intro site so it won’t go to the home page (example not shown, but just omit the first part of the if block).
If you try the ActionFactory run() code in my question, that will display the intro site in the entire Window. I wanted the intro site to be a sub-window within the perspective, so I used the method below by setting showIntro(null, true) – true meaning don’t take up the entire window (they call the Boolean standby).
The page_id corresponds to the page id setup in your documentation XML file when setting up your extension point org.eclipse.ui.intro.config content variable.
final IIntroPart intro = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(). getWorkbenchWindow().getWorkbench().getIntroManager(). getIntro(); if (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(). getWorkbenchWindow().getWorkbench().getIntroManager(). isIntroStandby(intro)) { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(). getWorkbenchWindow().getWorkbench().getIntroManager(). closeIntro(intro); help_button.setSelection(false); } else { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(). getWorkbenchWindow().getWorkbench().getIntroManager(). showIntro(null, true).getIntroSite(); IIntroURL introURL = IntroURLFactory.createIntroURL( "http://org.eclipse.ui.intro/showPage?id=" + page_id); introURL.execute(); help_button.setSelection(true); }