10. Creating Custom Dialogs

Note:

Implementing Custom Dialogs in Java requires knowledge of the Java programming language and general software development knowledge and practice. No technical support can be given for Custom Dialog implementations.

10.1. Overview

In edit-on Pro you can create custom dialogs by overwriting existing dialogs or creating new dialogs. Overwriting an existing dialog is done by overwriting the action linked to it. For example, if you wanted to overwrite the "Insert Link" dialog, you'd need to overwrite the LINK action.

10.2. Implementing a Custom Dialog

To implement a custom dialog, you must perform the following steps:

  1. Construct a class that extends the abstract class javax.swing.AbstractAction .

  2. Override the method actionPerformed() of the java.awt.event.ActionListener interface.

  3. In the actionPerformed() method, build and display your custom user interface and handle the data exchange between your class and edit-on Pro.

  4. Build your class.

  5. Deploy it to your server.

  6. Specify your custom class as a class attrbute of the selected action element in the user interface configuration file and hand over your class name.

10.2.1. Interfacing with edit-on Pro

As the custom dialog class must extend the class javax.swing.AbstractAction , you can use the methods getKeys , getValue and putValue to find and set the value of the properties available in the dialog you are overwriting. getKeys will return an array of objects which have been set for the custom dialog you are overwriting. The objects may be an array themselves.

When overwriting an existing dialog, getKeys will contain the following objects:

  1. ACTIONID : name of the action calling the dialog (see chapter Actions ). ACTIONID is of type java.lang.String .

  2. SmallIcon : the icon associated to the action. SmallIcon is of type java.lang.String .

  3. enabled : determines if the action is enabled. enabled is of type boolean.

  4. cancelaction : determines if the default action of the dialog should be executed. If set to true, the default action is not executed and only the custom dialog code is executed. If set to false, the default action is executed.

  5. defaultshortcut : the default keyboard shortcut associated to the action. defaultshortcut is of type java.lang.String .

  6. apiobject : a reference to the instance of the edit-on Pro applet (of type com.realobjects.eop.japplet.SwingEditorApplet )

  7. frame : when constructing your dialogs, use this as parent. frame is of type java.awt.Frame .

  8. EOPDATA : a hashtable containing key / value pairs providing more sophisticated possibilities to interact with the action. EOPDATA is of type java.util.Hashtable .

  9. defaultaction : the default action object of the dialog as an AbstractAction. Can be used to call the default action within a customized standard action.

10.2.2. Interacting with EOPDATA

Depending on the action you are overwriting, the hashtable EOPDATA will contain another set of keys. For example, when you overwrite the LINKPROPERTIES action, EOPDATA will contain the following keys:

  • allowedAttributes : a list of the allowed attributes for the current element.

  • attributes : a hashtable containing name / value pairs of the attributes the elememt currently has

For a complete reference of the keys available when overwriting exisiting actions, please see the chapter Keys available in EOPDATA for each action .

10.2.3. Interacting with Custom Dialogs Derived from Custom Actions

When you do create a custom dialog by creating a custom action you are not able to interface with the applet using the EOPDATA hashtable. Instead, you can use the API methods described in the chapter JavaScript API / Java API .

Example II.27. Using Java API methods in a custom dialog

SwingEditorApplet applet = 
    (SwingEditorApplet)getValue("apiobject");
applet.insertHTMLData("<p>some content</p>");


10.3. Deploying a Custom Dialog

To deploy a custom dialog, you have to overwrite the corresponding action or create a new custom action in the uiconfig.xml file. For example, in case you want to overwrite the "Insert Hyperlink" dialog, you need to overwrite the LINK action. To do so, add the following line in the <actions>...</actions> section of the uiconfig.xml:

Example II.28. Overwriting the LINK action

<actions> 
    <action id="LINK" 
        class="com.realobjects.customdialog.insertlink.InsertLinkDialog" />
</actions>

Use the class attribute to indicate the name of your class containing the custom dialog class. The class file must be located in the applet codebase. It can also be provided in a JAR file relative to the applet codebase. Use the JavaScript API method addArchive to load additional JAR archives in addition to applet archive. For details see the chapter JavaScript API / Java API .