Package org.nuiton.jaxx.compiler.tags
Class DefaultComponentHandler
- java.lang.Object
-
- org.nuiton.jaxx.compiler.tags.DefaultObjectHandler
-
- org.nuiton.jaxx.compiler.tags.DefaultComponentHandler
-
- All Implemented Interfaces:
TagHandler
- Direct Known Subclasses:
AbstractButtonHandler,JAXXComboBoxHandler,JAXXListHandler,JAXXTreeHandler,JComboBoxHandler,JInternalFrameHandler,JListHandler,JMenuHandler,JPopupMenuHandler,JProgressBarHandler,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 org.nuiton.jaxx.compiler.tags.DefaultObjectHandler
DefaultObjectHandler.ProxyEventInfo
-
-
Field Summary
Fields Modifier and Type Field Description static StringACTION_ICON_ATTRIBUTEstatic StringADD_TO_CONTAINER_ATTRIBUTEstatic StringBEAN_SCOPE_ATTRIBUTEstatic StringBORDER_ATTRIBUTEstatic StringBORDER_FACTORY_PREFIXstatic StringCONTAINER_DELEGATE_ATTRIBUTEstatic StringFONT_FACE_ATTRIBUTEstatic StringFONT_SIZE_ATTRIBUTEstatic StringFONT_STYLE_ATTRIBUTEstatic StringFONT_WEIGHT_ATTRIBUTEstatic StringHEIGHT_ATTRIBUTEstatic StringI18N_MNEMONIC_ATTRIBUTEstatic StringICON_ATTRIBUTEstatic StringICON_IMAGE_ATTRIBUTEprotected static org.apache.logging.log4j.LoggerlogLoggerstatic StringNAME_ATTRIBUTEstatic StringTITLED_BORDER_ATTRIBUTEstatic StringTITLED_BORDER_PREFIXstatic StringWIDTH_ATTRIBUTEstatic StringX_ATTRIBUTEstatic StringY_ATTRIBUTE-
Fields inherited from class org.nuiton.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, I18N_ATTRIBUTE, I18N_PROPERTY_ATTRIBUTE, ID_ATTRIBUTE, IMPLEMENTS_ATTRIBUTE, INITIALIZER_ATTRIBUTE, JAVA_BEAN_ATTRIBUTE, jaxxBeanInfo, LAYOUT_ATTRIBUTE, MNEMONIC_ATTRIBUTE, objectMap, OVERRIDE_PARAMETER, STYLE_CLASS_ATTRIBUTE, SUPER_GENERIC_TYPE_ATTRIBUTE
-
Fields inherited from interface org.nuiton.jaxx.compiler.tags.TagHandler
XMLNS_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description DefaultComponentHandler(ClassDescriptor beanClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseComponent(CompiledObject object, Element tag, JAXXCompiler compiler)voidcompileFirstPass(Element tag, JAXXCompiler compiler)Performs the first pass of compilation on an XML tag from a JAXX source file.voidcompileSecondPass(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(String key, String value)Maps string values onto integers, so that int-valued enumeration properties can be specified by strings.StringgetContainerDelegate()StringgetGetPropertyCode(String id, String name, JAXXCompiler compiler)Returns a snippet of Java code which will retrieve an object property at runtime.ClassDescriptorgetPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler)Returns the type of the named property.StringgetSetPropertyCode(String id, String name, 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(String property)protected voidopenComponent(CompiledObject object, Element tag, JAXXCompiler compiler)protected voidscanAttributesForDependencies(Element tag, JAXXCompiler compiler)Scans all attributes for any dependency classes and adds them to the current compilation set.voidsetAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler)Set a single property on an object.protected voidsetDefaults(CompiledObject object, Element tag, JAXXCompiler compiler)Initializes the default settings of the object, prior to setting its attribute values.-
Methods inherited from class org.nuiton.jaxx.compiler.tags.DefaultObjectHandler
addEventHandler, addProxyEventInfo, addProxyEventInfo, addProxyEventInfo, addProxyEventInfo, applyStylesheets, cleanConstructorParams, compileChildrenFirstPass, compileChildrenSecondPass, compileChildTagFirstPass, compileChildTagSecondPass, convertFromString, createCompiledObject, getAttributeComparator, getAttributeOrdering, getBeanClass, getEventClass, getEventInfo, getJAXXBeanInfo, getJAXXBeanInfo, getSafeCompiledObject, isEventHandlerName, isMemberBound, registerCompiledObject, safeInit, setAttributeFromCss, setAttributes, setProperty, toString
-
-
-
-
Field Detail
-
BORDER_ATTRIBUTE
public static final String BORDER_ATTRIBUTE
- See Also:
- Constant Field Values
-
TITLED_BORDER_ATTRIBUTE
public static final String TITLED_BORDER_ATTRIBUTE
- See Also:
- Constant Field Values
-
ACTION_ICON_ATTRIBUTE
public static final String ACTION_ICON_ATTRIBUTE
- See Also:
- Constant Field Values
-
I18N_MNEMONIC_ATTRIBUTE
public static final String I18N_MNEMONIC_ATTRIBUTE
- See Also:
- Constant Field Values
-
CONTAINER_DELEGATE_ATTRIBUTE
public static final String CONTAINER_DELEGATE_ATTRIBUTE
- See Also:
- Constant Field Values
-
FONT_FACE_ATTRIBUTE
public static final String FONT_FACE_ATTRIBUTE
- See Also:
- Constant Field Values
-
FONT_SIZE_ATTRIBUTE
public static final String FONT_SIZE_ATTRIBUTE
- See Also:
- Constant Field Values
-
FONT_STYLE_ATTRIBUTE
public static final String FONT_STYLE_ATTRIBUTE
- See Also:
- Constant Field Values
-
FONT_WEIGHT_ATTRIBUTE
public static final String FONT_WEIGHT_ATTRIBUTE
- See Also:
- Constant Field Values
-
HEIGHT_ATTRIBUTE
public static final String HEIGHT_ATTRIBUTE
- See Also:
- Constant Field Values
-
ICON_ATTRIBUTE
public static final String ICON_ATTRIBUTE
- See Also:
- Constant Field Values
-
ICON_IMAGE_ATTRIBUTE
public static final String ICON_IMAGE_ATTRIBUTE
- See Also:
- Constant Field Values
-
NAME_ATTRIBUTE
public static final String NAME_ATTRIBUTE
- See Also:
- Constant Field Values
-
WIDTH_ATTRIBUTE
public static final String WIDTH_ATTRIBUTE
- See Also:
- Constant Field Values
-
X_ATTRIBUTE
public static final String X_ATTRIBUTE
- See Also:
- Constant Field Values
-
Y_ATTRIBUTE
public static final String Y_ATTRIBUTE
- See Also:
- Constant Field Values
-
BEAN_SCOPE_ATTRIBUTE
public static final String BEAN_SCOPE_ATTRIBUTE
- See Also:
- Constant Field Values
-
ADD_TO_CONTAINER_ATTRIBUTE
public static final String ADD_TO_CONTAINER_ATTRIBUTE
- See Also:
- Constant Field Values
-
log
protected static final org.apache.logging.log4j.Logger log
Logger
-
BORDER_FACTORY_PREFIX
public static final String BORDER_FACTORY_PREFIX
-
TITLED_BORDER_PREFIX
public static final String TITLED_BORDER_PREFIX
-
-
Constructor Detail
-
DefaultComponentHandler
public DefaultComponentHandler(ClassDescriptor beanClass)
-
-
Method Detail
-
init
protected void init() throws IntrospectionExceptionDescription copied from class:DefaultObjectHandlerPerforms introspection on the beanClass and stores the results.- Overrides:
initin classDefaultObjectHandler- Throws:
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, Element tag, JAXXCompiler compiler) throws CompilerException
Description 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(Element tag, JAXXCompiler compiler) throws CompilerException, IOException
Description 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 occursIOException- if an I/O error occurs
-
compileSecondPass
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException
Description 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 occursIOException- if an I/O error occurs
-
openComponent
protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException
- Throws:
CompilerException
-
closeComponent
protected void closeComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException
- Throws:
CompilerException
-
isPropertyInherited
public boolean isPropertyInherited(String property) throws UnsupportedAttributeException
- 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, String propertyName, JAXXCompiler compiler) throws CompilerException
Description 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 String getGetPropertyCode(String id, String name, JAXXCompiler compiler) throws CompilerException
Description 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 String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException
Description 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, String propertyName, 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
protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler)
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(String key, 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 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:
IllegalArgumentException- if the property is an enumeration, but the value is not validNumberFormatException- 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 String getContainerDelegate()
-
-