public interface IWorkbenchBrowserSupport
The support has a two-phase approach to opening URLs. A browser instance is
created first, then openURL
is called on it. This provides for
browser instance reuse for as long as needed. The step of creating the
browser instance encourages reuse itself by not creating new instances of
browsers if one with the same id is already open. It also makes it possible
to reuse browser instances restored after workbench is restarted.
The simplest way to open a URL is:
IWorkbenchSupport.createBrowser("myId").openURL(url);
The call above will show the provided URL by reusing the browser instance with the matching id, or creating a new one if one does not exist already.
When more advanced control over the behavior of a browser instance is required, it is recommended to create the instance first, then reuse it as needed.
This interface is not intended to be implemented by clients.
IWebBrowser
Modifier and Type | Field and Description |
---|---|
static int |
AS_EDITOR
Style constant (value 1<<5) indicating that the internal web
browser will be hosted in a workbench editor area.
|
static int |
AS_EXTERNAL
Style constant (value 1<<7) indicating that the external web
browser must be used even if the implementation supports internal
browsers and the user didn't set the preference to external browsers.
|
static int |
AS_VIEW
Style constant (value 1<<6) indicating that the internal web
browser will be hosted in a workbench view.
|
static int |
LOCATION_BAR
Style parameter (value 1<<1) indicating that the address combo and
'Go' button will created for the browser.
|
static int |
NAVIGATION_BAR
Style parameter (value 1<<2) indicating that the navigation bar for
navigating web pages will be created for the web browser.
|
static int |
PERSISTENT
Style constant (value 1<<4) indicating that the internal web
browser will reopen after restarting the workbench (if used).
|
static int |
STATUS
Style constant (value 1<<3) indicating that status will be tracked
and shown for the browser (page loading progress, text messages etc.).
|
Modifier and Type | Method and Description |
---|---|
IWebBrowser |
createBrowser(int style,
String browserId,
String name,
String tooltip)
Creates the new web browser instance.
|
IWebBrowser |
createBrowser(String browserId)
Creates the new web browser instance.
|
IWebBrowser |
getExternalBrowser()
Returns a shared instance of the external web browser.
|
boolean |
isInternalWebBrowserAvailable()
Tests whether web browser as an SWT widget can be created in this
workbench instance.
|
static final int LOCATION_BAR
static final int NAVIGATION_BAR
static final int STATUS
static final int PERSISTENT
static final int AS_EDITOR
static final int AS_VIEW
static final int AS_EXTERNAL
IWebBrowser createBrowser(int style, String browserId, String name, String tooltip) throws PartInitException
The method will reuse an existing browser instance if the same
browserId
value is passed to it. A persisted browser
instance restored upon startup can be accessed this way. If
null
is passed as a browserId, a unique id will be
generated each time method is called.
If the user has chosen not to use the internal browser or it is not available on the current platform, an external browser will be used and all style parameters will be ignored.
style
- the style display constants. Style constants should be
bitwise-ORed together.browserId
- if an instance of a browser with the same id is already
opened, it will be returned instead of creating a new one.
Passing null
will create a new instance with a
generated id every time.name
- a name used for the presentation of the internal browsertooltip
- a tooltip used for the presentation of the internal browserPartInitException
- if the operation failed for some reasonIWebBrowser createBrowser(String browserId) throws PartInitException
createBrowser(id).openURL(url)
.
browserId
- if an instance of a browser with the same id is already
opened, it will be returned instead of creating a new one.
Passing null
will create a new instance with a
generated id every time.PartInitException
- if the operation failed for some reasonIWebBrowser getExternalBrowser() throws PartInitException
PartInitException
- if the operation failed for some reasonboolean isInternalWebBrowserAvailable()
false
,
createBrowser
would ignore browser styles
AS_EDITOR
and AS_VIEW
and always create an
external browser.true
if internal web browser can be created on
this platform, false
otherwise.
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.