com.intellij.openapi.ui
Class DialogWrapper

java.lang.Object
  extended by com.intellij.openapi.ui.DialogWrapper
Direct Known Subclasses:
AbstractFieldPanel.Viewer, AbstractWizard, ContentChooser, HTTPProxySettingsDialog, Messages.ChooseDialog, Messages.InputDialog, OptionsDialog, PasswordPromptDialog, SelectDateDialog, SelectElementsToDeleteDialog, SelectFromListDialog

public abstract class DialogWrapper
extends java.lang.Object


Field Summary
static int CANCEL_EXIT_CODE
          The default exit code for "Cancel" action.
static java.lang.String DEFAULT_ACTION
          If your action returned by createActions method has non null value for this key, then the button that corresponds to the action will be the default button for the dialog.
static int NEXT_USER_EXIT_CODE
          If you use your custom exit codes you have have to start them with this constant.
static int OK_EXIT_CODE
          The default exit code for "OK" action.
 
Constructor Summary
protected DialogWrapper(boolean canBeParent)
           
protected DialogWrapper(java.awt.Component parent, boolean canBeParent)
           
protected DialogWrapper(Project project, boolean canBeParent)
          Creates modal DialogWrapper.
 
Method Summary
 void addKeyListener(java.awt.event.KeyListener listener)
           
 void addMouseListener(java.awt.event.MouseListener listener)
           
 void addMouseListener(java.awt.event.MouseMotionListener listener)
           
 void centerRelativeToParent()
           
 void clickDefaultButton()
          Programmatically perform a "click" of default dialog's button.
 void close(int exitCode)
          Closes and disposes the dialog and sets the specified exit code.
protected  javax.swing.Action[] createActions()
          This is factory method which creates action of dialog.
protected abstract  javax.swing.JComponent createCenterPanel()
          Factory method.
protected  javax.swing.JComponent createContentPane()
           
protected  javax.swing.border.Border createContentPaneBorder()
          Factory method.
protected  void createDefaultActions()
           
protected  javax.swing.JButton createJButtonForAction(javax.swing.Action action)
          Creates JButton for the specified action.
protected  javax.swing.Action[] createLeftSideActions()
           
protected  javax.swing.JComponent createNorthPanel()
          Factory method.
protected  javax.swing.JComponent createSouthPanel()
          This is factory method.
protected  javax.swing.JComponent createTitlePane()
           
protected  void dispose()
          Dispose the wrapped and releases all resources allocated be the wrapper to help more effecient garbage collection.
 void doCancelAction()
          This method is invoked by default implementation of "Cancel" action.
protected  void doHelpAction()
          This method is invoked by default implementation of "Help" action.
protected  void doOKAction()
          This method is invoked by default implementation of "OK" action.
protected  javax.swing.Action getCancelAction()
           
 java.awt.Container getContentPane()
           
 java.lang.String getDimensionKey()
           
protected  java.lang.String getDimensionServiceKey()
          This is factory method.
 int getExitCode()
           
protected  javax.swing.Action getHelpAction()
           
 float getHorizontalStretch()
           
 java.awt.Point getInitialLocation()
           
 java.awt.Point getLocation()
           
protected  javax.swing.Action getOKAction()
           
 java.awt.Window getOwner()
           
 javax.swing.JComponent getPreferredFocusedComponent()
           
 java.awt.Dimension getPreferredSize()
           
 javax.swing.JRootPane getRootPane()
           
 java.awt.Dimension getSize()
           
 java.lang.String getTitle()
           
 float getVerticalStretch()
           
 java.awt.Window getWindow()
           
protected  void init()
           
 boolean isModalProgress()
           
 boolean isOK()
           
 boolean isOKActionEnabled()
           
protected  boolean isProgressDialog()
           
 void isResizable()
           
 boolean isShowing()
           
 boolean isVisible()
           
 void pack()
           
 void repaint()
           
protected  void setButtonsAlignment(int alignment)
          Sets horizontal alignment of dialog's the buttons.
 void setButtonsMargin(java.awt.Insets insets)
          Sets margine for command buttons ("OK", "Cance", "Help").
protected  void setCancelButtonIcon(javax.swing.Icon icon)
           
protected  void setCancelButtonText(java.lang.String text)
           
 void setCrossClosesWindow(boolean crossClosesWindow)
           
protected  void setHorizontalStretch(float hStretch)
           
 void setLocation(int x, int y)
           
 void setLocation(java.awt.Point p)
           
 void setModal(boolean modal)
           
protected  void setOKActionEnabled(boolean isEnabled)
           
protected  void setOKButtonIcon(javax.swing.Icon icon)
           
protected  void setOKButtonText(java.lang.String text)
           
 void setResizable(boolean resizable)
           
 void setSize(int width, int height)
           
 void setTitle(java.lang.String title)
           
 void setUndecorated(boolean undecorated)
           
protected  void setVerticalStretch(float vStretch)
           
 boolean shouldCloseOnCross()
           
 void show()
           
 void toBack()
           
 void toFront()
           
 void validate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OK_EXIT_CODE

public static final int OK_EXIT_CODE
The default exit code for "OK" action.

See Also:
Constant Field Values

CANCEL_EXIT_CODE

public static final int CANCEL_EXIT_CODE
The default exit code for "Cancel" action.

See Also:
Constant Field Values

NEXT_USER_EXIT_CODE

public static final int NEXT_USER_EXIT_CODE
If you use your custom exit codes you have have to start them with this constant.

See Also:
Constant Field Values

DEFAULT_ACTION

public static final java.lang.String DEFAULT_ACTION
If your action returned by createActions method has non null value for this key, then the button that corresponds to the action will be the default button for the dialog. It's true if you don't change this behaviour of createJButtonForAction(Action) method.

See Also:
Constant Field Values
Constructor Detail

DialogWrapper

protected DialogWrapper(Project project,
                        boolean canBeParent)
Creates modal DialogWrapper. The currently active window will be the dialog's parent.

Parameters:
project - parent window for the dialog will be calculated based on focused window for the specified project. This parameter can be null. In this case parent window will be suggested based on current focused window.
canBeParent - specifies whether the dialog can be parent for other windows. This parameter is used by WindowManager.

DialogWrapper

protected DialogWrapper(boolean canBeParent)

DialogWrapper

protected DialogWrapper(java.awt.Component parent,
                        boolean canBeParent)
Parameters:
parent - parent component whicg is used to canculate heavy weight window ancestor. parent cannot be null and must be showing.
Method Detail

createDefaultActions

protected void createDefaultActions()

setUndecorated

public void setUndecorated(boolean undecorated)

addMouseListener

public final void addMouseListener(java.awt.event.MouseListener listener)
See Also:
Component.addMouseListener(java.awt.event.MouseListener)

addMouseListener

public final void addMouseListener(java.awt.event.MouseMotionListener listener)
See Also:
Component.addMouseMotionListener(java.awt.event.MouseMotionListener)

addKeyListener

public final void addKeyListener(java.awt.event.KeyListener listener)
See Also:
Component.addKeyListener(java.awt.event.KeyListener)

close

public final void close(int exitCode)
Closes and disposes the dialog and sets the specified exit code.


createContentPaneBorder

protected javax.swing.border.Border createContentPaneBorder()
Factory method. It creates border for dialog's content pane. By default content pane has has empty border with (8,8,8,8) insets. The subclasses can retirn null in overridden methods. In this case there will be no any border in the content pane.


createSouthPanel

protected javax.swing.JComponent createSouthPanel()
This is factory method. It creates the panel located at the south of the content pane. By default that panel contains dialog's buttons. This default implementation uses createActions() and createJButtonForAction(Action) methods to construct the panel.


createJButtonForAction

protected javax.swing.JButton createJButtonForAction(javax.swing.Action action)
Creates JButton for the specified action. If the button has not null value for DialogWrapper.DEFAULT_ACTION key then the created button will be the default one for the dialog.

See Also:
DEFAULT_ACTION

createTitlePane

protected javax.swing.JComponent createTitlePane()

createNorthPanel

protected javax.swing.JComponent createNorthPanel()
Factory method. It creates the panel located at the north of the dialog's content pane. The implementation can return null value. In this case there will be no input panel.


createCenterPanel

protected abstract javax.swing.JComponent createCenterPanel()
Factory method. It creates panel with dialog options. Options panel is located at the center of the dialog's content pane. The implementation can return null value. In this case there will be no options panel.


toFront

public void toFront()
See Also:
Window.toFront()

toBack

public void toBack()
See Also:
Window.toBack()

dispose

protected void dispose()
Dispose the wrapped and releases all resources allocated be the wrapper to help more effecient garbage collection. You should never invoke this method twice or invoke any method of the wrapper after invocation of dispose.


doCancelAction

public void doCancelAction()
This method is invoked by default implementation of "Cancel" action. It just closes dialog with CANCEL_EXIT_CODE. This is convenient place to override functionality of "Cancel" action. Note that the method does nothing if "Cancel" action isn't enabled.


clickDefaultButton

public void clickDefaultButton()
Programmatically perform a "click" of default dialog's button. The method does nothing if the dialog has no default button.


doOKAction

protected void doOKAction()
This method is invoked by default implementation of "OK" action. It just closes dialog with OK_EXIT_CODE. This is convenient place to override functionality of "OK" action. Note that the method does nothing if "OK" action isn't enabled.


shouldCloseOnCross

public boolean shouldCloseOnCross()
Returns:
whether the native window cross butoon closes the window or not. true means that cross performs hide or dispose of the dialog.

createActions

protected javax.swing.Action[] createActions()
This is factory method which creates action of dialog. Each action is represented by JButton which is created by createJButtonForAction(Action) method. These buttons are places into panel which is created by createButtonsPanel method. Therefore you have anough ways to customise the dialog by ovverriding of createActions(), createButtonsPanel() and createJButtonForAction(Action) methods. By default the createActions() method returns "OK" and "Cancel" action.

See Also:
createSouthPanel(), createJButtonForAction(javax.swing.Action)

createLeftSideActions

protected javax.swing.Action[] createLeftSideActions()

getOKAction

protected javax.swing.Action getOKAction()
Returns:
default implementation of "OK" action. This action just invokes doOKAction() method.
See Also:
doOKAction()

getCancelAction

protected javax.swing.Action getCancelAction()
Returns:
default implementation of "Cancel" action. This action just invokes doCancelAction() method.
See Also:
doCancelAction()

getHelpAction

protected javax.swing.Action getHelpAction()
Returns:
default implementation of "Help" action. This action just invokes doHelpAction() method.
See Also:
doHelpAction()

isProgressDialog

protected boolean isProgressDialog()

isModalProgress

public final boolean isModalProgress()

getContentPane

public java.awt.Container getContentPane()
See Also:
JDialog.getContentPane()

validate

public void validate()
See Also:
Container.validate()

repaint

public void repaint()
See Also:
Component.repaint()

getDimensionServiceKey

protected java.lang.String getDimensionServiceKey()
This is factory method. It returns key for installation into the dimension service. If this method returns null then the component does not require installation into dimension service. This default implementation returns null.


getDimensionKey

public final java.lang.String getDimensionKey()

getExitCode

public int getExitCode()

getPreferredFocusedComponent

public javax.swing.JComponent getPreferredFocusedComponent()
Returns:
component which should be focused when the dialog appears on the screen.

getHorizontalStretch

public final float getHorizontalStretch()
Returns:
horizontal stretch of the dialog. It means that the dialog's horizontal size is the product of horizontal stretch by horizontal size of packed dialog. The default value is 1.0f

getVerticalStretch

public final float getVerticalStretch()
Returns:
vertical stretch of the dialog. It means that the dialog's vertical size is the product of vertical stretch by vertical size of packed dialog. The default value is 1.0f

setHorizontalStretch

protected final void setHorizontalStretch(float hStretch)

setVerticalStretch

protected final void setVerticalStretch(float vStretch)

getOwner

public java.awt.Window getOwner()
See Also:
Window.getOwner()

getWindow

public java.awt.Window getWindow()

getRootPane

public javax.swing.JRootPane getRootPane()
See Also:
JDialog.getRootPane()

getSize

public java.awt.Dimension getSize()
See Also:
Component.getSize()

getTitle

public java.lang.String getTitle()
See Also:
Dialog.getTitle()

init

protected void init()

createContentPane

protected javax.swing.JComponent createContentPane()

pack

public void pack()
See Also:
Window.pack()

getPreferredSize

public java.awt.Dimension getPreferredSize()

setButtonsAlignment

protected final void setButtonsAlignment(int alignment)
Sets horizontal alignment of dialog's the buttons.

Parameters:
alignment - alignment of the buttons. Acceptable values are SwingConstants.CENTER and SwingConstants.RIGHT. The SwingConstants.RIGHT is the default value.
Throws:
java.lang.IllegalArgumentException - if alignment isn't acceptable

setButtonsMargin

public final void setButtonsMargin(java.awt.Insets insets)
Sets margine for command buttons ("OK", "Cance", "Help").


setCrossClosesWindow

public final void setCrossClosesWindow(boolean crossClosesWindow)

setCancelButtonIcon

protected final void setCancelButtonIcon(javax.swing.Icon icon)

setCancelButtonText

protected final void setCancelButtonText(java.lang.String text)

setModal

public void setModal(boolean modal)

setOKActionEnabled

protected void setOKActionEnabled(boolean isEnabled)

setOKButtonIcon

protected final void setOKButtonIcon(javax.swing.Icon icon)

setOKButtonText

protected final void setOKButtonText(java.lang.String text)

doHelpAction

protected void doHelpAction()
This method is invoked by default implementation of "Help" action. This is convenient place to override functionality of "Help" action. Note that the method does nothing if "Help" action isn't enabled.


isOK

public boolean isOK()

isOKActionEnabled

public boolean isOKActionEnabled()

isVisible

public boolean isVisible()
See Also:
Component.isVisible()

isShowing

public boolean isShowing()
See Also:
Window.isShowing()

setSize

public void setSize(int width,
                    int height)
See Also:
Component.setSize(int, int)

setTitle

public void setTitle(java.lang.String title)
See Also:
Dialog.setTitle(java.lang.String)

isResizable

public void isResizable()
See Also:
Dialog.isResizable()

setResizable

public void setResizable(boolean resizable)
See Also:
Dialog.setResizable(boolean)

getLocation

public java.awt.Point getLocation()
See Also:
Component.getLocation()

setLocation

public void setLocation(java.awt.Point p)
See Also:
Component.setLocation(Point)

setLocation

public void setLocation(int x,
                        int y)
See Also:
Component.setLocation(int,int)

centerRelativeToParent

public void centerRelativeToParent()

show

public void show()

getInitialLocation

public java.awt.Point getInitialLocation()
Returns:
Location in absolute coordinates which is used when dialog has no dimension service key or no position was stored yet. Can return null. In that case dialog will be centered relative to its owner.