net.xoetrope.html
Class XApplet

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by javax.swing.JApplet
                      extended by net.xoetrope.html.XApplet
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer

public class XApplet
extends javax.swing.JApplet

This class is constructed with a window or frame and can be part of an applet or an application. The class acts as the main entry point to an XUI application and provides some of the infrastructure needed to support the application.

The applet can provide support for a frameset or a single page. Page display functions are also supported to allow the application to display more than a single page or change the page that is displayed.

By choosing either the AWT or Swing version of the XApplet you choose to have either an AWT or a Swing application/applet. In general once this choice has been made you should not mix toolkits.

Copyright (c) Xoetrope Ltd., 1998-2004
License: see license.txt

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JApplet
javax.swing.JApplet.AccessibleJApplet
 
Nested classes/interfaces inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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
 
Field Summary
protected  int clientHeight
           
protected  int clientWidth
           
protected static java.lang.Class defaultSourceClass
           
protected  netscape.javascript.JSObject doc
           
protected static int index
           
protected  XDataSource modelDataSource
           
protected  XPageManager pageMgr
           
protected static java.lang.String[][] values
           
protected  netscape.javascript.JSObject win
           
 
Fields inherited from class javax.swing.JApplet
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
XApplet()
           
 
Method Summary
 XContentHolder addTarget(java.lang.String name, java.lang.Object constraint, int preferredWidth, int preferredHeight)
          Add a new frame or target area to a frameset
 void callMethod(java.lang.String methodName)
           
 PageSupport displayPage(PageSupport page)
          Called when a page has been added or shown via the XPageManager.
 PageSupport displayPage(PageSupport pageObj, java.lang.String target)
           Called when a page has been added or shown via the XPageManager.
 XHtmlTarget findTarget(java.lang.String target)
          Finds the target area for a page display request, this only applies to a frameset.
static XApplet getApplet()
           
 int getClientHeight()
          Get the height of the main window.
 int getClientWidth()
          Get the width of the main window.
 XHtmlPage getCurrentPage()
           
 java.net.URL getDocumentBase()
          Template method, unused at present
 java.lang.Object getFrame()
          Gets the Frame containing the applet.
static java.lang.Object getMenuBar()
          Get the menubar.
 int getNumTargets()
          Get the number of target areas in the container
protected  XPageLoader getSecondaryClassLoader(java.lang.String packageName)
           Construct a new builder and set the default package.
 XHtmlTarget getTarget(int idx)
          Get the target for a page display request.
 void hidePage(netscape.javascript.JSObject page)
          Remove the page from container.
 void init()
          Initializes the applet XApplet
protected  void initialise(netscape.javascript.JSObject s)
           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.
protected  void setContent(netscape.javascript.JSObject s)
          Load the content into the model.
static void setDefaultDataSource(java.lang.String className)
          Sets the default datasource class.
 void setHome()
          Set the home page using the startup properties.
static void setMenuBar(java.lang.Object mb)
          Set the menubar.
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 storeValues(java.lang.String id, java.lang.String value)
          Stores the values entered in the edit fields in a static String[][].
 void XApplet()
           
 
Methods inherited from class javax.swing.JApplet
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.applet.Applet
destroy, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

win

protected netscape.javascript.JSObject win

doc

protected netscape.javascript.JSObject doc

pageMgr

protected XPageManager pageMgr

modelDataSource

protected XDataSource modelDataSource

defaultSourceClass

protected static java.lang.Class defaultSourceClass

clientWidth

protected int clientWidth

clientHeight

protected int clientHeight

values

protected static java.lang.String[][] values

index

protected static int index
Constructor Detail

XApplet

public XApplet()
Method Detail

XApplet

public void XApplet()

init

public void init()
Initializes the applet XApplet

Overrides:
init in class java.applet.Applet

callMethod

public void callMethod(java.lang.String methodName)

getCurrentPage

public XHtmlPage getCurrentPage()

storeValues

public void storeValues(java.lang.String id,
                        java.lang.String value)
Stores the values entered in the edit fields in a static String[][].

Parameters:
id - the id of the edit field (MUST be the same as one of the values in the first column of the static String[][]).
value - the value to be saved.

getApplet

public static XApplet getApplet()

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:
frame - the owner frame
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

setDefaultDataSource

public static 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

getFrame

public java.lang.Object getFrame()
Gets the Frame containing the applet.

Returns:
Frame which is the applet or application's parent

initialise

protected void initialise(netscape.javascript.JSObject s)

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

Parameters:
f - The Frame which acts as the parent.
skipReset - Lets the application know whether to skip resetting the style manager

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(netscape.javascript.JSObject s)
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.

Parameters:
f - the frame

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. Loads the first page for the application.


displayPage

public PageSupport 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.

Parameters:
page - The XPage which has been loaded.
Returns:
the page being displayed

displayPage

public PageSupport 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:

  • Find the appropriate target area
  • Ask the page to make its components non visible (to avoid flicker during the page update)
  • Set the page size
  • Save the current page's data by calling 'saveBoundComponentValues
  • Mark the current page as deactivated, and call the page's deactivated() method
  • Remove the old page from the container
  • Add the new page
  • Update the new page's bindings by calling updateBindings()
  • Update the new page's data by calling updateBoundComponentValues()
  • Layout the container and request it to repaint
  • Show the new page
  • Mark the new page as activated, and call its pageActivated method

    Parameters:
    page - The XPage which has been loaded.
    target - the area to update
    Returns:
    the page being displayed

    hidePage

    public void hidePage(netscape.javascript.JSObject page)
    Remove the page from container. The page is simply removed and the container validated.

    Parameters:
    page -

    findTarget

    public XHtmlTarget findTarget(java.lang.String target)
    Finds the target area for a page display request, this only applies to a frameset. If there is no frameset the main area or default area is named 'content' and this area is used if null is used as the target name.

    Parameters:
    target - the target area name
    Returns:
    the container to be updated

    getTarget

    public XHtmlTarget getTarget(int idx)
    Get the target for a page display request. The target areas are stored in the order in which they were declared or added.

    Parameters:
    idx - the target area
    Returns:
    the container to be updated

    getNumTargets

    public int getNumTargets()
    Get the number of target areas in the container


    addTarget

    public XContentHolder addTarget(java.lang.String name,
                                    java.lang.Object constraint,
                                    int preferredWidth,
                                    int preferredHeight)
    Add a new frame or target area to a frameset

    Parameters:
    name - the frame name
    constraint - the BorderlayoutConstraint
    preferredWidth - the preferred width
    preferredHeight - the preferred height
    return - the new target

    getClientWidth

    public int getClientWidth()
    Get the width of the main window.


    getClientHeight

    public int getClientHeight()
    Get the height of the main window.


    setMenuBar

    public static void setMenuBar(java.lang.Object mb)
    Set the menubar.

    Parameters:
    mb -

    getMenuBar

    public static java.lang.Object getMenuBar()
    Get the menubar.


    getDocumentBase

    public java.net.URL getDocumentBase()
    Template method, unused at present

    Overrides:
    getDocumentBase in class java.applet.Applet