com.jeta.open.gui.framework
Class JETADialog

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Dialog
                  extended by javax.swing.JDialog
                      extended by com.jeta.open.gui.framework.JETADialog
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class JETADialog
extends JDialog

This is a base class for all dialogs in the system. It provides a skeleton dialog box with a cancel and ok button. Callers can add their own containers to this dialog's content panel. This class also supports validators for the dialog. This allows the dialog to validate the input and if validation fails, maintain the dialog on the screen. See JETARule.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JDialog
JDialog.AccessibleJDialog
 
Nested classes/interfaces inherited from class java.awt.Dialog
Dialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityType
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String ID_BUTTON_PANEL
          The name of the button panel.
static String ID_CANCEL
           
static String ID_OK
          The names of the ok and cancel buttons.
 
Fields inherited from class javax.swing.JDialog
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Dialog
DEFAULT_MODALITY_TYPE
 
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, EXIT_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JETADialog(Dialog owner, boolean bModal)
          ctor
JETADialog(Frame owner, boolean bModal)
          ctor
 
Method Summary
protected  void _initialize()
          Initializes the components on this dialog
 boolean actionPerformed(String commandId, ActionEvent evt)
          Forwarded from the view when an action occurs.
 void addController(JETAController controller)
          Adds a controller to the list of controllers that can handle events for this dialog.
 void addDialogListener(JETADialogListener listener)
          Adds a listener to the list of listeners for this dialog
 void addValidator(JETARule validator)
          This adds a rule that will be used to validate the user input for this dialog.
 void addValidator(Object parameter, JETARule validator)
          This adds a rule that will be used to validate the user input for this dialog.
 void cmdCancel()
          Closes the dialog
 void cmdOk()
          Close the dialog and set the ok flag
 void dispose()
          Dispose the dialog
 JPanel getButtonPanel()
           
 JButton getCloseButton()
           
 JETAController getController()
           
 Container getDialogContentPanel()
           
 JButton getHelpButton()
           
 JButton getOkButton()
           
 Dimension getPreferredSize()
          Returns the preferred size for this dialog.
protected  Dimension getPreferredSize(Dimension contentDims)
          Returns the preferred size for this dialog.
 Component getPrimaryPanel()
           
 boolean isOk()
           
 void removeAllControllers()
          Removes all registered controllers added to this dialog
 void setButtonPanelVisible(boolean bvis)
          Shows/Hides the button panel on this dialog.
 void setCancelEnabled(boolean bCancel)
          Enables/Disables the cancel command
 void setCloseText(String txt)
          Sets the text for the close button
 void setController(JETAController controller)
          Sets the controller that will handle events for this dialog
 void setFont(Font f)
          Sets the font for the ok and close buttons on this dialog
 void setInitialFocusComponent(JComponent comp)
          Sets the component in this frame that will have initial focus.
protected  void setOk(boolean bok)
          Sets the Ok flag
 void setOkText(String txt)
          Sets the text for the ok button
 void setPrimaryPanel(JComponent primaryPanel)
          Sets the one and only panel for this dialog
 void setTitle(String title)
          Sets the title to the frame
 void showCenter()
          Shows the dialog in the center of the screen
 void showOkButton(boolean bvis)
          Shows/hides the ok button
 void updateComponents(EventObject evt)
          Updates the components in the dialog based on the model state.
protected  boolean validateListeners()
          Iterates through the list of listeners and allows them to process the inputs.
protected  boolean validateValidators()
          Iterates through the list of controller validators and allows them to validate the input for this dialog.
 
Methods inherited from class javax.swing.JDialog
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Dialog
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setUndecorated, setVisible, show, toBack
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, 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, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ID_BUTTON_PANEL

public static final String ID_BUTTON_PANEL
The name of the button panel.

See Also:
Constant Field Values

ID_OK

public static final String ID_OK
The names of the ok and cancel buttons.

See Also:
Constant Field Values

ID_CANCEL

public static final String ID_CANCEL
See Also:
Constant Field Values
Constructor Detail

JETADialog

public JETADialog(Dialog owner,
                  boolean bModal)
ctor


JETADialog

public JETADialog(Frame owner,
                  boolean bModal)
ctor

Method Detail

actionPerformed

public boolean actionPerformed(String commandId,
                               ActionEvent evt)
Forwarded from the view when an action occurs.

Parameters:
commandId - the name of the action associated with the event
evt - the action event
Returns:
true if the controller handled the action

addController

public void addController(JETAController controller)
Adds a controller to the list of controllers that can handle events for this dialog. When an menu or toolbar event occurs, the event is routed to each controller added to this frame. Once a controller is found that handles the event, the event routing is considered complete and no other controllers are evaluated.

Parameters:
controller - the controller to add

addDialogListener

public void addDialogListener(JETADialogListener listener)
Adds a listener to the list of listeners for this dialog


addValidator

public void addValidator(JETARule validator)
This adds a rule that will be used to validate the user input for this dialog. The validate method is called on each of these rules when the user hits the ok button. If any rule fails validation, an error message appears and the dialog will not close.


addValidator

public void addValidator(Object parameter,
                         JETARule validator)
This adds a rule that will be used to validate the user input for this dialog. The validate method is called on each of these validators when the user hits the ok button. If any rule fails validation, an error message appears and the dialog will not close.

Parameters:
parameter - a parameter to pass to the validator. If this object is an Object[] type, then it is passed directly to the validator.
validator - the rule to add to this dialog.

cmdCancel

public void cmdCancel()
Closes the dialog


cmdOk

public void cmdOk()
Close the dialog and set the ok flag


dispose

public void dispose()
Dispose the dialog

Overrides:
dispose in class Window

getButtonPanel

public JPanel getButtonPanel()
Returns:
the panel at the bottom of this dialog that contains the ok and cancel buttons

getCloseButton

public JButton getCloseButton()
Returns:
the close button for this dialog

getController

public JETAController getController()
Returns:
the controller for this dialog

getDialogContentPanel

public Container getDialogContentPanel()
Returns:
the content container for this dialog. Callers add their controls to this container.

getHelpButton

public JButton getHelpButton()
Returns:
the Help button for this dialog Normally, this button is not visible.

getOkButton

public JButton getOkButton()
Returns:
the Ok button for this dialog

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size for this dialog. This includes the title bar height, border height,width, and ok/cancel button heights. This dialog also gets the preferred size of the content panel, so you need to correctly set the preferred size in any content panel you set for this dialog.

Overrides:
getPreferredSize in class Container
Returns:
the preferred size for this dialog so that the caller can size the window properly

getPreferredSize

protected Dimension getPreferredSize(Dimension contentDims)
Returns the preferred size for this dialog. The size is calculated assuming the that dimensions of the main content panel are passed in by the caller. The content panel dimensions are added to the title bar height, border height,width, and ok/cancel button heights.

Returns:
the preferred size for this dialog so that the caller can size the window properly

getPrimaryPanel

public Component getPrimaryPanel()
Returns:
the one and only panel for this dialog. The panel must have been set previously by calling setPrimaryPanel.

_initialize

protected void _initialize()
Initializes the components on this dialog


isOk

public boolean isOk()
Returns:
true if the user clicked the Ok button to close the dialog.

removeAllControllers

public void removeAllControllers()
Removes all registered controllers added to this dialog


setButtonPanelVisible

public void setButtonPanelVisible(boolean bvis)
Shows/Hides the button panel on this dialog.


setCancelEnabled

public void setCancelEnabled(boolean bCancel)
Enables/Disables the cancel command


setCloseText

public void setCloseText(String txt)
Sets the text for the close button


setFont

public void setFont(Font f)
Sets the font for the ok and close buttons on this dialog

Overrides:
setFont in class Container
Parameters:
f - the new font to set

setPrimaryPanel

public void setPrimaryPanel(JComponent primaryPanel)
Sets the one and only panel for this dialog


setController

public void setController(JETAController controller)
Sets the controller that will handle events for this dialog


setInitialFocusComponent

public void setInitialFocusComponent(JComponent comp)
Sets the component in this frame that will have initial focus.

Parameters:
comp - the component that gets initial focus when dialog is displayed

setOk

protected void setOk(boolean bok)
Sets the Ok flag


setOkText

public void setOkText(String txt)
Sets the text for the ok button


setTitle

public void setTitle(String title)
Sets the title to the frame

Overrides:
setTitle in class Dialog

showCenter

public void showCenter()
Shows the dialog in the center of the screen


showOkButton

public void showOkButton(boolean bvis)
Shows/hides the ok button


updateComponents

public void updateComponents(EventObject evt)
Updates the components in the dialog based on the model state.


validateListeners

protected boolean validateListeners()
Iterates through the list of listeners and allows them to process the inputs. For example, the user may be inputing parameters for a databse. We would like to perform the database operation. If the operation fails, we would like the dialog to remain on the screen so the user can make any appropriate adjustments to the dialog data. This is the purpose of the JETADialogListeners.


validateValidators

protected boolean validateValidators()
Iterates through the list of controller validators and allows them to validate the input for this dialog. If any controller fails validation, then we show an error message and return false.



Copyright © 2005-2007 Jeff Tassin & Todd Viegut. All Rights Reserved.