org.formaria.swing
Class Page

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by org.formaria.swing.layer.LayerManager
                      extended by org.formaria.swing.Page
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, ExceptionHandler, ILayerManager, PageSupport, PersistentState
Direct Known Subclasses:
Dialog, GroovyPage, NavigationHelper, Toolbar

public class Page
extends LayerManager
implements ExceptionHandler, PageSupport, PersistentState

A basic unit for building applications. Page integrates with page and event management facilities provided by Aria. The page also provides a number of methods to help control the page lifecycle and many methods to manage the state of the user interface. Most application functionality within an application will be implemented in derivates of the page class, however this is not strictly necessary and the page can act as little more than a container for the user interface components.

Pages can be displayed using the PageDisplay interface implemented by Applet and invoked by the Page manager. Pages can be constructed directly or via the AriaBuilder. The page lifecycle also interaccts with the data bindings, triggering data updates and saving.

The page implements the PageSupport interface which abstracts many of the methods used by the Aria framework to interact with its notion of a page. Through the PageSupport interface the framework can interact with pages that are implement with Widget sets such as Swing and SWT which have different hierarchies and diffent means of instantiation.

The Page class is little more than a shell and many of its methods are implemented by the PageHelper class, the page delegates to an instance of the page helper. The page also defines a set of constants for common components, but the page and moreover the framework is not limited to just these components.

Copyright (c) Formaria Ltd., 2008

License: see license.txt

$Revision: 2.33 $

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Nested classes/interfaces inherited from interface org.formaria.aria.PageSupport
PageSupport.IDialog
 
Field Summary
protected  WidgetAdapter adapter
          The component adapter for the current widget set.
protected  StyleFactory componentFactory
          Deprecated. use getComponentFactory() instead.
protected  PageHelper pageHelper
          The helper class that implements many functions on behalf of the page, particularly the widget specific operations and those operations specified by the PageSupport interface.
protected  PageManager pageMgr
          The page manager for the current project, the page manager controls the update and display of pages.
protected  Project project
          The owner project.
protected  DataModel rootModel
          The root model of the current project.
 
Fields inherited from class org.formaria.swing.layer.LayerManager
BACKGROUND
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface org.formaria.aria.PageSupport
ACTIVATED, ANNOTATEDIMAGE, ARIA_AWT_PACKAGE, ARIA_HTML_PACKAGE, ARIA_SWING_PACKAGE, ARIA_SWT_PACKAGE, BORDER_LAYOUT, BOX_LAYOUT, BUTTON, CARD_LAYOUT, CHECK, COLUMN_LAYOUT, COMBO, CREATED, DEACTIVATED, DISCARDED, DISPLAYED, EDIT, FLOW_LAYOUT, GRID_LAYOUT, GRIDBAG_LAYOUT, GROUP, GUIDE_LAYOUT, HOTSPOTIMAGE, IMAGE, IMAGEMAP, LABEL, LAYER_LAYOUT, LIST, LOADED, MENU, MENUBAR, MENUITEM, METACONTENT, NULL_LAYOUT, PANEL, PASSWORD, RADIO, SCALE_LAYOUT, SCROLLABLEMETACONTENT, SCROLLPANE, SPLITPANE, SPRING_LAYOUT, TABLE, TABPANEL, TEXTAREA, UNKNOWN, UNKNOWN_PAGE_STATE, WMF
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Page()
          Constructs an empty page, setting up the references to projects, data models and so on plus setting up a component factory to help instantiate the page's children.
 
Method Summary
 int accumulateMessages(boolean start, int level)
          Informs the handler when a page validation is starting or stopping.
 void addBinding(DataBinding b)
          Add a binding of a component to the data model.
 void addHandler(java.lang.Object comp, long eventType, java.lang.String methodName)
          Adds an event handler.
 void addHandler(java.lang.Object srcObj, java.lang.String methodName, java.lang.String adderMethod, java.lang.String listenerInterface, long eventMask, java.lang.Object listener)
          Adds a handler for action events
 void addListener(java.lang.Object comp, java.lang.String listenerName, java.lang.String argType, java.lang.Object listener)
          Adds a listener for an event type.
 void addNestedPage(PageSupport ps)
          Add a nested page reference
 void addNotify()
          Repaint the component once it has been created
 Validator addValidation(java.lang.Object comp, java.lang.String validationName)
          Adds a validation to this page.
 Validator addValidation(java.lang.Object comp, java.lang.String validationName, java.lang.String method)
          Adds a validation to this page.
 Validator addValidation(java.lang.Object comp, java.lang.String validationName, java.lang.String method, int mask, XmlElement pageEle)
          Adds a validation to this page.
 int checkValidations(java.lang.Object scope)
          Check all validations for this page.
 void clearMouseClick()
          Clear the mouse click tracking
 void clearValidations()
          Reset/removes all validations
 void enterDataBindingContext(java.lang.String contextName)
          Gets the named DataBindingContext object bound to this PageHelper object, creating the context if necessary.
 java.lang.Object evaluateAttribute(java.lang.String attribValue)
          Evaluates an attribute value.
 java.lang.String evaluatePath(java.lang.String path)
          Evaluates a path (potentially) containing a method call
 void exitDataBindingContext()
          Exit the data binding context and return to the parent context if any
 java.lang.Object findComponent(java.lang.Object container, java.lang.String name)
          Find a named component in the container.
 java.lang.Object findComponent(java.lang.String name)
          Find a named component in the container.
 java.lang.Object getAttribute(java.lang.String attribName)
          Gets the value of an attribute of this page
 java.lang.Object getAttribute(java.lang.String attribName, java.lang.String compName)
          Gets the value of an attribute of the named component.
 java.lang.Object getAttributes()
          Gets the table of attributes used by this page.
 DataBinding getBinding(java.lang.Object targetComp)
          Find the data binding associated with a component
 DataBinding getBinding(java.lang.String targetPath)
          Find the data binding associated with a data source path
 java.util.Vector getBindings()
          Get the data bindings in the current data binding context.
 ComponentFactory getComponentFactory()
          Get the component factory instance being used by this page.
 java.lang.String getComponentName(java.lang.Object comp)
          Get a name for a component.
 java.util.EventObject getCurrentEvent()
          Get the current event.
 DataBindingContext getDataBindingContext()
          Get the DataBindingContext object bound to this page
 DataBindingContext getDataBindingContext(java.lang.String contextName)
          Gets the named DataBindingContext context
 java.lang.Object getEventAttribute(java.lang.Object c, java.lang.String attribName)
          Gets an attribute value
 AriaEventHandler getEventHandler()
          Get the current event handler.
 java.lang.String getExtension()
          Get the file extension of this page.
 java.awt.Graphics getGraphics()
          Customizes the graphics context by adding anti-aliasing rendering hints if the start-up parameter AntiAlias=true
 java.lang.Object getOwner()
          Get the parent
 java.lang.String getPageName()
          Get the name of this page.
 java.awt.Dimension getPageSize()
          Get the size of the page
 Project getProject()
          Get the current project, the project that owns this page
 int getStatus()
          Get the page status, indicating whther the page has been created, activated and so on
 ValidationHandler getValidationHandler()
          Gets the validation handler
 boolean handleEventHandlerException(Project project, java.lang.Object container, java.lang.Throwable error)
          Handle an exception during the invocation of a page's event handler.
 boolean handleException(java.lang.Object comp, java.lang.Exception ex, java.lang.Object validator)
          A method called when a validation exeption has been trapped.
 boolean isFocusChangeSuppressed()
          Check the focus change status.
 void layout()
          Deprecated. As of JDK version 1.1, replaced by doLayout().
 void pageActivated()
          A method called once the page has been created and initialized but just prior to display.
 void pageAdded()
          A method called once the page has been added to its parent container but not yet displayed
 void pageCreated()
          A method called once the page has been created but not yet initialized.
 void pageDeactivated()
          Called whenver the page is about to loose scope and be hidden.
 void paint(java.awt.Graphics g)
          Paint the background of this component with the background color
 void paintSuper(java.lang.Object g)
          Get the super class to paint the background
 void removeBinding(DataBinding b)
          Remove a binding of a component to the data model.
 void restoreState(XmlElement root)
          Restore the application state
 int saveBoundComponentValues()
          Save the component values to the model
 void saveState(XmlElement stateElement)
          Save the application state
 void setAttribute(java.lang.String attribName, java.lang.String compName, java.lang.Object attribValue)
          Set a named attributes.
 void setClearPage(boolean value)
          Modify the clearPage flag.
 void setComponentFactory(StyleFactory factory)
          Set the component factory instance being used by this page when constructing new pages.
 void setEventHandler(AriaEventHandler eh)
          Set the current event handler
 void setExceptionHandler(ExceptionHandler eh)
          Set the validation exception handler called when a validation exception is trapped.
 void setExtension(java.lang.String ext)
          Get the file extension of this page
 void setLayout(java.lang.Object obj)
          Set the layout manager
 void setPageName(java.lang.String name)
          Get the name of this page
 void setStatus(int newStatus)
          Set the page status
 void setValidationFactory(ValidationFactory vf)
          Sets the factory used to create Validator objects
 void showComponents(java.lang.Object container, boolean visible, int recursionLevel)
          Show or hide the components.
 void showHandCursor(java.lang.Object comp)
          Show the hand/pointer cursor for this component.
 void showMessage(java.lang.Object parent, java.lang.String title, java.lang.String msg)
          Shows a modal message box.
 void showMessage(java.lang.String title, java.lang.String msg)
          Shows a modal message box.
 PageSupport showPage(java.lang.String className)
          Load and show a page.
 PageSupport showPage(java.lang.String className, java.lang.String target)
          Load and show a page and show it in a named target area.
 PageSupport showPrevious()
          Show the previously displayed page.
 java.lang.String stripAttributeValues(java.lang.String path)
          Remove the attribute paths from a path e.g.
 java.lang.String translate(java.lang.String key)
          Translate a string by looking it up in the current resource bundle.
 void update(java.awt.Graphics g)
          Overrides the update method so as to allow the suppression of the default clearing of the background.
 void updateBinding(DataBinding binding)
          Update the bound model node for the binding.
 int updateBindings()
          Iterate all of the bindings in the page to reflect the model state.
 int updateBoundComponentValues()
          Update the UI components with values from the model
static void updateChildLayouts(java.awt.Container parent)
          Update any children or children of children that have a layout.
 int validationHandler()
          Invoke the validators for the last event.
 boolean wasEnterPressed()
          Was the last event a press of the Enter key?
 boolean wasMouseClicked()
          A utility method used to determine if the last event corrseponds to a mouse click.
 boolean wasMouseDoubleClicked()
          A utility method used to determine if the last event corrseponds to a mouse double click.
 boolean wasMouseRightClicked()
          A utility method used to determine if the last event corrseponds to a mouse right click.
 
Methods inherited from class org.formaria.swing.layer.LayerManager
add, add, add, add, add, addLayer, deleteLayer, getActiveLayer, getActiveLayerIndex, getComponent, getInputContext, getLayer, getLayer, getLayerNames, isEnabled, isFocusable, isLayerEnabled, isLayerEnabled, isLayerVisible, moveLayerDown, moveLayerUp, paintChildren, setActiveLayer, setBounds, setLayerEnabled, setLayerName, setLayerVisible, setLayout, updateLayerSizes
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.formaria.aria.PageSupport
doLayout, getName, setBackground, setLocation, setName, setSize, setVisible, validate
 
Methods inherited from interface org.formaria.aria.layer.ILayerManager
setSize
 

Field Detail

project

protected Project project
The owner project. Each page belongs to a single project and normally there is just one instance of a page per project. The project provides many resources and acts as a central, coordinating point for referencing such resources.


pageMgr

protected PageManager pageMgr
The page manager for the current project, the page manager controls the update and display of pages. References to the instantiated pages are held by the page manager even if the pages are not currently visible.


rootModel

protected DataModel rootModel
The root model of the current project. The data model acts as a hierachical collection of objects that can be referenced via an Path like syntax. The data bindings generally reference objects in this data model. The rootModel is the root node in the model with all other nodes being children of this node. Normally the rootModel is a singleton (within a project).


adapter

protected WidgetAdapter adapter
The component adapter for the current widget set. The page as an abstract entity does not deal directly with components of one widget set or another, instead it interacts with the widgets via a widget adapter that provides a common set of interfaces needed to manage the page. The adapter does not however try to provide a full interface the widgets, rather it provides just those interface methods needed by the page.


pageHelper

protected PageHelper pageHelper
The helper class that implements many functions on behalf of the page, particularly the widget specific operations and those operations specified by the PageSupport interface.


componentFactory

protected StyleFactory componentFactory
Deprecated. use getComponentFactory() instead.
The component factory used by this page. The factory instantiates components and sets the basic style of those components.

Constructor Detail

Page

public Page()
Constructs an empty page, setting up the references to projects, data models and so on plus setting up a component factory to help instantiate the page's children.

Method Detail

getPageName

public java.lang.String getPageName()
Get the name of this page. The page name is used internally by the page manager to reference the page.

Returns:
the page name

setPageName

public void setPageName(java.lang.String name)
Get the name of this page

Parameters:
name - the page name

getProject

public Project getProject()
Get the current project, the project that owns this page

Specified by:
getProject in interface PageSupport
Returns:
the owner project

getExtension

public java.lang.String getExtension()
Get the file extension of this page. The page file extension is used internally by the page manager to reference the page.

Specified by:
getExtension in interface PageSupport
Returns:
the page file extension

setExtension

public void setExtension(java.lang.String ext)
Get the file extension of this page

Specified by:
setExtension in interface PageSupport
Parameters:
ext - the page file extension

update

public void update(java.awt.Graphics g)
Overrides the update method so as to allow the suppression of the default clearing of the background. If the background is not to be cleared then the clearPage flag can be set to false using the setClearPage method.

Overrides:
update in class javax.swing.JComponent
Parameters:
g - the graphics context

paintSuper

public void paintSuper(java.lang.Object g)
Get the super class to paint the background

Parameters:
g - the graphics context

paint

public void paint(java.awt.Graphics g)
Paint the background of this component with the background color

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - the graphics context

addNotify

public void addNotify()
Repaint the component once it has been created

Overrides:
addNotify in class javax.swing.JComponent

setLayout

public void setLayout(java.lang.Object obj)
Set the layout manager

Specified by:
setLayout in interface PageSupport
Parameters:
obj - the layout manager

getOwner

public java.lang.Object getOwner()
Get the parent

Specified by:
getOwner in interface PageSupport
Returns:
the owner/parent of the page

getPageSize

public java.awt.Dimension getPageSize()
Get the size of the page

Specified by:
getPageSize in interface PageSupport
Returns:
the page dimensions

setClearPage

public void setClearPage(boolean value)
Modify the clearPage flag. This flag determines if the default behaviour is used to update the page whereby the background is first erased and then the content painted or alternatively if the erase is suppressed.

Specified by:
setClearPage in interface PageSupport
Parameters:
value - true to clear

getGraphics

public java.awt.Graphics getGraphics()
Customizes the graphics context by adding anti-aliasing rendering hints if the start-up parameter AntiAlias=true

Overrides:
getGraphics in class javax.swing.JComponent

showComponents

public void showComponents(java.lang.Object container,
                           boolean visible,
                           int recursionLevel)
Show or hide the components. In the AWT the heavyweight peers are created visible and paint themselves once created and therefore cause problems for page transitions.

Specified by:
showComponents in interface PageSupport
Parameters:
recursionLevel - the number of layers of recursion (occurs with nested panels)
container - the container whose components are being modified
visible - the visibility flag, true to make the components visible

findComponent

public java.lang.Object findComponent(java.lang.String name)
Find a named component in the container. Any child containers of the container will be searched recursively till the named component is found. The first component with a matching name will be returned. The name is specified by the name attribute if the component is declared via XML. Component names should follow normal Java conventions.

Specified by:
findComponent in interface PageSupport
Parameters:
name - the name to locate
Returns:
the component or null if nothing is found

findComponent

public java.lang.Object findComponent(java.lang.Object container,
                                      java.lang.String name)
Find a named component in the container. Any child containers of the container will be searched recursively till the named component is found. The first component with a matching name will be returned.

Specified by:
findComponent in interface PageSupport
Parameters:
container - the page or container to search
name - the name to locate
Returns:
the component or null if nothing is found

layout

public void layout()
Deprecated. As of JDK version 1.1, replaced by doLayout().

Overrides:
layout in class java.awt.Container

updateChildLayouts

public static void updateChildLayouts(java.awt.Container parent)
Update any children or children of children that have a layout. Aria often uses null layouts and in some cases the children do not get laid out if a null layout is in use. This method therefore iterates the children, requesting them to update their layouts. The method is called recursively.

Parameters:
parent - the container to be laid out

setExceptionHandler

public void setExceptionHandler(ExceptionHandler eh)
Set the validation exception handler called when a validation exception is trapped. The exception handler can be customized to determine how exceptions and other errors are notified to the user.

Specified by:
setExceptionHandler in interface PageSupport
Parameters:
eh - the new event handler

handleException

public boolean handleException(java.lang.Object comp,
                               java.lang.Exception ex,
                               java.lang.Object validator)
A method called when a validation exeption has been trapped. Override this method if you want to customize a particluar error message. Alternatively a custom exception handler can be installed.

Specified by:
handleException in interface ExceptionHandler
Specified by:
handleException in interface PageSupport
Parameters:
comp - Component being validated
ex - The exception caused
validator - The validator being used to validate.
Returns:
true to continue with error validation or false to suppress further validation.

handleEventHandlerException

public boolean handleEventHandlerException(Project project,
                                           java.lang.Object container,
                                           java.lang.Throwable error)
Handle an exception during the invocation of a page's event handler. The page normally implements this interface and has the first chance at handling the error. Thereafter if false is returned a central (optional) exception handler owned by the project is invoked.

Specified by:
handleEventHandlerException in interface ExceptionHandler
Specified by:
handleEventHandlerException in interface PageSupport
Parameters:
project - the current project
container - the page
error - the exception or error that was thrown
Returns:
true to continue processing, false to stop processing

clearValidations

public void clearValidations()
Reset/removes all validations

Specified by:
clearValidations in interface PageSupport

checkValidations

public int checkValidations(java.lang.Object scope)
Check all validations for this page. Typically this method should be invoked prior to a page transition or a critical transaction. The method causes all the validations rules on the page to be checked.

Specified by:
checkValidations in interface PageSupport
Parameters:
scope - the container whose children or check, or null for all children
Returns:
the maximum error level raised by the validators

accumulateMessages

public int accumulateMessages(boolean start,
                              int level)
Informs the handler when a page validation is starting or stopping. Typically when it starts the page will begin to accumulate message which are to be displayed. When the parameter is false the page will usually display the accumulated messages. In some cases a validation rule may occur multiple times or there may be several validations on a single input field such that a user input may lead to several validation errors and therefore in such circumstances you may want to accumulate all the errors and display a single message to the user rather than bombarding the user with popup error message dialogs (which the user may just ignore). The accumulated messages may also be displayed in a console or some less intrusive way.

Specified by:
accumulateMessages in interface ExceptionHandler
Specified by:
accumulateMessages in interface PageSupport
Parameters:
start - boolean to indicate whether the accumulation is started or stopped.
level - int which indicates the most serious level of error encountered
Returns:
the new level which might be set to zero if a confirm dialog is displayed

addValidation

public Validator addValidation(java.lang.Object comp,
                               java.lang.String validationName,
                               java.lang.String method,
                               int mask,
                               XmlElement pageEle)
Adds a validation to this page.

Specified by:
addValidation in interface PageSupport
Parameters:
comp - the component being validated
validationName - the name of the validation in the validation file
method - the method used to get the component's value if any
mask - the event mask used to filter the events that trigger the validation
pageEle - the XML element which is declared in the page
Returns:
the new and initialized Validator

addValidation

public Validator addValidation(java.lang.Object comp,
                               java.lang.String validationName,
                               java.lang.String method)
Adds a validation to this page. It is assumed that the validation will be invoked in response to FocusEvent.FOCUS_LOST events

Specified by:
addValidation in interface PageSupport
Parameters:
comp - the component being validated
validationName - the name of the validation in the validation file
method - the method used to get the component's value if any
Returns:
the new and initialized Validator

addValidation

public Validator addValidation(java.lang.Object comp,
                               java.lang.String validationName)
Adds a validation to this page. It is assumed that the validation will be invoked in response to FocusEvent.FOCUS_LOST events

Specified by:
addValidation in interface PageSupport
Parameters:
comp - the component being validated
validationName - the name of the validation in the validation file
Returns:
the new and initialized Validator

setValidationFactory

public void setValidationFactory(ValidationFactory vf)
Sets the factory used to create Validator objects

Specified by:
setValidationFactory in interface PageSupport
Parameters:
vf - The validation factory

getValidationHandler

public ValidationHandler getValidationHandler()
Gets the validation handler

Specified by:
getValidationHandler in interface PageSupport
Returns:
the validation handler

validationHandler

public int validationHandler()
Invoke the validators for the last event. Multiple validations are checked in the order in which they were added.

Specified by:
validationHandler in interface PageSupport
Returns:
the maximum level returned by the validators

getEventHandler

public AriaEventHandler getEventHandler()
Get the current event handler. The event handler provides a set of methods and interfaces used to respond to common events. The default event handler ultimately uses reflection to invoke a specific response method, but you can install a custom event handler using the setEventHandler method.

Specified by:
getEventHandler in interface PageSupport
Returns:
the event handler

setEventHandler

public void setEventHandler(AriaEventHandler eh)
Set the current event handler

Specified by:
setEventHandler in interface PageSupport
Parameters:
eh - The event handler

getCurrentEvent

public java.util.EventObject getCurrentEvent()
Get the current event. This method will return the last event, which may be required to distinguish the subtypes of a specific listener interface. Aria also provides some utility methods like wasMouseClicked which checks if the mouseListener interface's mouseClicked method was invoked. Aria does not paramterize its response methods to promote simplicity and because in most cases an application only processes a fraction of the methods provided by the listener interfaces - the trade-off however is that sometimes it is necessary to query details of the event. If it is a common requirement for your application to do such process consider building an extra helper

Specified by:
getCurrentEvent in interface PageSupport
Returns:
the AWTEvent that was last triggered

addListener

public void addListener(java.lang.Object comp,
                        java.lang.String listenerName,
                        java.lang.String argType,
                        java.lang.Object listener)
Adds a listener for an event type. This method should not normally be called by an application

Specified by:
addListener in interface PageSupport
Parameters:
comp - the component that fires events
listenerName - the name of the listener interface
argType - the listener arguments
listener - the listener implementation

addHandler

public void addHandler(java.lang.Object comp,
                       long eventType,
                       java.lang.String methodName)
                throws java.lang.Exception
Adds an event handler. A specific handler such as the addActionHandler should be used instead of calling this method

Specified by:
addHandler in interface PageSupport
Parameters:
comp - the component that fires the event
eventType - the event ID/mask
methodName - the method to be invoked in response to the object
Throws:
java.lang.Exception - The handler could not be found or added

isFocusChangeSuppressed

public boolean isFocusChangeSuppressed()
Check the focus change status. Sometimes the focus change events are suppressed within the Aria framework as validation errors may cause popup error messages (dialogs) to pop up, the popups then cause a change in focus, which in turn may cause other validation errors. Typically the focus change caused by these error dialogs is not what was intended when the validation rule was declared and therefore to suppress these unwanted errors the focus change can be suppressed. The error may also be self generating, making it impossible to correct the input if the validation rule fires when the error dialog is dismissed - again, suppressing the focus event rectifies the problem.

Specified by:
isFocusChangeSuppressed in interface PageSupport
Returns:
true if the focus change events are being suppressed.

addHandler

public void addHandler(java.lang.Object srcObj,
                       java.lang.String methodName,
                       java.lang.String adderMethod,
                       java.lang.String listenerInterface,
                       long eventMask,
                       java.lang.Object listener)
Adds a handler for action events

Specified by:
addHandler in interface PageSupport
Parameters:
srcObj - the menu item that fires the events
methodName - the method to be invoked in response to the action event
adderMethod - the adder method name e.g. addActionListener
listenerInterface - the listener interface e.g. java.awt.event.ActionListener
eventMask - the event mask e.g. AWTEvent.ACTION_EVENT_MASK
listener - the listener implementation, usually the page's this pointer
See Also:
ActionListener, ActionEvent

wasMouseClicked

public boolean wasMouseClicked()
A utility method used to determine if the last event corrseponds to a mouse click. The notion of a click is extended by assuming the a mouse press and release within a single component constitutes a click even if not at the same coordinate. A MouseEvent.MOUSE_CLICKED is only triggered when the press and release are at the same location and this is often inadequate for end-user interaction.

Specified by:
wasMouseClicked in interface PageSupport
Returns:
true if the mouse was clicked

clearMouseClick

public void clearMouseClick()
Clear the mouse click tracking


wasMouseDoubleClicked

public boolean wasMouseDoubleClicked()
A utility method used to determine if the last event corrseponds to a mouse double click. The notion of a click is extended by assuming the a mouse press and release within a single component constitutes a click even if not at the same coordinate. A MouseEvent.MOUSE_CLICKED is only triggered when the press and release are at the same location and this is often inadequate for end-user interaction.

Specified by:
wasMouseDoubleClicked in interface PageSupport
Returns:
true if the mouse was double clicked

wasMouseRightClicked

public boolean wasMouseRightClicked()
A utility method used to determine if the last event corrseponds to a mouse right click. The notion of a click is extended by assuming the a mouse press and release within a single component constitutes a click even if not at the same coordinate. A MouseEvent.MOUSE_CLICKED is only triggered when the press and release are at the same location and this is often inadequate for end-user interaction.

Specified by:
wasMouseRightClicked in interface PageSupport
Returns:
true if the mouse was right clicked

wasEnterPressed

public boolean wasEnterPressed()
Was the last event a press of the Enter key?

Returns:

showHandCursor

public void showHandCursor(java.lang.Object comp)
Show the hand/pointer cursor for this component. When the mouse is moved over the component the hand cursor will be displayed

Specified by:
showHandCursor in interface PageSupport
Parameters:
comp - the component

getBindings

public java.util.Vector getBindings()
Get the data bindings in the current data binding context. The returned vector may contain nested data binding contextss

Specified by:
getBindings in interface PageSupport
Returns:
the bindings collection

addBinding

public void addBinding(DataBinding b)
Add a binding of a component to the data model. If the page has already been activated this method will update the binding automatically.

Specified by:
addBinding in interface PageSupport
Parameters:
b - the binding

removeBinding

public void removeBinding(DataBinding b)
Remove a binding of a component to the data model.

Specified by:
removeBinding in interface PageSupport
Parameters:
b - the binding

updateBindings

public int updateBindings()
Iterate all of the bindings in the page to reflect the model state. The method is normally invoked upon a page transition.

Specified by:
updateBindings in interface PageSupport
Returns:
non zero if errors are detected

updateBinding

public void updateBinding(DataBinding binding)
Update the bound model node for the binding. First the output path is reevaluated and then updated by setting the output node. Then the source path is reevaluated and set. Evaluation of the paths allows derived classes to dynamically modify the bindings. Some bindings may save the selection or state information to the output node and subsequently use it to restore the component state. This method does not alter the data held by the bound model nodes. To actually save the data use saveBoundComponentValues and to update the UI use updateBoundComponentValues.

Specified by:
updateBinding in interface PageSupport
Parameters:
binding - the binding to update

updateBoundComponentValues

public int updateBoundComponentValues()
Update the UI components with values from the model

Specified by:
updateBoundComponentValues in interface PageSupport
Returns:
non zero if errors are detected

saveBoundComponentValues

public int saveBoundComponentValues()
Save the component values to the model

Specified by:
saveBoundComponentValues in interface PageSupport
Returns:
non zero if errors are detected

getDataBindingContext

public DataBindingContext getDataBindingContext()
Get the DataBindingContext object bound to this page

Specified by:
getDataBindingContext in interface PageSupport
Returns:
DataBindingContext object

getDataBindingContext

public DataBindingContext getDataBindingContext(java.lang.String contextName)
Gets the named DataBindingContext context

Specified by:
getDataBindingContext in interface PageSupport
Parameters:
contextName - the name of the context
Returns:
DataBindingContext object

getBinding

public DataBinding getBinding(java.lang.Object targetComp)
Find the data binding associated with a component

Specified by:
getBinding in interface PageSupport
Parameters:
targetComp - the component whose binding is required
Returns:
the binding or null if no binding is found

getBinding

public DataBinding getBinding(java.lang.String targetPath)
Find the data binding associated with a data source path

Specified by:
getBinding in interface PageSupport
Parameters:
targetPath - the path to the bound model
Returns:
the binding or null if no binding is found

enterDataBindingContext

public void enterDataBindingContext(java.lang.String contextName)
Gets the named DataBindingContext object bound to this PageHelper object, creating the context if necessary. The context is set as the default data binding context by this method.

Specified by:
enterDataBindingContext in interface PageSupport
Parameters:
contextName - the data binding context name

exitDataBindingContext

public void exitDataBindingContext()
Exit the data binding context and return to the parent context if any

Specified by:
exitDataBindingContext in interface PageSupport
Parameters:
contextName - the data binding context name

getStatus

public int getStatus()
Get the page status, indicating whther the page has been created, activated and so on

Specified by:
getStatus in interface PageSupport
Returns:
the current status

setStatus

public void setStatus(int newStatus)
Set the page status

Specified by:
setStatus in interface PageSupport
Parameters:
newStatus - the new page status

pageActivated

public void pageActivated()
A method called once the page has been created and initialized but just prior to display. Override this method if you need to add custom behavior when the page is activated or displayed.

Specified by:
pageActivated in interface PageSupport

pageAdded

public void pageAdded()
A method called once the page has been added to its parent container but not yet displayed

Specified by:
pageAdded in interface PageSupport

pageCreated

public void pageCreated()
A method called once the page has been created but not yet initialized. Override this method if you need to implement custom creation when the page is created. The method is only called when the page is instantiated and not when the page is redisplayed. The pageActivated method is invoked whenever a page is displayed.

Specified by:
pageCreated in interface PageSupport

pageDeactivated

public void pageDeactivated()
Called whenver the page is about to loose scope and be hidden.

Specified by:
pageDeactivated in interface PageSupport

setAttribute

public void setAttribute(java.lang.String attribName,
                         java.lang.String compName,
                         java.lang.Object attribValue)

Set a named attributes. The attributes are stored in a hashtable owned by the page. Derived classes may access the hashtable directly but the preferred method of access is the getAttribute method. Attributes are used by the AriaBuilder class for component attributes other than those it handles directly. The attributes can be thought of as component properties or extra data and need not be used directly by the component.

Attributes are stored using a key in the form attribName_compName or just the attribName if compName is null.

Specified by:
setAttribute in interface PageSupport
Parameters:
attribName - the attribute name
compName - the component name or null if it is a page attribute
attribValue - the attribute value
See Also:
getAttribute(java.lang.String)

getAttribute

public java.lang.Object getAttribute(java.lang.String attribName)
Gets the value of an attribute of this page

Specified by:
getAttribute in interface PageSupport
Parameters:
attribName - the name of the attribute
Returns:
the value

getAttribute

public java.lang.Object getAttribute(java.lang.String attribName,
                                     java.lang.String compName)
Gets the value of an attribute of the named component.

Specified by:
getAttribute in interface PageSupport
Parameters:
attribName - the name of the attribute
compName - the component name
Returns:
the value

getAttributes

public java.lang.Object getAttributes()
Gets the table of attributes used by this page. The method is not intended for general use and should be used with great care.

Returns:
the table of attributes

getComponentName

public java.lang.String getComponentName(java.lang.Object comp)
Get a name for a component. If the component doesn't have one use the component hashcode

Specified by:
getComponentName in interface PageSupport
Parameters:
comp - the component
Returns:
the name

getEventAttribute

public java.lang.Object getEventAttribute(java.lang.Object c,
                                          java.lang.String attribName)
Gets an attribute value

Specified by:
getEventAttribute in interface PageSupport
Parameters:
c - the component whose attribute is being requested
attribName - the name of the attribute
Returns:
the value

evaluateAttribute

public java.lang.Object evaluateAttribute(java.lang.String attribValue)
Evaluates an attribute value. An attribute may be a value or a method call. If brackets are part of the value it is assumed that a method call is intended. The method call is indicated by the '$' symbol e.g. ${myMethod()}

Specified by:
evaluateAttribute in interface PageSupport
Parameters:
attribValue - the raw attribute value
Returns:
the evaluated attribute

evaluatePath

public java.lang.String evaluatePath(java.lang.String path)
Evaluates a path (potentially) containing a method call

Specified by:
evaluatePath in interface PageSupport
Parameters:
path - the raw path
Returns:
the evaluated path

stripAttributeValues

public java.lang.String stripAttributeValues(java.lang.String path)
Remove the attribute paths from a path e.g. remove @value=ignore

Specified by:
stripAttributeValues in interface PageSupport
Parameters:
path - the path to strip
Returns:
the stripped path

getComponentFactory

public ComponentFactory getComponentFactory()
Get the component factory instance being used by this page. Normally the page instantiates an instance of the StyleFactory but this can be changed at any time and this method returns the current instance.

Specified by:
getComponentFactory in interface PageSupport
Returns:
the component factory

setComponentFactory

public void setComponentFactory(StyleFactory factory)
Set the component factory instance being used by this page when constructing new pages. Normally there is no need to change the component factory. If you need to instantiate a component not included by default the component registration mechanism should be used.

Specified by:
setComponentFactory in interface PageSupport
Parameters:
factory - the component factory

translate

public java.lang.String translate(java.lang.String key)
Translate a string by looking it up in the current resource bundle. The translator is a project resource and the resource bundle is also defined on an application level.

Specified by:
translate in interface PageSupport
Parameters:
key - the resource bundle key
Returns:
the translated text

showMessage

public void showMessage(java.lang.String title,
                        java.lang.String msg)
Shows a modal message box. The dialog is displayed in such a way that it does not trigger a focus change event.

Specified by:
showMessage in interface PageSupport
Parameters:
title - the message dialog title
msg - the text of the message

showMessage

public void showMessage(java.lang.Object parent,
                        java.lang.String title,
                        java.lang.String msg)
Shows a modal message box. The dialog is displayed in such a way that it does not trigger a focus change event.

Specified by:
showMessage in interface PageSupport
Parameters:
parent - the message dialog parent
title - the message dialog title
msg - the text of the message

showPage

public PageSupport showPage(java.lang.String className)
Load and show a page.

Parameters:
className - The name, without package info, of the page to be displayed
Returns:
the page being displayed

showPage

public PageSupport showPage(java.lang.String className,
                            java.lang.String target)
Load and show a page and show it in a named target area. The target areas are the named 'frames' of the frames file. The default 'content' area is used by default if the named area cannot be found.

Parameters:
className - The name, without package info, of the page to be displayed
target - the area to update
Returns:
the page being displayed

showPrevious

public PageSupport showPrevious()
Show the previously displayed page. Although the method works with framesets the page history applies only to the main content area.

Returns:
The previous Page

addNestedPage

public void addNestedPage(PageSupport ps)
Add a nested page reference

Specified by:
addNestedPage in interface PageSupport
Parameters:
ps - the nested page

saveState

public void saveState(XmlElement stateElement)
Save the application state

Specified by:
saveState in interface PersistentState

restoreState

public void restoreState(XmlElement root)
Restore the application state

Specified by:
restoreState in interface PersistentState