Implementing Custom Form Controls

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

You can specify them using the following properties:

Custom Form Control Implementation

Sample Java code for a custom combo box form control implementation 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);
  }

If the custom form control is intended to work in the Oxygen XML Editor standalone distribution, the declaration of swtEditorClassName is not required. The renderer (the class that draws the value) and the editor (the class that edits the value) have different properties because you can present a value in one way and edit it in another.

The custom form controls can use any of the predefined properties of the oxy_editor function, as well as specified custom properties. This is an example of how to specify a custom form control:
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"
    )
}
Note: Add these custom Java implementations in the classpath of the document type associated with the document you are editing. To get you started, the Java sources for the SimpleURLChooserEditor are available in the Oxygen SDK.

The oxy_editor function can receive other functions as parameters for obtaining complex behaviors.

The following example shows how the combo box editor can obtain its values from the current XML file by calling the oxy_xpath function:
link:before{
      content: "Managed by:"
        oxy_editor(
            type, combo, 
            edit, "@manager",
            values, oxy_xpath('string-join(//@id , ",") '));