The Java Developer's Guide to EclipseThe Java Developer's Guide to Eclipse

In Chapter 34, OLE and ActiveX Interoperability, you learned how to embed ActiveX controls in the Eclipse Platform. Learning how to work with the SWT OLE API is an important part of this example, but this example also reinforces what you've learned so far about the contribution, resource, and editor frameworks. The goals of this example are to illustrate the principals of building an Eclipse-aware user interface while leveraging the investment in legacy code. 

Running the Example

Verify that you have imported the project com.ibm.jdg2e.activex.editor from the CD-ROM. To run the example, launch the run-time instance of Eclipse (Run > Run As > Eclipse Application).

  1. Create a new project and a new .htm file. The newly created file will open using this plug-in's editor.
  2. Create some text in the WYSIWYG (IE) editor page and then use the Bold, Underline, and Italic actions available on the menu bar or the buttons on the Workbench toolbar.
  3. Switch to the default text editor page and look at the raw HTML. 

The following figure shows the running example with the Internet Explorer ActiveX control and JFace Text working together inside a multi-page editor. The ActiveX control is running inside the tab labeled, IE Design Mode the JFace Text editor is running inside the index.htm tab of the editor.

OLE HTML Editor

The plug-in also writes information messages into the host console.

Roadmap of the Example

The editor provides you with a multi-page editor containing two pages. The editor page implements a text editor used to edit an .htm source file. The other page implements a WYSIWYG HTML editor page based on the IE Web Browser ActiveX control. The fun part of the example adds in menu and toolbar action contributions which allows the user to set the font to bold, italic, and underline.

Plug-in Utilities

Class (All) Description
ActiveXEditorImages Convenience class for storing references to image descriptors used by the OLE editor.
ActiveXEditorPlugin The main plug-in class.

Editors

Using the IE Web Browser control, we integrate that web browser's editing capability into an Eclipse multi-page editor using editor input from Eclipse resources and connect custom actions to the Workbench toolbar and menus.

Class (All) Description
ActiveXBrowserView This class hosts the IE ActiveX control (shdocvw.dll).
ActiveXHTMLEditor This class manages the life cycle of two editor pages inside this multi-page editor. The class keeps the editor contents synchronized and handles Save and Save As actions.
ActiveXMultiPageEditorContributor Manages the installation/deinstallation of global actions for multi-page editors. Responsible for the redirection of global actions to the active editor. A multi-page contributor replaces the contributors for the individual editors in the multi-page editor.
ActiveXWebBrowser This class wrappers, or is a proxy to, an aggregate of OLE automation objects contained in the Microsoft Web Browser control and the Dynamic HTML (DHTML) Object Model (DOM) in the MSHTML control, Shell.Explorer (OleControlSite).

 The IDL files (shdocvw.idl for the browser control and mshtml.idl for the HTML control) are included here for reference.

References

© Copyright International Business Machines Corporation, 2003, 2004, 2006. All Rights Reserved.
Code or samples provided herein are provided without warranty of any kind.