incubator.net.xoetrope.xui
Class XApplicationContext

java.lang.Object
  extended by incubator.net.xoetrope.xui.XApplicationContext
All Implemented Interfaces:
java.awt.event.WindowListener, java.util.EventListener, XPageDisplay

public class XApplicationContext
extends java.lang.Object

    
implements XPageDisplay, java.awt.event.WindowListener

    


Field Summary
protected  boolean bUseWindow
          true if a popup window is in use
protected  int clientHeight
          The height of the client area
protected  int clientWidth
          The width of the client area
protected  java.lang.Class defaultSourceClass
          The default model data source class
protected  XDataSource modelDataSource
          The model data source
protected  XPageManager pageMgr
          The page manager
protected  XStartupObject startupObject
          The Applet/Application/Startup instance
 
Constructor Summary
XApplicationContext(XStartupObject startObject, java.lang.String[] args)
          A default constructor.
XApplicationContext(XStartupObject startObject, java.lang.String defTargetClass, java.lang.String[] args)
          A default constructor.
 
Method Summary
protected  void addShutdownHook()
           
 XContentHolder addTarget(java.lang.String name, java.lang.Object constraint, int preferredWidth, int preferredHeight, java.util.Hashtable params)
          Add a new frame or target area to a frameset
 java.lang.Object displayPage(PageSupport page)
          Called when a page has been added or shown via the XPageManager.
 java.lang.Object displayPage(PageSupport pageObj, java.lang.String target)
          Called when a page has been added or shown via the XPageManager.
 java.lang.Object findTarget(java.lang.String target)
          Finds the target area for a page display request, this only applies to a frameset.
 int getClientHeight()
          Get the height of the main window.
 int getClientWidth()
          Get the width of the main window.
 int getNumTargets()
          Get the number of targets in the container
protected  XPageLoader getSecondaryClassLoader(java.lang.String packageName)
          Construct a new builder and set the default package.
 java.lang.Object getTarget(int idx)
          Get the target for a page display request.
 void hidePage(XPage page)
          Remove the page from container.
 void init()
          Invoked when used as an applet.
protected  void initialise()
          Generic function which is called from the constructor if it's an application or from start if its an applet.
protected  void register()
          Load the componentFactories by reading the factory names from the startup file.
 void removeAllTargets()
          Remove all frames/targets from the current frameset
protected  void setContent()
          Load the content into the model.
 void setDefaultDataSource(java.lang.String className)
          Sets the default datasource class.
 void setDefaultTargetClass(java.lang.String clsName)
          Set the name of the default target class
 void setHome()
          Set the home page using the startup properties.
protected  void setResourceFile(java.lang.String startFile)
          Setup the default resource file for the application and load some of the information in it.
protected  void setup(java.lang.String[] args)
          Setup the applet by setting paths and then initializing the applet.
 void windowActivated(java.awt.event.WindowEvent e)
          Template method, unused at present
 void windowClosed(java.awt.event.WindowEvent e)
          Template method, unused at present
 void windowClosing(java.awt.event.WindowEvent e)
          Exit the application
 void windowDeactivated(java.awt.event.WindowEvent e)
          Template method, unused at present
 void windowDeiconified(java.awt.event.WindowEvent e)
          Template method, unused at present
 void windowIconified(java.awt.event.WindowEvent e)
          Template method, unused at present
 void windowOpened(java.awt.event.WindowEvent e)
          Template method, unused at present
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pageMgr

protected XPageManager pageMgr
The page manager


bUseWindow

protected boolean bUseWindow
true if a popup window is in use


modelDataSource

protected XDataSource modelDataSource
The model data source


defaultSourceClass

protected java.lang.Class defaultSourceClass
The default model data source class


startupObject

protected XStartupObject startupObject
The Applet/Application/Startup instance


clientWidth

protected int clientWidth
The width of the client area


clientHeight

protected int clientHeight
The height of the client area

Constructor Detail

XApplicationContext

public XApplicationContext(XStartupObject startObject,
                           java.lang.String[] args)
A default constructor. Most of the setup work is actually done by the initialize method and is called by the main method or the init method depending on whether or not an application of applet is being launched.


XApplicationContext

public XApplicationContext(XStartupObject startObject,
                           java.lang.String defTargetClass,
                           java.lang.String[] args)
A default constructor. Most of the setup work is actually done by the initialize method and is called by the main method or the init method depending on whether or not an application of applet is being launched.

Method Detail

setup

protected void setup(java.lang.String[] args)
Setup the applet by setting paths and then initializing the applet. This method is a stand-in for the main method, processing the commandline parameters, so that its work is reusable and does not needed to be redone by derived classes. This method should not be called directly by user code.

Parameters:
args - the command line arguments

getSecondaryClassLoader

protected XPageLoader getSecondaryClassLoader(java.lang.String packageName)

Construct a new builder and set the default package. XUI sometimes uses additional class loaders to find the resources needed in a project. By default XUI uses the XuiBuilder class loader to convert XML files to Java classes.

A custom class loader can be referenced in the startup properties file using the 'BuilderClass' property. Once this property has been determined this method will instantiate an instance of that class if necessary.

Parameters:
packageName - the name of the default widget package e.g. net.xoetrope.awt, this is normally defined as a result of choosing the appropriate version of the XApplet class
Returns:
the page (page class instance) loader instance

setDefaultDataSource

public void setDefaultDataSource(java.lang.String className)
Sets the default datasource class. The default data source will be used to provide any initial data for the XModel. Normally this data is static data that will be used to populate things like lists and provide default values.

Parameters:
className - the name of the datasource class e.g. net.xoetrope.data.XDataSource.class, this class reads data from an XML file

setResourceFile

protected void setResourceFile(java.lang.String startFile)
Setup the default resource file for the application and load some of the information in it. The resource file is the startup properties file

Parameters:
startFile - The name of the file to be loaded, by default startup.properties

init

public void init()
Invoked when used as an applet. Sets up the startup file and initialises the application. Reads the applet parameters and calls initialize.


initialise

protected void initialise()

Generic function which is called from the constructor if it's an application or from start if its an applet.

The initialization process proceeds in the following order
  1. Register the component factories
  2. Setup the project class
  3. Setup the page manager
  4. Setup the resource manager
  5. Setup the style manager
  6. Size the main window
  7. Set the layout
  8. Add a shutdown hook
  9. Display the main window
the style manager


addShutdownHook

protected void addShutdownHook()

register

protected void register()
Load the componentFactories by reading the factory names from the startup file. The value of the 'NumComponentFactories' is first read and then the value of ComponentFactory (i.e. ComponentFactory0, ComponentFactory1) where is the number, starting at zero, of the factory. Each factory is then instantiated and will be called upon to construct components in the order in which the factories were registered.


setContent

protected void setContent()
Load the content into the model. In the process an instance of the default model data source class is instantiated and reads data from a file pointed to by the 'ModelData' startup parameter.


setHome

public void setHome()
Set the home page using the startup properties. The home page is established by combining the two startup properties 'StartPackage' and 'StartClass'. By default 'StartClass' is set to a value of 'home. Both startup parameters are optional. Load the first page for the application.


displayPage

public java.lang.Object displayPage(PageSupport page)
Called when a page has been added or shown via the XPageManager. The page manager then requests that the applet/application then displays the page in the appropriate location.

Specified by:
displayPage in interface XPageDisplay
Parameters:
page - The XPage which has been loaded.
Returns:
the page being displayed

displayPage

public java.lang.Object displayPage(PageSupport pageObj,
                                    java.lang.String target)

Called when a page has been added or shown via the XPageManager. The page manager then requests that the applet/application then displays the page in the appropriate location.

The sequence with which the page transition occurs is as follows: