package net.xoetrope.xui;
import java.awt.Component;
import java.util.Vector;
import java.util.EventObject;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.Graphics;
import java.awt.Rectangle;
import net.xoetrope.xml.XmlElement;
import net.xoetrope.xui.build.BuildProperties;
import net.xoetrope.xui.data.XDataBinding;
import net.xoetrope.xui.data.XModel;
import net.xoetrope.xui.events.XuiEventHandler;
import net.xoetrope.xui.style.XStyleFactory;
import net.xoetrope.xui.exception.XExceptionHandler;
import net.xoetrope.xui.validation.XValidationFactory;
import net.xoetrope.xui.validation.XValidationHandler;
import net.xoetrope.xui.validation.XValidator;
/**
* <p>A basic unit for building applications. XPage integrates with
* page and event management facilities provided by XUI. 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.
* </p><p>
* Pages can be displayed using the XPageDisplay interface implemented by
* XApplet and invoked by the XPage manager. Pages can be constructed directly
* or via the XuiBuilder. The page lifecycle also interaccts with the data
* bindings, triggering data updates and saving.
* </p>
* <p>
* The page implements the PageSupport interface which abstracts many of the
* methods used by the XUI 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.
* </p><p>
* The XPage class is little more than a shell and many of its methods are
* implemented by the XPageHelper 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.
* </p>
* <p>Copyright (c) Xoetrope Ltd., 2002-2006</p>
* <p>License: see license.txt</p>
* $Revision: 2.33 $
*/
public class XPage extends Container implements XExceptionHandler, PageSupport
{
/**
* The package name for the built-in AWT component
*/
public static final String XUI_AWT_PACKAGE = "net.xoetrope.awt";
/**
* The package name for the built-in Swing component
*/
public static final String XUI_SWING_PACKAGE = "net.xoetrope.swing";
/**
* The package name for the built-in SWT components
*/
public static final String XUI_SWT_PACKAGE = "net.xoetrope.swt";
/**
* The package name for the built-in HTML components
*/
public static final String XUI_HTML_PACKAGE = "net.xoetrope.html";
/**
* Tag for an unknown component type (not one of the built-in types)
*/
public final static String UNKNOWN = "Unknown";
/**
* Tag for a panel
*/
public final static String PANEL = "Panel";
/**
* Tag for a label component
*/
public final static String LABEL = "Label";
/**
* Tag for a radio button
*/
public final static String RADIO = "RadioButton";
/**
* Tag for a checkbox
*/
public final static String CHECK = "Checkbox";
/**
* Tag for a combo box or drop down list
*/
public final static String COMBO = "ComboBox";
/**
* Tag for a list box
*/
public final static String LIST = "List";
/**
* Tag for an image component
*/
public final static String IMAGE = "Image";
/**
* A single text editing field
*/
public final static String EDIT = "Edit";
/**
* Tag for a push button
*/
public final static String BUTTON = "Button";
/**
* Tag for Tagged text
*/
public final static String METACONTENT = "MetaContent";
/**
* Tag for a radio button group
*/
public final static String GROUP = "Group";
/**
* Tag for a scroll pane
*/
public final static String SCROLLPANE = "ScrollPane";
/**
* Tag for a Scrollable tagged text
*/
public final static String SCROLLABLEMETACONTENT = "ScrollableMetaContent";
/**
* Tag for a hotspot image
*/
public final static String HOTSPOTIMAGE = "HotspotImage";
/**
* Tag for a table component
*/
public final static String TABLE = "Table";
/**
* Tag for a vector image
*/
public final static String WMF = "Wmf";
/**
* Tag for an annotated image component
* @deprecated merged with imagemap
*/
public final static String ANNOTATEDIMAGE = "AnnotatedImage";
/**
* Tag for a menubar
*/
public final static String MENUBAR = "MenuBar";
/**
* Tag for a menu
*/
public final static String MENU = "Menu";
/**
* Tag for a menu item
*/
public final static String MENUITEM = "MenuItem";
/**
* Tag for a multiline text field
*/
public final static String TEXTAREA = "TextArea";
/**
* Tag for a password edit field
*/
public final static String PASSWORD = "Password";
/**
* Tag for an image map
*/
public final static String IMAGEMAP = "ImageMap";
/**
* Tag for a tabbed panel
*/
public final static String TABPANEL = "TabPanel";
/**
* Tag for a splitter
*/
public final static String SPLITPANE = "SplitPane";
// Built-in LayoutManager types
/**
* ID for an NULL layout
*/
public final static int NULL_LAYOUT = 0;
/**
* ID for a border layout
*/
public final static int BORDER_LAYOUT = 1;
/**
* ID for a flow layout
*/
public final static int FLOW_LAYOUT = 2;
/**
* ID for a card layout
*/
public final static int CARD_LAYOUT = 3;
/**
* ID for a grid layout
*/
public final static int GRID_LAYOUT = 4;
/**
* ID for a grid bag layout
*/
public final static int GRIDBAG_LAYOUT = 5;
/**
* This type of layout simulates the Swing layout by using a GridLayout such
* that the layoutStyle attribute indicates vertical or horizontal layout. A
* layoutStyle of '0' indicates a vertical layout and any other value indicates
* a horizontal layout.
*/
public final static int BOX_LAYOUT = 6;
/**
* SpringLayout ID
*/
public final static int SPRING_LAYOUT = 7;
/**
* ScaleLayout ID
*/
public final static int SCALE_LAYOUT = 8;
/**
* GuideLayout ID
*/
public final static int GUIDE_LAYOUT = 9;
/**
* LayerLayout ID
*/
public final static int LAYER_LAYOUT = 10;
/**
* ColumnLayout ID
*/
public final static int COLUMN_LAYOUT = 11;
// Page states
/**
* The page state is unknown
*/
public final static int UNKNOWN_PAGE_STATE = 0;
/**
* The page has been loaded
*/
public final static int LOADED = 1;
/**
* The page has been created
*/
public final static int CREATED = 2;
/**
* The page has been activated
*/
public final static int ACTIVATED = 3;
/**
* The page has been activated and displayed
*/
public final static int DISPLAYED = 4;
/**
* The page has been deactivated
*/
public final static int DEACTIVATED = 5;
/**
* The page has been discarded
*/
public final static int DISCARDED = 6;
/**
* 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.
*/
protected XProject project;
/**
* 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.
*/
protected XPageManager pageMgr;
/**
* The root model of the current project. The data model acts as a hierachical
* collection of objects that can be referenced via an XPath 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).
*/
protected XModel rootModel;
/**
* 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.
*/
protected WidgetAdapter adapter;
/**
* 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 XPageHelper pageHelper;
/**
* The component factory used by this page. The factory instantiates components
* and sets the basic style of those components.
* @deprecated use getComponentFactory() instead.
*/
protected XStyleFactory componentFactory;
/**
* The antialias member controls use of antialiasing. By default it is turned
* off so page graphics are not automatically antialiased
*/
protected static boolean antiAlias = false;
/**
* 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.
*/
public XPage()
{
project = XProjectManager.getCurrentProject();
rootModel = project.getModel();
pageMgr = project.getPageManager();
adapter = WidgetAdapter.getInstance();
pageHelper = new XPageHelper( project, this );
componentFactory = (XStyleFactory)pageHelper.getComponentFactory();
// Check for page annotations
pageMgr.attachPage( this );
}
/**
* Get the name of this page. The page name is used internally by the page
* manager to reference the page.
* @return the page name
*/
public String getPageName()
{
return pageHelper.getPageName();
}
/**
* Get the name of this page
* @param name the page name
*/
public void setPageName( String name )
{
pageHelper.setPageName( name );
}
/**
* Get the current project, the project that owns this page
* @return the owner project
*/
public XProject getProject()
{
return project;
}
/**
* Get the file extension of this page. The page file extension is used internally by the page
* manager to reference the page.
* @return the page file extension
*/
public String getExtension()
{
return pageHelper.getPageExtension();
}
/**
* Get the file extension of this page
* @param ext the page file extension
*/
public void setExtension( String ext )
{
pageHelper.setPageExtension( ext );
}
/**
* 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.
* @param g the graphics context
*/
public void update( Graphics g )
{
if ( pageHelper.clearPage )
super.update( g );
else
paint( g );
}
/**
* Get the super class to paint the background
* @param g the graphics context
*/
public void paintSuper( Object g )
{
super.paint( ( Graphics )g );
}
/**
* Paint the background of this component with the background color
* @param g the graphics context
*/
public void paint( Graphics g )
{
if ( isVisible()) {
g.setColor( getBackground());
Rectangle rect = g.getClipBounds();
g.fillRect( rect.x, rect.y, rect.width + 1, rect.height + 1 );
try {
super.paint( g );
}
catch ( Exception e ) {
e.printStackTrace();
}
}
}
/**
* Repaint the component once it has been created
*/
public void addNotify()
{
super.addNotify();
invalidate();
}
/**
* Set the layout manager
* @param obj the layout manager
*/
public void setLayout( Object obj )
{
super.setLayout( (LayoutManager)obj );
}
/**
* Get the parent
* @return the owner/parent of the page
*/
public Object getOwner()
{
return getParent();
}
/**
* Get the size of the page
* @return the page dimensions
*/
public Dimension getPageSize()
{
return super.getSize();
}
/**
* 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.
* @param value true to clear
*/
public void setClearPage( boolean value )
{
pageHelper.setClearPage( value );
}
/**
* Customizes the graphics context by adding anti-aliasing rendering hints
* if the start-up parameter AntiAlias=true
*/
public Graphics getGraphics()
{
Graphics g = super.getGraphics();
if ( antiAlias && !BuildProperties.BUILD_JDK_118 ) {
((java.awt.Graphics2D) g).setRenderingHint( java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,
java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
((java.awt.Graphics2D) g).setRenderingHint( java.awt.RenderingHints.KEY_ANTIALIASING,
java.awt.RenderingHints.VALUE_ANTIALIAS_ON );
}
return g;
}
/**
* 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.
* @param recursionLevel the number of layers of recursion (occurs with nested panels)
* @param container the container whose components are being modified
* @param visible the visibility flag, true to make the components visible
*/
public void showComponents( Object container, boolean visible, int recursionLevel )
{
pageHelper.showComponents( container, visible, recursionLevel );
}
/**
* 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.
* @param name the name to locate
* @return the component or null if nothing is found
*/
public Object findComponent( String name )
{
return pageHelper.findComponent( 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.
* @param container the page or container to search
* @param name the name to locate
* @return the component or null if nothing is found
*/
public Object findComponent( Object container, String name )
{
return pageHelper.findComponent( container, name );
}
/**
* @deprecated As of JDK version 1.1,
* replaced by <code>doLayout()</code>.
*/
public void layout()
{
LayoutManager layoutMgr = getLayout();
if ( layoutMgr != null )
layoutMgr.layoutContainer( this );
else
updateChildLayouts( this );
}
/**
* Update any children or children of children that have a layout. XUI 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.
* @param parent the container to be laid out
*/
public static void updateChildLayouts( Container parent )
{
// Now do the layout
int numComps = parent.getComponentCount();
for ( int i = 0; i < numComps; i++ ) {
Component comp = parent.getComponent( i );
if ( comp instanceof Container ) {
LayoutManager lm = ((Container)comp).getLayout();
if ( lm != null )
lm.layoutContainer( (Container)comp );
else
updateChildLayouts( (Container)comp );
}
}
}
//--Start of Validation-------------------------------------------------------
/**
* 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.
* @param eh the new event handler
*/
public void setExceptionHandler( XExceptionHandler eh )
{
pageHelper.setExceptionHandler( eh );
}
/**
* 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.
*
* @param comp Component being validated
* @param ex The exception caused
* @param validator The validator being used to validate.
* @return true to continue with error validation or false to suppress further
* validation.
*/
public boolean handleException( Object comp, Exception ex, Object validator )
{
return pageHelper.handleException( comp, ex, validator );
}
/**
* 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.
*
* @param project the current project
* @param container the page
* @param error the exception or error that was thrown
* @return true to continue processing, false to stop processing
*/
public boolean handleEventHandlerException( XProject project, Object container, Throwable error )
{
return pageHelper.handleEventHandlerException( project, container, error );
}
/**
* Reset/removes all validations
*/
public void clearValidations()
{
pageHelper.clearValidations();
}
/**
* 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.
* @return the maximum error level raised by the validators
*/
public int checkValidations()
{
return pageHelper.checkValidations();
}
/**
* 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.
* @param start boolean to indicate whether the accumulation is started or stopped.
* @param level int which indicates the most serious level of error encountered
* @return the new level which might be set to zero if a confirm dialog is displayed
*/
public int accumulateMessages( boolean start, int level )
{
return pageHelper.accumulateMessages( start, level );
}
/**
* Adds a validation to this page.
* @param comp the component being validated
* @param validationName the name of the validation in the validation file
* @param method the method used to get the component's value if any
* @param mask the event mask used to filter the events that trigger the validation
* @param pageEle the XML element which is declared in the page
* @return the new and initialized XValidator
*/
public XValidator addValidation( Object comp, String validationName, String method, int mask, XmlElement pageEle )
{
return pageHelper.addValidation( comp, validationName, method, mask, pageEle );
}
/**
* Adds a validation to this page. It is assumed that the validation will be
* invoked in response to FocusEvent.FOCUS_LOST events
* @param comp the component being validated
* @param validationName the name of the validation in the validation file
* @param method the method used to get the component's value if any
* @return the new and initialized XValidator
*/
public XValidator addValidation( Object comp, String validationName, String method )
{
return pageHelper.addValidation( comp, validationName, method );
}
/**
* Adds a validation to this page. It is assumed that the validation will be
* invoked in response to FocusEvent.FOCUS_LOST events
* @param comp the component being validated
* @param validationName the name of the validation in the validation file
* @return the new and initialized XValidator
*/
public XValidator addValidation( Object comp, String validationName )
{
return pageHelper.addValidation( comp, validationName );
}
/**
* Sets the factory used to create XValidator objects
* @param vf The validation factory
*/
public void setValidationFactory( XValidationFactory vf )
{
pageHelper.setValidationFactory( vf );
}
/**
* Gets the validation handler
* @return the validation handler
*/
public XValidationHandler getValidationHandler()
{
return pageHelper.getValidationHandler();
}
/**
* Invoke the validators for the last event. Multiple validations are checked
* in the order in which they were added.
* @return the maximum level returned by the validators
*/
public int validationHandler()
{
return pageHelper.validationHandler( getEventHandler());
}
//--End of Validation---------------------------------------------------------
//--Start of Event Handling---------------------------------------------------
/**
* 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.
* @return the event handler
*/
public XuiEventHandler getEventHandler()
{
return pageHelper.getEventHandler();
}
/**
* Set the current event handler
* @param eh The event handler
*/
public void setEventHandler( XuiEventHandler eh )
{
pageHelper.setEventHandler( eh );
}
/**
* Get the current event. This method will return the last event, which may be
* required to distinguish the subtypes of a specific listener interface. XUI
* also provides some utility methods like wasMouseClicked which checks if the
* mouseListener interface's mouseClicked method was invoked. XUI 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
* @return the AWTEvent that was last triggered
*/
public EventObject getCurrentEvent()
{
return pageHelper.getCurrentEvent();
}
/**
* Adds a listener for an event type. This method should not normally be
* called by an application
* @param comp the component that fires events
* @param listenerName the name of the listener interface
* @param argType the listener arguments
* @param listener the listener implementation
*/
public void addListener( Object comp, String listenerName, String argType, Object listener )
{
pageHelper.addListener( comp, listenerName, argType, listener );
}
/**
* Adds an event handler. A specific handler such as the addActionHandler should
* be used instead of calling this method
* @param comp the component that fires the event
* @param eventType the event ID/mask
* @param methodName the method to be invoked in response to the object
* @throws java.lang.Exception The handler could not be found or added
*/
public void addHandler( Object comp, long eventType, String methodName ) throws Exception
{
pageHelper.addHandler( comp, eventType, methodName );
}
/**
* Check the focus change status. Sometimes the focus change events are
* suppressed within the XUI 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.
* @return true if the focus change events are being suppressed.
*/
public boolean isFocusChangeSuppressed()
{
return pageHelper.isFocusChangeSuppressed();
}
/**
* Adds a handler for action events
* @param srcObj the menu item that fires the events
* @param methodName the method to be invoked in response to the action event
* @param adderMethod the adder method name e.g. addActionListener
* @param listenerInterface the listener interface e.g. java.awt.event.ActionListener
* @param eventMask the event mask e.g. AWTEvent.ACTION_EVENT_MASK
* @param listener the listener implementation, usually the page's this pointer
* @see java.awt.event.ActionListener
* @see java.awt.event.ActionEvent
*/
public void addHandler( Object srcObj, String methodName, String adderMethod, String listenerInterface, long eventMask, Object listener )
{
pageHelper.addHandler( srcObj, methodName, adderMethod, listenerInterface, eventMask, listener );
}
/**
* 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.
* @return true if the mouse was clicked
*/
public boolean wasMouseClicked()
{
return pageHelper.wasMouseClicked();
}
/**
* 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.
* @return true if the mouse was double clicked
*/
public boolean wasMouseDoubleClicked()
{
return pageHelper.wasMouseDoubleClicked();
}
/**
* 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.
* @return true if the mouse was right clicked
*/
public boolean wasMouseRightClicked()
{
return pageHelper.wasMouseRightClicked();
}
/**
* Show the hand/pointer cursor for this component. When the mouse is moved
* over the component the hand cursor will be displayed
* @param comp the component
*/
public void showHandCursor( Object comp )
{
pageHelper.showHandCursor( comp );
}
//--End of Event Handling-----------------------------------------------------
//--Start of Data Binding-----------------------------------------------------
/**
* Get the data bindings
* @return the bindings collection
*/
public Vector getBindings()
{
return pageHelper.getBindings();
}
/**
* Add a binding of a component to the data model. If the page has already
* been activated this method will update the binding automatically.
* @param b the binding
*/
public void addBinding( XDataBinding b )
{
pageHelper.addBinding( b );
}
/**
* Remove a binding of a component to the data model.
* @param b the binding
*/
public void removeBinding( XDataBinding b )
{
pageHelper.removeBinding( b );
}
/**
* Iterate all of the bindings in the page to reflect the model state. The
* method is normally invoked upon a page transition.
*/
public void updateBindings()
{
pageHelper.updateBindings();
}
/**
* 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.
* @param binding the binding to update
*/
public void updateBinding( XDataBinding binding )
{
pageHelper.updateBinding( binding );
}
/**
* Update the UI components with values from the model
*/
public void updateBoundComponentValues()
{
pageHelper.updateBoundComponentValues();
}
/**
* Save the component values to the model
*/
public void saveBoundComponentValues()
{
pageHelper.saveBoundComponentValues();
}
/**
* Get the XDataBindingContext object bound
* to this page
* @return XDataBindingContext object
*/
public XDataBindingContext getDataBindingContext()
{
return pageHelper.getDataBindingContext();
}
/**
* Find the data binding associated with a component
* @param targetComp the component whose binding is required
* @return the binding or null if no binding is found
*/
public XDataBinding getBinding( Object targetComp )
{
return pageHelper.getBinding( targetComp );
}
/**
* Find the data binding associated with a data source path
* @param targetPath the path to the bound model
* @return the binding or null if no binding is found
*/
public XDataBinding getBinding( String targetPath )
{
return pageHelper.getBinding( targetPath );
}
/**
* Get the page status, indicating whther the page has been created,
* activated and so on
* @return the current status
*/
public int getStatus()
{
return pageHelper.getStatus();
}
/**
* Set the page status
* @param newStatus the new page status
*/
public void setStatus( int newStatus )
{
pageHelper.setStatus( newStatus );
}
/**
* 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.
*/
public void pageActivated()
{
pageHelper.pageActivated();
}
/**
* A method called once the page has been added to its parent container but
* not yet displayed
*/
public void pageAdded()
{
pageHelper.pageAdded();
}
/**
* 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.
*/
public void pageCreated()
{
pageHelper.pageCreated();
}
/**
* Called whenver the page is about to loose scope and be hidden.
*/
public void pageDeactivated()
{
pageHelper.pageDeactivated();
}
//--End of Data Binding-------------------------------------------------------
//--End of Attribute Methods--------------------------------------------------
/**
* <p>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 XuiBuilder 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.</p>
* <p>
* Attributes are stored using a key in the form attribName_compName or just
* the attribName if compName is null.
* </p>
* @param attribName the attribute name
* @param compName the component name or null if it is a page attribute
* @param attribValue the attribute value
* @see #getAttribute
*/
public void setAttribute( String attribName, String compName, Object attribValue )
{
pageHelper.setAttribute( attribName, compName, attribValue );
}
/**
* Gets the value of an attribute of this page
* @param attribName the name of the attribute
* @return the value
*/
public Object getAttribute( String attribName )
{
return pageHelper.getAttribute( attribName );
}
/**
* Gets the value of an attribute of the named component.
* @param attribName the name of the attribute
* @param compName the component name
* @return the value
*/
public Object getAttribute( String attribName, String compName )
{
return pageHelper.getAttribute( attribName, compName );
}
/**
* Gets the table of attributes used by this page. The method is not intended
* for general use and should be used with great care.
* @return the table of attributes
*/
public Object getAttributes()
{
return pageHelper.getAttributes();
}
/**
* Get a name for a component. If the component doesn't have one use the
* component hashcode
* @param comp the component
* @return the name
*/
public String getComponentName( Object comp )
{
return pageHelper.getComponentName( comp );
}
/**
* Gets an attribute value
* @return the value
* @param c the component whose attribute is being requested
* @param attribName the name of the attribute
*/
public Object getEventAttribute( Object c, String attribName )
{
return pageHelper.getEventAttribute( c, attribName );
}
/**
* 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()}
* @param attribValue the raw attribute value
* @return the evaluated attribute
*/
public Object evaluateAttribute( String attribValue )
{
return pageHelper.evaluateAttribute( attribValue );
}
/**
* Evaluates a path (potentially) containing a method call
* @param path the raw path
* @return the evaluated path
*/
public String evaluatePath( String path )
{
return pageHelper.evaluatePath( path );
}
/**
* Remove the attribute paths from a path e.g. remove @value=ignore
* @param path the path to strip
* @return the stripped path
*/
public String stripAttributeValues( String path )
{
return pageHelper.stripAttributeValues( path );
}
/**
* Get the component factory instance being used by this page. Normally the
* page instantiates an instance of the XStyleFactory but this can be
* changed at any time and this method returns the current instance.
* @return the component factory
*/
public XComponentFactory getComponentFactory()
{
return pageHelper.getComponentFactory();
}
/**
* 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.
* @param factory the component factory
*/
public void setComponentFactory( XStyleFactory factory )
{
pageHelper.setComponentFactory( factory );
}
/**
* 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.
* @param key the resource bundle key
* @return the translated text
*/
public String translate( String key )
{
return pageHelper.translate( key );
}
//--End of Attribute Methods--------------------------------------------------
//--Start of MessageBox methods-----------------------------------------------
/**
* Shows a modal message box. The dialog is displayed in such a way that it
* does not trigger a focus change event.
* @param title the message dialog title
* @param msg the text of the message
*/
public void showMessage( String title, String msg )
{
pageHelper.showMessage( title, msg );
}
/**
* Shows a modal message box. The dialog is displayed in such a way that it
* does not trigger a focus change event.
* @param parent the message dialog parent
* @param title the message dialog title
* @param msg the text of the message
*/
public void showMessage( Object parent, String title, String msg )
{
pageHelper.showMessage( parent, title, msg );
}
//--End of MessageBox methods-------------------------------------------------
//--Start of PageManager proxy methods----------------------------------------
/**
* Load and show a page.
* @param className The name, without package info, of the page to be displayed
* @return the page being displayed
*/
public PageSupport showPage( String className )
{
return pageMgr.showPage( className, null );
}
/**
* 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.
* @param className The name, without package info, of the page to be displayed
* @param target the area to update
* @return the page being displayed
*/
public PageSupport showPage( String className, String target )
{
return pageMgr.showPage( className, target );
}
/**
* Show the previously displayed page. Although the method works with framesets
* the page history applies only to the main content area.
* @return The previous XPage
*/
public PageSupport showPrevious()
{
return pageMgr.showPrevious();
}
//--End of PageManager proxy methods------------------------------------------
/**
* A bare interface used to distinguish dialogs from normal pages and checked
* by the PageManager when loading pages
*/
public interface IXDialog
{
}
}