Package jaxx.compiler.tags
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
-
Nested Class Summary
Nested classes/interfaces inherited from class jaxx.compiler.tags.DefaultObjectHandler
DefaultObjectHandler.ProxyEventInfo -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringACTION_ICON_ATTRIBUTEstatic java.lang.StringBORDER_ATTRIBUTEstatic java.lang.StringBORDER_FACTORY_PREFIXstatic java.lang.StringCONTAINER_DELEGATE_ATTRIBUTEstatic java.lang.StringFONT_FACE_ATTRIBUTEstatic java.lang.StringFONT_SIZE_ATTRIBUTEstatic java.lang.StringFONT_STYLE_ATTRIBUTEstatic java.lang.StringFONT_WEIGHT_ATTRIBUTEstatic java.lang.StringHEIGHT_ATTRIBUTEstatic java.lang.StringI18N_MNEMONIC_ATTRIBUTEstatic java.lang.StringICON_ATTRIBUTEstatic java.lang.StringICON_IMAGE_ATTRIBUTEprotected static org.apache.commons.logging.LoglogLoggerstatic java.lang.StringNAME_ATTRIBUTEstatic java.lang.StringTITLED_BORDER_PREFIXstatic java.lang.StringWIDTH_ATTRIBUTEstatic java.lang.StringX_ATTRIBUTEstatic java.lang.StringY_ATTRIBUTEFields inherited from class jaxx.compiler.tags.DefaultObjectHandler
ABSTRACT_ATTRIBUTE, BORDER_LAYOUT_PREFIX, CONSTRAINTS_ATTRIBUTE, CONSTRUCTOR_PARAMS_ATTRIBUTE, DECORATOR_ATTRIBUTE, DISPLAYED_MNEMONIC_ATTRIBUTE, DISPLAYED_MNEMONIC_INDEX_ATTRIBUTE, GENERIC_TYPE_ATTRIBUTE, GRID_LAYOUT_PREFIX, HANDLER_ATTRIBUTE, ID_ATTRIBUTE, IMPLEMENTS_ATTRIBUTE, INITIALIZER_ATTRIBUTE, JAVA_BEAN_ATTRIBUTE, jaxxBeanInfo, LAYOUT_ATTRIBUTE, MNEMONIC_ATTRIBUTE, objectMap, STYLE_CLASS_ATTRIBUTE, SUPER_GENERIC_TYPE_ATTRIBUTEFields inherited from interface jaxx.compiler.tags.TagHandler
XMLNS_ATTRIBUTE -
Constructor Summary
Constructors Constructor Description DefaultComponentHandler(ClassDescriptor beanClass) -
Method Summary
Modifier and Type Method Description protected voidcloseComponent(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler)voidcompileFirstPass(org.w3c.dom.Element tag, JAXXCompiler compiler)Performs the first pass of compilation on an XML tag from a JAXX source file.voidcompileSecondPass(org.w3c.dom.Element tag, JAXXCompiler compiler)Performs the second pass of compilation on an XML tag from a JAXX source file.protected voidconfigureProxyEventInfo()Configures the event handling for members which do not firePropertyChangeEventwhen modified.protected intconstantValue(java.lang.String key, java.lang.String value)Maps string values onto integers, so that int-valued enumeration properties can be specified by strings.java.lang.StringgetContainerDelegate()java.lang.StringgetGetPropertyCode(java.lang.String id, java.lang.String name, JAXXCompiler compiler)Returns a snippet of Java code which will retrieve an object property at runtime.ClassDescriptorgetPropertyType(CompiledObject object, java.lang.String propertyName, JAXXCompiler compiler)Returns the type of the named property.java.lang.StringgetSetPropertyCode(java.lang.String id, java.lang.String name, java.lang.String valueCode, JAXXCompiler compiler)Returns a snippet of Java code which will set an object property at runtime.protected voidinit()Performs introspection on the beanClass and stores the results.booleanisContainer()Returnstrueif this component can contain other components.booleanisPropertyInherited(java.lang.String property)protected voidopenComponent(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler)protected voidscanAttributesForDependencies(org.w3c.dom.Element tag, JAXXCompiler compiler)Scans all attributes for any dependency classes and adds them to the current compilation set.voidsetAttribute(CompiledObject object, java.lang.String propertyName, java.lang.String stringValue, boolean inline, JAXXCompiler compiler)Set a single property on an object.protected voidsetDefaults(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler)Initializes the default settings of the object, prior to setting its attribute values.Methods inherited from class jaxx.compiler.tags.DefaultObjectHandler
addEventHandler, addProxyEventInfo, addProxyEventInfo, addProxyEventInfo, addProxyEventInfo, applyStylesheets, compileChildrenFirstPass, compileChildrenSecondPass, compileChildTagFirstPass, compileChildTagSecondPass, convertFromString, createCompiledObject, getAttributeComparator, getAttributeOrdering, getBeanClass, getEventClass, getEventInfo, getJAXXBeanInfo, getJAXXBeanInfo, isEventHandlerName, isMemberBound, registerCompiledObject, safeInit, setAttributeFromCss, setAttributes, setProperty, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
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 logLogger -
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
-
-
Method Details
-
init
protected void init() throws java.beans.IntrospectionExceptionDescription copied from class:DefaultObjectHandlerPerforms introspection on the beanClass and stores the results.- Overrides:
initin classDefaultObjectHandler- Throws:
java.beans.IntrospectionException- if any pb
-
configureProxyEventInfo
protected void configureProxyEventInfo()Description copied from class:DefaultObjectHandlerConfigures the event handling for members which do not firePropertyChangeEventwhen modified. The default implementation does nothing. Subclasses should override this method to calladdProxyEventInfofor each member which requires special handling.- Overrides:
configureProxyEventInfoin classDefaultObjectHandler
-
setDefaults
protected void setDefaults(CompiledObject object, org.w3c.dom.Element tag, JAXXCompiler compiler) throws CompilerExceptionDescription copied from class:DefaultObjectHandlerInitializes the default settings of the object, prior to setting its attribute values. The default implementation does nothing.- Overrides:
setDefaultsin classDefaultObjectHandler- Parameters:
object- the object to initializetag- the tag being compiledcompiler- the currentJAXXCompiler- Throws:
CompilerException
-
compileFirstPass
public void compileFirstPass(org.w3c.dom.Element tag, JAXXCompiler compiler) throws CompilerException, java.io.IOExceptionDescription copied from interface:TagHandlerPerforms the first pass of compilation on an XML tag from a JAXX source file.TagHandlerimplementations affect the generated.javafile by calling methods in theJAXXCompiler.- Specified by:
compileFirstPassin interfaceTagHandler- Overrides:
compileFirstPassin classDefaultObjectHandler- Parameters:
tag- the XML tag to compilecompiler- the active JAXXCompiler- Throws:
CompilerException- if a compilation error occursjava.io.IOException- if an I/O error occurs
-
compileSecondPass
public void compileSecondPass(org.w3c.dom.Element tag, JAXXCompiler compiler) throws CompilerException, java.io.IOExceptionDescription copied from interface:TagHandlerPerforms the second pass of compilation on an XML tag from a JAXX source file.TagHandlerimplementations affect the generated.javafile by calling methods in theJAXXCompiler.- Specified by:
compileSecondPassin interfaceTagHandler- Overrides:
compileSecondPassin classDefaultObjectHandler- Parameters:
tag- the XML tag to compilecompiler- the active JAXXCompiler- Throws:
CompilerException- if a compilation error occursjava.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
- Overrides:
isPropertyInheritedin classDefaultObjectHandler- Parameters:
property- property name to test- Returns:
trueif 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 CompilerExceptionDescription copied from class:DefaultObjectHandlerReturns the type of the named property. This is the return type of the property'sgetmethod; for instanceJLabel'stextproperty is aString.- Overrides:
getPropertyTypein classDefaultObjectHandler- Parameters:
object- the object being compiledpropertyName- the simple JavaBeans-style name of the propertycompiler- the currentJAXXCompiler- 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 CompilerExceptionDescription copied from class:DefaultObjectHandlerReturns a snippet of Java code which will retrieve an object property at runtime. Typically the code is just a call to the property'sgetmethod, but it can be arbitrarily complex.- Overrides:
getGetPropertyCodein classDefaultObjectHandler- Parameters:
id- Java code for the object whose property is being retrievedname- the name of the property to retrievecompiler- the currentJAXXCompiler- 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 CompilerExceptionDescription copied from class:DefaultObjectHandlerReturns a snippet of Java code which will set an object property at runtime. Typically the code is just a call to the property'ssetmethod, but it can be arbitrarily complex.- Overrides:
getSetPropertyCodein classDefaultObjectHandler- Parameters:
id- Java code for the object whose property is being setname- the name of the property to setvalueCode- Java expression representing the value to set the property tocompiler- the currentJAXXCompiler- 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:DefaultObjectHandlerSet 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 usingDefaultObjectHandler.convertFromString(String, String, Class).- Overrides:
setAttributein classDefaultObjectHandler- Parameters:
object- the object on which to set the propertypropertyName- the name of the property to setstringValue- the raw string value of the property from the XMLinline-trueif the value was directly specified as an inline class tag attribute,falseotherwise (a default value, specified in CSS, etc.)compiler- the currentJAXXCompiler
-
scanAttributesForDependencies
Description copied from class:DefaultObjectHandlerScans all attributes for any dependency classes and adds them to the current compilation set. Called bycompileFirstPass()(it is an error to add dependencies after pass 1 is complete).- Overrides:
scanAttributesForDependenciesin classDefaultObjectHandler- Parameters:
tag- tag to scancompiler- 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 byDefaultObjectHandler.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 theenumerationValuesvalue of theJAXXPropertyDescriptor.- Overrides:
constantValuein classDefaultObjectHandler- Parameters:
key- the name of the int-typed propertyvalue- 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 validjava.lang.NumberFormatException- if the property is not an enumeration
-
isContainer
public boolean isContainer()Returnstrueif this component can contain other components. For children to be allowed, the component must be a subclass ofContainerand itsJAXXBeanInfomust not have the valuefalsefor itsisContainervalue.- Returns:
trueif children are allowed
-
getContainerDelegate
public java.lang.String getContainerDelegate()
-