Class DefaultComponentHandler

java.lang.Object
jaxx.compiler.tags.DefaultObjectHandler
jaxx.compiler.tags.DefaultComponentHandler
All Implemented Interfaces:
TagHandler
Direct Known Subclasses:
JAXXComboBoxHandler, JAXXListHandler, JAXXTreeHandler, JCheckBoxHandler, JComboBoxHandler, JInternalFrameHandler, JListHandler, JMenuHandler, JPopupMenuHandler, JProgressBarHandler, JRadioButtonHandler, JScrollPaneHandler, JSliderHandler, JSpinnerHandler, JSplitPaneHandler, JTabbedPaneHandler, JTextComponentHandler, JToolBarHandler, JTreeHandler, JWindowHandler, JXLayerHandler, TableHandler

public class DefaultComponentHandler
extends DefaultObjectHandler
  • Field Details

    • BORDER_ATTRIBUTE

      public static final java.lang.String BORDER_ATTRIBUTE
      See Also:
      Constant Field Values
    • ACTION_ICON_ATTRIBUTE

      public static final java.lang.String ACTION_ICON_ATTRIBUTE
      See Also:
      Constant Field Values
    • I18N_MNEMONIC_ATTRIBUTE

      public static final java.lang.String I18N_MNEMONIC_ATTRIBUTE
      See Also:
      Constant Field Values
    • CONTAINER_DELEGATE_ATTRIBUTE

      public static final java.lang.String CONTAINER_DELEGATE_ATTRIBUTE
      See Also:
      Constant Field Values
    • FONT_FACE_ATTRIBUTE

      public static final java.lang.String FONT_FACE_ATTRIBUTE
      See Also:
      Constant Field Values
    • FONT_SIZE_ATTRIBUTE

      public static final java.lang.String FONT_SIZE_ATTRIBUTE
      See Also:
      Constant Field Values
    • FONT_STYLE_ATTRIBUTE

      public static final java.lang.String FONT_STYLE_ATTRIBUTE
      See Also:
      Constant Field Values
    • FONT_WEIGHT_ATTRIBUTE

      public static final java.lang.String FONT_WEIGHT_ATTRIBUTE
      See Also:
      Constant Field Values
    • HEIGHT_ATTRIBUTE

      public static final java.lang.String HEIGHT_ATTRIBUTE
      See Also:
      Constant Field Values
    • ICON_ATTRIBUTE

      public static final java.lang.String ICON_ATTRIBUTE
      See Also:
      Constant Field Values
    • ICON_IMAGE_ATTRIBUTE

      public static final java.lang.String ICON_IMAGE_ATTRIBUTE
      See Also:
      Constant Field Values
    • NAME_ATTRIBUTE

      public static final java.lang.String NAME_ATTRIBUTE
      See Also:
      Constant Field Values
    • WIDTH_ATTRIBUTE

      public static final java.lang.String WIDTH_ATTRIBUTE
      See Also:
      Constant Field Values
    • X_ATTRIBUTE

      public static final java.lang.String X_ATTRIBUTE
      See Also:
      Constant Field Values
    • Y_ATTRIBUTE

      public static final java.lang.String Y_ATTRIBUTE
      See Also:
      Constant Field Values
    • log

      protected static final org.apache.commons.logging.Log log
      Logger
    • BORDER_FACTORY_PREFIX

      public static final java.lang.String BORDER_FACTORY_PREFIX
    • TITLED_BORDER_PREFIX

      public static final java.lang.String TITLED_BORDER_PREFIX
  • Constructor Details

    • DefaultComponentHandler

      public DefaultComponentHandler​(ClassDescriptor beanClass)
  • Method Details

    • init

      protected void init() throws java.beans.IntrospectionException
      Description copied from class: DefaultObjectHandler
      Performs introspection on the beanClass and stores the results.
      Overrides:
      init in class DefaultObjectHandler
      Throws:
      java.beans.IntrospectionException - if any pb
    • configureProxyEventInfo

      protected void configureProxyEventInfo()
      Description copied from class: DefaultObjectHandler
      Configures the event handling for members which do not fire PropertyChangeEvent when modified. The default implementation does nothing. Subclasses should override this method to call addProxyEventInfo for each member which requires special handling.
      Overrides:
      configureProxyEventInfo in class DefaultObjectHandler
    • setDefaults

      protected void setDefaults​(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler) throws CompilerException
      Description copied from class: DefaultObjectHandler
      Initializes the default settings of the object, prior to setting its attribute values. The default implementation does nothing.
      Overrides:
      setDefaults in class DefaultObjectHandler
      Parameters:
      object - the object to initialize
      tag - the tag being compiled
      compiler - the current JAXXCompiler
      Throws:
      CompilerException
    • compileFirstPass

      public void compileFirstPass​(org.w3c.dom.Element tag, JAXXCompiler compiler) throws CompilerException, java.io.IOException
      Description copied from interface: TagHandler
      Performs the first pass of compilation on an XML tag from a JAXX source file. TagHandler implementations affect the generated .java file by calling methods in the JAXXCompiler.
      Specified by:
      compileFirstPass in interface TagHandler
      Overrides:
      compileFirstPass in class DefaultObjectHandler
      Parameters:
      tag - the XML tag to compile
      compiler - the active JAXXCompiler
      Throws:
      CompilerException - if a compilation error occurs
      java.io.IOException - if an I/O error occurs
    • compileSecondPass

      public void compileSecondPass​(org.w3c.dom.Element tag, JAXXCompiler compiler) throws CompilerException, java.io.IOException
      Description copied from interface: TagHandler
      Performs the second pass of compilation on an XML tag from a JAXX source file. TagHandler implementations affect the generated .java file by calling methods in the JAXXCompiler.
      Specified by:
      compileSecondPass in interface TagHandler
      Overrides:
      compileSecondPass in class DefaultObjectHandler
      Parameters:
      tag - the XML tag to compile
      compiler - the active JAXXCompiler
      Throws:
      CompilerException - if a compilation error occurs
      java.io.IOException - if an I/O error occurs
    • openComponent

      protected void openComponent​(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler) throws CompilerException
      Throws:
      CompilerException
    • closeComponent

      protected void closeComponent​(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler) throws CompilerException
      Throws:
      CompilerException
    • isPropertyInherited

      public boolean isPropertyInherited​(java.lang.String property) throws UnsupportedAttributeException
      Overrides:
      isPropertyInherited in class DefaultObjectHandler
      Parameters:
      property - property name to test
      Returns:
      true if the specified property should be inherited by child components when specified via CSS.
      Throws:
      UnsupportedAttributeException - if attribute is not supported
    • getPropertyType

      public ClassDescriptor getPropertyType​(CompiledObject object, java.lang.String propertyName, JAXXCompiler compiler) throws CompilerException
      Description copied from class: DefaultObjectHandler
      Returns the type of the named property. This is the return type of the property's get method; for instance JLabel's text property is a String.
      Overrides:
      getPropertyType in class DefaultObjectHandler
      Parameters:
      object - the object being compiled
      propertyName - the simple JavaBeans-style name of the property
      compiler - the current JAXXCompiler
      Returns:
      the property's type
      Throws:
      CompilerException - if the type cannot be determined
    • getGetPropertyCode

      public java.lang.String getGetPropertyCode​(java.lang.String id, java.lang.String name, JAXXCompiler compiler) throws CompilerException
      Description copied from class: DefaultObjectHandler
      Returns a snippet of Java code which will retrieve an object property at runtime. Typically the code is just a call to the property's get method, but it can be arbitrarily complex.
      Overrides:
      getGetPropertyCode in class DefaultObjectHandler
      Parameters:
      id - Java code for the object whose property is being retrieved
      name - the name of the property to retrieve
      compiler - the current JAXXCompiler
      Returns:
      the snippet
      Throws:
      CompilerException - if a compilation error occurs
    • getSetPropertyCode

      public java.lang.String getSetPropertyCode​(java.lang.String id, java.lang.String name, java.lang.String valueCode, JAXXCompiler compiler) throws CompilerException
      Description copied from class: DefaultObjectHandler
      Returns a snippet of Java code which will set an object property at runtime. Typically the code is just a call to the property's set method, but it can be arbitrarily complex.
      Overrides:
      getSetPropertyCode in class DefaultObjectHandler
      Parameters:
      id - Java code for the object whose property is being set
      name - the name of the property to set
      valueCode - Java expression representing the value to set the property to
      compiler - the current JAXXCompiler
      Returns:
      the snippet
      Throws:
      CompilerException - if a compilation error occurs
    • setAttribute

      public void setAttribute​(CompiledObject object, java.lang.String propertyName, java.lang.String stringValue, boolean inline, JAXXCompiler compiler)
      Description copied from class: DefaultObjectHandler
      Set a single property on an object. The value may be either a simple value or contain data binding expressions. Simple values are first converted to the property's type using DefaultObjectHandler.convertFromString(String, String, Class).
      Overrides:
      setAttribute in class DefaultObjectHandler
      Parameters:
      object - the object on which to set the property
      propertyName - the name of the property to set
      stringValue - the raw string value of the property from the XML
      inline - true if the value was directly specified as an inline class tag attribute, false otherwise (a default value, specified in CSS, etc.)
      compiler - the current JAXXCompiler
    • scanAttributesForDependencies

      protected void scanAttributesForDependencies​(org.w3c.dom.Element tag, JAXXCompiler compiler)
      Description copied from class: DefaultObjectHandler
      Scans all attributes for any dependency classes and adds them to the current compilation set. Called by compileFirstPass() (it is an error to add dependencies after pass 1 is complete).
      Overrides:
      scanAttributesForDependencies in class DefaultObjectHandler
      Parameters:
      tag - tag to scan
      compiler - compiler to use
    • constantValue

      protected int constantValue​(java.lang.String key, java.lang.String value)
      Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively. You do not normally need to call this method yourself; it is invoked by DefaultObjectHandler.convertFromString(java.lang.String, java.lang.String, java.lang.Class<?>) when an int-valued property has a value which is not a valid number. By default, this method looks at the enumerationValues value of the JAXXPropertyDescriptor.
      Overrides:
      constantValue in class DefaultObjectHandler
      Parameters:
      key - the name of the int-typed property
      value - the non-numeric value that was specified for the property
      Returns:
      the constant integer value
      Throws:
      java.lang.IllegalArgumentException - if the property is an enumeration, but the value is not valid
      java.lang.NumberFormatException - if the property is not an enumeration
    • isContainer

      public boolean isContainer()
      Returns true if this component can contain other components. For children to be allowed, the component must be a subclass of Container and its JAXXBeanInfo must not have the value false for its isContainer value.
      Returns:
      true if children are allowed
    • getContainerDelegate

      public java.lang.String getContainerDelegate()