| java.lang.Object net.xoetrope.builder.XuiBuilder
All known Subclasses: net.xoetrope.builder.editor.XEditorXuiBuilder,
XuiBuilder | public class XuiBuilder implements XPageLoader(Code) | | 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-2003
License: see license.txt
$Revision: 1.29 $
|
Constructor Summary | |
public | XuiBuilder() | public | XuiBuilder(String packageName) Construct a new builder and set the default package
Parameters: packageName - the name of the default package e.g. |
Method Summary | |
protected void | addBindings(XPage page, XmlElement model) Adds data bindings to the page. | protected Component | addComponent(XmlElement childNode) Adds an individual component element to the page (this method may be called
recursively for nested elements). | protected void | addComponents(Component page, XmlElement model) | protected void | addEvents(XPage page, XmlElement model) Adds the event handlers. | protected void | addHandler(XPage xpage, Component targetComp, String typeStr, String name) Adds an event handler. | protected void | addMenu(XPage page, XmlElement model) Adds a menu to the application. | protected void | addValidations(XPage page, XmlElement model) | public Object | evaluateAttribute(XPage page, String attributeValue) Get the value of an attribute. | public static Hashtable | getCurrentAttributes() | protected XDataBinding | getFactoryBinding(Component compType, XModel model, XmlElement bindingNode) | protected int | getInt(String s, int def) | protected Object | getMenuItem(String name) | protected XValidationFactory | getValidationFactory(String validationFileName) | protected void | init(String packageName) | protected XPage | loadClass(String className) | public void | loadFrames(String defPackageName, String frameSetName, XPageDisplay pageDisplay) Loads a frameset. | public XPage | loadPage(String defPackageName, String pageName, boolean include) Loads an XPage via a reader obtained from the XResourceManager (searches
the classpath). | public XPage | readPage(Reader reader, String pageName, boolean include) Read an XML description of the page and construct a new XPage. | public static void | registerBindingFactory(XDataBindingFactory fact) Register a data binding factory. | protected void | setComponentAttributes(Component comp, Hashtable attribs) | public void | setPackageName(String defPackageName) Set the default package name. | public void | setPageAttribute(Component c, String name, String value) | protected void | setPageName(String pageName) | protected void | setupPage(XmlElement model, String pageName, boolean include) Loads the page based on the contents of the page tag or by using default
values. |
XuiBuilder | public XuiBuilder()(Code) | | Construct an instance of the builder with the default package set to net.xoetrope.awt
|
XuiBuilder | public XuiBuilder(String packageName)(Code) | | Construct a new builder and set the default package
Parameters: packageName - the name of the default package e.g. net.xoetrope.awt |
addBindings | protected void addBindings(XPage page, XmlElement model)(Code) | | Adds data bindings to the page.
Parameters: page - the page to which the component/data bindings are added Parameters: model - the data model |
addComponent | protected Component addComponent(XmlElement childNode)(Code) | | Adds an individual component element to the page (this method may be called
recursively for nested elements). Several methods will be attempted until a
component is successfully created. Firstly the built-in component types are
checked, then any additional registered component constructors. The types
can be specified by type ID, type name or class name.
Parameters: childName - the name of the child element Parameters: childNode - the XML element containing the component specification. the new component |
addComponents | protected void addComponents(Component page, XmlElement model)(Code) | | Adds the elements specified by the Components element and its children
Parameters: page - the new page object Parameters: model - the Components XML element (and implicitly its children) |
addEvents | protected void addEvents(XPage page, XmlElement model)(Code) | | Adds the event handlers. Events are specified in the XML as having 'type'
(e.g. MouseHandler, ActionHandler etc...), 'name' (the method name to be
invoked) and 'target' (the name of the component to which the handler is
attached) attributes
Parameters: page - The page that contains the response methods Parameters: model - the 'events' XML element |
addHandler | protected void addHandler(XPage xpage, Component targetComp, String typeStr, String name)(Code) | | Adds an event handler.
Parameters: xpage - The page that contains the response methods Parameters: targetComp - the component to which the event handler is added Parameters: typeStr - the type of handler Parameters: name - the name of the response method |
addMenu | protected void addMenu(XPage page, XmlElement model)(Code) | | Adds a menu to the application. Although specified in the XML as part of the
page the menu is actually added to the application frame.
Parameters: page - the page Parameters: model - the Menu XML element |
addValidations | protected void addValidations(XPage page, XmlElement model)(Code) | | Adds validation rules to the components
Parameters: page - the page Parameters: model - the Validations XML element |
evaluateAttribute | public Object evaluateAttribute(XPage page, String attributeValue)(Code) | | Get the value of an attribute.
Parameters: page - the page being loaded Parameters: attributeValue - the raw value of the attribute the evaluated value of the attribute |
getCurrentAttributes | public static Hashtable getCurrentAttributes()(Code) | | Get the table of component attributes
the attributes hash table. |
getFactoryBinding | protected XDataBinding getFactoryBinding(Component compType, XModel model, XmlElement bindingNode)(Code) | | Try to get a binding factory to construct the binding
Parameters: compType - the component type Parameters: model - the source data model Parameters: bindingNode - the XML element defining the binding the new binding if one could be constructed |
getInt | protected int getInt(String s, int def)(Code) | | Convert a string to an int or else return the default value
Parameters: s - the number as a string Parameters: def - the default value the converted value |
getMenuItem | protected Object getMenuItem(String name)(Code) | | Gets a reference to a menu object
Parameters: name - the name of the menu item |
getValidationFactory | protected XValidationFactory getValidationFactory(String validationFileName)(Code) | | Construct a validation factory appropriate to this builder
Parameters: validationFileName - the validations file to read the validation factory |
init | protected void init(String packageName)(Code) | | Initialize the builder
Parameters: packageName - the default componnet package or use AWT if none is specified |
loadFrames | public void loadFrames(String defPackageName, String frameSetName, XPageDisplay pageDisplay)(Code) | | Loads a frameset. If a frameset is used then the calls to the XPageDisplay
interface should use the form that specifies the target areas. By default
frames are specified in a file (if found) called frames.xml. The frames
are added to a container laid out with a BorderLayout.
Frames can be used to control how parts of the screen are updated. The
default page updated by the page transition/swapping methods is the 'content'
frame. Other areas can be used as non swapping areas for toolbars,
navigation controls, sidebars or status areas. Frames may also be hidden
and shown as needed.
Parameters: defPackageName - the package or path to the page Parameters: frameSetName - the page name or the name of the class implementing the page Parameters: pageDisplay - the object that will display the pages and frameset |
loadPage | public XPage loadPage(String defPackageName, String pageName, boolean include)(Code) | | Loads an XPage via a reader obtained from the XResourceManager (searches
the classpath). The pageName is assumed to be the name of an XML file. For
example if the pageName is 'welcome' then the 'welcome.xml' file is read as
a UTF8 encoded XML file (by default).
Parameters: defPackageName - the package or path to the page Parameters: pageName - the page name or the name of the class implementing the page Parameters: include - true if the page to be loaded is being included in anotherpage in which case any class attribute of the included page is ignored the page |
readPage | public XPage readPage(Reader reader, String pageName, boolean include)(Code) | | Read an XML description of the page and construct a new XPage. An instance
of the class specified by the class attribute is constructed or else an
instance of XPage if no class attribute is specified. The new page is
populated but is not yet added to its parent.
The startup file parameter 'DefaultClass' is used to obtain a default for
each page's class if a class parameter is not specified in the page's XML
The startup file parameter 'Validations' is used to obtain a default for
each page's set of validation rules
Parameters: reader - a input stream from which to read the page Parameters: pageName - the name of the page Parameters: include - the page to be loaded is being included in another page the page |
registerBindingFactory | public static void registerBindingFactory(XDataBindingFactory fact)(Code) | | Register a data binding factory. An add-on library or plug-in may wish to
customize the data bindings, particularly if it provides extended model
node types. Such extended nodes may need adapters to be useful for some or
all widgets and other binding contexts. Registration of the binding factory
allows the necessary adapters and bindings to be created on request.
Parameters: fact - the new binding factory |
setComponentAttributes | protected void setComponentAttributes(Component comp, Hashtable attribs)(Code) | | Iterate through the attributes and set the attributes for a component
Parameters: comp - the component Parameters: attribs - the attributes. |
setPackageName | public void setPackageName(String defPackageName)(Code) | | Set the default package name. The default package name is used when
creating widgets such that a button class like XButton is instatiated as
.XButton.class. By default this expands to
net.xoetrope.awt.XButton.clas
Parameters: defPackageName - the default package name |
setPageAttribute | public void setPageAttribute(Component c, String name, String value)(Code) | | Get a page attribute (this version does nothing)
Parameters: c - Parameters: name - Parameters: value - |
setPageName | protected void setPageName(String pageName)(Code) | | Set the name of the page
Parameters: pageName - the new page name. |
setupPage | protected void setupPage(XmlElement model, String pageName, boolean include)(Code) | | Loads the page based on the contents of the page tag or by using default
values.
Parameters: pageName - the name of the page Parameters: include - the page to be loaded is being included in another page the page |
|
|