Adding Custom Layout Managers

JDeveloper supports the integration of other layout managers with its Java Visual Editor. Users will be able to work with the layout manager using both the Java Visual Editor and the Property Inspector when you:

  1. Write an oracle.jdevimpl.uieditor.LayoutAssistant implementation to be associated with the LayoutManager
  2. Register the LayoutAssistant implementation with the IDE
  3. (Optionally) Register a java.beans.PropertyEditor with the IDE to handle any special constraints type

To Create a Custom Layout Manager Assistant

Each LayoutManager must be associated with a LayoutAssistant implementation. The class oracle.jdevimpl.uieditor.assistant.BasicLayoutAssistant provides a minimal implementation of the interface oracle.jdevimpl.uieditor.LayoutAssistant and will be used for any LayoutManager for which no explicit registration has been made. There are several required methods in the interface, but it is beyond the scope of this topic to describe them. Integrators may wish to subclass their LayoutAssistant implementations from this minimal implementation.  Refer to the javadoc for the LayoutAssistant interface for details.

To Register the Layout Assistant

To register the new layout assistant, you need to add a key-value definition to oracle.jdevimpl.uieditor.UIEditorAddin section in the JDeveloper\lib\addins.xml file as follows:


<property>
     <key>PREFIX.LAYOUT_MANAGER_CLASS_NAME</key>
     <value>LAYOUT_ASSISTANT_CLASS_NAME</value>
</property>

    

where:

For example; if you were to register a LayoutAssistant implementation oracle.jdevimpl.uieditor.assistant.GridBagLayoutAssistant for the java.awt.GridBagLayout layout manager, the property to add would look like:


<property>
     <key>jdeveloper.uiassistant.java.awt.GridBagLayout</key>
     <value>oracle.jdevimpl.uieditor.assistant.GridBagLayoutAssistant</value>
</property>    

Note that in order for the layout assistant to be available from within the IDE, so that it will appear in the Property Inspector's layout property list, the layout assistant must be added to the IDEClasspath as a directive in JDeveloper\bin\jdev.conf file. For example:

AddJavaLibFile <myAssistant.jar>

where, myAssistant.jar contains the compiled class file for your LayoutAssistant implementation.

To Register a Constraints PropertyEditor For the Layout Manager

If your custom layout manager uses a constraint class, you may want to register a class implementing java.beans.PropertyEditor for editing the constraints. You register the property editor class under Inspector.PropertyEditor in the ide.properties file, where:

For example, if you were to register the property editor for the GridBagLayout layout manager's GridBagConstraints, your entry in the ide.properties file would look like:

Inspector.PropertyEditor.count=1

Inspector.PropertyEditor.editor1.type=java.awt.GridBagConstraints
Inspector.PropertyEditor.editor1.editor=oracle.jdevimpl.uieditor.assistant.GridBagConstraintsEditor

Note: Your property editor class also needs to be in the IDEClasspath as described above for the layout manager assistant.


Defining Property Accessors
Creating a Property Editor