|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.richclient.application.support.ApplicationServicesAccessor
org.springframework.richclient.dialog.ApplicationDialog
public abstract class ApplicationDialog
Abstract Base Class for a dialog with standard layout, buttons, and behavior.
Use of this class will apply a standard appearance to dialogs in the application.
Subclasses implement the body of the dialog (wherein business objects are
manipulated), and the action taken by the OK
button. Aside
from creating the dialog's contentj with createDialogContentPane()
,
a proper disposing should be implemented in
disposeDialogContentPane()
.
Services of a ApplicationDialog
include:
OK
and Cancel
buttons at the bottom of the
dialog -OK
is the default, and the Escape
key
activates Cancel
(the latter works only if the dialog receives
the escape keystroke, and not one of its components)
Field Summary | |
---|---|
protected static String |
DEFAULT_CANCEL_COMMAND_ID
|
protected static String |
DEFAULT_FINISH_COMMAND_ID
|
protected static String |
DEFAULT_FINISH_SUCCESS_MESSAGE_KEY
|
protected static String |
DEFAULT_FINISH_SUCCESS_TITLE_KEY
|
protected org.apache.commons.logging.Log |
logger
|
protected static String |
SUCCESS_FINISH_MESSAGE_KEY
|
protected static String |
SUCCESS_FINISH_TITLE_KEY
|
Constructor Summary | |
---|---|
ApplicationDialog()
Create dialog with default closeAction CloseAction.DISPOSE . |
|
ApplicationDialog(String title,
Component parent)
Create dialog with default closeAction CloseAction.DISPOSE . |
|
ApplicationDialog(String title,
Component parent,
CloseAction closeAction)
Creates a new application dialog. |
Method Summary | |
---|---|
protected void |
addActionKeyBinding(KeyStroke key,
String actionKey)
Add an action key binding to this dialog. |
protected void |
addActionKeyBinding(KeyStroke key,
String actionKey,
Action action)
Add an action key binding to this dialog. |
protected void |
addDialogComponents()
Subclasses may override to customize how this dialog is built. |
protected void |
attachListeners()
Attach the handler that invokes the lifecycle methods on the ApplicationDialog . |
protected void |
componentsChanged()
Subclasses should call if layout of the dialog components changes. |
protected JComponent |
createButtonBar()
Return a standardized row of command buttons, right-justified and all of the same size, with OK as the default button, and no mnemonics used, as per the Java Look and Feel guidelines. |
protected void |
createDialog()
Builds/initializes the dialog and all of its components. |
protected abstract JComponent |
createDialogContentPane()
Return the GUI which allows the user to manipulate the business objects related to this dialog. |
protected void |
dispose()
Close and dispose of the visual dialog. |
protected void |
disposeDialogContentPane()
Cleanup any components/objects that are created during createDialogContentPane() . |
protected ActionMap |
getActionMap()
Return the ActionMap of the dialog. |
protected ActionCommand |
getCallingCommand()
Returns the command that opened this dialog. |
protected ActionCommand |
getCancelCommand()
Returns the cancel command. |
protected String |
getCancelCommandId()
Returns the id for the cancel command. |
protected Object[] |
getCommandGroupMembers()
Template getter method to return the commands to populate the dialog button bar. |
JDialog |
getDialog()
Return the JDialog, create it if needed (lazy). |
protected Container |
getDialogContentPane()
Return the contentPane of the dialog. |
protected boolean |
getDisplayFinishSuccessMessage()
Return the message that needs to be set on a succesful finish. |
protected ActionCommand |
getFinishCommand()
Returns the finish command. |
protected String |
getFinishCommandId()
Subclasses may override to return a custom message key, default is "okCommand", corresponding to the "&OK" label. |
protected String |
getFinishSecurityControllerId()
Subclasses may override to return a security controller id to be attached to the finish command. |
protected String |
getFinishSuccessMessage()
Returns the message to use upon succesful finish. |
protected Object[] |
getFinishSuccessMessageArguments()
Returns the arguments to use in the succesful finish message. |
protected String |
getFinishSuccessTitle()
Returns the title to use upon succesful finish. |
protected Object[] |
getFinishSuccessTitleArguments()
Returns the arguments to use in the finish succesful title. |
protected InputMap |
getInputMap()
Return the InputMap of the dialog. |
protected Point |
getLocation()
Return the location of the dialog. |
protected Component |
getLocationRelativeTo()
Return the relative location of the dialog. |
Component |
getParentComponent()
Returns the parent Component. |
Window |
getParentWindow()
Returns the parent window based on the internal parent Component. |
protected Dimension |
getPreferredSize()
Return the preferred size for the dialog. |
protected String |
getTitle()
Returns the title of this dialog. |
static Window |
getWindowForComponent(Component parentComponent)
--jh-- This method is copied from JOptionPane. |
protected void |
hide()
Hide the dialog. |
protected void |
init()
Hook called in constructor. |
boolean |
isControlCreated()
Returns true if the JDialog is constructed. |
boolean |
isEnabled()
Returns whether this Dialog is enabled. |
boolean |
isShowing()
Returns true if the JDialog is showing. |
protected void |
onAboutToShow()
Template lifecycle method invoked right before the dialog is to become visible. |
protected void |
onCancel()
Handle a dialog cancellation request. |
protected abstract boolean |
onFinish()
Request invocation of the action taken when the user hits the OK (finish) button. |
protected void |
onInitialized()
Template lifecycle method invoked after the dialog control is initialized. |
protected void |
onWindowActivated()
Template lifecycle method invoked when the dialog is activated. |
protected void |
onWindowClosing()
Template lifecycle method invoked when the dialog's window is closing. |
protected void |
onWindowGainedFocus()
Template lifecycle method invoked when the dialog gains focus. |
protected void |
onWindowLostFocus()
Template lifecycle method invoked when the dialog loses focus. |
protected void |
registerCancelCommandAsDefault()
Register the cancel button as the default dialog button. |
protected void |
registerDefaultCommand()
Register the finish button as the default dialog button. |
protected void |
registerDefaultCommand(ActionCommand command)
Register the provided button as the default dialog button. |
void |
setCallingCommand(ActionCommand callingCommand)
Set the command that opened this dialog. |
void |
setCloseAction(CloseAction action)
Set the CloseAction of this dialog. |
void |
setDefaultEnabled(boolean enabled)
When opening the dialog, the finish button can be enabled by default. |
void |
setDisplayFinishSuccessMessage(boolean displayFinishSuccessMessage)
Message to show upon succesful completion. |
void |
setEnabled(boolean enabled)
Enable/disable the finish command of the dialog. |
protected void |
setFinishEnabled(boolean enabled)
Enable/disable the finish command. |
void |
setLocation(Point location)
Set a specific location for the JDialog to popup. |
void |
setLocationRelativeTo(Component locationRelativeTo)
Set a relative location for the JDialog to popup. |
void |
setModal(boolean modal)
Set the modal property of the dialog. |
void |
setParentComponent(Component parentComponent)
The parent Component that will be used to extract the Frame/Dialog owner for the JDialog at creation. |
void |
setPreferredSize(Dimension preferredSize)
Set the preferrred size for the JDialog. |
void |
setResizable(boolean resizable)
Set the resizable property of the dialog. |
void |
setTitle(String title)
Sets the title. |
void |
showDialog()
Show the dialog. |
protected void |
showFinishSuccessMessageDialog()
Opens a dialog which contains the sussesful finish message. |
Methods inherited from class org.springframework.richclient.application.support.ApplicationServicesAccessor |
---|
getActiveWindow, getApplication, getApplicationContext, getApplicationName, getApplicationServices, getCommandConfigurer, getComponentFactory, getConversionService, getIconSource, getImageSource, getMessage, getMessage, getMessage, getMessage, getMessages, getMessageSource, getObjectConfigurer, getService |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String DEFAULT_FINISH_COMMAND_ID
protected static final String DEFAULT_CANCEL_COMMAND_ID
protected static final String DEFAULT_FINISH_SUCCESS_MESSAGE_KEY
protected static final String DEFAULT_FINISH_SUCCESS_TITLE_KEY
protected static final String SUCCESS_FINISH_MESSAGE_KEY
protected static final String SUCCESS_FINISH_TITLE_KEY
protected final org.apache.commons.logging.Log logger
Constructor Detail |
---|
public ApplicationDialog()
CloseAction.DISPOSE
. No
parent or title set.
init()
public ApplicationDialog(String title, Component parent)
CloseAction.DISPOSE
.
title
- text that will appear on dialog's titlebar.parent
- component serving as parent in it's hierarchy.init()
public ApplicationDialog(String title, Component parent, CloseAction closeAction)
title
- text which appears in the title bar after the name of the
application.parent
- frame to which this dialog is attached.closeAction
- sets the behaviour of the dialog upon close. Default
closeAction is CloseAction.DISPOSE
.init()
Method Detail |
---|
protected void init()
public void setTitle(String title)
setTitle
in interface TitleConfigurable
title
- the titleprotected String getTitle()
getCallingCommandText()
,
DEFAULT_DIALOG_TITLE
public void setParentComponent(Component parentComponent)
parentComponent
- Component that is a Frame/Window or has one in its
parent hierarchy.public Component getParentComponent()
setParentComponent(Component)
public void setCloseAction(CloseAction action)
CloseAction
of this dialog. Default action is
CloseAction.DISPOSE
which disposes the visual dialog upon
closing. When using CloseAction.HIDE
the visual components are
cached and reused.
action
- the CloseAction
to use when closing the dialog.public void setDefaultEnabled(boolean enabled)
enabled
- true
when the finish button should be
enabled by default, false
otherwise.public void setModal(boolean modal)
Dialog.setModal(boolean)
public void setResizable(boolean resizable)
Dialog.setResizable(boolean)
public void setLocation(Point location)
location
- point on screen where to place the JDialog.public void setLocationRelativeTo(Component locationRelativeTo)
Window.setLocationRelativeTo(Component)
public void setPreferredSize(Dimension preferredSize)
JComponent.setPreferredSize(Dimension)
public void setEnabled(boolean enabled)
setEnabled
in interface Guarded
enabled
- true
to enable the object, false
to disable it.public void setDisplayFinishSuccessMessage(boolean displayFinishSuccessMessage)
public void setCallingCommand(ActionCommand callingCommand)
getFinishSuccessMessage()
,
getFinishSuccessTitle()
protected void setFinishEnabled(boolean enabled)
public boolean isEnabled()
isEnabled
in interface Guarded
public boolean isShowing()
true
if the JDialog is showing.
Window.isShowing()
public boolean isControlCreated()
true
if the JDialog is constructed.
public JDialog getDialog()
protected Container getDialogContentPane()
JDialog.getContentPane()
public void showDialog()
Show the dialog. The dialog will be created if it doesn't exist yet. Before setting the dialog visible, a hook method onAboutToShow is called and the location will be set.
When showing the dialog several times, it will always be opened on the location that has been set, or relative to the parent. (former location will not persist)
protected void componentsChanged()
protected final void createDialog()
Follows the Java Look and Feel guidelines for spacing elements.
public static Window getWindowForComponent(Component parentComponent) throws HeadlessException
--jh-- This method is copied from JOptionPane. I'm still trying to figure out why they chose to have a static method with package visibility for this one instead of just making it public.
Returns the specified component's toplevelFrame
or
Dialog
.
parentComponent
- the Component
to check for a
Frame
or Dialog
Frame
or Dialog
that contains
the component, or the default frame if the component is null
,
or does not have a valid Frame
or Dialog
parent
HeadlessException
- if
GraphicsEnvironment.isHeadless
returns true
GraphicsEnvironment.isHeadless()
protected String getFinishCommandId()
protected String getFinishSecurityControllerId()
protected abstract boolean onFinish()
OK
(finish) button.
protected boolean getDisplayFinishSuccessMessage()
protected void showFinishSuccessMessageDialog()
getFinishSuccessTitle()
,
getFinishSuccessMessage()
protected String getFinishSuccessMessage()
protected ActionCommand getCallingCommand()
protected Object[] getFinishSuccessMessageArguments()
protected String getFinishSuccessTitle()
protected Object[] getFinishSuccessTitleArguments()
protected String getCancelCommandId()
protected ActionCommand getFinishCommand()
protected ActionCommand getCancelCommand()
protected void addActionKeyBinding(KeyStroke key, String actionKey)
key
- the KeyStroke
that triggers the command/action.actionKey
- id of command that will be triggered by the KeyStroke
.addActionKeyBinding(KeyStroke, String, Action)
protected void addActionKeyBinding(KeyStroke key, String actionKey, Action action)
key
- the KeyStroke
that triggers the command/action.actionKey
- id of the action.action
- Action
that will be triggered by the KeyStroke
.getActionMap()
,
getInputMap()
,
ActionMap.put(Object, Action)
,
InputMap.put(KeyStroke, Object)
protected ActionMap getActionMap()
ActionMap
of the dialog.
JComponent.getActionMap()
protected InputMap getInputMap()
InputMap
of the dialog.
JComponent.getInputMap(int)
protected void addDialogComponents()
protected Point getLocation()
protected Component getLocationRelativeTo()
protected Dimension getPreferredSize()
protected abstract JComponent createDialogContentPane()
OK
and Cancel
buttons, in a standard manner.
Any components/objects created at this point need to be disposed in
disposeDialogContentPane()
.
disposeDialogContentPane()
protected final void attachListeners()
ApplicationDialog
.
DialogEventHandler
protected JComponent createButtonBar()
protected Object[] getCommandGroupMembers()
protected void registerDefaultCommand()
protected final void registerCancelCommandAsDefault()
protected final void registerDefaultCommand(ActionCommand command)
command
- The button to become the default.protected void onInitialized()
protected void onAboutToShow()
protected void onWindowGainedFocus()
protected void onWindowActivated()
protected void onWindowLostFocus()
protected void onWindowClosing()
protected void onCancel()
protected final void dispose()
disposeDialogContentPane()
. Any other objects that are created
in createDialogContentPane()
can be handled here as well.
disposeDialogContentPane()
protected void disposeDialogContentPane()
createDialogContentPane()
. This method is called if the
CloseAction
is set to CloseAction.DISPOSE
and the dialog
is being closed. This ensures that when disposing the surrounding dialog,
the content pane can be disposed as well.
createDialogContentPane()
,
dispose()
protected final void hide()
public Window getParentWindow()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |