Eclipse RCP Browser Example
by, 11-14-2011 at 05:33 PM (2464 Views)
This is an example of a simple Eclipse Rich Client Platform (RCP) application. It is a bare bones web browser, using the SWT Browser control.
To load the browser example source into your workspace, load project org.eclipse.ui.examples.rcp.browser from the Eclipse CVS repository.
The code is in package org.eclipse.ui.examples.browser, and consists of an application class (BrowserApp), a workbench advisor for configuring the workbench (BrowserAdvisor), and a single perspective (BrowserPerspectiveFactory) containing a single view (BrowserView).
The application defines several built-in actions in the menu and toolbar that are typical for web browsers (Back, Forward, Stop, Refresh). These are added in BrowserActionBuilder when a new window is opened (see BrowserAdvisor.fillActionBars(...)). These actions are defined as retargetable actions, for which the view registers handling actions.
The view consists of an address bar (a Label and a Text control) and the Browser control. To handle status and progress events, it simply passes on the relevant events from the Browser control to the Workbench status line.
Running the example
To run the RCP Browser example from within the Eclipse SDK:
1. Load project org.eclipse.ui.examples.rcp.browser from the Eclipse repository into a self-hosting workspace.
2. Create a new "Run-time workbench" launch configuration called "Browser Example".
3. On the "Arguments" tab, select "Run a product" and choose select "org.eclipse.ui.examples.rcp.browser.product" from the drop-down.
4. On the "Plug-ins" tab, configure it to include only the required plug-ins:
· Press "Deselect All"
· Check "org.eclipse.ui.examples.rcp.browser"
· Press "Add Required Plug-ins"
· Check "org.eclipse.update.configurator"
5. Run or debug the launch config.
As you can see, it's hard to tell that this application has anything at all to do with Eclipse (apart from the default web site that it browses!). There is no resource navigator, no mention of the Eclipse Platform, and none of the familiar menu bar items from the platform workbench. (The few Eclipse-related features, such as the window icon, could also be reconfigured if desired.)