|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.xoetrope.builder.XuiBuilder
public class XuiBuilder
A builder of XUI pages from an XML source. An instance of the class is setup
by XApplet as a secondary page loader so that if a class file for the
page is not found then an attempt is made to load the page from an XML file
with the same base name.
Components, Menus, Events, Validations and Data Binding can be configured via the
XML declarations.
The loading process itself relies heavily on the component factories to do
the bulk of the work involved in constructing and adding components. The XPage
class also performs much of the work involved in adding events and binding data.
Copyright (c) Xoetrope Ltd., 2002-2007
License: see license.txt
$Revision: 2.59 $
| Field Summary | |
|---|---|
protected WidgetAdapter |
adapter
|
protected java.util.Hashtable |
attributeSets
|
protected java.lang.Object |
checkBoxGroup
|
protected XStyleFactory |
componentFactory
|
protected static java.util.Hashtable |
currentAttributes
|
protected XProject |
currentProject
|
protected ComponentCustomizer |
customizer
|
static java.lang.String |
DEFAULT_PAGE_CLASS
The default class used to instantiate a page. |
protected XAttributeEvaluator |
evaluator
The default attribute evaluator. |
protected XuiEventHandler |
eventHandler
|
protected java.lang.String |
includeFileName
|
protected XLayoutHelper |
layoutHelper
|
protected XAppender |
menuBar
|
protected java.lang.String |
packageName
|
protected PageSupport |
page
|
protected PageSupport |
rootPage
|
protected java.lang.ClassLoader |
secondaryClassloader
A secondary classloader for attempts to load classes referenced by a page |
protected java.util.Hashtable |
validationFactories
|
| Constructor Summary | |
|---|---|
XuiBuilder(XProject project)
Construct an instance of the builder with the default package set to net.xoetrope.awt |
|
XuiBuilder(XProject project,
java.lang.String packageName)
Construct a new builder and set the default package |
|
| Method Summary | |
|---|---|
protected void |
addBinding(XmlElement childNode)
Adds data bindings to the page. |
protected void |
addBindings(PageSupport page,
XmlElement model)
Adds data bindings to the page. |
protected java.lang.Object |
addComponent(XmlElement childNode)
Adds an individual component element to the page (this method may be called recursively for nested elements). |
protected void |
addComponents(java.lang.Object page,
XmlElement model)
Adds the elements specified by the Components element and its children |
protected void |
addEvent(XmlElement childNode)
Adds the event handlers. |
protected void |
addEvents(PageSupport page,
XmlElement model)
Adds the event handlers. |
void |
addHandler(PageSupport xpage,
java.lang.Object targetComp,
java.lang.String typeStr,
java.lang.String methodName)
Adds an event handler. |
protected void |
addMenu(PageSupport page,
XmlElement model)
Adds a menu to the application. |
void |
addScripts(PageSupport page,
XmlElement scriptsNode)
Store the scripts in the page |
protected void |
addValidations(PageSupport page,
XmlElement model)
Adds validation rules to the components |
java.lang.Object |
evaluateAttribute(PageSupport page,
java.lang.String attributeValue)
Get the value of an attribute. |
java.lang.String |
evaluateAttributeAsString(PageSupport page,
java.lang.String attributeValue)
Get the value of an attribute. |
static java.util.Hashtable |
getCurrentAttributes()
Get the table of component attributes |
XDataBinding |
getFactoryBinding(PageSupport page,
java.lang.Object compType,
java.util.Hashtable instanceConfig)
Try to get a binding factory to construct the binding |
protected int |
getInt(java.lang.String s,
int def)
Convert a string to an int or else return the default value |
protected java.lang.Object |
getMenuItem(java.lang.String name)
Gets a reference to a menu object |
protected XValidationFactory |
getValidationFactory(java.lang.String validationFileName)
Construct a validation factory appropriate to this builder |
protected void |
init(java.lang.String packageName)
Initialize the builder |
void |
insertAttributes(XmlElement node)
Insert the attributes of a named attribute set into the node |
void |
loadAttributeSet(XmlElement childNode)
Process an attribute element |
protected PageSupport |
loadClass(java.lang.String className)
Loads a class as the basis for a page |
boolean |
loadFrames(java.lang.String defPackageName,
java.lang.String frameSetName,
XPageDisplay pageDisplay,
boolean useFrames)
Loads a frameset. |
protected void |
loadOtherElement(PageSupport page,
XmlElement childNode)
Load any element other than the predefined node types e.g. |
PageSupport |
loadPage(java.lang.String defPackageName,
java.lang.String pageName,
boolean include)
Loads an XPage via a reader obtained from the XProject (searches the classpath). |
protected void |
loadSingleTarget(XPageDisplay pageDisplay)
Load a single target, used in case a frameset is not loaded |
void |
popIncludeReference(java.lang.String includeFileName)
A method that the editor can overload to keep track of includes |
void |
popRepeatReference(java.lang.String includeFileName)
A method that the editor can overload to keep track of repeats |
void |
pushIncludeReference(java.lang.String includeFileName)
A method that the editor can overload to keep track of includes |
void |
pushRepeatReference(java.lang.String includeFileName)
A method that the editor can overload to keep track of repeats |
PageSupport |
readPage(java.io.Reader reader,
java.lang.String pageName,
java.lang.String ext,
boolean include)
Read an XML description of the page and construct a new XPage. |
void |
setAttributeEvaluator(XAttributeEvaluator e)
Set the attribute evaluator object. |
void |
setClassLoader(java.lang.ClassLoader cl)
Set a secondary classloader for loading the classes referenced by pages |
protected void |
setComponentAttributes(java.lang.String compType,
java.lang.Object comp,
java.util.Hashtable attribs)
Iterate through the attributes and set the attributes for a component |
void |
setPackageName(java.lang.String defPackageName)
Set the default package name. |
void |
setPage(PageSupport p)
Set the current page |
void |
setPageAttribute(java.lang.Object c,
java.lang.String name,
java.lang.String value)
Get a page attribute (this version does nothing) |
protected void |
setPageExtension(java.lang.String ext)
Set the file extension of the page |
protected void |
setPageName(java.lang.String pageName)
Set the name of the page |
protected void |
setResourceBundle(PageSupport page,
java.lang.String attribValue)
Set the name of the page's resource bundle |
protected void |
setupPage(XmlElement model,
java.lang.String pageName,
java.lang.String ext,
boolean include)
Loads the page based on the contents of the page tag or by using default values. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String packageName
protected XStyleFactory componentFactory
protected java.lang.Object checkBoxGroup
protected PageSupport page
protected PageSupport rootPage
protected XAppender menuBar
protected java.util.Hashtable validationFactories
protected java.util.Hashtable attributeSets
protected static java.util.Hashtable currentAttributes
protected XLayoutHelper layoutHelper
protected XProject currentProject
protected WidgetAdapter adapter
protected ComponentCustomizer customizer
protected XAttributeEvaluator evaluator
protected XuiEventHandler eventHandler
protected java.lang.ClassLoader secondaryClassloader
protected java.lang.String includeFileName
public static final java.lang.String DEFAULT_PAGE_CLASS
| Constructor Detail |
|---|
public XuiBuilder(XProject project)
project - the current project
public XuiBuilder(XProject project,
java.lang.String packageName)
project - the current projectpackageName - the name of the default package e.g. net.xoetrope.awt| Method Detail |
|---|
protected void init(java.lang.String packageName)
packageName - the default componnet package or use AWT if none is specifiedpublic void setClassLoader(java.lang.ClassLoader cl)
setClassLoader in interface XPageLoadercl - the class loaderpublic void setPackageName(java.lang.String defPackageName)
setPackageName in interface XPageLoaderdefPackageName - the default package namepublic void setPage(PageSupport p)
setPage in interface XPageLoaderp - the page object
public PageSupport loadPage(java.lang.String defPackageName,
java.lang.String pageName,
boolean include)
loadPage in interface XPageLoaderdefPackageName - the package or path to the pagepageName - the page name or the name of the class implementing the pageinclude - true if the page to be loaded is being included in another
page in which case any class attribute of the included page is ignored
public boolean loadFrames(java.lang.String defPackageName,
java.lang.String frameSetName,
XPageDisplay pageDisplay,
boolean useFrames)
loadFrames in interface XPageLoaderdefPackageName - the package or path to the pageframeSetName - the page name or the name of the class implementing the pagepageDisplay - the object that will display the pages and framesetuseFrames - true to setup the frameset or false to add just a single target area
protected void loadSingleTarget(XPageDisplay pageDisplay)
pageDisplay - the object that will display the pages and frameset
public PageSupport readPage(java.io.Reader reader,
java.lang.String pageName,
java.lang.String ext,
boolean include)
readPage in interface XPageLoaderreader - a input stream from which to read the pagepageName - the name of the pageext - the file extensioninclude - the page to be loaded is being included in another page
protected PageSupport loadClass(java.lang.String className)
throws java.lang.ClassNotFoundException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
className - the full class name
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException
protected void loadOtherElement(PageSupport page,
XmlElement childNode)
page - the page currently being loadedchildNode - the xml element to process
protected void setupPage(XmlElement model,
java.lang.String pageName,
java.lang.String ext,
boolean include)
pageName - the name of the pageext - the file extensioninclude - the page to be loaded is being included in another page
protected void setResourceBundle(PageSupport page,
java.lang.String attribValue)
page - the page that owns the resourcethe - resource bundle name, minus any extension
public void setPageAttribute(java.lang.Object c,
java.lang.String name,
java.lang.String value)
c - the component associated with an attributename - the attribute namevalue - the attribute valuepublic void loadAttributeSet(XmlElement childNode)
attrElement - the attribute elementpublic void insertAttributes(XmlElement node)
node - the node to be modified if it has an atttributes attributepublic void setAttributeEvaluator(XAttributeEvaluator e)
e - the new evaluator
public java.lang.Object evaluateAttribute(PageSupport page,
java.lang.String attributeValue)
page - the page being loadedattributeValue - the raw value of the attribute
public java.lang.String evaluateAttributeAsString(PageSupport page,
java.lang.String attributeValue)
page - the page being loadedattributeValue - the raw value of the attribute
protected void addComponents(java.lang.Object page,
XmlElement model)
page - the new page objectmodel - the Components XML element (and implicitly its children)
protected void addEvents(PageSupport page,
XmlElement model)
page - The page that contains the response methodsmodel - the 'events' XML elementprotected void addEvent(XmlElement childNode)
childNode - the 'events' XML element
public void addHandler(PageSupport xpage,
java.lang.Object targetComp,
java.lang.String typeStr,
java.lang.String methodName)
xpage - The page that contains the response methodstargetComp - the component to which the event handler is addedtypeStr - the type of handlermethodName - the name of the response method
protected void addBindings(PageSupport page,
XmlElement model)
page - the page to which the component/data bindings are addedmodel - the data modelprotected void addBinding(XmlElement childNode)
model - the data model
public XDataBinding getFactoryBinding(PageSupport page,
java.lang.Object compType,
java.util.Hashtable instanceConfig)
currentProject - the current projectpage - the page that will own the bindingcompType - the component typebindingNode - the XML element defining the binding
protected void setPageName(java.lang.String pageName)
pageName - the new page name.protected void setPageExtension(java.lang.String ext)
ext - the new file extension.protected java.lang.Object addComponent(XmlElement childNode)
childNode - the XML element containing the component specification.
protected void addMenu(PageSupport page,
XmlElement model)
page - the pagemodel - the Menu XML element
protected void addValidations(PageSupport page,
XmlElement model)
page - the pagemodel - the Validations XML element
public void addScripts(PageSupport page,
XmlElement scriptsNode)
page - the current pagescriptsNode - the scripts xml node
protected void setComponentAttributes(java.lang.String compType,
java.lang.Object comp,
java.util.Hashtable attribs)
comp - the componentattribs - the attributes.protected java.lang.Object getMenuItem(java.lang.String name)
name - the name of the menu item
protected XValidationFactory getValidationFactory(java.lang.String validationFileName)
validationFileName - the validations file to read
protected int getInt(java.lang.String s,
int def)
s - the number as a stringdef - the default value
public static java.util.Hashtable getCurrentAttributes()
public void pushIncludeReference(java.lang.String includeFileName)
public void popIncludeReference(java.lang.String includeFileName)
public void pushRepeatReference(java.lang.String includeFileName)
public void popRepeatReference(java.lang.String includeFileName)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||