org.formaria.editor.project.writer
Class AriaWriter

java.lang.Object
  extended by org.formaria.editor.project.writer.AriaWriter

public class AriaWriter
extends java.lang.Object

Write out the XML description of an Aria page.

Copyright: Copyright (c) Formaria Ltd., 2002-2003


Field Summary
protected  EditorProject currentProject
           
protected  java.util.ArrayList<java.lang.String> filesWritten
           
protected  GuidePane guidePane
           
protected  ComponentHelper helpers
           
protected  java.lang.String implementingClassName
           
protected  PageResource includedPageResources
           
protected  java.util.Stack<java.lang.String> includeStack
           
protected  LayoutHelper layoutHelper
           
protected  java.util.Hashtable pageAttribs
           
protected  PageResource pageResources
           
protected  XmlParserFactory parserFactory
           
protected  java.util.Stack<java.lang.String> repeatStack
           
protected  Page targetPage
           
 
Constructor Summary
AriaWriter(EditorProject project, PageResource resources, GuidePane gp)
          Create a new XML writer
 
Method Summary
protected  void addPluginProperties(java.lang.Object comp, XmlElement childXml)
          Allow each plugin to add attributes to the pages
protected  void addPluginProperties(XmlElement element)
          Allow each plugin to add attributes to the pages
protected  void addUserProperties(java.lang.Object owner, XmlElement element, PropertyHelper helper)
          Allow each plugin to add attributes to the pages
 XmlElement getBaseElement()
           
 java.lang.String getXml()
          Get the XML for the styles as a String ready for writing to file
protected  boolean isIncluded(java.awt.Component comp)
          Check if the specified component is a child of the top level include component.
protected  boolean isRepeated(java.awt.Component comp)
          Check if the specified component is a child of the top level repeat component.
 void write(java.io.FileOutputStream fos)
          Write the XML definition of the current Aria page
protected  int writeBindings(java.awt.Container page, XmlElement element)
          Write out the component data bindings and their attributes.
protected  void writeComponents(java.awt.Container page, XmlElement element)
          Write out the components and their attributes
 int writeEvent(XmlElement element, java.lang.String methodName, java.lang.String target, java.lang.String handlerName)
          Append the XML for an event node
protected  int writeEvents(java.awt.Container page, XmlElement element)
          Write out the component events and their attributes
protected  void writeGuides(XmlElement element)
          Write the guides
protected  void writeInclude(java.lang.String pageName, java.awt.Container page, XmlElement element)
          Write out the components and their attributes in a page to be included
protected  void writeLayout(java.lang.Object comp, XmlElement element)
          Write out the layout properties
protected  void writeMenu(javax.swing.JMenuBar menuBar, XmlElement childXml, javax.swing.JMenu menu)
          Write the menus
protected  int writeMenuEvents(java.awt.Container page, javax.swing.JMenu menu, XmlElement element)
           
protected  void writeMenus(XmlElement element, java.awt.Container cont)
          Write the menus
 void writeProperties(java.lang.Object owner, XmlElement element, PropertyHelper helper)
           
protected  void writeRepeat(java.lang.String expression, java.awt.Container repeatReferenceComponent, XmlElement element)
          Write out the components and their attributes in a page to be repeated
protected  int writeValidations(java.awt.Container page, XmlElement element)
          Append the XML for the validations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

targetPage

protected Page targetPage

pageResources

protected PageResource pageResources

includedPageResources

protected PageResource includedPageResources

implementingClassName

protected java.lang.String implementingClassName

currentProject

protected EditorProject currentProject

helpers

protected ComponentHelper helpers

guidePane

protected GuidePane guidePane

parserFactory

protected XmlParserFactory parserFactory

pageAttribs

protected java.util.Hashtable pageAttribs

layoutHelper

protected LayoutHelper layoutHelper

filesWritten

protected java.util.ArrayList<java.lang.String> filesWritten

includeStack

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

repeatStack

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

AriaWriter

public AriaWriter(EditorProject project,
                  PageResource resources,
                  GuidePane gp)
Create a new XML writer

Parameters:
resources - the page to write
Method Detail

write

public void write(java.io.FileOutputStream fos)
           throws java.io.IOException
Write the XML definition of the current Aria page

Parameters:
writer - the IO Writer
Throws:
java.io.IOException

getXml

public java.lang.String getXml()
                        throws java.io.IOException
Get the XML for the styles as a String ready for writing to file

Returns:
the formatted output string
Throws:
java.io.IOException

getBaseElement

public XmlElement getBaseElement()

writeComponents

protected void writeComponents(java.awt.Container page,
                               XmlElement element)
Write out the components and their attributes

Parameters:
page -
element -

writeProperties

public void writeProperties(java.lang.Object owner,
                            XmlElement element,
                            PropertyHelper helper)

writeInclude

protected void writeInclude(java.lang.String pageName,
                            java.awt.Container page,
                            XmlElement element)
Write out the components and their attributes in a page to be included

Parameters:
pageName -
page -
element -

writeRepeat

protected void writeRepeat(java.lang.String expression,
                           java.awt.Container repeatReferenceComponent,
                           XmlElement element)
Write out the components and their attributes in a page to be repeated

Parameters:
expression -
repeatReferenceComponent -
element -

addUserProperties

protected void addUserProperties(java.lang.Object owner,
                                 XmlElement element,
                                 PropertyHelper helper)
Allow each plugin to add attributes to the pages

Parameters:
element -

addPluginProperties

protected void addPluginProperties(XmlElement element)
Allow each plugin to add attributes to the pages

Parameters:
element -

addPluginProperties

protected void addPluginProperties(java.lang.Object comp,
                                   XmlElement childXml)
Allow each plugin to add attributes to the pages

Parameters:
element -

writeLayout

protected void writeLayout(java.lang.Object comp,
                           XmlElement element)
Write out the layout properties

Parameters:
page - the target page
element - the XML element to which the node is added

writeEvents

protected int writeEvents(java.awt.Container page,
                          XmlElement element)
Write out the component events and their attributes

Parameters:
page - the target page
element - the XML element to which the node is added
Returns:
the number of elements written

writeMenuEvents

protected int writeMenuEvents(java.awt.Container page,
                              javax.swing.JMenu menu,
                              XmlElement element)

writeEvent

public int writeEvent(XmlElement element,
                      java.lang.String methodName,
                      java.lang.String target,
                      java.lang.String handlerName)
Append the XML for an event node

Parameters:
element - the parent element
method - the response method name
target - the componentto which the method responds
handlerName - the name/type of event handler to be used
Returns:

writeValidations

protected int writeValidations(java.awt.Container page,
                               XmlElement element)
Append the XML for the validations

Parameters:
element - the parent element
method - the response method name
target - the componentto which the method responds
handlerName - the name/type of event handler to be used
Returns:

writeBindings

protected int writeBindings(java.awt.Container page,
                            XmlElement element)
Write out the component data bindings and their attributes. Each 'bind' node must have the 'target' and 'source' attributes and may optionally have the 'output' and 'type' attributes. The 'target' attributes identifies the target component or the component whose content/state will be modified. The 'source' node identifies the data source in the data model while the 'output' node identifies the node where the component state or output is saved. The output node is optional and is used to distinguish initial data or content from the selection state or user input values. The 'type' attribute is used to distinguish the type of binding where a component may have multiple bindings, for example a radio button may have a text and a state binding.

Parameters:
page - the page being loaded
element - the bindings xml element
Returns:
the number of elements written

isIncluded

protected boolean isIncluded(java.awt.Component comp)
Check if the specified component is a child of the top level include component.

Parameters:
comp - the component to check
Returns:
true is the comp is a child of teh include

isRepeated

protected boolean isRepeated(java.awt.Component comp)
Check if the specified component is a child of the top level repeat component.

Parameters:
comp - the component to check
Returns:
true is the comp is a child of teh include

writeGuides

protected void writeGuides(XmlElement element)
Write the guides

Parameters:
element - the parent xml element

writeMenus

protected void writeMenus(XmlElement element,
                          java.awt.Container cont)
Write the menus

Parameters:
element - the parent xml element
cont - the page/container that owns the menu

writeMenu

protected void writeMenu(javax.swing.JMenuBar menuBar,
                         XmlElement childXml,
                         javax.swing.JMenu menu)
Write the menus

Parameters:
element - the parent xml element
cont - the page/container that owns the menu