uk.ac.kcl.cch.jb.pliny.browser
Class BrowserViewer

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byuk.ac.kcl.cch.jb.pliny.browser.BrowserViewer
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class BrowserViewer
extends org.eclipse.swt.widgets.Composite


Field Summary
protected  org.eclipse.swt.widgets.ToolItem back
           
protected  org.eclipse.swt.browser.Browser browser
           
protected  BusyIndicator busy
           
static int BUTTON_BAR
          Style parameter (value 2) indicating that the toolbar will be available on the web browser.
 org.eclipse.swt.dnd.Clipboard clipboard
           
 org.eclipse.swt.widgets.Combo combo
           
protected  BrowserEditor container
           
protected  File file
           
protected  Thread fileListenerThread
           
protected  org.eclipse.swt.widgets.ToolItem forward
           
protected static List history
           
protected  boolean loading
           
static int LOCATION_BAR
          Style parameter (value 1) indicating that the URL and Go button will be on the local toolbar.
protected  org.eclipse.swt.browser.LocationListener locationListener2
           
protected  boolean newWindow
           
protected static String PREF_INTERNAL_WEB_BROWSER_HISTORY
           
protected  int progressWorked
           
protected static String PROPERTY_TITLE
           
protected  List propertyListeners
           
protected  boolean showToolbar
           
protected  boolean showURLbar
           
protected  Object syncObject
           
protected  long timestamp
           
protected  String title
           
protected  IBrowserToolbarContribution[] toolbarContributions
           
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
BrowserViewer(org.eclipse.swt.widgets.Composite parent, BrowserEditor container, IBrowserToolbarContribution[] toolbarContributions)
          Creates a new Web browser given its parent and a style value describing its behavior and appearance.
BrowserViewer(org.eclipse.swt.widgets.Composite parent, BrowserEditor container, IBrowserToolbarContribution[] toolbarContributions, int style)
           
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a property change listener to this instance.
protected  void addSynchronizationListener()
           
protected  void addToHistory(String url)
           
 boolean back()
          Navigate to the previous session history item.
 void dispose()
           
protected  void firePropertyChangeEvent(String propertyName, Object oldValue, Object newValue)
          Fire a property change event.
 boolean forward()
          Navigate to the next session history item.
 org.eclipse.swt.browser.Browser getBrowser()
          Returns the underlying SWT browser widget.
 BrowserEditor getContainer()
           
protected static File getFile(String location)
           
 String getURL()
          Returns the current URL.
 void giveBusyIndicatorResource(Resource resource)
           
 void home()
          Navigate to the home URL.
 boolean isBackEnabled()
          Returns true if the receiver can navigate to the previous session history item, and false otherwise.
 boolean isForwardEnabled()
          Returns true if the receiver can navigate to the next session history item, and false otherwise.
 void refresh()
          Refresh the current page.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a property change listener from this instance.
protected  void removeSynchronizationListener()
           
 void runToolbarItem(int i)
           
 void setContainer(BrowserEditor container)
           
 boolean setFocus()
           
static void setInternalWebBrowserHistory(List list)
           
 void setURL(String url)
          Loads a URL.
 void stop()
          Stop any loading and rendering activity.
protected  void updateBackNextBusy()
           
protected  void updateHistory()
          Update the history list to the global/shared copy.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, 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, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PREF_INTERNAL_WEB_BROWSER_HISTORY

protected static final String PREF_INTERNAL_WEB_BROWSER_HISTORY
See Also:
Constant Field Values

LOCATION_BAR

public static final int LOCATION_BAR
Style parameter (value 1) indicating that the URL and Go button will be on the local toolbar.

See Also:
Constant Field Values

BUTTON_BAR

public static final int BUTTON_BAR
Style parameter (value 2) indicating that the toolbar will be available on the web browser. This style parameter cannot be used without the LOCATION_BAR style.

See Also:
Constant Field Values

PROPERTY_TITLE

protected static final String PROPERTY_TITLE
See Also:
Constant Field Values

clipboard

public org.eclipse.swt.dnd.Clipboard clipboard

combo

public org.eclipse.swt.widgets.Combo combo

showToolbar

protected boolean showToolbar

showURLbar

protected boolean showURLbar

back

protected org.eclipse.swt.widgets.ToolItem back

forward

protected org.eclipse.swt.widgets.ToolItem forward

busy

protected BusyIndicator busy

loading

protected boolean loading

history

protected static List history

browser

protected org.eclipse.swt.browser.Browser browser

newWindow

protected boolean newWindow

container

protected BrowserEditor container

title

protected String title

progressWorked

protected int progressWorked

propertyListeners

protected List propertyListeners

toolbarContributions

protected IBrowserToolbarContribution[] toolbarContributions

file

protected File file

timestamp

protected long timestamp

fileListenerThread

protected Thread fileListenerThread

locationListener2

protected org.eclipse.swt.browser.LocationListener locationListener2

syncObject

protected Object syncObject
Constructor Detail

BrowserViewer

public BrowserViewer(org.eclipse.swt.widgets.Composite parent,
                     BrowserEditor container,
                     IBrowserToolbarContribution[] toolbarContributions)
Creates a new Web browser given its parent and a style value describing its behavior and appearance. This code is essentially taken from the plugin org.eclipse.ui.browser, but is not accessible -- so needed to be duplicated here.

The style value is either one of the style constants defined in the class header or class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
toolbarContributions -

BrowserViewer

public BrowserViewer(org.eclipse.swt.widgets.Composite parent,
                     BrowserEditor container,
                     IBrowserToolbarContribution[] toolbarContributions,
                     int style)
Method Detail

getBrowser

public org.eclipse.swt.browser.Browser getBrowser()
Returns the underlying SWT browser widget.

Returns:
the underlying browser

home

public void home()
Navigate to the home URL.


setURL

public void setURL(String url)
Loads a URL.

Parameters:
url - the URL to be loaded
Returns:
true if the operation was successful and false otherwise.
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the url is null
org.eclipse.swt.SWTException -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
See Also:
getURL()

updateBackNextBusy

protected void updateBackNextBusy()

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a property change listener to this instance.

Parameters:
listener - java.beans.PropertyChangeListener

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a property change listener from this instance.

Parameters:
listener - java.beans.PropertyChangeListener

firePropertyChangeEvent

protected void firePropertyChangeEvent(String propertyName,
                                       Object oldValue,
                                       Object newValue)
Fire a property change event.


forward

public boolean forward()
Navigate to the next session history item. Convenience method that calls the underlying SWT browser.

Returns:
true if the operation was successful and false otherwise
Throws:
org.eclipse.swt.SWTException -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
See Also:
back

back

public boolean back()
Navigate to the previous session history item. Convenience method that calls the underlying SWT browser.

Returns:
true if the operation was successful and false otherwise
Throws:
org.eclipse.swt.SWTException -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
See Also:
forward

isBackEnabled

public boolean isBackEnabled()
Returns true if the receiver can navigate to the previous session history item, and false otherwise. Convenience method that calls the underlying SWT browser.

Returns:
the receiver's back command enabled state
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
back

isForwardEnabled

public boolean isForwardEnabled()
Returns true if the receiver can navigate to the next session history item, and false otherwise. Convenience method that calls the underlying SWT browser.

Returns:
the receiver's forward command enabled state
Throws:
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
forward

stop

public void stop()
Stop any loading and rendering activity. Convenience method that calls the underlying SWT browser.

Throws:
org.eclipse.swt.SWTException -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed

refresh

public void refresh()
Refresh the current page. Convenience method that calls the underlying SWT browser.

Throws:
org.eclipse.swt.SWTException -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed

setInternalWebBrowserHistory

public static void setInternalWebBrowserHistory(List list)

addToHistory

protected void addToHistory(String url)

dispose

public void dispose()

runToolbarItem

public void runToolbarItem(int i)

getURL

public String getURL()
Returns the current URL. Convenience method that calls the underlying SWT browser.

Returns:
the current URL or an empty String if there is no current URL
Throws:
org.eclipse.swt.SWTException -
  • ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
  • ERROR_WIDGET_DISPOSED when the widget has been disposed
See Also:
setURL(String)

setFocus

public boolean setFocus()

updateHistory

protected void updateHistory()
Update the history list to the global/shared copy.


getContainer

public BrowserEditor getContainer()

setContainer

public void setContainer(BrowserEditor container)

addSynchronizationListener

protected void addSynchronizationListener()

getFile

protected static File getFile(String location)

removeSynchronizationListener

protected void removeSynchronizationListener()

giveBusyIndicatorResource

public void giveBusyIndicatorResource(Resource resource)