com.sun.javatest.tool
Class ToolDialog

java.lang.Object
  extended by com.sun.javatest.tool.ToolDialog
Direct Known Subclasses:
ContextManager.TestManagerDialog, ServiceViewer

public abstract class ToolDialog
extends java.lang.Object

Lightweight wrapper class to provide standard support for tool dialogs. Dialogs have a title, optional menu bar, a body, and an optional set of buttons, including a default button. The actual dialog displayed may be a JDialog, or a JInternalFrame, depending on the current desktop.


Nested Class Summary
 class ToolDialog.Restorer
           
 
Field Summary
protected  java.awt.Component parent
          Parent component of this dialog.
protected  Tool tool
          Parent tool of this dialog.
protected  UIFactory uif
          Factory associated with this dialog instance.
 
Constructor Summary
protected ToolDialog(java.awt.Component parent, UIFactory uif, java.lang.String uiKey)
          Create a ToolDialog.
 
Method Summary
protected  void disableDefaultDisposeHandler()
          By default disposing tool leads closing tool's ToolDialogs.
 void dispose()
          Dispose of any window system resources used by the dialog.
protected  java.awt.Container getBody()
          Get the component for the main body of the dialog.
protected  javax.swing.JButton[] getButtons()
          Get the buttons from the button bar at the bottom of the dialog.
protected  javax.swing.JButton getDefaultButton()
          Get the default button from the button bar at the bottom of the dialog.
 java.awt.Container getDialogParent()
          Get a parent component for a dialog to use.
protected  javax.swing.JMenuBar getJMenuBar()
          Get the menu bar for the dialog.
protected  java.awt.Point getLocation()
          Get the location of the dialog.
protected  ToolDialog.Restorer getRestorer()
           
protected  java.awt.Dimension getSize()
          Get the size of the dialog.
protected  java.lang.String getTitle()
          Get the title for the dialog.
 Tool getTool()
          Get the tool for which this is a dialog.
protected abstract  void initGUI()
          Initialize the GUI, by calling the various setXXX methods.
 boolean isShowing()
          Check if the dialog is currently showing on the screen.
 boolean isVisible()
          Check if the dialog is currently showing on the screen.
 void pack()
          packs the dialog.
protected  void setBody(java.awt.Container body)
          Set the component for the main body of the dialog.
protected  void setButtons(javax.swing.JButton[] buttons, javax.swing.JButton defaultButton)
          Set the buttons to appear in a button bar at the bottom of the dialog.
protected  void setComponentListener(java.awt.event.ComponentListener l)
          Set a ComponentListener to be registered on the dialog.
protected  void setDefaultCloseOperation(int operation)
          This method add to allow subclasses of ToolDialog to change default close operation.
protected  void setHelp(java.lang.String helpID)
          Set the help ID for the dialog.
protected  void setI18NTitle(java.lang.String key)
          Specify the title for the dialog.
protected  void setI18NTitle(java.lang.String key, java.lang.Object arg)
          Specify the title for the dialog.
protected  void setI18NTitle(java.lang.String key, java.lang.Object[] args)
          Specify the title for the dialog.
protected  void setJMenuBar(javax.swing.JMenuBar menuBar)
          Set the menu bar for the dialog.
protected  void setLocation(int x, int y)
          Set the location of the dialog.
protected  void setLocation(java.awt.Point p)
          Set the location of the dialog.
protected  void setRestorer(ToolDialog.Restorer restorer)
           
protected  void setSize(java.awt.Dimension d)
          Set the size of the dialog.
protected  void setSize(int width, int height)
          Set the size of the dialog.
 void setVisible(boolean b)
          Specify whether the dialog should be made visible on the screen or not.
protected  void windowClosingAction(java.awt.AWTEvent e)
          this method invokes in Window/JInternalFrame listener (depends on dialog variable instance).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected final java.awt.Component parent
Parent component of this dialog.


uif

protected final UIFactory uif
Factory associated with this dialog instance.


tool

protected final Tool tool
Parent tool of this dialog.

Constructor Detail

ToolDialog

protected ToolDialog(java.awt.Component parent,
                     UIFactory uif,
                     java.lang.String uiKey)
Create a ToolDialog.

Parameters:
parent - The parent component of this dialog.
uif - Factory instance associated with this dialog
uiKey - Key to use to get strings and other properties for this dialog.
Method Detail

getTool

public Tool getTool()
Get the tool for which this is a dialog.

Returns:
the tool for which this is a dialog

isShowing

public boolean isShowing()
Check if the dialog is currently showing on the screen.

Returns:
True if this dialog is currently showing, false otherwise.
See Also:
isVisible(), setVisible(boolean)

isVisible

public boolean isVisible()
Check if the dialog is currently showing on the screen.

Returns:
True if this dialog is currently visible, false otherwise.
See Also:
setVisible(boolean)

pack

public void pack()
packs the dialog. The method is useful when it's necessary to call pack separately from setVisible(boolean)

See Also:
setVisible(boolean)

setVisible

public void setVisible(boolean b)
Specify whether the dialog should be made visible on the screen or not.

Parameters:
b - True if the dialog should be made visible, false if is should be made invisible.
See Also:
isVisible()

dispose

public void dispose()
Dispose of any window system resources used by the dialog. The client-supplied components (menu bar, body, buttons) are not disposed, meaning the dialog can be made visible again, if desired. To dispose the client components, subtype this method.


getDialogParent

public java.awt.Container getDialogParent()
Get a parent component for a dialog to use.

Returns:
a component which can be used as a parent (JDialog or Frame), or null if none is available.

initGUI

protected abstract void initGUI()
Initialize the GUI, by calling the various setXXX methods.


getTitle

protected java.lang.String getTitle()
Get the title for the dialog.

Returns:
The title string for this dialog (localized)
See Also:
setI18NTitle(java.lang.String)

setI18NTitle

protected void setI18NTitle(java.lang.String key)
Specify the title for the dialog.

Parameters:
key - key to use to retrieve the dialogs title
See Also:
getTitle()

setI18NTitle

protected void setI18NTitle(java.lang.String key,
                            java.lang.Object arg)
Specify the title for the dialog.

Parameters:
key - key to use to retrieve the dialogs title
arg - item to substitute into the title from the resource bundle
See Also:
getTitle()

setI18NTitle

protected void setI18NTitle(java.lang.String key,
                            java.lang.Object[] args)
Specify the title for the dialog.

Parameters:
key - key to use to retrieve the dialogs title
args - items to substitute into the title from the resource bundle
See Also:
getTitle()

setHelp

protected void setHelp(java.lang.String helpID)
Set the help ID for the dialog. This must be called before the dialog is made visible.

Parameters:
helpID - the help identifier for this dialog

getJMenuBar

protected javax.swing.JMenuBar getJMenuBar()
Get the menu bar for the dialog.

Returns:
the menu bar being used for this dialog, may be null
See Also:
setJMenuBar(javax.swing.JMenuBar)

setJMenuBar

protected void setJMenuBar(javax.swing.JMenuBar menuBar)
Set the menu bar for the dialog.

Parameters:
menuBar - The menu bar for this dialog; should not be null.
See Also:
getJMenuBar()

getBody

protected java.awt.Container getBody()
Get the component for the main body of the dialog.

Returns:
the body container for this dialog
See Also:
setBody(java.awt.Container)

setBody

protected void setBody(java.awt.Container body)
Set the component for the main body of the dialog. This should not include the button bar, which should be set separately. This method must be called befor ethe dialog is made visible.

Parameters:
body - the body container that should be used by this dialog
See Also:
getBody()

getButtons

protected javax.swing.JButton[] getButtons()
Get the buttons from the button bar at the bottom of the dialog.

Returns:
array of buttons currently used in this dialog
See Also:
setButtons(javax.swing.JButton[], javax.swing.JButton)

getDefaultButton

protected javax.swing.JButton getDefaultButton()
Get the default button from the button bar at the bottom of the dialog.

Returns:
the button currently set to be the default
See Also:
setButtons(javax.swing.JButton[], javax.swing.JButton)

setButtons

protected void setButtons(javax.swing.JButton[] buttons,
                          javax.swing.JButton defaultButton)
Set the buttons to appear in a button bar at the bottom of the dialog. A default button can also be specified. The default button gets the focus when the dialog is initially activated, and will be activated if the user clicks "Enter". The default button should not normally have a mnemonic, per JL&F.

Parameters:
buttons - buttons to use
defaultButton - button from the previous argument which should be used as the default
See Also:
getButtons(), getDefaultButton()

setComponentListener

protected void setComponentListener(java.awt.event.ComponentListener l)
Set a ComponentListener to be registered on the dialog. This is useful for listening for events when the dialog is made visible and invisible.

Parameters:
l - listener to attach to this component

getSize

protected java.awt.Dimension getSize()
Get the size of the dialog. An exception will be thrown if the dialog has not yet been shown, or if it is has been disposed since it was shown on the screen.

Returns:
the current size of this dialog
See Also:
setSize(java.awt.Dimension)

setSize

protected void setSize(java.awt.Dimension d)
Set the size of the dialog. An exception will be thrown if the dialog has not yet been shown, or if it is has been disposed since it was shown on the screen.

Parameters:
d - the new size of this dialog
See Also:
getSize()

setSize

protected void setSize(int width,
                       int height)
Set the size of the dialog. An exception will be thrown if the dialog has not yet been shown, or if it is has been disposed since it was shown on the screen.

Parameters:
width - the new width of this dialog
height - the new height of this dialog
See Also:
getSize()

getLocation

protected java.awt.Point getLocation()
Get the location of the dialog. An exception will be thrown if the dialog has not yet been shown, or if it is has been disposed since it was shown on the screen.

Returns:
the current location of this dialog
See Also:
setLocation(java.awt.Point)

setLocation

protected void setLocation(java.awt.Point p)
Set the location of the dialog. An exception will be thrown if the dialog has not yet been shown, or if it is has been disposed since it was shown on the screen.

Parameters:
p - the new location of this dialog
See Also:
getLocation()

setLocation

protected void setLocation(int x,
                           int y)
Set the location of the dialog. An exception will be thrown if the dialog has not yet been shown, or if it is has been disposed since it was shown on the screen.

Parameters:
x - - the x-coordinate of the new location's top-left corner in the parent's coordinate space
y - - the y-coordinate of the new location's top-left corner in the parent's coordinate space
See Also:
getLocation()

setDefaultCloseOperation

protected void setDefaultCloseOperation(int operation)
This method add to allow subclasses of ToolDialog to change default close operation.

Parameters:
operation - one of WindowConstants used by JDialog/JInternalFrame setDefaultCloseOperation method

windowClosingAction

protected void windowClosingAction(java.awt.AWTEvent e)
this method invokes in Window/JInternalFrame listener (depends on dialog variable instance). Should be overwritten in subclass if you want to handle window closing event. You may need to change default close operation first for this event to be fired


disableDefaultDisposeHandler

protected void disableDefaultDisposeHandler()
By default disposing tool leads closing tool's ToolDialogs. This approach is wrong in some certain cases. QuickStartWizard can be example. Unlike most other cases QSW is a �parent� for its tool This method provides way to disable default behavior


getRestorer

protected ToolDialog.Restorer getRestorer()

setRestorer

protected void setRestorer(ToolDialog.Restorer restorer)


Copyright 1996-2009 Sun Microsystems, Inc. All Rights Reserved.