## com.ibm.lab.soln.interopedit.editors
Class ActiveXWebBrowser

    java.lang.Object
      |
      +--com.ibm.lab.soln.interopedit.editors.ActiveXWebBrowser

public class ActiveXWebBrowser
extends java.lang.Object

This uses OleAutomation objects o send commands to the Win32 "Shell.Explorer" OLE control. Instances of this class manage the setup, typical use, and teardown of a simple web browser. This class wrappers, or is a proxy to, an aggregate of OLE automation objects contained in the Microsoft Web Browser control. Shell.Explorer (OleControSite). The Shdocvw.dll component is more frequently referred as the WebBrowser Control.The WebBrowser control in turn hosts the MSHTML control (mshtml.dll). Mshtml.dll is the component that performs the HTML parsing and rendering in Internet Explorer 4.0 and later. The MSHTML control provides all interfaces for accessing the DOM. The IDispatch interfaces used in this exercise are the same interfaces used to access the object model by scripts within web pages. We implement just a small portion of the automation capabilities of MSHTML here in this excercise. The MSHTML control (mshtml.dll) with IE 5.5 and above exposes a automation model that supports most commonly used editing features for both text and forms. This makes it possible to develop WYSIWYG HTML editing inside an Eclipse editor. This editor page allows users to enter * formatted text, images, etc. To learn more about MSTHL the DOM and the editing capabilities, see the MSDN:

Field Summary
`static int` | `DISPID_ACTIVE_ELEMENT`
`static int` | `DISPID_BODY`
`static int` | `DISPID_DOCUMENT`
`static int` | `DISPID_DOCUMENT_ELEMENT`
`static int` | `DISPID_INNERHTML`
`static int` | `DISPID_READYSTATE`
`static int` | `READYSTATE_COMPLETE`
`static int` | `READYSTATE_INTERACTIVE`
`static int` | `READYSTATE_LOADED`
`static int` | `READYSTATE_LOADING`
`static int` | `READYSTATE_UNINITIALIZED`

Constructor Summary
`ActiveXWebBrowser(org.eclipse.swt.ole.win32.OleAutomation oleAutomation, org.eclipse.swt.ole.win32.OleControlSite controlSite)` Creates a Web browser control.

Method Summary
`int` | `delete()` Method to delete/clear the document contents
`void` | `dispose()` Method disposes of the OLE Automation object.
`int` | `docExecCommand(java.lang.String command)` Method docExecCommand.
`int` | `getDocReadyState()` Returns the current state of the control.
`org.eclipse.swt.ole.win32.OleAutomation` | `getDocumentAutomation()` Method gets the document automation object.
`org.eclipse.swt.ole.win32.OleAutomation` | `getElementAutomation()` Method A helper to dig out the document element
`java.lang.String` | `getinnerHTML()` Method gets all the HTML code in the document
`int` | `getReadyState()` Returns the current state of the control.
`static ActiveXWebBrowser` | `getWebBrowser()` Returns the webBrowser.
`int` | `Navigate(java.lang.String url)` Navigates to a particular URL.
`void` | `Refresh()` Refreshes the currently viewed page.
`int` | `replace(java.lang.String replaceText)` Method to replace the document contents
`int` | `selectAll()` Method to Select All editor contents
`boolean` | `setDesignModeProperty(java.lang.String flag)` Method setDesignModePropertyOn.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DISPID_ACTIVE_ELEMENT

    public static final int DISPID_ACTIVE_ELEMENT

### DISPID_BODY

    public static final int DISPID_BODY

### DISPID_DOCUMENT

    public static final int DISPID_DOCUMENT

### DISPID_DOCUMENT_ELEMENT

    public static final int DISPID_DOCUMENT_ELEMENT

### DISPID_INNERHTML

    public static final int DISPID_INNERHTML

### DISPID_READYSTATE

    public static final int DISPID_READYSTATE

### READYSTATE_COMPLETE

    public static final int READYSTATE_COMPLETE

### READYSTATE_INTERACTIVE

    public static final int READYSTATE_INTERACTIVE

### READYSTATE_LOADED

    public static final int READYSTATE_LOADED

### READYSTATE_LOADING

    public static final int READYSTATE_LOADING

### READYSTATE_UNINITIALIZED

    public static final int READYSTATE_UNINITIALIZED

Constructor Detail

### ActiveXWebBrowser

    public ActiveXWebBrowser(org.eclipse.swt.ole.win32.OleAutomation oleAutomation,
                             org.eclipse.swt.ole.win32.OleControlSite controlSite)

  Creates a Web browser control.

  Typical use:
  `OleControlSite oleControlSite = new OleControlSite(oleFrame, style, "Shell.Explorer");
  OleAutomation oleAutomation = new OleAutomation(oleControlSite);
  OleWebBrowser webBrowser = new OleWebBrowser(oleControlSite, oleAutomation);
  `

  Parameters:
    `oleAutomation` - the OleAutomation object for this control.
    `oleControlSite` - the OleControlSite object for this control.

Method Detail

### delete

    public int delete()

  Method to delete/clear the document contents
  Parameters:
    `string` -
  Returns:
    int

### dispose

    public void dispose()

  Method disposes of the OLE Automation object.

### docExecCommand

    public int docExecCommand(java.lang.String command)

  Method docExecCommand.
  Parameters:
    `command` - - see the document exec command identifiers in MSDN
  Returns:
    int

### getDocReadyState

    public int getDocReadyState()

  Returns the current state of the control.
  Returns:
    the current state of the control, one of: READYSTATE_UNINITIALIZED; READYSTATE_LOADING; READYSTATE_LOADED; READYSTATE_INTERACTIVE; READYSTATE_COMPLETE.

### getDocumentAutomation

    public org.eclipse.swt.ole.win32.OleAutomation getDocumentAutomation()

  Method gets the document automation object.
  Returns:
    OleAutomation

### getElementAutomation

    public org.eclipse.swt.ole.win32.OleAutomation getElementAutomation()

  Method A helper to dig out the document element
  Returns:
    OleAutomation

### getinnerHTML

    public java.lang.String getinnerHTML()

  Method gets all the HTML code in the document
  Returns:
    String

### getReadyState

    public int getReadyState()

  Returns the current state of the control.
  Returns:
    the current state of the control, one of: READYSTATE_UNINITIALIZED; READYSTATE_LOADING; READYSTATE_LOADED; READYSTATE_INTERACTIVE; READYSTATE_COMPLETE.

### getWebBrowser

    public static ActiveXWebBrowser getWebBrowser()

  Returns the webBrowser.
  Returns:
    ActiveXWebBrowser

### Navigate

    public int Navigate(java.lang.String url)

  Navigates to a particular URL.
  Returns:
    the platform-defined result code for the "Navigate" method invocation

### Refresh

    public void Refresh()

  Refreshes the currently viewed page.
  Returns:
    the platform-defined result code for the "Refresh" method invocation

### replace

    public int replace(java.lang.String replaceText)

  Method to replace the document contents
  Parameters:
    `string` - - replacement text
  Returns:
    int

### selectAll

    public int selectAll()

  Method to Select All editor contents
  Parameters:
    `string` -
  Returns:
    int

### setDesignModeProperty

    public boolean setDesignModeProperty(java.lang.String flag)

  Method setDesignModePropertyOn. Enables editing inside the IE ActiveX control