Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.common.awt.dialogs
Class OptionDlg  view OptionDlg download OptionDlg.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Dialog
                  extended bycom.flexstor.common.awt.dialogs.ModalDlg
                      extended bycom.flexstor.common.awt.dialogs.OptionDlg
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
InputDialog, MessageBox

public abstract class OptionDlg
extends ModalDlg
implements java.awt.event.ActionListener, java.awt.event.KeyListener

This class adds default buttons to a modal dialog as well as default action and cancel behavior for enter key and escape. It builds a button panel on the bottom depending on the option passed into the constructor. These are the options:


Predefined return values are: Custom buttons can be added by adding ActionButtons to the vector vButtons. Action ids should start at ACTION_CUSTOM + 1. These buttons will automatically be created and added to the button panel.
createButtonPanel() can be overwritten to create a custom button layout.
canPerformDefaultAction() is abstract and must be overwritten by subclasses to indicate that the default action can indeed be executed.


Nested Class Summary
 
Nested classes inherited from class java.awt.Dialog
java.awt.Dialog.AccessibleAWTDialog
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int ACTION_APPLY
          Result code for Apply button
static int ACTION_CANCEL
          Result code for Cancel button
static int ACTION_CUSTOM
          Starting value for custom action ids
static int ACTION_DISCARD
          Result code for Discard button
static int ACTION_HELP
          Result code for Help button
static int ACTION_NO
          Result code for No button
static int ACTION_OK
          Result code for OK button
static int ACTION_SAVE
          Result code for Save button
static int ACTION_YES
          Result code for Yes button
static int APPLY_DISCARD_CANCEL
          Constant for options Apply, discard, and Cancel
private  java.awt.Component cSource
           
protected static com.flexstor.common.awt.HelpHandlerI helpHandler
           
static java.lang.String IDENTIFIER
           
protected  com.flexstor.common.awt.KeyWatcher keyWatcher
           
protected  int nCancelActionId
           
protected  int nDefaultActionId
           
protected  int nStatus
           
static int OK
          Constant for options Ok
static int OK_CANCEL
          Constant for options Ok and Cancel
static int OK_CANCEL_HELP
          Constant for options Ok, Cancel, and Help
protected  java.awt.Panel pnlButtons
           
protected  java.util.Vector vButtons
           
static int YES_NO
          Constant for options Yes and No
static int YES_NO_CANCEL
          Constant for options Yes, No, and Cancel
 
Fields inherited from class com.flexstor.common.awt.dialogs.ModalDlg
bEnforceMinimumSize, focusComponent, fParent
 
Fields inherited from class java.awt.Dialog
 
Fields inherited from class java.awt.Window
 
Fields inherited from class java.awt.Container
 
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
OptionDlg(java.awt.Frame fParent, int nButtons)
          Creates a dialog with a parent and predefined options.
OptionDlg(java.awt.Frame fParent, java.lang.String sTitle, int nButtons)
          Creates a dialog with a parent, a dialog title, and predefined options.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Performs the default dialog behavior:
ACTION_HELP: pops up the help file, uses getWindowId() of subclasses
All other : set status and dispose of dialog
 void addNotify()
          Creates the buton panel.
protected abstract  boolean canPerformDefaultAction()
          This abstract method returns a boolean indicating if the default action can be executed, i.e.
protected  void createButtonPanel()
          If subclasses need a different layout for the buttons, they should overwrite this method.
protected  java.util.Vector createButtons(int nButtons)
          Creates the predefined buttons and returns them in the vector vButtons which is a protected member.
 int getCancelAction()
          Returns the cancel action id.
protected  com.flexstor.common.awt.field.ActionButton getComponentForId(int nId)
          Retrieves the component for a given action id.
 int getDefaultAction()
          Returns the default action id.
protected  int getFieldId()
          Subclasses need to overwrite this method to define the field id for the help call, default indicate no call to the help system.
 int getStatus()
          Returns the user's choice as an action id
protected  int getWindowId()
          Subclasses need to overwrite this method to define their window id for the help call, default indicate no call to the help system.
protected  void initialize(int nButtons)
          Performs initializations for all constructors.
 void keyPressed(java.awt.event.KeyEvent e)
          Empty method, implementing KeyListener
 void keyReleased(java.awt.event.KeyEvent e)
          All key event handling occurs on the key release.
Escape fires an action event with the cancel action id.
Enter fires an action event with the default action id.
F1 fires an action event with the help action id.
 void keyTyped(java.awt.event.KeyEvent e)
          Empty method, implementing KeyListener
static void registerHelpHandler(com.flexstor.common.awt.HelpHandlerI handler)
          Registers the global help handler for dialogs.
 void setCancelAction(int nActionId)
          Defines the cancel action if the user hits the escape key or closes the dialog with the close box or system menu.
 void setContent(java.awt.Component c)
          Sets the center component of the predefined border layout.
 void setDefaultAction(int nActionId)
          Defines the default action if the user hits the enter key.
protected  void setStatus(int nStatus)
          Sets the new status
 
Methods inherited from class com.flexstor.common.awt.dialogs.ModalDlg
centerOn, enableInput, setFocusComponent, setMinimumSizeEnforcement, setVisible, validate
 
Methods inherited from class java.awt.Dialog
dispose, getAccessibleContext, getTitle, hide, isModal, isResizable, isUndecorated, paramString, setModal, setResizable, setTitle, setUndecorated, show
 
Methods inherited from class java.awt.Window
addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getGraphicsConfiguration, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusDownCycle, update, 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, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, 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, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IDENTIFIER

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

ACTION_OK

public static final int ACTION_OK
Result code for OK button

See Also:
Constant Field Values

ACTION_CANCEL

public static final int ACTION_CANCEL
Result code for Cancel button

See Also:
Constant Field Values

ACTION_YES

public static final int ACTION_YES
Result code for Yes button

See Also:
Constant Field Values

ACTION_NO

public static final int ACTION_NO
Result code for No button

See Also:
Constant Field Values

ACTION_APPLY

public static final int ACTION_APPLY
Result code for Apply button

See Also:
Constant Field Values

ACTION_DISCARD

public static final int ACTION_DISCARD
Result code for Discard button

See Also:
Constant Field Values

ACTION_HELP

public static final int ACTION_HELP
Result code for Help button

See Also:
Constant Field Values

ACTION_SAVE

public static final int ACTION_SAVE
Result code for Save button

See Also:
Constant Field Values

ACTION_CUSTOM

public static final int ACTION_CUSTOM
Starting value for custom action ids

See Also:
Constant Field Values

YES_NO

public static final int YES_NO
Constant for options Yes and No

See Also:
Constant Field Values

YES_NO_CANCEL

public static final int YES_NO_CANCEL
Constant for options Yes, No, and Cancel

See Also:
Constant Field Values

OK_CANCEL

public static final int OK_CANCEL
Constant for options Ok and Cancel

See Also:
Constant Field Values

OK

public static final int OK
Constant for options Ok

See Also:
Constant Field Values

APPLY_DISCARD_CANCEL

public static final int APPLY_DISCARD_CANCEL
Constant for options Apply, discard, and Cancel

See Also:
Constant Field Values

OK_CANCEL_HELP

public static final int OK_CANCEL_HELP
Constant for options Ok, Cancel, and Help

See Also:
Constant Field Values

helpHandler

protected static com.flexstor.common.awt.HelpHandlerI helpHandler

nStatus

protected int nStatus

nDefaultActionId

protected int nDefaultActionId

nCancelActionId

protected int nCancelActionId

pnlButtons

protected java.awt.Panel pnlButtons

vButtons

protected java.util.Vector vButtons

keyWatcher

protected com.flexstor.common.awt.KeyWatcher keyWatcher

cSource

private java.awt.Component cSource
Constructor Detail

OptionDlg

public OptionDlg(java.awt.Frame fParent,
                 int nButtons)
Creates a dialog with a parent and predefined options.


OptionDlg

public OptionDlg(java.awt.Frame fParent,
                 java.lang.String sTitle,
                 int nButtons)
Creates a dialog with a parent, a dialog title, and predefined options.

Method Detail

initialize

protected void initialize(int nButtons)
Performs initializations for all constructors.


createButtons

protected java.util.Vector createButtons(int nButtons)
Creates the predefined buttons and returns them in the vector vButtons which is a protected member. Also sets the default action and cancel action.


createButtonPanel

protected void createButtonPanel()
If subclasses need a different layout for the buttons, they should overwrite this method.


setContent

public void setContent(java.awt.Component c)
Sets the center component of the predefined border layout.


addNotify

public void addNotify()
Creates the buton panel. Adds a window listener to perform the default cancel action when the window close box is clicked.

Overrides:
addNotify in class ModalDlg

getComponentForId

protected com.flexstor.common.awt.field.ActionButton getComponentForId(int nId)
Retrieves the component for a given action id.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Performs the default dialog behavior:
ACTION_HELP: pops up the help file, uses getWindowId() of subclasses
All other : set status and dispose of dialog

Specified by:
actionPerformed in interface java.awt.event.ActionListener

setStatus

protected void setStatus(int nStatus)
Sets the new status


getStatus

public int getStatus()
Returns the user's choice as an action id


getWindowId

protected int getWindowId()
Subclasses need to overwrite this method to define their window id for the help call, default indicate no call to the help system.


getFieldId

protected int getFieldId()
Subclasses need to overwrite this method to define the field id for the help call, default indicate no call to the help system.


setDefaultAction

public void setDefaultAction(int nActionId)
Defines the default action if the user hits the enter key.


getDefaultAction

public int getDefaultAction()
Returns the default action id.


setCancelAction

public void setCancelAction(int nActionId)
Defines the cancel action if the user hits the escape key or closes the dialog with the close box or system menu.


getCancelAction

public int getCancelAction()
Returns the cancel action id.


keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Empty method, implementing KeyListener

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
All key event handling occurs on the key release.
Escape fires an action event with the cancel action id.
Enter fires an action event with the default action id.
F1 fires an action event with the help action id.

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Empty method, implementing KeyListener

Specified by:
keyPressed in interface java.awt.event.KeyListener

canPerformDefaultAction

protected abstract boolean canPerformDefaultAction()
This abstract method returns a boolean indicating if the default action can be executed, i.e. if this method returns false, the enter key does NOT fire an action event.


registerHelpHandler

public static void registerHelpHandler(com.flexstor.common.awt.HelpHandlerI handler)
Registers the global help handler for dialogs. Subsequent calls will replace the help handler.