***  This class is subject to change.  ***

com.sas.swing.visuals
Class OptionsDialog

com.sas.swing.visuals.OptionsDialog
All Implemented Interfaces:
LayoutConstants, java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants
Direct Known Subclasses:
EntityAttributeValueDialog, FormatSelector, QualifiersDialog, SelectorDialog

public class OptionsDialog
implements LayoutConstants, java.awt.event.ActionListener

A generic dialog class that handles adding and responding to general buttons such as "OK", "Cancel", "Apply", etc.

See Also:
Serialized Form

Field Summary
protected  int buttons
           
static java.lang.String RB_KEY
           
 
Fields inherited from interface com.sas.swing.visuals.util.LayoutConstants
DOTS_BUTTON_INSETS, EMPTY_INSETS, HGAP, HMARGIN, INDENTED_BORDER, TAB_BORDER, TEXTFIELD_INSETS, VGAP, VMARGIN
 
Constructor Summary
OptionsDialog(java.awt.Frame parent, PanelInterface panel, boolean modal)
          Creates a new Dialog for the specified panel.
OptionsDialog(java.awt.Frame f, PanelInterface panel, boolean modal, int buttons, int buttonLocation)
          Creates a new Dialog for the specified panel.
OptionsDialog(java.awt.Frame parent, java.lang.String title, boolean modal)
          Creates a new dialog initialized with the specified title.
OptionsDialog(java.awt.Frame f, java.lang.String title, boolean modal, int buttons, int buttonLocation)
          Creates a new dialog initialized with the specified title and buttons.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent actionEvent)
           
 void addButton(javax.swing.AbstractButton b)
          Adds the specified button to the dialog.
protected  javax.swing.AbstractButton[] createButtons(int newButtons)
          Factory method to create the buttons for the specified identifiers.
protected  javax.swing.AbstractButton getButton(int id)
           
 int getButtonLocation()
          Returns the location of the buttons in the dialog.
 java.lang.String getHelpID()
          Returns the help id for this dialog.
 javax.swing.JPanel getMainPanel()
          Returns the main panel of this dialog.
 PanelInterface getPanel()
          Returns that panel hosted by this dialog.
 void onApply()
          Handles the "apply" action which usually occurs whenever the button for the CommonButtons.APPLY_BUTTON identifier is pressed.
 void onCancel()
          Handles the "cancel" action which usually occurs whenever the button for the CommonButtons.CANCEL_BUTTON identifier is pressed.
 void onClose()
          Handles the "close" action which usually occurs whenever the button for the CommonButtons.CLOSE_BUTTON identifier is pressed.
 void onHelp()
          Handles the "help" action which usually occurs whenever the button for the CommonButtons.HELP_BUTTON identifier is pressed.
 void onOK()
          Handles the "ok" action.
protected  void processWindowEvent(java.awt.event.WindowEvent event)
          Process the window events that occur on this dialog.
 void setButtonLocation(int newButtonLocation)
          Sets the location of the buttons in the dialog.
 void setButtons(int newButtons)
          Adds the specified buttons to the dialog.
 void setHelpID(java.lang.String newValue)
          Sets the help id for this dialog.
 void setPanel(PanelInterface newValue)
          Sets the panel to be hosted by this dialog.
 void setVisible(boolean visible)
           
protected  void updateButtonsForPanel()
           
 boolean wasCancelled()
          Indicates if this dialog was cancelled after it was displayed.
 

Field Detail

RB_KEY

public static final java.lang.String RB_KEY
See Also:
Constant Field Values

buttons

protected int buttons
Constructor Detail

OptionsDialog

public OptionsDialog(java.awt.Frame parent,
                     java.lang.String title,
                     boolean modal)
Creates a new dialog initialized with the specified title. The new dialog will have the default buttons positioned in the CommonButtons.SOUTH_EAST location.

This is an alias for:

    Dialog(parent, title, modal, CommonButtons.OK_CANCEL_BUTTONS, CommonButtons.SOUTH_EAST)
 

Parameters:
parent - the parent frame of the new dialog
title - the title of the dialog to display on the title bar
modal - true for modal, false for non-modal

OptionsDialog

public OptionsDialog(java.awt.Frame f,
                     java.lang.String title,
                     boolean modal,
                     int buttons,
                     int buttonLocation)
Creates a new dialog initialized with the specified title and buttons.

Valid button identifiers and locations are any of those or a combination of those from CommonButtons.

Parameters:
parent - the parent frame of the new dialog
title - the title of the dialog to display on the title bar
modal - true for modal, false for non-modal
buttons - the buttons to add to the dialog
buttonLocation - the location to position the buttons on the dialog

OptionsDialog

public OptionsDialog(java.awt.Frame parent,
                     PanelInterface panel,
                     boolean modal)
Creates a new Dialog for the specified panel. The new dialog will have ok and cancel positioned in the CommonButtons.SOUTH_EAST location.

This is an alias for:

    Dialog(parent, panel, modal, CommonButtons.OK_CANCEL_BUTTONS, CommonButtons.SOUTH_EAST)
 

Parameters:
parent - the parent frame of the new dialog
panel - the panel to display in the dialog
modal - true for modal, false for non-modal
app - the application that owns this dialog

OptionsDialog

public OptionsDialog(java.awt.Frame f,
                     PanelInterface panel,
                     boolean modal,
                     int buttons,
                     int buttonLocation)
Creates a new Dialog for the specified panel. This is a convenience for creating a new dialog and calling setPanel().

Parameters:
f - the parent frame of the new dialog
panel - the panel to display in the dialog
modal - true for modal, false for non-modal
app - the application which owns this dialog
Method Detail

getMainPanel

public javax.swing.JPanel getMainPanel()
Returns the main panel of this dialog. All custom components should be added to this panel.

Returns:
the main panel of this dialog

getHelpID

public java.lang.String getHelpID()
Returns the help id for this dialog. The help id serves as the context for help presented via a JavaHelp system. The help id can be null.

Returns:
the help id for this dialog or null

setHelpID

public void setHelpID(java.lang.String newValue)
Sets the help id for this dialog.

Parameters:
newValue - the new help id

wasCancelled

public boolean wasCancelled()
Indicates if this dialog was cancelled after it was displayed.

Returns:
true if cancelled, otherwise false

onApply

public void onApply()
Handles the "apply" action which usually occurs whenever the button for the CommonButtons.APPLY_BUTTON identifier is pressed. This is also called from the onOK method. If this dialog hosts an instance of PanelInterface its onApply() method will first be called.


onCancel

public void onCancel()
Handles the "cancel" action which usually occurs whenever the button for the CommonButtons.CANCEL_BUTTON identifier is pressed. This method hides the dialog by calling the onClose() method. If this dialog hosts an instance of PanelInterface its onCancel() method will first be called.


onClose

public void onClose()
Handles the "close" action which usually occurs whenever the button for the CommonButtons.CLOSE_BUTTON identifier is pressed. This is also called from the onCancel and onOK() methods. The dialog is hidden by calling setVisible(false).

If this dialog hosts an instance of PanelInterface then its isContentsValid() method will first be called. If the isContentsValid() method returns false, then the onClose method returns without doing anything else. If it returns true, then the PanelInterface onClose() method is called, followed by the dialog being hidden by calling setVisible(false).


onOK

public void onOK()
Handles the "ok" action. This occurs whenever the button for the CommonButtons.OK_BUTTON identifier is pressed. This method first applies any changes by calling the onApply() method and then it hides the dialog by calling the onClose() method.


getPanel

public PanelInterface getPanel()
Returns that panel hosted by this dialog.

Returns:
the panel hosted by this dialog or null

setPanel

public void setPanel(PanelInterface newValue)
Sets the panel to be hosted by this dialog.

Parameters:
newValue - the panel to be hosted by this dialog

updateButtonsForPanel

protected void updateButtonsForPanel()

getButton

protected javax.swing.AbstractButton getButton(int id)

onHelp

public void onHelp()
Handles the "help" action which usually occurs whenever the button for the CommonButtons.HELP_BUTTON identifier is pressed. By default, does nothing.


setButtons

public void setButtons(int newButtons)
Adds the specified buttons to the dialog.

Valid button identifiers are any of those or a combination of those from CommonButtons.

Parameters:
buttons - the buttons to add to the dialog

createButtons

protected javax.swing.AbstractButton[] createButtons(int newButtons)
Factory method to create the buttons for the specified identifiers. The default implemenation calls CommonButtons.createButtons() to create the button instances.

Valid button identifiers are any of those or a combination of those from CommonButtons.

Parameters:
buttons - Identifies the buttons to create
See Also:
CommonButtons

getButtonLocation

public int getButtonLocation()
Returns the location of the buttons in the dialog. Possible values are:

Returns:
the location of the buttons in the dialog
See Also:
setButtonLocation(int)

setButtonLocation

public void setButtonLocation(int newButtonLocation)
Sets the location of the buttons in the dialog. Possible values are:

Parameters:
buttonLocation - a location to position the buttons

addButton

public void addButton(javax.swing.AbstractButton b)
Adds the specified button to the dialog.

Parameters:
b - the button to add to the dialog

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent actionEvent)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

processWindowEvent

protected void processWindowEvent(java.awt.event.WindowEvent event)
Process the window events that occur on this dialog. If the dialog is closed from the title bar (i.e. by clicking the 'x' button), this method will handle that by calling the onCancel method.

Overrides:
processWindowEvent in class javax.swing.JDialog
Parameters:
event - the event to handle

setVisible

public void setVisible(boolean visible)
Overrides:
setVisible in class java.awt.Dialog

***  This class is subject to change.  ***




Copyright © 2009 SAS Institute Inc. All Rights Reserved.