Class ToolDialog

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

public abstract class ToolDialog extends 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

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Mask used for ToolDialog initialization.
    static final int
    Mask used for ToolDialog initialization.
    static final int
    Mask that allows free floating to dialog created with DIALOG mask.
    static final int
    Mask that sets default modality (as JDialog.setModal(true)) to dialog created with DIALOG mask that blocks all AWT frames.
    static final int
    Mask that enables blocking input to all top-level windows from the same Java application except those from its own child hierarchy..
    static final int
    Mask that enables blocking input to all top-level windows (without any owner) from the same document except those from its own child hierarchy.
    static final int
    Mask that enables blocking input to all top-level windows run from the same toolkit except those from its own child hierarchy.
    protected final Component
    Parent component of this dialog.
    protected Tool
    Parent tool of this dialog.
    protected final UIFactory
    Factory associated with this dialog instance.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ToolDialog(Component parent, UIFactory uif, String uiKey)
    Create standard ToolDialog.
    protected
    ToolDialog(Component parent, UIFactory uif, String uiKey, int type)
    Create a ToolDialog with specified type.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    By default disposing tool leads closing tool's ToolDialogs.
    void
    Dispose of any window system resources used by the dialog.
    protected Container
    Get the component for the main body of the dialog.
    protected JButton[]
    Get the buttons from the button bar at the bottom of the dialog.
    protected JButton
    Get the default button from the button bar at the bottom of the dialog.
    Get a parent component for a dialog to use.
    protected JMenuBar
    Get the menu bar for the dialog.
    protected Point
    Get the location of the dialog.
     
    protected Dimension
    Get the size of the dialog.
    protected String
    Get the title for the dialog.
    Get the tool for which this is a dialog.
    protected abstract void
    Initialize the GUI, by calling the various setXXX methods.
    boolean
    Check if the dialog is currently showing on the screen.
    boolean
    Check if the dialog is currently showing on the screen.
    void
    packs the dialog.
    protected void
    Set the component for the main body of the dialog.
    protected void
    setButtons(JButton[] buttons, JButton defaultButton)
    Set the buttons to appear in a button bar at the bottom of the dialog.
    protected void
    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(String helpID)
    Set the help ID for the dialog.
    protected void
    Specify the title for the dialog.
    protected void
    Specify the title for the dialog.
    protected void
    setI18NTitle(String key, Object... args)
    Specify the title for the dialog.
    protected void
    Set the menu bar for the dialog.
    protected void
    setLocation(int x, int y)
    Set the location of the dialog.
    protected void
    Set the location of the dialog.
    protected void
     
    protected void
    setSize(int width, int height)
    Set the size of the dialog.
    protected void
    Set the size of the dialog.
    protected void
     
    void
     
    void
    setVisible(boolean b)
    Specify whether the dialog should be made visible on the screen or not.
    protected void
    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 Details

  • Constructor Details

    • ToolDialog

      protected ToolDialog(Component parent, UIFactory uif, String uiKey)
      Create standard 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.
    • ToolDialog

      protected ToolDialog(Component parent, UIFactory uif, String uiKey, int type)
      Create a ToolDialog with specified type.
      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.
      type - dialog type mask.
      See Also:
  • Method Details

    • getTool

      public Tool getTool()
      Get the tool for which this is a dialog.
      Returns:
      the tool for which this is a dialog
    • setTool

      public void setTool(Component parent)
    • setTool

      protected void setTool(Tool t)
    • 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

      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

      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:
    • pack

      public void pack()
      packs the dialog. The method is useful when it's necessary to call pack separately from setVisible(boolean)
      See Also:
    • 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 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 String getTitle()
      Get the title for the dialog.
      Returns:
      The title string for this dialog (localized)
      See Also:
    • setI18NTitle

      protected void setI18NTitle(String key)
      Specify the title for the dialog.
      Parameters:
      key - key to use to retrieve the dialogs title
      See Also:
    • setI18NTitle

      protected void setI18NTitle(String key, 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:
    • setI18NTitle

      protected void setI18NTitle(String key, 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:
    • setHelp

      protected void setHelp(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 JMenuBar getJMenuBar()
      Get the menu bar for the dialog.
      Returns:
      the menu bar being used for this dialog, may be null
      See Also:
    • setJMenuBar

      protected void setJMenuBar(JMenuBar menuBar)
      Set the menu bar for the dialog.
      Parameters:
      menuBar - The menu bar for this dialog; should not be null.
      See Also:
    • getBody

      protected Container getBody()
      Get the component for the main body of the dialog.
      Returns:
      the body container for this dialog
      See Also:
    • setBody

      protected void setBody(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 before the dialog is made visible.
      Parameters:
      body - the body container that should be used by this dialog
      See Also:
    • getButtons

      protected 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:
    • getDefaultButton

      protected 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

      protected void setButtons(JButton[] buttons, 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:
    • setComponentListener

      protected void setComponentListener(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 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

      protected void setSize(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:
    • 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:
    • getLocation

      protected 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

      protected void setLocation(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:
    • 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:
    • 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(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)