com.metamatrix.toolbox.ui.widget
Class DialogPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.metamatrix.toolbox.ui.widget.DialogPanel
All Implemented Interfaces:
UIConstants, ButtonConstants, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
AboutPanel, AccumulatorPanel, CallbackChoicesDialogPanel, ConfigurationPanel, ConfirmationPanel, ConfirmationPanel, DeploymentsSummaryPanel.HostExistsInfoPanel, DirectoryChooserPanel, LoginPanel, MessagePanel, ModifiedDirectoryChooserPanel, ProcessMgmtPanel, RowsNotSelectedPanel, ServiceMgmtPanel, WizardPanel

public class DialogPanel
extends javax.swing.JPanel
implements ButtonConstants, UIConstants

This class is intended to be used everywhere within the application that a dialog panel needs to be displayed. It provides for a navigation button bar at the bottom of the panel, a set of methods to work with it, and a default pair of "accept" and "cancel" buttons within the bar. Support exists for multiple accept buttons, however it is up to the developer to ensure that if accept buttons are removed or reordered, the list of accept buttons is updated appropriately.

Since:
2.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface com.metamatrix.toolbox.ui.widget.ButtonConstants
ACCEPT_BUTTON, APPLY_BUTTON, BACK_BUTTON, CANCEL_BUTTON, CONTEXT_SENSITIVE_HELP, DEFAULTS_BUTTON, DETAILS_BUTTON, EXIT_BUTTON, FINISH_BUTTON, HELP_BUTTON, LOGIN_BUTTON, NEXT_BUTTON, NO_BUTTON, OVERWRITE_BUTTON, REPLACE_BUTTON, RETRY_BUTTON, SKIP_BUTTON, YES_BUTTON
 
Fields inherited from interface com.metamatrix.toolbox.ui.UIConstants
DATE_FORMAT_PROPERTY, SPACER_HORIZONTAL_LENGTH_PROPERTY, WINDOW_BORDER_PROPERTY
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DialogPanel()
          Creates a panel with a BorderLayout and a navigation bar in the SOUTH region.
DialogPanel(java.awt.Component content)
          Creates a panel with a BorderLayout, a navigation bar in the SOUTH region, and the specified content in the CENTER region.
 
Method Summary
protected  void accept(WidgetActionEvent event)
          Called when the panel's parent is a DialogWindow and the user activates the accept button.
 int addAcceptButton(ButtonWidget button)
          Adds the specified button as the accept button to the end of the navigation bar.
 void addAcceptButton(ButtonWidget button, int index)
          Adds the specified button as the accept button to the navigation bar at the specified index.
 int addCancelButton(ButtonWidget button)
          Adds the specified button as the cancel button to the end of the navigation bar.
 void addCancelButton(ButtonWidget button, int index)
          Adds the specified button as the cancel button to the navigation bar at the specified index.
 int addHelpButton(ButtonWidget button)
          Adds the specified button as the help button to the front of the navigation bar.
 void addHelpButton(ButtonWidget button, int index)
          Adds the specified button as the help button to the navigation bar at the specified index.
 int addNavigationButton(ButtonWidget button)
          Adds the specified button immediately before the space in front of the cancel button.
 void addNavigationButton(ButtonWidget button, int index)
          Adds the specified button to the navigation bar at the specified index.
protected  void addNavigationComponent(java.awt.Component component, int index)
          Adds the specified component to the navigation bar at the specified index.
 int addNavigationSpacer(SpacerWidget spacer)
          Adds the specified spacer immediately before the space in front of the cancel button.
 void addNavigationSpacer(SpacerWidget spacer, int index)
          Adds the specified spacer to the navigation bar at the specified index.
protected  void buildNavigationBar()
          Creates a navigation bar with default accept and cancel buttons, and if a context-sensitive-help property exists, a help button.
 boolean canAccept()
           
 boolean canCancel()
           
protected  void cancel(WidgetActionEvent event)
          Called when the panel's parent is a DialogWindow and the user activates the cancel button or cancels the dialog via the title bar close button (with the 'X' icon) or the title bar system menu 'Close' option.
protected  ButtonWidget createAcceptButton()
          Creates an accept button with a default label (as determined by the ToolboxStandards class).
protected  ButtonWidget createCancelButton()
          Creates an cancel button with a default label (as determined by the ToolboxStandards class).
protected  ButtonWidget createHelpButton()
          Creates a help button with a default label (as determined by the ToolboxStandards class).
protected  javax.swing.JComponent createNavigationBar()
          Creates a navigation bar that will contain all buttons that apply to the entire panel.
protected  void equalizeNavigationButtonWidths()
          Sets the size of all navigation buttons to the size of the largest navigation button.
 ButtonWidget getAcceptButton()
           
 java.util.List getAcceptButtons()
           
 ButtonWidget getCancelButton()
           
 java.awt.Component getContent()
           
 java.awt.Container getContentContainer()
           
 ButtonWidget getHelpButton()
           
 javax.swing.JComponent getNavigationBar()
          Retrieves the navigation bar.
 ButtonWidget getNavigationButton(java.lang.String text)
          Retrieves the button in the navigation bar with the specified text.
 java.awt.Component getNavigationComponent(int index)
          Retrieves the component in the navigation bar (either a button or spacer) at the specified index.
 int getNavigationComponentIndex(java.awt.Component component)
          Retrieves the index of the specified component in the navigation bar.
 ButtonWidget getSelectedButton()
           
 java.awt.Window getWindowAncestor()
          Gets the Window ancestor of this panel
protected  void initializeDialogPanel()
          Initializes the panel: Adds a content panel to the center Adds the navigation bar to the bottom, initialized with default next and cancel buttons.
 int removeNavigationButton(ButtonWidget button)
          Removes the specified button from the navigation bar.
 java.awt.Component removeNavigationComponent(int index)
          Removes the component (either a button or spacer) at the specified index from the navigation bar.
 void removeNavigationSpacer(SpacerWidget spacer)
          Removes the specified spacer from the navigation bar.
protected  void setCanAccept(boolean canAccept)
           
protected  void setCanCancel(boolean canCancel)
           
 void setContent(java.awt.Component content)
          Sets the specified component as the main content to be displayed in the CENTER region of the panel.
 void setLayout(java.awt.LayoutManager layout)
          Overridden to ensure this class uses a BorderLayout
 void setVisible(boolean visible)
          Overridden to clear the selected button each time the panel is made visible.
protected  void validateState()
          Ensures that the navigation bar exists in the panel.
protected  void windowActivated()
          To be overridden by subclasses, allowing you to refresh your dialog panel when the focus on the parent window is lost and then reactivated.
protected  void windowAdded()
          To be overridden by subclasses, allowing you to refresh your dialog panel when the focus on the parent window is added.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DialogPanel

public DialogPanel()
Creates a panel with a BorderLayout and a navigation bar in the SOUTH region.

Since:
2.0

DialogPanel

public DialogPanel(java.awt.Component content)
Creates a panel with a BorderLayout, a navigation bar in the SOUTH region, and the specified content in the CENTER region.

Parameters:
content - The component to be displayed.
Since:
2.0
Method Detail

accept

protected void accept(WidgetActionEvent event)
Called when the panel's parent is a DialogWindow and the user activates the accept button. Does nothing by default.

Parameters:
event - The WidgetActionEvent generated from activating the button
Since:
2.0

addAcceptButton

public int addAcceptButton(ButtonWidget button)
Adds the specified button as the accept button to the end of the navigation bar.

Parameters:
button - The button to add as an accept button
Returns:
The index at which the button was added
Since:
2.0

addAcceptButton

public void addAcceptButton(ButtonWidget button,
                            int index)
Adds the specified button as the accept button to the navigation bar at the specified index.

Parameters:
button - The button to add as an accept button
index - The index within the navigation bar to add the button
Since:
2.0

addCancelButton

public int addCancelButton(ButtonWidget button)
Adds the specified button as the cancel button to the end of the navigation bar.

Parameters:
button - The button to add as an cancel button
Returns:
The index at which the button was added
Since:
2.0

addCancelButton

public void addCancelButton(ButtonWidget button,
                            int index)
Adds the specified button as the cancel button to the navigation bar at the specified index.

Parameters:
button - The button to add as an cancel button
index - The index within the navigation bar to add the button
Since:
2.0

addHelpButton

public int addHelpButton(ButtonWidget button)
Adds the specified button as the help button to the front of the navigation bar.

Parameters:
button - The button to add as a help button
Returns:
The index at which the button was added
Since:
2.0

addHelpButton

public void addHelpButton(ButtonWidget button,
                          int index)
Adds the specified button as the help button to the navigation bar at the specified index.

Parameters:
button - The button to add as a help button
index - The index within the navigation bar to add the button
Since:
2.0

addNavigationButton

public int addNavigationButton(ButtonWidget button)
Adds the specified button immediately before the space in front of the cancel button.

Parameters:
button - The button to add
Returns:
The index at which the button was added
Since:
2.0

addNavigationButton

public void addNavigationButton(ButtonWidget button,
                                int index)
Adds the specified button to the navigation bar at the specified index.

Parameters:
button - The button to add
index - The index within the navigation bar to add the button
Since:
2.0

addNavigationComponent

protected void addNavigationComponent(java.awt.Component component,
                                      int index)
Adds the specified component to the navigation bar at the specified index.

Parameters:
component - The component to add
index - The index within the navigation bar at which to add the component
Since:
2.0

addNavigationSpacer

public int addNavigationSpacer(SpacerWidget spacer)
Adds the specified spacer immediately before the space in front of the cancel button.

Parameters:
spacer - The spacer to add
Returns:
The index at which the button was added
Since:
2.0

addNavigationSpacer

public void addNavigationSpacer(SpacerWidget spacer,
                                int index)
Adds the specified spacer to the navigation bar at the specified index.

Parameters:
spacer - The spacer to add
index - The index within the navigation bar to add the spacer
Since:
2.0

buildNavigationBar

protected void buildNavigationBar()
Creates a navigation bar with default accept and cancel buttons, and if a context-sensitive-help property exists, a help button.

Since:
2.0

canAccept

public boolean canAccept()
Since:
3.0

canCancel

public boolean canCancel()
Since:
3.0

cancel

protected void cancel(WidgetActionEvent event)
Called when the panel's parent is a DialogWindow and the user activates the cancel button or cancels the dialog via the title bar close button (with the 'X' icon) or the title bar system menu 'Close' option. Does nothing by default.

Parameters:
event - The WidgetActionEvent generated from activating the button or closing the window
Since:
2.0

createAcceptButton

protected ButtonWidget createAcceptButton()
Creates an accept button with a default label (as determined by the ToolboxStandards class).

Returns:
The accept button
Since:
2.0

createCancelButton

protected ButtonWidget createCancelButton()
Creates an cancel button with a default label (as determined by the ToolboxStandards class).

Returns:
The cancel button
Since:
2.0

createHelpButton

protected ButtonWidget createHelpButton()
Creates a help button with a default label (as determined by the ToolboxStandards class).

Returns:
The help button
Since:
2.0

createNavigationBar

protected javax.swing.JComponent createNavigationBar()
Creates a navigation bar that will contain all buttons that apply to the entire panel.

Since:
2.0

equalizeNavigationButtonWidths

protected void equalizeNavigationButtonWidths()
Sets the size of all navigation buttons to the size of the largest navigation button.

Since:
2.0

getAcceptButton

public ButtonWidget getAcceptButton()
Returns:
The first accept button
Since:
2.0

getAcceptButtons

public java.util.List getAcceptButtons()
Returns:
The modifiable list of accept buttons; never null
Since:
3.1

getCancelButton

public ButtonWidget getCancelButton()
Returns:
The cancel button
Since:
2.0

getContent

public java.awt.Component getContent()
Returns:
The content component
Since:
2.0

getContentContainer

public java.awt.Container getContentContainer()
Returns:
The content component container
Since:
2.0

getHelpButton

public ButtonWidget getHelpButton()
Returns:
The help button
Since:
2.0

getNavigationBar

public javax.swing.JComponent getNavigationBar()
Retrieves the navigation bar.

Returns:
The navigation bar
Since:
2.0

getNavigationButton

public ButtonWidget getNavigationButton(java.lang.String text)
Retrieves the button in the navigation bar with the specified text.

Parameters:
text - The button text
Returns:
The button if found, null otherwise
Since:
2.0

getNavigationComponent

public java.awt.Component getNavigationComponent(int index)
Retrieves the component in the navigation bar (either a button or spacer) at the specified index.

Parameters:
index - The index within the navigation bar of the component
Returns:
The component
Since:
2.0

getNavigationComponentIndex

public int getNavigationComponentIndex(java.awt.Component component)
Retrieves the index of the specified component in the navigation bar.

Parameters:
component - The component
Returns:
The index of the component if found, -1 otherwise
Since:
2.0

getSelectedButton

public ButtonWidget getSelectedButton()
Returns:
The last selected button, or null if none were selected.
Since:
2.0

getWindowAncestor

public java.awt.Window getWindowAncestor()
Gets the Window ancestor of this panel

Returns:
The Window
Since:
2.0

initializeDialogPanel

protected void initializeDialogPanel()
Initializes the panel:

Since:
2.0

removeNavigationButton

public int removeNavigationButton(ButtonWidget button)
Removes the specified button from the navigation bar.

Parameters:
button - The button to remove
Returns:
The index from which the button was removed if found, -1 otherwise
Since:
2.0

removeNavigationComponent

public java.awt.Component removeNavigationComponent(int index)
Removes the component (either a button or spacer) at the specified index from the navigation bar.

Parameters:
index - The index within the navigation bar of the component
Returns:
The component removed
Since:
2.0

removeNavigationSpacer

public void removeNavigationSpacer(SpacerWidget spacer)
Removes the specified spacer from the navigation bar.

Parameters:
spacer - The spacer to remove
Since:
2.0

setCanAccept

protected void setCanAccept(boolean canAccept)
Since:
3.0

setCanCancel

protected void setCanCancel(boolean canCancel)
Since:
3.0

setContent

public void setContent(java.awt.Component content)
Sets the specified component as the main content to be displayed in the CENTER region of the panel.

Parameters:
content - The component
Since:
2.0

setLayout

public void setLayout(java.awt.LayoutManager layout)
Overridden to ensure this class uses a BorderLayout

Overrides:
setLayout in class java.awt.Container
Since:
2.0
See Also:
Container.setLayout(LayoutManager)

setVisible

public void setVisible(boolean visible)
Overridden to clear the selected button each time the panel is made visible.

Overrides:
setVisible in class javax.swing.JComponent
Since:
2.0

validateState

protected void validateState()
Ensures that the navigation bar exists in the panel.

Since:
2.0

windowActivated

protected void windowActivated()
To be overridden by subclasses, allowing you to refresh your dialog panel when the focus on the parent window is lost and then reactivated.

Since:
2.0

windowAdded

protected void windowAdded()
To be overridden by subclasses, allowing you to refresh your dialog panel when the focus on the parent window is added.

Since:
2.0


Copyright © 2009. All Rights Reserved.