com.retek.commons.gui.core
Class WidgetManager

java.lang.Object
  extended bycom.retek.commons.gui.core.WidgetManager
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.KeyListener, java.beans.PropertyChangeListener

public class WidgetManager
extends java.lang.Object
implements java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.event.ItemListener, java.awt.event.ActionListener, java.beans.PropertyChangeListener

This class manages all the editable widgets in a particular "component space". It handles monitoring whether or not the widget values have been altered (dirty data), it handles masks, validators, actions triggered by the widgets and error management of non-fatal errors.

Retek Inc. Copyright (c) 2002


Field Summary
static java.lang.String DOWN_NAV
           
static java.lang.String LEFT_NAV
           
static java.lang.String RIGHT_NAV
           
static java.lang.String UP_NAV
           
static java.lang.String WIDGET_HAS_DATA
           
static java.lang.String WIDGET_IS_EMPTY
           
 
Constructor Summary
WidgetManager()
          Returns new WidgetManager object.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Implements the action listener interface method.
 void addWidgetManager(WidgetManager manager)
          Adds a child WidgetManager to this monitor.
static java.lang.String buildName(java.lang.String widgetName, int index)
          Constructs a widget name from a widget name and counter index.
 void clearAllExceptions()
          Clears all messages from the message map and releases all components from error state.
 void clearBusinessExceptions()
          Clears all messages from the message map and releases all business exceptions.
 void clearPrimaryException()
          Clears the primary exception.
 void clearUIExceptions()
          Clears all messages from the message map and releases all GUI exceptions.
 void clearWidgetHistory()
          Clears the widget history of all stored values.
 void displayException(BusinessException exception, RetekLogger logger)
          Displays an entire business exception, highlighting all the appropriate fields and display the appropriate error message.
 void displayException(UiBusinessException exception, RetekLogger logger)
          Displays an entire business exception, highlighting all the appropriate fields and display the appropriate error message.
 void focusGained(java.awt.event.FocusEvent event)
          Method called when focus is gained on a registered test field.
 void focusLost(java.awt.event.FocusEvent event)
          Whenever a registered widget looses focus, this method determines which widget and calls the appropriate focusLost method.
 RStatusBar getStatusBar()
          Gets the status bar the widget manager is using.
 boolean hasAnyExceptions()
          Retrieves whether or not the widget manager or any of its child widget managers currently has any widgets that have errors associated with them.
 boolean hasBusinessExceptions()
          Retrieves whether or not the widget manager or any of its child widget managers currently has any business exceptions associated with them.
 boolean hasUIExceptions()
          Retrieves whether or not the widget manager or any of its child widget managers currently has any UI exceptions associated with them.
 boolean isModified()
          Retrieves whether or not the contents of any registered components or those of any child managers have been altered.
 void itemStateChanged(java.awt.event.ItemEvent event)
          Implements the item listener interface method.
 void keyPressed(java.awt.event.KeyEvent event)
          Implements the key listener interface method.
 void keyReleased(java.awt.event.KeyEvent event)
          Implements the key listener interface method.
 void keyTyped(java.awt.event.KeyEvent event)
          Implements the key listener interface method.
protected  void propagateException(UiBusinessException exception)
          Propagates a business exception to children widget managers.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Implementation of the PropertyChangeListener method.
 void register(java.lang.String widgetName, RCheckBox checkBox)
          Registers a check box with the widget manager.
 void register(java.lang.String widgetName, RCheckBox checkBox, boolean monitor)
          Registers a check box with the widget manager.
 void register(java.lang.String widgetName, RComboBox comboBox)
          Registers a combo box with the widget manager.
 void register(java.lang.String widgetName, RComboBox comboBox, boolean monitor)
          Registers a combo box with the widget manager.
 void register(java.lang.String widgetName, RDateField dateField)
          Registers a date field with the widget manager.
 void register(java.lang.String widgetName, RDateField dateField, boolean monitor)
          Registers a date field with the widget manager.
 void register(java.lang.String widgetName, RLabel label)
          Registers a label with the widget manager.
 void register(java.lang.String widgetName, RPasswordField passwordField)
          Registers a password field with the widget manager.
 void register(java.lang.String widgetName, RPasswordField passwordField, boolean monitor)
          Registers a password field with the widget manager.
 void register(java.lang.String widgetName, RRadioButton radioButton)
          Registers a radio button with the widget manager.
 void register(java.lang.String widgetName, RRadioButton radioButton, boolean monitor)
          Registers a radio button with the widget manager.
 void register(java.lang.String widgetName, RTextArea textArea)
          Registers a text area with the widget manager.
 void register(java.lang.String widgetName, RTextArea textArea, boolean monitor)
          Registers a text area with the widget manager.
 void register(java.lang.String widgetName, RTextField textField)
          Registers a text field with the widget manager.
 void register(java.lang.String widgetName, RTextField textField, boolean monitor)
          Registers a text field with the widget manager.
 void registerAction(java.lang.String widgetName, REventListener listener, java.lang.String command)
          Registers a command to be received as an RActionEvent for the particular widget.
 void registerCluster(java.lang.String clusterName, java.lang.String widgetName)
          Registers a widget as part of a cluster
 void registerEntryAction(java.lang.String widgetName, REventListener listener, java.lang.String command)
          Registers a command to be received as an RActionEvent for the particular widget.
 void registerKeyAction(java.lang.String widgetName, REventListener listener)
          Registers to receive actions from a widget when keystrokes occur in the widget.
 void registerMask(java.lang.String widgetName, Mask mask)
          Registers a format mask for a particular widget name.
 void registerValidator(java.lang.String widgetName, FormatValidator validator)
          Registers a format validator for a particular widget.
 void releaseWidget(java.lang.String widgetName)
          Clears a single widgets of errors, releasing it from error state and removing its error message.
 void reregister(java.lang.String widgetName, javax.swing.JComponent component)
          Reregisters a component name with the widget manager without altering any of the other values.
 void setActionsEnabled(boolean enabled)
          Enables or disables the action triggers in the widget manager.
static void setFieldSizesBundle(RPropertyBundle newFieldSizes)
          Sets the fields sizes bundle to be used by all widget managers.
 void setModified(boolean modified)
          Explicitly sets the state of the WidgetManager.
 void setMonitorEnabled(boolean enabled)
          Enables or disables the monitor part of the widget manager that tracks the modification of widget contents.
 void setNavigationEnabled(boolean enabled)
          Enables or disables the navigation functionality of the widget manager.
 void setStatusBar(RStatusBar statusBar)
          Sets the status bar for the widget manager to use (otherwise it uses its own).
 void unregister(java.lang.String widgetName)
          Removes a widget and all other registered information from the widget manager.
 void unregisterAction(java.lang.String widgetName)
          Removes a previous action from the widget manager.
 void unregisterEntryAction(java.lang.String widgetName)
          Removes a previous entry action from the widget manager.
 void unregisterKeyAction(java.lang.String widgetName)
          Removes a previous key action from the widget manager.
 void unregisterValidator(java.lang.String widgetName)
          Removes a previous validator from the widget manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UP_NAV

public static final java.lang.String UP_NAV
See Also:
Constant Field Values

DOWN_NAV

public static final java.lang.String DOWN_NAV
See Also:
Constant Field Values

LEFT_NAV

public static final java.lang.String LEFT_NAV
See Also:
Constant Field Values

RIGHT_NAV

public static final java.lang.String RIGHT_NAV
See Also:
Constant Field Values

WIDGET_IS_EMPTY

public static final java.lang.String WIDGET_IS_EMPTY
See Also:
Constant Field Values

WIDGET_HAS_DATA

public static final java.lang.String WIDGET_HAS_DATA
See Also:
Constant Field Values
Constructor Detail

WidgetManager

public WidgetManager()
Returns new WidgetManager object.

Method Detail

setFieldSizesBundle

public static void setFieldSizesBundle(RPropertyBundle newFieldSizes)
Sets the fields sizes bundle to be used by all widget managers.


setStatusBar

public void setStatusBar(RStatusBar statusBar)
Sets the status bar for the widget manager to use (otherwise it uses its own).

Parameters:
statusBar - A status bar.

getStatusBar

public RStatusBar getStatusBar()
Gets the status bar the widget manager is using.

Returns:
A status bar.

register

public void register(java.lang.String widgetName,
                     RTextField textField)
Registers a text field with the widget manager. This text field will be monitored for value changes by using a key listener.

Parameters:
widgetName - The name to assign to the text field.
textField - The text field to be registered.

register

public void register(java.lang.String widgetName,
                     RTextField textField,
                     boolean monitor)
Registers a text field with the widget manager. This text field will be monitored for value changes by using a key listener.

Parameters:
widgetName - The name to assign to the text field.
textField - The text field to be registered.
monitor - True if the field should be monitored for changes, false if not.

register

public void register(java.lang.String widgetName,
                     RDateField dateField)
Registers a date field with the widget manager. This date field will be monitored for value changes by using a key listener.

Parameters:
widgetName - The name to assign to the date field.
dateField - The text field to be registered.

register

public void register(java.lang.String widgetName,
                     RDateField dateField,
                     boolean monitor)
Registers a date field with the widget manager. This date field will be monitored for value changes by using a key listener.

Parameters:
widgetName - The name to assign to the date field.
dateField - The text field to be registered.
monitor - True if the field should be monitored for changes, false if not.

register

public void register(java.lang.String widgetName,
                     RPasswordField passwordField)
Registers a password field with the widget manager. This password field will be monitored for value changes by using a key listener.

Parameters:
widgetName - The name to assign to the password field.
passwordField - The password field to be registered.

register

public void register(java.lang.String widgetName,
                     RPasswordField passwordField,
                     boolean monitor)
Registers a password field with the widget manager. This password field will be monitored for value changes by using a key listener.

Parameters:
widgetName - The name to assign to the password field.
passwordField - The password field to be registered.
monitor - True if the field should be monitored for changes, false if not.

register

public void register(java.lang.String widgetName,
                     RTextArea textArea)
Registers a text area with the widget manager. This text area will be monitored for value changes by using a key listener.

Parameters:
widgetName - The name to assign to the text area.
textArea - The text area to be registered.

register

public void register(java.lang.String widgetName,
                     RTextArea textArea,
                     boolean monitor)
Registers a text area with the widget manager. This text area will be monitored for value changes by using a key listener.

Parameters:
widgetName - The name to assign to the text area.
textArea - The text area to be registered.

register

public void register(java.lang.String widgetName,
                     RComboBox comboBox)
Registers a combo box with the widget manager. This combo box will be monitored for value changes by using an item listener.

Parameters:
widgetName - The name to assign to the combo box.
comboBox - The combo box to be registered.

register

public void register(java.lang.String widgetName,
                     RComboBox comboBox,
                     boolean monitor)
Registers a combo box with the widget manager. This combo box will be monitored for value changes by using an item listener.

Parameters:
widgetName - The name to assign to the combo box.
comboBox - The combo box to be registered.

register

public void register(java.lang.String widgetName,
                     RCheckBox checkBox)
Registers a check box with the widget manager. This check box will be monitored for value changes by using an item listener.

Parameters:
widgetName - The name to assign to the check box.
checkBox - The check box to be registered.

register

public void register(java.lang.String widgetName,
                     RCheckBox checkBox,
                     boolean monitor)
Registers a check box with the widget manager. This check box will be monitored for value changes by using an item listener.

Parameters:
widgetName - The name to assign to the check box.
checkBox - The check box to be registered.

register

public void register(java.lang.String widgetName,
                     RRadioButton radioButton)
Registers a radio button with the widget manager. This radio button will be monitored for value changes by using an item listener.

Parameters:
widgetName - The name to assign to the radio button.
radioButton - The radio button to be registered.

register

public void register(java.lang.String widgetName,
                     RRadioButton radioButton,
                     boolean monitor)
Registers a radio button with the widget manager. This radio button will be monitored for value changes by using an item listener.

Parameters:
widgetName - The name to assign to the radio button.
radioButton - The radio button to be registered.

register

public void register(java.lang.String widgetName,
                     RLabel label)
Registers a label with the widget manager. This is only used if a label matches a check box but is not actually the check box label supplied by JCheckBox. This allows highlighting of the check box label when errors occur. Use the same widget name as check box for correct functionality.

Parameters:
widgetName - The name to assign to the label.
label - The label to be registered.

unregister

public void unregister(java.lang.String widgetName)
Removes a widget and all other registered information from the widget manager.

Parameters:
widgetName - The name of the widget to remove.

reregister

public void reregister(java.lang.String widgetName,
                       javax.swing.JComponent component)
Reregisters a component name with the widget manager without altering any of the other values.

Parameters:
widgetName - The new name of the widget.

registerCluster

public void registerCluster(java.lang.String clusterName,
                            java.lang.String widgetName)
Registers a widget as part of a cluster

Parameters:
clusterName - The full cluster name

registerMask

public void registerMask(java.lang.String widgetName,
                         Mask mask)
Registers a format mask for a particular widget name.

Parameters:
widgetName - The widget name.
mask - The mask to assign to the widget.
Throws:
java.lang.IllegalArgumentException - Thrown if the specific group and name has not been registered.

registerValidator

public void registerValidator(java.lang.String widgetName,
                              FormatValidator validator)
Registers a format validator for a particular widget.

Parameters:
widgetName - The widget name.
validator - The validator to assign to the widget name.

registerAction

public void registerAction(java.lang.String widgetName,
                           REventListener listener,
                           java.lang.String command)
Registers a command to be received as an RActionEvent for the particular widget. This command is only triggered when the widget looses focus and its value has been changed.

Parameters:
widgetName - The widget name.
listener - The object that should receive the RActionEvent.
command - The command to receive inside RActionEvent.

unregisterAction

public void unregisterAction(java.lang.String widgetName)
Removes a previous action from the widget manager. An action will no longer be triggered for this widget.

Parameters:
widgetName - The widget name.

unregisterValidator

public void unregisterValidator(java.lang.String widgetName)
Removes a previous validator from the widget manager.

Parameters:
widgetName - The widget name.

registerEntryAction

public void registerEntryAction(java.lang.String widgetName,
                                REventListener listener,
                                java.lang.String command)
Registers a command to be received as an RActionEvent for the particular widget. This command is only triggered when the widget gains focus and its value has been changed.

Parameters:
widgetName - The widget name.
listener - The object that should receive the RActionEvent.
command - The command to receive inside RActionEvent.

unregisterEntryAction

public void unregisterEntryAction(java.lang.String widgetName)
Removes a previous entry action from the widget manager. An action will no longer be triggered for this widget.

Parameters:
widgetName - The widget name.

registerKeyAction

public void registerKeyAction(java.lang.String widgetName,
                              REventListener listener)
Registers to receive actions from a widget when keystrokes occur in the widget. This method will only work for subclasses of JTextComponent.

Parameters:
widgetName - The widget name.
listener - The object that should receive the RActionEvent.

unregisterKeyAction

public void unregisterKeyAction(java.lang.String widgetName)
Removes a previous key action from the widget manager. An action will no longer be triggered for this widget when keys are pressed.

Parameters:
widgetName - The widget name.

buildName

public static java.lang.String buildName(java.lang.String widgetName,
                                         int index)
Constructs a widget name from a widget name and counter index. This is used to create unique names when multiple widget names need to be used in the same component space.

Parameters:
widgetName - The widget name.
index - The index of the particular group (if more than one identical grouping).
Returns:
The widget name.

addWidgetManager

public void addWidgetManager(WidgetManager manager)
Adds a child WidgetManager to this monitor.


setNavigationEnabled

public void setNavigationEnabled(boolean enabled)
Enables or disables the navigation functionality of the widget manager. If true, the widget manager will send out all navigation keystrokes as actions.

Parameters:
enabled - True if the navigation should be enabled, false if not.

setActionsEnabled

public void setActionsEnabled(boolean enabled)
Enables or disables the action triggers in the widget manager.

Parameters:
enabled - True if the actions should be sent, false if they should be ignored.

setMonitorEnabled

public void setMonitorEnabled(boolean enabled)
Enables or disables the monitor part of the widget manager that tracks the modification of widget contents.

Parameters:
enabled - True if the monitor should be active, false if not.

setModified

public void setModified(boolean modified)
Explicitly sets the state of the WidgetManager. If true, the contents of the the widgets being monitored are considered altered. If false, then the state is reset in the widget manager and all children widget managers.

Parameters:
modified - True is the widget contents are altered, false if not.

isModified

public boolean isModified()
Retrieves whether or not the contents of any registered components or those of any child managers have been altered.

Returns:
True if the contents of any components have been altered, false if not.

keyPressed

public void keyPressed(java.awt.event.KeyEvent event)
Implements the key listener interface method. This empty implementation satisfies the listener interface requirement.

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
event - Details about the key event that has occurred.

keyTyped

public void keyTyped(java.awt.event.KeyEvent event)
Implements the key listener interface method. If a key is typed in a monitored field, the state of the monitor is set to "modified".

Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
event - Details about the key event that has occurred.

keyReleased

public void keyReleased(java.awt.event.KeyEvent event)
Implements the key listener interface method. If the released keystroke is a DELETE key, the state of the monitor is set to modified. Special functions are not delived to the keyTyped() method.

Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
event - Details about the key event that has occurred.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Implementation of the PropertyChangeListener method. Whenever the date field gains or looses focus it sends out a property change notification.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - Details about the PropertyChangeEvent.

focusGained

public void focusGained(java.awt.event.FocusEvent event)
Method called when focus is gained on a registered test field. It stores the value currently in the field so that it can tell if it has been modified later. It examines the message map to determine if an error should be displayed.

Specified by:
focusGained in interface java.awt.event.FocusListener
Parameters:
event - Details about the focus event that has occurred.

focusLost

public void focusLost(java.awt.event.FocusEvent event)
Whenever a registered widget looses focus, this method determines which widget and calls the appropriate focusLost method.

Specified by:
focusLost in interface java.awt.event.FocusListener
Parameters:
event - Details about the focus event that occurred.

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent event)
Implements the item listener interface method. This method sets the modified state of the screen to true whenever it is triggered. Trigger appropriate action if an action has been registered.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
event - Details about the item event that has occurred.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Implements the action listener interface method. This method sets the modified state of the screen to true whenever it is triggered. Trigger appropriate action if an action has been registered.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - Details about the action event that has occurred.

clearWidgetHistory

public void clearWidgetHistory()
Clears the widget history of all stored values.


releaseWidget

public void releaseWidget(java.lang.String widgetName)
Clears a single widgets of errors, releasing it from error state and removing its error message.

Parameters:
widgetName - The widget name of the component to clear.

displayException

public void displayException(BusinessException exception,
                             RetekLogger logger)
Displays an entire business exception, highlighting all the appropriate fields and display the appropriate error message. This exception is sent to each child widget manager until all widgets have been found and highlighted.

Parameters:
exception - The business exception to display.

displayException

public void displayException(UiBusinessException exception,
                             RetekLogger logger)
Displays an entire business exception, highlighting all the appropriate fields and display the appropriate error message. This exception is sent to each child widget manager until all widgets have been found and highlighted.

Parameters:
exception - The business exception to display.

propagateException

protected void propagateException(UiBusinessException exception)
Propagates a business exception to children widget managers. This is a cleaner implementation that guarantees that children do not receive the primary message.

Parameters:
exception - The business exception to propagage.

hasAnyExceptions

public boolean hasAnyExceptions()
Retrieves whether or not the widget manager or any of its child widget managers currently has any widgets that have errors associated with them.


hasBusinessExceptions

public boolean hasBusinessExceptions()
Retrieves whether or not the widget manager or any of its child widget managers currently has any business exceptions associated with them.


hasUIExceptions

public boolean hasUIExceptions()
Retrieves whether or not the widget manager or any of its child widget managers currently has any UI exceptions associated with them.


clearPrimaryException

public void clearPrimaryException()
Clears the primary exception.


clearAllExceptions

public void clearAllExceptions()
Clears all messages from the message map and releases all components from error state.


clearBusinessExceptions

public void clearBusinessExceptions()
Clears all messages from the message map and releases all business exceptions.


clearUIExceptions

public void clearUIExceptions()
Clears all messages from the message map and releases all GUI exceptions.



Copyright © 2005 Retek Inc. All Rights Reserved. - Generated at Fri, 01/21/2005 14:25