Oculus Layout Builder Plugin API Documentation
November 25, 2002

com.oculustech.layoutbuilder.pluginapi
Class AbstractComponentMetaInfo

java.lang.Object
  |
  +--com.oculustech.layoutbuilder.pluginapi.AbstractComponentMetaInfo
All Implemented Interfaces:
ComponentMetaInfo

public abstract class AbstractComponentMetaInfo
extends java.lang.Object
implements ComponentMetaInfo

Abstract implementation of ComponentMetaInfo. Provides default code generation facilities.


Constructor Summary
AbstractComponentMetaInfo()
           
 
Method Summary
 boolean canInlineConstruction()
          Return true iif it is OK to inline the construction of this component in the add() call.
 java.lang.String[] defaultInspectorFieldsToExclude()
          Returns the set of fields that should be excluded when fields are automatically generated by reflection.
 boolean doIncludeDefaultInspectorFields()
          If this returns true, the system will automatically generate fields in the inspector by reflecting on the component's class.
 java.lang.String generateCode(java.lang.String variableName, boolean asInlinedInstance, boolean asLocalVariable)
          Generate code for this component.
 java.lang.String generateDeclaration(java.lang.String variableName)
          This should generate a class declaration for this component.
 java.lang.Class getComponentClass()
          Returns class of object returned by getComponent().
protected  java.lang.String getDeclarationType()
          Returns the class name to use in the generated code (getComponentClass().getName() with package adjusted to be more user friendly).
static FieldInfo getFieldInfo(ComponentMetaInfo cmi, java.lang.String fieldName)
          Returns the FieldInfo for the field of the given name within cmi.
 FieldInfo getFieldInfo(java.lang.String name)
          Gets the FieldInfo for the field of the given name.
static boolean hasTextConstructor(java.lang.Class c)
          Returns true if given class has a constructor taking one argument of type String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.oculustech.layoutbuilder.pluginapi.ComponentMetaInfo
getComponent, getFields
 

Constructor Detail

AbstractComponentMetaInfo

public AbstractComponentMetaInfo()
Method Detail

getDeclarationType

protected java.lang.String getDeclarationType()
Returns the class name to use in the generated code (getComponentClass().getName() with package adjusted to be more user friendly).

Default implementation returns class of object returned by getComponent(). Strips off java.awt or javax.swing package names; leaves others.


getComponentClass

public java.lang.Class getComponentClass()
Returns class of object returned by getComponent().

canInlineConstruction

public boolean canInlineConstruction()
Return true iif it is OK to inline the construction of this component in the add() call. This results in more compact code, but makes it impossible to call side-effecting methods (setXXX) on the component.

Default implementation returns false except for trivial JLabel instances.

Specified by:
canInlineConstruction in interface ComponentMetaInfo

generateDeclaration

public java.lang.String generateDeclaration(java.lang.String variableName)
This should generate a class declaration for this component. It should include type and variable name only; it should not include modifiers (private, static, final), nor should it initialize the variable. It should include a final semicolon (e.g. "MyComponentClass variableName;")

Default implementation creates trivial declaration as per above.

Specified by:
generateDeclaration in interface ComponentMetaInfo

generateCode

public java.lang.String generateCode(java.lang.String variableName,
                                     boolean asInlinedInstance,
                                     boolean asLocalVariable)
Generate code for this component. If asInlinedInstance is true, then this should be a constructor/factory call only, which can be nested directly into an add(Component) call. asInlinedInstance will only be true if canInlineConstruction() returns true. If asLocalVariable is true, code should include variable declarator when initializing variable name; otherwise, variable was already declared as class variable, and code should not include declarator.

Default implementation uses text constructor if Text field is set, default constructor otherwise, and then sets all fields that are not default values.

Specified by:
generateCode in interface ComponentMetaInfo

doIncludeDefaultInspectorFields

public boolean doIncludeDefaultInspectorFields()
If this returns true, the system will automatically generate fields in the inspector by reflecting on the component's class. These fields will be used in addition to any defined by getFields(). defaultInspectorFieldsToExclude() can be used to exclude any of these fields from being automatically generated. Generated fields will be used in addition to any returned by getFields().

Default implementation returns true.

Specified by:
doIncludeDefaultInspectorFields in interface ComponentMetaInfo

defaultInspectorFieldsToExclude

public java.lang.String[] defaultInspectorFieldsToExclude()
Returns the set of fields that should be excluded when fields are automatically generated by reflection. Use only the part of the name after get/set, i.e., "Name" for the field corresponding to getName/setName methods.

Default implementation returns empty array.

Specified by:
defaultInspectorFieldsToExclude in interface ComponentMetaInfo

hasTextConstructor

public static boolean hasTextConstructor(java.lang.Class c)
Returns true if given class has a constructor taking one argument of type String.

getFieldInfo

public FieldInfo getFieldInfo(java.lang.String name)
Gets the FieldInfo for the field of the given name.

getFieldInfo

public static FieldInfo getFieldInfo(ComponentMetaInfo cmi,
                                     java.lang.String fieldName)
Returns the FieldInfo for the field of the given name within cmi.

Oculus Layout Builder Plugin API Documentation
November 25, 2002

Copyright 2002 Oculus Technologies Corporation. 103 Broad Street, 6th Floor,
Boston, Massachusetts, 02110, U.S.A. All Rights Reserved.