Implementing Custom Form Controls

If the built-in form controls are not sufficient for your needs, you can implement custom form controls in Java.

Custom Form Controls Implementation

You can specify custom form controls using the following properties:

The following is a sample Java code for implementing a custom combo box form control that inserts an XML element in the content when the editing stops:

public class ComboBoxEditor  extends AbstractInplaceEditor {
  /**
   * @see ro.sync.ecss.extensions.api.editor.InplaceEditor#stopEditing()
   */
  @Override
   public void stopEditing() {
     Runnable customCommit =  new Runnable() {
      @Override
       public void run() {
        AuthorDocumentController documentController = context.getAuthorAccess().getDocumentController();
        documentController.insertXMLFragment( "<custom/>", offset);
      }
    };
    EditingEvent event =  new EditingEvent(customCommit,  true);
    fireEditingStopped(event);
  }

The custom form controls can use any of the predefined properties of the built-in form controls, as well as specified custom properties.

This following is an example of how to specify a custom form control in the CSS:
myElement {
    content: oxy_editor(
        rendererClassName, "com.custom.editors.CustomRenderer",
        swingEditorClassName, "com.custom.editors.SwingCustomEditor",
        swtEditorClassName, "com.custom.editors.SwtCustomEditor",
        edit, "@my_attr",
        customProperty1, "customValue1",
        customProperty2, "customValue2"
    )
}

How to Implement Custom Form Controls

To implement a custom form control, follow these steps:
  1. Download the Oxygen XML Editor SDK at http://oxygenxml.com/oxygen_sdk_maven.html.
  2. Implement the custom form control by extending ro.sync.ecss.extensions.api.editor.InplaceEditorRendererAdapter. You could also use ro.sync.ecss.extensions.api.editor.AbstractInplaceEditor, which offers some default implementations and listeners management.
  3. Pack the previous implementation in a Java JAR library.
  4. Copy the JAR library to the [OXYGEN_DIR]/frameworks/[FRAMEWORK_DIR] directory.
  5. In Oxygen XML Editor, open the Preferences dialog box, go to Document Type Association, edit the appropriate framework, and add the JAR library in the Classpath tab.
  6. Specify the custom form control in your CSS, as described above.