org.formaria.editor.project
Class EditorAriaBuilder

java.lang.Object
  extended by org.formaria.builder.AriaBuilder
      extended by org.formaria.editor.project.EditorAriaBuilder
All Implemented Interfaces:
PageLoader, EditorBuilder

public class EditorAriaBuilder
extends AriaBuilder
implements EditorBuilder

Subclasses the AriaBuilder primarily to listen for the events being registered for components

Copyright (c) Formaria Ltd., 1998-2004

$Revision: 1.37 $ License: see license.txt


Field Summary
protected  java.util.HashMap<java.lang.String,java.awt.Component> componentNames
           
protected  java.lang.String currentInclude
           
protected  EditorProject currentProject
           
protected  java.lang.String currentRepeat
           
protected  PageResource currentResource
           
protected  boolean duplicateNamesCorrected
           
protected  java.util.Stack<org.formaria.editor.project.EditorAriaBuilder.IncludeReference> includeStack
           
protected  PageDesigner pageDesigner
           
protected  java.util.Stack<java.lang.String> repeatStack
           
 
Fields inherited from class org.formaria.builder.AriaBuilder
adapter, attributeSets, checkBoxGroup, componentFactory, currentAttributes, customizer, DEFAULT_PAGE_CLASS, evaluator, eventHandler, includeFileName, layoutHelper, menuBar, packageName, page, rootPage, secondaryClassloader, validationFactories
 
Constructor Summary
EditorAriaBuilder(EditorProject project, StyleFactory stylefact)
          Construct a new builder and set a custom StyleFactory
 
Method Summary
protected  java.awt.Component 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
 void addHandler(PageSupport page, java.lang.Object targetComp, java.lang.String typeStr, java.lang.String name)
          Overrides the super method.
protected  void addMenu(PageSupport page, XmlElement model)
          Adds a menu to the application.
 void addMenuHandler(PageSupport xpage, java.lang.String targetStr, java.lang.String methodStr)
          Deprecated. - is this even used?
protected  void addValidations(PageSupport page, XmlElement model)
          Adds validation rules to the components
 void checkComponentName(java.awt.Component comp)
          Check that the component names are not duplicated.
 DataBinding getFactoryBinding(PageSupport page, java.lang.Object compType, java.util.Hashtable instanceConfig)
          Try to get a binding factory to construct the binding
protected  ValidationFactory getValidationFactory(java.lang.String validationFileName)
          Construct a validation factory appropriate to this builder
protected  PageSupport loadClass(java.lang.String className)
          Loads a class as the basis for a page.
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 Page via a reader obtained from the ResourceManager (searches the classpath).
 java.util.Hashtable popIncludeReference(java.lang.String includeFileName)
          A method that the editor can overload to keep track of includes
 void popRepeatReference(java.lang.String repeatReference)
          A method that the editor can overload to keep track of repeats
 void pushIncludeReference(java.lang.String includeFileName, java.util.Hashtable store)
          A method that the editor can overload to keep track of includes
 void pushRepeatReference(java.lang.String repeatReference)
          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 Page.
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 setPageAttribute(java.lang.Object c, java.lang.String attributeName, java.lang.String attributeValue)
          Get a page attribute (this version does nothing)
 void setPageDesigner(PageDesigner designer)
           
protected  void setPageName(java.lang.String pageName, java.lang.String ext)
           
protected  void setResourceBundle(PageSupport page, java.lang.String attribValue)
          Set the name of the page's resource bundle
 
Methods inherited from class org.formaria.builder.AriaBuilder
addBinding, addBindings, addEvent, addEvents, addScripts, evaluateAttribute, evaluateAttributeAsString, getCurrentAttributes, getInt, getMenuItem, getType, init, insertAttributes, loadAttributeSet, loadFrames, loadSingleTarget, setAttributeEvaluator, setClassLoader, setPackageName, setPage, setPageExtension, setPageName, setupPage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pageDesigner

protected PageDesigner pageDesigner

currentProject

protected EditorProject currentProject

currentResource

protected PageResource currentResource

includeStack

protected java.util.Stack<org.formaria.editor.project.EditorAriaBuilder.IncludeReference> includeStack

currentInclude

protected java.lang.String currentInclude

repeatStack

protected java.util.Stack<java.lang.String> repeatStack

currentRepeat

protected java.lang.String currentRepeat

componentNames

protected java.util.HashMap<java.lang.String,java.awt.Component> componentNames

duplicateNamesCorrected

protected boolean duplicateNamesCorrected
Constructor Detail

EditorAriaBuilder

public EditorAriaBuilder(EditorProject project,
                         StyleFactory stylefact)
Construct a new builder and set a custom StyleFactory

Parameters:
stylefact - A custom StyleFactory
Method Detail

setPageDesigner

public void setPageDesigner(PageDesigner designer)
Specified by:
setPageDesigner in interface EditorBuilder

loadOtherElement

protected void loadOtherElement(PageSupport page,
                                XmlElement childNode)
Load any element other than the predefined node types e.g. Component, Bindings etc... Allows an editor to insert extra data in the page, e.g. guides

Overrides:
loadOtherElement in class AriaBuilder
Parameters:
page - the page currently being loaded
childNode - the xml element to process

setResourceBundle

protected void setResourceBundle(PageSupport page,
                                 java.lang.String attribValue)
Set the name of the page's resource bundle

Overrides:
setResourceBundle in class AriaBuilder
Parameters:
page - the page that owns the resource
the - resource bundle name, minus any extension

getFactoryBinding

public DataBinding getFactoryBinding(PageSupport page,
                                     java.lang.Object compType,
                                     java.util.Hashtable instanceConfig)
Try to get a binding factory to construct the binding

Overrides:
getFactoryBinding in class AriaBuilder
Parameters:
currentProject - the current project
page - the page that will own the binding
compType - the component type
bindingNode - the XML element defining the binding
Returns:
the new binding if one could be constructed

addComponent

protected java.awt.Component addComponent(XmlElement childNode)
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.

Overrides:
addComponent in class AriaBuilder
Parameters:
childNode - the XML element containing the component specification.
Returns:
the new component

addComponents

protected void addComponents(java.lang.Object page,
                             XmlElement model)
Adds the elements specified by the Components element and its children

Overrides:
addComponents in class AriaBuilder
Parameters:
page - the new page object
model - the Components XML element (and implicitly its children)

checkComponentName

public void checkComponentName(java.awt.Component comp)
Check that the component names are not duplicated. Append an 'x' to any duplicate name.


pushIncludeReference

public void pushIncludeReference(java.lang.String includeFileName,
                                 java.util.Hashtable store)
A method that the editor can overload to keep track of includes

Overrides:
pushIncludeReference in class AriaBuilder
Parameters:
includeFileName - the name of the include file being embedded
store - the current state prior to the include

popIncludeReference

public java.util.Hashtable popIncludeReference(java.lang.String includeFileName)
A method that the editor can overload to keep track of includes

Overrides:
popIncludeReference in class AriaBuilder
Parameters:
includeFileName - the name of the include file that was embedded
Returns:
the previous page reference if any, otherwise null is returned.

pushRepeatReference

public void pushRepeatReference(java.lang.String repeatReference)
A method that the editor can overload to keep track of repeats

Overrides:
pushRepeatReference in class AriaBuilder

popRepeatReference

public void popRepeatReference(java.lang.String repeatReference)
A method that the editor can overload to keep track of repeats

Overrides:
popRepeatReference in class AriaBuilder

addHandler

public void addHandler(PageSupport page,
                       java.lang.Object targetComp,
                       java.lang.String typeStr,
                       java.lang.String name)
Overrides the super method. First call the super method and then register the event with the Project. This allows the editor to display the methods for components when they are selected and also to save them.

Overrides:
addHandler in class AriaBuilder
Parameters:
xpage - The page that contains the response methods
targetComp - the component to which the event handler is added
typeStr - the type of handler
name - the name of the response method

addMenuHandler

public void addMenuHandler(PageSupport xpage,
                           java.lang.String targetStr,
                           java.lang.String methodStr)
Deprecated. - is this even used?

Add a menu handler

Parameters:
xpage - the owner page
targetStr - the name of the menu/menuItem
methodStr - the name of teh response method

addValidations

protected void addValidations(PageSupport page,
                              XmlElement model)
Adds validation rules to the components

Overrides:
addValidations in class AriaBuilder
Parameters:
page - the page
model - the Validations XML element

addMenu

protected void addMenu(PageSupport page,
                       XmlElement model)
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.

Overrides:
addMenu in class AriaBuilder
Parameters:
page - the page
model - the Menu XML element

setPageName

protected void setPageName(java.lang.String pageName,
                           java.lang.String ext)

readPage

public 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 Page. An instance of the class specified by the class attribute is constructed or else an instance of Page 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

Specified by:
readPage in interface PageLoader
Specified by:
readPage in interface EditorBuilder
Overrides:
readPage in class AriaBuilder
Parameters:
reader - a input stream from which to read the page
pageName - the name of the page
ext - the file extension
include - the page to be loaded is being included in another page
Returns:
the page

loadClass

protected PageSupport loadClass(java.lang.String className)
                         throws java.lang.ClassNotFoundException,
                                java.lang.IllegalAccessException,
                                java.lang.InstantiationException
Loads a class as the basis for a page. Reloads the class each time so that the code can be recompiled and reloaded.

Overrides:
loadClass in class AriaBuilder
Parameters:
className - the full class name
Returns:
an instance of the Page class or a derivative
Throws:
java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.InstantiationException

loadPage

public PageSupport loadPage(java.lang.String defPackageName,
                            java.lang.String pageName,
                            boolean include)
Loads an Page via a reader obtained from the ResourceManager (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.

Specified by:
loadPage in interface PageLoader
Overrides:
loadPage in class AriaBuilder
Parameters:
defPackageName - the package or path to the page
pageName - the page name or the name of the class implementing the page
include - 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
fullPathProvided - the full path to the page name is provided
Returns:
the page

setPageAttribute

public void setPageAttribute(java.lang.Object c,
                             java.lang.String attributeName,
                             java.lang.String attributeValue)
Description copied from class: AriaBuilder
Get a page attribute (this version does nothing)

Overrides:
setPageAttribute in class AriaBuilder
Parameters:
c - the component associated with an attribute
attributeName - the attribute name
attributeValue - the attribute value

setComponentAttributes

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

Overrides:
setComponentAttributes in class AriaBuilder
Parameters:
comp - the component
attribs - the attributes.

getValidationFactory

protected ValidationFactory getValidationFactory(java.lang.String validationFileName)
Construct a validation factory appropriate to this builder

Overrides:
getValidationFactory in class AriaBuilder
Parameters:
validationFileName - the validations file to read
Returns:
the validation factory