|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
com.genuitec.blinki.webkit.swt.WebKitBrowser
public class WebKitBrowser
An SWT WebKit browser component that provides navigation, rendering,
and event and JavaScript management services. The WebKit implementation is
based on the Google Chromium
framework. Unlike Google Chrome, WebKitBrowser components run in the
application's process and share the SWT message thread. The event model
enables asynchronous notification of browser events. Popup support is
available as well as the ability to veto a popup's instantiation. See
OpenWindowListener.open(WindowEvent) for details on popup support.
This component must be executed with JavaSE 6 or greater.
The listeners and events are slightly modified versions of their original counterpart in org.eclipse.swt.browser. They were replicated since their current Eclipse 3.4 design is unnecessarily restrictive and prevents creation of events from outside of the SWT browser package. We have communicate these issues to the Eclipse SWT team in the hopes that the design constraints can be relaxed to eliminate these and several other workaround hacks.
The WebKitBrowser drives the Chromium WebKit engine through a custom JNI bridge. The JNI bridge uses the Chromium Embedded Framework developed by Marshall Greenblat with contributions from the Genuitec Mobile Web Team and the TeamDev Java Integration Team.
public class HelloWorld {
public static void main(String [] args) {
Display display = new Display();
Shell shell = new Shell(display); //create window
shell.setLayout(new FillLayout());
WebKitBrowser browser= new WebKitBrowser(shell, SWT.NONE); //create browser
browser.setText("hello world");
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Known Issues:
current and total fields
OpenWindowListener,
CloseWindowListener,
LocationListener,
ProgressListener,
StatusTextListener,
TitleListener,
VisibilityWindowListener| Field Summary |
|---|
| Fields inherited from class org.eclipse.swt.widgets.Control |
|---|
handle |
| Constructor Summary | |
|---|---|
WebKitBrowser(org.eclipse.swt.widgets.Composite parent,
int style)
Create an new instance. |
|
| Method Summary | |
|---|---|
void |
addBrowserMenuEventListener(BrowserMenuEventListener listener)
|
void |
addCloseWindowListener(org.eclipse.swt.browser.CloseWindowListener listener)
Register a listener to receive callback WindowEvents when the browser is being closed |
void |
addLocationListener(org.eclipse.swt.browser.LocationListener listener)
Register a listener to receive callback LocationListener when the browser is navigating to a new page or upon completion of navigation |
void |
addOpenWindowListener(org.eclipse.swt.browser.OpenWindowListener listener)
Register a listener to receive callback WindowEvents when the browser is opened or a popup window is opened. |
void |
addProgressListener(org.eclipse.swt.browser.ProgressListener listener)
Register a listener to receive callback ProgressEvents when the browser is loading a resource, e.g., html page, image, script, etc. |
void |
addStatusTextListener(org.eclipse.swt.browser.StatusTextListener listener)
Register a listener to receive callback StatusTextEvents when the browser |
void |
addTitleListener(org.eclipse.swt.browser.TitleListener listener)
Register a listener to receive callback TitleEvents when the browser page has changed. |
void |
addVisibilityWindowListener(org.eclipse.swt.browser.VisibilityWindowListener listener)
Register a listener to receive callback WindowEvents when the browser is opened or a popup window is opened. |
boolean |
back()
Navigate to the previous URL in the browser's history |
static void |
deleteCookie(java.lang.String name,
java.lang.String url)
Delete the cookie that is associated with a URL. |
java.lang.Object |
evaluate(java.lang.String script)
Execute a JavaScript script and return value from it |
boolean |
execute(java.lang.String script)
Execute a JavaScript script |
boolean |
forward()
Navigate to the next URL in the browser's history |
static java.lang.String |
getCookie(java.lang.String name,
java.lang.String url)
Returns the value of a cookie that is associated with a URL. |
static java.lang.String[] |
getCookiesNames(java.lang.String url)
Returns array of all cookies names that is associated with a URL. |
JSAlertHandler |
getJSAlertHandler()
|
WebKitBrowser |
getPopupParent()
When the browser is a popup, return the parent browser; otherwise return null |
java.lang.String |
getText()
Get the HTML source code representing the current page loaded by the browser. |
java.lang.String |
getUrl()
Return the current URL loaded by the browser. |
java.lang.String |
getUserAgent()
Get user agent |
boolean |
isBackEnabled()
Check if there is one or more older URLs in the browser history. |
boolean |
isFocusControl()
Determine if the browser has focus. |
boolean |
isForwardEnabled()
Check if there is one or more newer URLs in the browser history. |
boolean |
isPopup()
|
void |
refresh()
Reload the current URL. |
void |
removeBrowserMenuEventListener(BrowserMenuEventListener listener)
|
void |
removeCloseWindowListener(org.eclipse.swt.browser.CloseWindowListener listener)
Remove a registered listener to no longer receive callback events |
void |
removeLocationListener(org.eclipse.swt.browser.LocationListener listener)
Remove a registered listener to no longer receive callback events |
void |
removeOpenWindowListener(org.eclipse.swt.browser.OpenWindowListener listener)
Remove a registered listener to no longer receive callback events |
void |
removeProgressListener(org.eclipse.swt.browser.ProgressListener listener)
Remove a registered listener to no longer receive callback events |
void |
removeStatusTextListener(org.eclipse.swt.browser.StatusTextListener listener)
Remove a registered listener to no longer receive callback events |
void |
removeTitleListener(org.eclipse.swt.browser.TitleListener listener)
Remove a registered listener to no longer receive callback events |
void |
removeVisibilityWindowListener(org.eclipse.swt.browser.VisibilityWindowListener listener)
Remove a registered listener to no longer receive callback events |
static boolean |
setCookie(java.lang.String value,
java.lang.String url)
Sets a cookie on a URL. |
void |
setJSAlertHandler(JSAlertHandler handler)
|
void |
setPopupParent(WebKitBrowser popupParent)
|
static void |
setProfileFolder(java.io.File profileFolder)
Set profile folder. |
boolean |
setText(java.lang.String html)
Directly provide the browser with HTML source code to load and display. |
boolean |
setUrl(java.lang.String url)
Navigate to the new URL. |
void |
setUserAgent(java.lang.String agent)
Set user agent |
void |
stop()
Discontinue loading the current page. |
| Methods inherited from class org.eclipse.swt.widgets.Composite |
|---|
changed, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList |
| Methods inherited from class org.eclipse.swt.widgets.Scrollable |
|---|
computeTrim, getClientArea, getHorizontalBar, getVerticalBar |
| Methods inherited from class org.eclipse.swt.widgets.Control |
|---|
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update |
| Methods inherited from class org.eclipse.swt.widgets.Widget |
|---|
addDisposeListener, addListener, dispose, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, setData, setData, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public WebKitBrowser(org.eclipse.swt.widgets.Composite parent,
int style)
parent - The containing SWT widgetstyle - The SWT UI styling bits. SWT.MOZILLA is meaningless and thus ignored| Method Detail |
|---|
public java.lang.String getUrl()
public boolean setUrl(java.lang.String url)
url - the URL to navigate to
public WebKitBrowser getPopupParent()
public void setPopupParent(WebKitBrowser popupParent)
public boolean isPopup()
public boolean execute(java.lang.String script)
script, - the JavaScript code to execute
public java.lang.Object evaluate(java.lang.String script)
script, - the JavaScript code to execute
public boolean forward()
public boolean back()
public boolean isBackEnabled()
public boolean isForwardEnabled()
public void refresh()
public void stop()
public java.lang.String getText()
public boolean setText(java.lang.String html)
html - The HTML source code for the browser to render
public java.lang.String getUserAgent()
public void setUserAgent(java.lang.String agent)
agent - public boolean isFocusControl()
isFocusControl in class org.eclipse.swt.widgets.Controlpublic void addOpenWindowListener(org.eclipse.swt.browser.OpenWindowListener listener)
listener - - register this listener for callbackspublic void removeOpenWindowListener(org.eclipse.swt.browser.OpenWindowListener listener)
listener, - OpenWindowListner to be removedpublic void addCloseWindowListener(org.eclipse.swt.browser.CloseWindowListener listener)
listener - - register this CloseWindowListener for WindowEventspublic void removeCloseWindowListener(org.eclipse.swt.browser.CloseWindowListener listener)
listener, - CloseWindowListner to be removedpublic void addLocationListener(org.eclipse.swt.browser.LocationListener listener)
listener - - register this listener for LocationEventspublic void removeLocationListener(org.eclipse.swt.browser.LocationListener listener)
listener, - LocationListner to be removedpublic void addProgressListener(org.eclipse.swt.browser.ProgressListener listener)
listener - - register this listener for ProgressEventspublic void removeProgressListener(org.eclipse.swt.browser.ProgressListener listener)
listener, - ProgressListner to be removedpublic void addStatusTextListener(org.eclipse.swt.browser.StatusTextListener listener)
listener - - register this listener to receive StatusTextEventspublic void removeStatusTextListener(org.eclipse.swt.browser.StatusTextListener listener)
listener, - StatusTextListener to be removedpublic void addTitleListener(org.eclipse.swt.browser.TitleListener listener)
listener - - register this listener for callbackspublic void removeTitleListener(org.eclipse.swt.browser.TitleListener listener)
listener, - TitelListener to be removedpublic void addVisibilityWindowListener(org.eclipse.swt.browser.VisibilityWindowListener listener)
listener - - register this listener for WindowEventpublic void removeVisibilityWindowListener(org.eclipse.swt.browser.VisibilityWindowListener listener)
listener, - VisibilityWindowListener to be removedpublic void addBrowserMenuEventListener(BrowserMenuEventListener listener)
listener - - register this listener for BrowserMenuEventpublic void removeBrowserMenuEventListener(BrowserMenuEventListener listener)
listener, - BrowserMenuEventListener to be removedpublic static void setProfileFolder(java.io.File profileFolder)
profileFolder - folder where
public static java.lang.String getCookie(java.lang.String name,
java.lang.String url)
name - the cookie nameurl - the URL that the cookie is associated with
null if no such cookie exists
java.lang.IllegalArgumentException - public static java.lang.String[] getCookiesNames(java.lang.String url)
url - the URL that the cookie is associated with
java.lang.IllegalArgumentException -
public static boolean setCookie(java.lang.String value,
java.lang.String url)
value parameter must be a cookie header string that
complies with RFC 2109.
The value is passed through to the native browser unchanged.
Example value strings:
foo=bar (basic session cookie)
foo=bar; path=/; domain=.eclipse.org (session cookie)
foo=bar; expires=Thu, 01-Jan-2030 00:00:01 GMT (persistent cookie)
foo=; expires=Thu, 01-Jan-1970 00:00:01 GMT (deletes cookie foo)
value - the cookie valueurl - the URL to associate the cookie with
true if the cookie was successfully set and false otherwise
java.lang.IllegalArgumentException -
public static void deleteCookie(java.lang.String name,
java.lang.String url)
name - the cookie nameurl - the URL that the cookie is associated with
java.lang.IllegalArgumentException - public void setJSAlertHandler(JSAlertHandler handler)
public JSAlertHandler getJSAlertHandler()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||