creamtec.webcream.gui
Class WindowUpdater

java.lang.Object
  extended by creamtec.webcream.gui.WindowUpdater
All Implemented Interfaces:
ActionEmulator

public class WindowUpdater
extends java.lang.Object
implements ActionEmulator

Used to update GUI windows with the data, received from HTTP request. If there is an action to be emulated, WindowUpdater handles it


Constructor Summary
WindowUpdater(ClientAgent agent)
          Creates window updater for the given client agent
 
Method Summary
 boolean actionOverridden(HTMLPage page, ActionData actionData)
          Returns true if this action is overidden by a configuration property
static void checkActionOperation(HTMLPage page, java.lang.String key)
          Checks if an operation is configured for this action, and if it is, calls ClientAgent.beginOperation().
 boolean defaultEmulateAction(HTMLPage page, ActionData actionData)
          The default emulation logic that is executed if no custom action processors claimed the responsibility for the action.
 boolean emulateAction(HTMLPage page, ActionData actionData)
          Emulates an action such as a button click, menu item selection or tabbed pane selection change.
 void emulateRequest(HTMLPage page, HttpRequestData data)
          Emulates HTTP request.
static java.lang.String getButtonKeyName(java.lang.Object button)
          Format of the key is: window.Window_Title.button.button_text
static java.lang.String getComponentClassName(java.lang.Object obj)
          Returns component class name without the package name
static java.lang.String getComponentName(java.lang.Object obj)
          Needed for components that must be accessible outside the context of HTMLPage
 ComponentUpdater getComponentUpdater(java.lang.String className)
          Returns the component updater for the given class name If a custom component updater is not registered for the given class, a default one is returned
 ComponentUpdater getDefaultComponentUpdater()
          Returns the default component updater that implements the default logic of component processing and updating in WebCream.
static java.lang.String getItemString(java.lang.Object item)
          Converts the item object to the proper stringified representation.
static java.lang.String getMenuItemKeyName(java.lang.String actionString)
          Format of the key is: window.Window_Title.menu.SubMenuIndex.MenuItemIndex.action
 void initCustomUpdatersAndEmulators(ClientAgent agent)
          Loads custom updaters from the application properties file.
 void registerActionEmulator(ActionEmulator emulator)
          Registers action emulator for all actions
 void registerActionEmulator(ActionEmulator emulator, java.lang.String windowFilter)
          Registers action emulator for windows whose title matches the specified filter string
 void resizeWindow(java.awt.Window window, java.lang.String resizeString, HTMLPage page)
          Resize string should follow the format "resize:width,height"
 void unregisterActionEmulator(ActionEmulator emulator)
          Removes the registration of action emulator
 void updateComponentTreeData(java.awt.Component comp, HttpRequestData data, ActionData actionData)
          Updates components of the given window with the data
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WindowUpdater

public WindowUpdater(ClientAgent agent)
Creates window updater for the given client agent

Parameters:
agent - ClientAgent
Method Detail

getComponentUpdater

public ComponentUpdater getComponentUpdater(java.lang.String className)
Returns the component updater for the given class name If a custom component updater is not registered for the given class, a default one is returned

Parameters:
className - fully qualified name of the class such as javax.swing.JButton
Returns:
ComponentUpdater

initCustomUpdatersAndEmulators

public void initCustomUpdatersAndEmulators(ClientAgent agent)
Loads custom updaters from the application properties file. Iterates the keys that start with "updater." and tries to load the class given as the key value. If loaded, the class is added to the component renderers map.


getDefaultComponentUpdater

public ComponentUpdater getDefaultComponentUpdater()
Returns the default component updater that implements the default logic of component processing and updating in WebCream. Can be used for delegation from custom updaters

Returns:
ComponentUpdater

registerActionEmulator

public void registerActionEmulator(ActionEmulator emulator)
Registers action emulator for all actions

Parameters:
emulator - ActionEmulator

registerActionEmulator

public void registerActionEmulator(ActionEmulator emulator,
                                   java.lang.String windowFilter)
Registers action emulator for windows whose title matches the specified filter string

Parameters:
emulator - ActionEmulator
windowFilter - the filter string, which can contain text and "*" to specify any text.

unregisterActionEmulator

public void unregisterActionEmulator(ActionEmulator emulator)
Removes the registration of action emulator

Parameters:
emulator - ActionEmulator

emulateRequest

public void emulateRequest(HTMLPage page,
                           HttpRequestData data)
                    throws java.lang.Exception
Emulates HTTP request. Depending on the type of the request, the window may be updated with data and an action can be processed.

Parameters:
page - HTMLPage
data - HttpRequestData
Throws:
java.lang.Exception

emulateAction

public boolean emulateAction(HTMLPage page,
                             ActionData actionData)
                      throws java.lang.Exception
Emulates an action such as a button click, menu item selection or tabbed pane selection change.

Specified by:
emulateAction in interface ActionEmulator
Parameters:
page - HTMLPage
actionData - ActionData
Returns:
boolean true if the action has been processed
Throws:
java.lang.Exception

actionOverridden

public boolean actionOverridden(HTMLPage page,
                                ActionData actionData)
                         throws java.lang.Exception
Returns true if this action is overidden by a configuration property

Parameters:
page - HTMLPage
actionData - ActionData
Returns:
boolean
Throws:
java.lang.Exception

defaultEmulateAction

public boolean defaultEmulateAction(HTMLPage page,
                                    ActionData actionData)
                             throws java.lang.Exception
The default emulation logic that is executed if no custom action processors claimed the responsibility for the action.

Parameters:
page - HTMLPage
actionData - ActionData
Returns:
boolean
Throws:
java.lang.Exception

checkActionOperation

public static void checkActionOperation(HTMLPage page,
                                        java.lang.String key)
Checks if an operation is configured for this action, and if it is, calls ClientAgent.beginOperation().

Parameters:
page - action key
key - String

updateComponentTreeData

public void updateComponentTreeData(java.awt.Component comp,
                                    HttpRequestData data,
                                    ActionData actionData)
                             throws java.lang.Exception
Updates components of the given window with the data

Parameters:
comp - component to be updated
data - request data
actionData - action parameters
Throws:
java.lang.Exception

resizeWindow

public void resizeWindow(java.awt.Window window,
                         java.lang.String resizeString,
                         HTMLPage page)
                  throws WebCreamException
Resize string should follow the format "resize:width,height"

Throws:
WebCreamException

getComponentClassName

public static java.lang.String getComponentClassName(java.lang.Object obj)
Returns component class name without the package name


getComponentName

public static java.lang.String getComponentName(java.lang.Object obj)
Needed for components that must be accessible outside the context of HTMLPage


getMenuItemKeyName

public static java.lang.String getMenuItemKeyName(java.lang.String actionString)
Format of the key is: window.Window_Title.menu.SubMenuIndex.MenuItemIndex.action

Parameters:
actionString - the action string submitted by the HTML page
Returns:
the key name that can be used to refer to the menu item that triggered this action

getButtonKeyName

public static java.lang.String getButtonKeyName(java.lang.Object button)
Format of the key is: window.Window_Title.button.button_text

Parameters:
button - the button that the key is generated for
Returns:
the key name that can be used to refer to the button

getItemString

public static java.lang.String getItemString(java.lang.Object item)
Converts the item object to the proper stringified representation. For instance, if the object is an instance of File, rather then calling toString() this method uses File.getName()

Parameters:
item - Object
Returns:
String


Copyright © 2000-2006 CreamTec LLC. All Rights Reserved.