bill.util.gui
Class ParentGUI

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--bill.util.gui.ParentGUI
All Implemented Interfaces:
Accessible, GUIUtilInterface, ImageObserver, MenuContainer, RootPaneContainer, Serializable, WindowConstants
Direct Known Subclasses:
ConfigurationGUI, CSVGUI

public class ParentGUI
extends JFrame
implements GUIUtilInterface

"Master" Swing GUI class. Contains things that are common to a typical Swing GUI.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Inner classes inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent
 
Field Summary
protected  ErrorFrame _errorFrame
          The frame of the validation errors window
protected  HelpAboutFrame _helpAbout
          Reference to the help about frame
protected  boolean _highlighting
          Indicates if we are using required field highlighting
protected  Vector _myFrames
          A list of all the frames (sub windows) that are currently active
protected  ParentGUI _parent
          The parent GUI that created this GUI
protected  boolean _wasModified
          Indicates if the GUI has unsaved modifications
static String ACTION_HELP_ABOUT
          The action name for the help->about menu option
static String ACTION_HIGHLIGHT
          The action name for the options->highlight required menu option
static String ACTION_METAL
          The action name for the options->look & feel->metal menu option
static String ACTION_MOTIF
          The action name for the options->look & feel->motif menu option
static String ACTION_TOOLTIP
          The action name for the options->show tool tips menu option
static String ACTION_WINDOWS
          The action name for the options->look & feel->windows menu option
static Color COLOR_NOT_REQUIRED_FIELD
          Color to make required fields' background when required highlighting is not set to on
static Color COLOR_REQUIRED_FIELD
          Color to make required fields' background
static String VALUE_METAL_LF
          Class name of the metal look and feel class
static String VALUE_MOTIF_LF
          Class name of the motif look and feel class
static String VALUE_WINDOWS_LF
          Class name of the windows look and feel class
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ParentGUI(ParentGUI parent, String title)
           
 
Method Summary
 void addFrame(JFrame frame)
          Add another frame to the list of frames that we care about.
 void addFrameClosing(JFrame frame)
          Called when a frame that was created to add data is being closed.
 void addFrameClosing(JFrame frame, boolean cancelled)
          Called when a frame that was created to add data is being closed.
 void closeDown()
          Frees up all resources used by this instance of the GUI and notifies the ParentGUI that launched us that we are closing down.
 String getDataFileName(String[] extensions, String filterDesc, boolean open)
          Creates and processes a file selection dialog to allow the user to indicate a data file to read or write.
 String getDataFileName(String[] extensions, String filterDesc, boolean open, String directory)
          Creates and processes a file selection dialog to allow the user to indicate a data file to read or write.
 ErrorFrame getErrorFrame()
          Retrieves a reference to the application's error frame.
 Configuration getGUIConfig()
          Getter for the GUI configuration file.
 HelpAboutFrame getHelpAboutFrame()
          Retrieves a reference to the application's help about frame.
 ParentGUI getParentWindow()
          Getter for the ParentGUI that created this GUI.
 boolean isHighlighting()
          Checks to see if required field highlighting has been requested.
 boolean isModified()
          Checks to see if the this GUI's data defined has been modified since it was last saved.
 boolean isToolTips()
          Checks to see if the user has indicated a desire to see tooltips.
protected  void propagateHighlighting(boolean display)
          Tells all the current open frames that they should either highlight or not highlinght required fields.
protected  void propagateToolTipDisplay(boolean display)
          Tells all the current open frames that they should either start or stop showing tool tips.
 void removeFrame(JFrame frame)
          Remove a frame from the list of frames that we care about.
 void setCursor(Cursor cursor)
          Sets the cursor image to the specified cursor.
 void setErrorFrame(ErrorFrame error)
          Sets the reference to the application's error frame.
 void setGUIConfig(Configuration config)
          Setter for the GUI configuration file.
 void setHelpAboutFrame(HelpAboutFrame help)
          Sets the reference to the application's help about frame.
 void setHighlighting(boolean highlight)
          Sets the highlighting indicator as indicated.
 void setModified(boolean modified)
          Sets the modification indicator as indicated.
 void setToolTips(boolean toolTips)
          Sets the tool tips indicator as indicated.
protected  void updateLookAndFeel(String lookFeel)
          Updates the look and feel of the GUI frames we know about.
 boolean verifyUnsavedChanges()
          Verifies that there are no unsaved changes, or if there are, if the user wants to discard them.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

ACTION_HIGHLIGHT

public static String ACTION_HIGHLIGHT
The action name for the options->highlight required menu option

ACTION_TOOLTIP

public static String ACTION_TOOLTIP
The action name for the options->show tool tips menu option

ACTION_HELP_ABOUT

public static String ACTION_HELP_ABOUT
The action name for the help->about menu option

ACTION_METAL

public static String ACTION_METAL
The action name for the options->look & feel->metal menu option

ACTION_MOTIF

public static String ACTION_MOTIF
The action name for the options->look & feel->motif menu option

ACTION_WINDOWS

public static String ACTION_WINDOWS
The action name for the options->look & feel->windows menu option

COLOR_REQUIRED_FIELD

public static Color COLOR_REQUIRED_FIELD
Color to make required fields' background

COLOR_NOT_REQUIRED_FIELD

public static Color COLOR_NOT_REQUIRED_FIELD
Color to make required fields' background when required highlighting is not set to on

VALUE_METAL_LF

public static String VALUE_METAL_LF
Class name of the metal look and feel class

VALUE_MOTIF_LF

public static String VALUE_MOTIF_LF
Class name of the motif look and feel class

VALUE_WINDOWS_LF

public static String VALUE_WINDOWS_LF
Class name of the windows look and feel class

_helpAbout

protected HelpAboutFrame _helpAbout
Reference to the help about frame

_errorFrame

protected ErrorFrame _errorFrame
The frame of the validation errors window

_wasModified

protected boolean _wasModified
Indicates if the GUI has unsaved modifications

_highlighting

protected boolean _highlighting
Indicates if we are using required field highlighting

_myFrames

protected Vector _myFrames
A list of all the frames (sub windows) that are currently active

_parent

protected ParentGUI _parent
The parent GUI that created this GUI
Constructor Detail

ParentGUI

public ParentGUI(ParentGUI parent,
                 String title)
Method Detail

getParentWindow

public ParentGUI getParentWindow()
Getter for the ParentGUI that created this GUI.
Returns:
Reference to the ParentGUI, or null if this GUI was started independently.

getHelpAboutFrame

public HelpAboutFrame getHelpAboutFrame()
Retrieves a reference to the application's help about frame.
Returns:
The error frame reference.

getErrorFrame

public ErrorFrame getErrorFrame()
Retrieves a reference to the application's error frame.
Returns:
The error frame reference.

isModified

public boolean isModified()
Checks to see if the this GUI's data defined has been modified since it was last saved.
Returns:
true if the data has been modified, false otherwise.

isHighlighting

public boolean isHighlighting()
Checks to see if required field highlighting has been requested.
Specified by:
isHighlighting in interface GUIUtilInterface
Returns:
true if the highlighting has been requested, false otherwise.

isToolTips

public boolean isToolTips()
Checks to see if the user has indicated a desire to see tooltips. If they have then the GUI displays "hover help".
Specified by:
isToolTips in interface GUIUtilInterface
Returns:
true if tool tips have been requested, false otherwise.

setModified

public void setModified(boolean modified)
Sets the modification indicator as indicated. This indicator is used to signal whether the GUI's data defined here has been changed since the last save occurred.
Parameters:
modified - The value to set the modification indicator to.

setHighlighting

public void setHighlighting(boolean highlight)
Sets the highlighting indicator as indicated. This indicator is used to signal whether required fields should be visually highlighted.
Parameters:
highlight - The value to set the highlighting indicator to.

setToolTips

public void setToolTips(boolean toolTips)
Sets the tool tips indicator as indicated. This indicator is used to signal whether "hover help" is being displayed to the user.
Parameters:
using - The value to set the tool tip display indicator to.

getGUIConfig

public Configuration getGUIConfig()
Getter for the GUI configuration file.
Returns:
Reference to the GUI configuration file.

setGUIConfig

public void setGUIConfig(Configuration config)
Setter for the GUI configuration file.
Parameters:
config - Reference to the new GUI configuration file.

addFrame

public void addFrame(JFrame frame)
Add another frame to the list of frames that we care about. This list of frames is used for correctly setting their look and feel.
Parameters:
frame - The frame being added to the list.

setErrorFrame

public void setErrorFrame(ErrorFrame error)
Sets the reference to the application's error frame.
Parameters:
error - The error frame reference.

setHelpAboutFrame

public void setHelpAboutFrame(HelpAboutFrame help)
Sets the reference to the application's help about frame.
Parameters:
help - The help about frame reference.

setCursor

public void setCursor(Cursor cursor)
Sets the cursor image to the specified cursor. The cursor is changed for the current frame and all the currently active child frames.
Overrides:
setCursor in class Window
Parameters:
cursor - One of the constants defined by the Cursor class. If this parameter is null then this component will inherit the cursor of its parent.

removeFrame

public void removeFrame(JFrame frame)
Remove a frame from the list of frames that we care about. This list of frames is used for correctly setting their look and feel.
Parameters:
frame - The frame being removed to the list.

addFrameClosing

public void addFrameClosing(JFrame frame)
Called when a frame that was created to add data is being closed. An example of this would be an AddKeyValueFrame object. If a subclass of ParentGUI wants to perform additional logic beyond removing the closed JFrame from the list of frames we are tracking, they should overload this method.
Specified by:
addFrameClosing in interface GUIUtilInterface
Parameters:
frame - The JFrame that is being closed.

addFrameClosing

public void addFrameClosing(JFrame frame,
                            boolean cancelled)
Called when a frame that was created to add data is being closed. An example of this would be an AddKeyValueFrame object. If a subclass of ParentGUI wants to perform additional logic beyond removing the closed JFrame from the list of frames we are tracking, they should overload this method. This version of this method allows the caller to indicate if the frame was closed by cancelling it.
Specified by:
addFrameClosing in interface GUIUtilInterface
Parameters:
frame - The JFrame that is being closed.
cancelled - If set to true, indicates the frame was closed by cancelling out of it. this could be via a cancel button or by using the window decorations.

updateLookAndFeel

protected void updateLookAndFeel(String lookFeel)
Updates the look and feel of the GUI frames we know about.
Parameters:
lookFeel - The look and feel to set the GUI to.

propagateToolTipDisplay

protected void propagateToolTipDisplay(boolean display)
Tells all the current open frames that they should either start or stop showing tool tips.
Parameters:
display - Indicates to show (value of true) or not show (value of false) tooltips.

propagateHighlighting

protected void propagateHighlighting(boolean display)
Tells all the current open frames that they should either highlight or not highlinght required fields.
Parameters:
display - Indicates to highlight (value of true) or not highlight (value of false) fields.

closeDown

public void closeDown()
Frees up all resources used by this instance of the GUI and notifies the ParentGUI that launched us that we are closing down.

getDataFileName

public String getDataFileName(String[] extensions,
                              String filterDesc,
                              boolean open)
Creates and processes a file selection dialog to allow the user to indicate a data file to read or write.
Parameters:
extensions - Array of file extensions to put in the extension filter list.
filterDesc - Description for the file extension filter.
open - Indicates if the file name is to be used for a file open of a save. true indicates an open, false indicates a save.
Returns:
The selected file name, or null if the user cancels the selection.

getDataFileName

public String getDataFileName(String[] extensions,
                              String filterDesc,
                              boolean open,
                              String directory)
Creates and processes a file selection dialog to allow the user to indicate a data file to read or write.
Parameters:
extensions - Array of file extensions to put in the extension filter list.
filterDesc - Description for the file extension filter.
open - Indicates if the file name is to be used for a file open of a save. true indicates an open, false indicates a save.
directory - The directory the file chooser should look in initially
Returns:
The selected file name, or null if the user cancels the selection.

verifyUnsavedChanges

public boolean verifyUnsavedChanges()
Verifies that there are no unsaved changes, or if there are, if the user wants to discard them. This is called before a new file is opened or the application is terminated to make sure the user is aware they have unsaved changes.
Returns:
true if there are no unsaved changes or the user wishes to discard the changes. false if there are unsaved changes and the user does not want to discard them.