Here's a few ways on how to do it:
- Using a Browser Widget ( added to a Composite)
- Using the EmbeddedBrowser View
Using a Browser Widget ( added to a Composite)
Eclipse and Lotus Expeditor offers each a simple browser widget that can be added to a composite. They a very much alike.
Here's a sample using the core Eclipse SWT browser widget:
Browser browser;
try {
browser = new Browser(composite, SWT.NONE);
browser.setLayoutData( new GridData(SWT.FILL, SWT.FILL, true, true));
browser.setUrl("http://www.ibm.com");
} catch (SWTError e) {
// Handle any errors.
}
And here's a sample with the Lotus Expeditor equivalent:
WebBrowser browser;
try {
browser = new WebBrowser(composite, SWT.NONE);
browser.setLayoutData( new GridData(SWT.FILL, SWT.FILL, true, true));
browser.setUrl("http://www.ibm.com");
} catch (SWTError e) {
// Handle any errors.
}
You can use the browser.setText("...") method to add custom HTML content into the browser, if needed.
You also have the ability to listen to events and traverse the DOM (Document Object Model).
Using the EmbeddedBrowser View
The Lotus Expeditor platform also gives you a viewpart based browser component.
// Every instance needs it's own unique id.
String id = "com.rcpcompany.lotus.notes.spy.browserview.sample";
// Create a map with all the needed properties.
Map configMap = new HashMap();
configMap.put(BrowserPreference.ID, id);
configMap.put(BrowserPreference.INITIAL_URL, url);
// Get the active page
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
// Create the browser instance.
EmbeddedBrowser browser = BrowserFactory.launch(page, configMap, id);
// Maximize the new browser view if needed.
page.setPartState(page.getActivePartReference(), IWorkbenchPage.STATE_MAXIMIZED);