org.openpermis.editor.policy.view
Class WizardDialog

java.lang.Object
  extended by org.openpermis.editor.policy.view.WizardDialog
Direct Known Subclasses:
CertificateChooser, LdapSelector, MessageDialog, SigningWizard

public abstract class WizardDialog
extends Object

Base class for wizard dialogs.

Since:
0.9.0

Nested Class Summary
protected static class WizardDialog.ContentStyle
          Determines how the content is presented.
 
Field Summary
protected static String CHOOSER_TEXT
          The text on the directory chooser buttons.
protected static String NEXT_FOCUS
          Client property for chooser buttons that contains the next focus field.
protected static int TEXT_AREA_ROWS
          The number of default rows in a text area.
protected static int TEXT_FIELD_COLUMNS
          The number of columns in a text field.
 
Constructor Summary
WizardDialog(ApplicationContext context)
          Creates a wizard dialog with the specified settings.
 
Method Summary
protected  File chooseFile(ApplicationContext.FileChooserType chooserType, FileType fileType, JTextField target)
          Opens a file chooser of the specified type and file type for the target text field.
 void close(boolean resultCode)
          Closes this dialog if it is currently showing.
protected
<T extends JTextComponent>
T
configure(T component)
          Configures the specified text component.
protected  void configureButton(JButton button, Action action)
          Configures a button that has the specified action.
protected  JComponent createButtonPane(ControlFactory controlFactory)
          Creates the button pane of this dialog.
protected  JButton createChooser(ApplicationContext.FileChooserType chooserType, FileType fileType, JTextField target)
          Creates a file chooser button for the specified target field.
protected  JComponent createContentPane(ControlFactory controlFactory)
          Creates the content pane of this dialog.
protected  JComponent createDialogContent(ControlFactory controlFactory)
          Creates the complete content pane of the dialog.
protected  JTextField createDisplayTextField(Action action)
          Creates and configures a disabled text field.
protected  FormBuilder createFormBuilder()
          Creates a form builder that is configured for use with this wizard.
protected  JComponent createHeaderPane(ControlFactory controlFactory)
          Creates the header pane of this dialog.
protected  JLabel createLabel(String name)
          Creates a named label for automated translation.
protected  JPasswordField createPasswordField()
          Creates and configures a password field.
protected  void focusNextComponent(JComponent target)
          Programmatically moves the focus to the next focus component for the specified target.
protected  Action getAction(String name)
          Returns the action from the action map with the specified name.
protected  ActionMap getActionMap()
           
protected  ApplicationContext getApplicationContext()
          Returns the context of the application that owns this view.
protected  List<Action> getButtonActions()
          Returns a list of actions to use for buttons at the bottom of the dialog.
protected  Action getCancelAction()
          Returns the default action to trigger if the cancel key is pressed.
protected  WizardDialog.ContentStyle getContentStyle()
          Returns the content pane wrapping style.
protected  JButton getDefaultButton()
           
protected  JDialog getDialog()
           
protected  String getDialogTitle()
          Returns the title used by the wizard dialog.
protected  Action getExecuteAction()
          Returns the default action to trigger if the enter key is pressed.
protected  org.jdesktop.application.ResourceMap getResourceMap()
           
protected  String getTitleDescriptionKey()
          Returns the key of the title description to display.
protected  String getTitleIconKey()
          Returns the key of the icon to display.
protected  String getTitleTextKey()
          Returns the key of the title text to display.
protected abstract  boolean initialize(Component parent)
          Initialize some wizard specific fields.
protected  boolean sameAction(Action a1, Action a2)
          Compares the names of two actions and returns true if they are equivalent.
protected  void setNextFocusComponent(JComponent target, JComponent nextFocus)
          Sets the next focus for a target component.
 boolean show(Component parent)
          Starts the wizard.
protected  void showErrorDialog(Component parent, String key, Object... args)
          Shows an error dialog with the specified title, message and paramters.
protected  void showErrorDialog(String key, Object... args)
          Shows an error dialog with the specified title, message and paramters.
protected abstract  void updateActions()
          Updates the actions according to the values in the wizard fields.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TEXT_FIELD_COLUMNS

protected static final int TEXT_FIELD_COLUMNS
The number of columns in a text field.

Constant Field Value:
20
Since:
0.9.0

TEXT_AREA_ROWS

protected static final int TEXT_AREA_ROWS
The number of default rows in a text area.

Constant Field Value:
5
Since:
0.9.0

CHOOSER_TEXT

protected static final String CHOOSER_TEXT
The text on the directory chooser buttons.

Constant Field Value:
"..."
Since:
0.9.0

NEXT_FOCUS

protected static final String NEXT_FOCUS
Client property for chooser buttons that contains the next focus field.

Constant Field Value:
"chooserNextFocus"
Since:
0.9.0
Constructor Detail

WizardDialog

public WizardDialog(ApplicationContext context)
Creates a wizard dialog with the specified settings.

Parameters:
context - the application context used to lookup the action and resource map.
Since:
0.9.0
Method Detail

getTitleIconKey

protected String getTitleIconKey()
Returns the key of the icon to display.

Lookup of the actual icon is performed using the getResourceMap().

The default value returned is View.icon.

Returns:
the key requested.
Since:
0.9.0

getTitleTextKey

protected String getTitleTextKey()
Returns the key of the title text to display.

Lookup of the actual text is performed using the getResourceMap().

The default value returned is View.title.

Returns:
the key requested.
Since:
0.9.0

getTitleDescriptionKey

protected String getTitleDescriptionKey()
Returns the key of the title description to display.

Lookup of the actual text is performed using the getResourceMap().

The default value returned is View.description.

Returns:
the key requested.
Since:
0.9.0

getButtonActions

protected List<Action> getButtonActions()
Returns a list of actions to use for buttons at the bottom of the dialog.

The default value returned is a list containing the name of the getCancelAction() and getExecuteAction().

Returns:
the list of button action keys to display.
Since:
0.9.0

getExecuteAction

protected Action getExecuteAction()
Returns the default action to trigger if the enter key is pressed.

Returns the action with the name execute by default.

Returns:
the execute action, may be null to disable key binding.
Since:
0.9.0

getCancelAction

protected Action getCancelAction()
Returns the default action to trigger if the cancel key is pressed.

Returns the action with the name cancel by default.

Returns:
the cancel action, may be null to disable key binding.
Since:
0.9.0

createDialogContent

protected JComponent createDialogContent(ControlFactory controlFactory)
Creates the complete content pane of the dialog.

Parameters:
controlFactory - the control factory to use for creating controls.
Returns:
the content pane of the dialog, including header and buttons.
Since:
0.9.0

createHeaderPane

protected JComponent createHeaderPane(ControlFactory controlFactory)
Creates the header pane of this dialog.

The default implementation creates a HeaderPane with the dialog icon, title and description.

Parameters:
controlFactory - the control factory to use for creating controls.
Returns:
the header pane requested.
Since:
0.9.0

getDialogTitle

protected String getDialogTitle()
Returns the title used by the wizard dialog.

Returns:
the title used by the wizard dialog.
Since:
0.9.0

getContentStyle

protected WizardDialog.ContentStyle getContentStyle()
Returns the content pane wrapping style.

Returns:
the content pane wrapping style to use.
Since:
0.9.0

createContentPane

protected JComponent createContentPane(ControlFactory controlFactory)
Creates the content pane of this dialog.

Parameters:
controlFactory - the control factory to use for creating controls.
Returns:
the content pane requested.
Since:
0.9.0

sameAction

protected boolean sameAction(Action a1,
                             Action a2)
Compares the names of two actions and returns true if they are equivalent.

Parameters:
a1 - the first action.
a2 - the second action.
Returns:
true if both actions have the same name, false otherwise.
Since:
0.9.0

configureButton

protected void configureButton(JButton button,
                               Action action)
Configures a button that has the specified action.

Parameters:
button - the button to configure.
action - the action of the button.
Since:
0.9.0

createButtonPane

protected JComponent createButtonPane(ControlFactory controlFactory)
Creates the button pane of this dialog.

The default implementation creates a panel with buttons for all the getButtonActions().

Sets the default button according to the default action.

Parameters:
controlFactory - the control factory to use for creating controls.
Returns:
the button pane requested.
Since:
0.9.0

updateActions

protected abstract void updateActions()
Updates the actions according to the values in the wizard fields.

Since:
0.9.0

initialize

protected abstract boolean initialize(Component parent)
Initialize some wizard specific fields.

Parameters:
parent - the parent component of the dialog.
Returns:
true if the initialization succeeded, false otherwise.
Since:
0.9.0

getApplicationContext

protected final ApplicationContext getApplicationContext()
Returns the context of the application that owns this view.

Returns:
the context of the application that owns this view.
Since:
0.9.0

getActionMap

protected final ActionMap getActionMap()
Returns:
the actionMap.
Since:
0.9.0

getAction

protected final Action getAction(String name)
Returns the action from the action map with the specified name.

Parameters:
name - the name of the action to return.
Returns:
the action requested, null if the action is not defined.
See Also:
getActionMap()
Since:
0.9.0

getResourceMap

protected final org.jdesktop.application.ResourceMap getResourceMap()
Returns:
the resourceMap.
Since:
0.9.0

getDialog

protected final JDialog getDialog()
Returns:
the dialog.
Since:
0.9.0

getDefaultButton

protected final JButton getDefaultButton()
Returns:
the defaultButton.
Since:
0.9.0

show

public boolean show(Component parent)
Starts the wizard.

Parameters:
parent - the parent component of the dialog.
Returns:
the result code of the dialog.
Since:
0.9.0

close

public void close(boolean resultCode)
Closes this dialog if it is currently showing.

Parameters:
resultCode - the return value for show(Component).
Since:
0.9.0

createFormBuilder

protected FormBuilder createFormBuilder()
Creates a form builder that is configured for use with this wizard.

Returns:
the form builder requested.
Since:
0.9.0

configure

protected final <T extends JTextComponent> T configure(T component)
Configures the specified text component.

Changes to the document of the text component will cause the actions of the wizard to be updated (see updateActions().

Type Parameters:
T - the type of text component to configure.
Parameters:
component - the text component to configure.
Returns:
the text component passed in for fluent use.
Since:
0.9.0

createLabel

protected final JLabel createLabel(String name)
Creates a named label for automated translation.

Parameters:
name - the name of the label.
Returns:
the label created.
Since:
0.9.0

createDisplayTextField

protected final JTextField createDisplayTextField(Action action)
Creates and configures a disabled text field.

Display text fields are usually paired with a chooser button.

Parameters:
action - optional that is responsible for filling the text field, if non-null the action is used as single-click target on the text field.
Returns:
the text field created.
Since:
0.9.0

createPasswordField

protected final JPasswordField createPasswordField()
Creates and configures a password field.

Returns:
the password field created.
Since:
0.9.0

setNextFocusComponent

protected final void setNextFocusComponent(JComponent target,
                                           JComponent nextFocus)
Sets the next focus for a target component.

Parameters:
target - the target for which to set the next focus.
nextFocus - the next focus component.
See Also:
focusNextComponent(JComponent)
Since:
0.9.0

focusNextComponent

protected final void focusNextComponent(JComponent target)
Programmatically moves the focus to the next focus component for the specified target.

Parameters:
target - the target for which to move the focus.
See Also:
setNextFocusComponent(JComponent, JComponent)
Since:
0.9.0

chooseFile

protected final File chooseFile(ApplicationContext.FileChooserType chooserType,
                                FileType fileType,
                                JTextField target)
Opens a file chooser of the specified type and file type for the target text field.

The choice is stored in the target text field.

Parameters:
chooserType - the type of chooser to open.
fileType - the file type to filter choices on.
target - the text field target to receive the selected file name.
Returns:
the file chosen, null if the user aborted.
Since:
0.9.0

createChooser

protected final JButton createChooser(ApplicationContext.FileChooserType chooserType,
                                      FileType fileType,
                                      JTextField target)
Creates a file chooser button for the specified target field.

Parameters:
chooserType - the file chooser type, either JFileChooser.OPEN_DIALOG or FileChooser.SAVE_DIALOG .
fileType - the file filter to use.
target - the field to store the chosen file to.
Returns:
the button created.
Since:
0.9.0

showErrorDialog

protected void showErrorDialog(String key,
                               Object... args)
Shows an error dialog with the specified title, message and paramters.

Parameters:
key - translation key for the title.
args - optional parameters for the title and message.
Since:
0.9.0

showErrorDialog

protected void showErrorDialog(Component parent,
                               String key,
                               Object... args)
Shows an error dialog with the specified title, message and paramters.

Parameters:
parent - the parent component to show the error dialog for.
key - translation key for the title.
args - optional parameters for the title and message.
Since:
0.9.0


OpenPermis Role Based Access Control 0.9.0 (Build 16)
2009/08/13 07:17:21
Copyright (c) 2002-2007 Ergon Informatik AG