Spiffy UI Framework

org.spiffyui.client.widgets.dialog
Class Dialog

java.lang.Object
  extended by DialogBox
      extended by org.spiffyui.client.widgets.dialog.Dialog
Direct Known Subclasses:
ConfirmDialog

public abstract class Dialog
extends DialogBox

This is a common ancestor class where we can change the behavior or look of all Dialogs. It handles the ESC key and the close X icon. Buttons are added to a button bar.


Constructor Summary
Dialog(java.lang.String id, java.lang.String title, java.lang.String titleStyle)
          Constructor defaulting to autohide false and modal true.
Dialog(java.lang.String id, java.lang.String title, java.lang.String titleStyle, boolean autohide, boolean modal)
          Create a new dialog with the specified parameters
 
Method Summary
 void addButton(java.lang.String id, java.lang.String text, java.lang.String buttonClickedValue)
          A convenient way to add a button to the button bar.
 Button addButton(java.lang.String id, java.lang.String text, java.lang.String buttonClickedValue, ClickHandler handler)
          A convenient way to add a button to the button bar.
 FlowPanel getButtonBar()
           
 java.lang.String getButtonClicked()
           
 java.lang.String getCloseText()
          Gets the close icon's tooltip text.
 int getDefaultButton()
           
 HTMLPanel getDialogBody()
           
 java.lang.String getId()
           
protected  void onPreviewNativeEvent(Event.NativePreviewEvent event)
          Overriding to close on pressing Esc key or clicking the close anchor.
 void replaceDialogBodyContents(Widget w)
          Replace the entire contents of the dialog body with the Widget
 void replaceTitle(java.lang.String title)
          Replaces the inner text of the title.
 void setButtonBar(FlowPanel buttonBar)
           
 void setButtonClicked(java.lang.String buttonClicked)
           
 void setCloseText(java.lang.String text)
          Sets this dialog's close icon's tooltip text.
 void setDefaultButton(int index)
          Set the focus to the button added to the button bar at the index specified.
 void setDialogBody(HTMLPanel dialogBody)
           
 void setId(java.lang.String id)
           
 void show()
          Overriding show so that the default button can have focus and thereby be keyboard accessible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dialog

public Dialog(java.lang.String id,
              java.lang.String title,
              java.lang.String titleStyle)
Constructor defaulting to autohide false and modal true.

Parameters:
id - - the id of this element
title - - the title of the dialog. Send in an empty String if the title needs to be set later. Use replaceTitle after calling show()
titleStyle - - the style of the title

Dialog

public Dialog(java.lang.String id,
              java.lang.String title,
              java.lang.String titleStyle,
              boolean autohide,
              boolean modal)
Create a new dialog with the specified parameters

Parameters:
id - - the id of this element
title - - the title of the dialog. Send in an empty String if the title needs to be set later. Use replaceTitle after calling show()
titleStyle - - the style of the title
autohide - - boolean true for if the dialog should be automatically hidden when the user clicks outside of it
modal - - boolean true for modal
Method Detail

getCloseText

public java.lang.String getCloseText()
Gets the close icon's tooltip text.

Returns:
the close text

setCloseText

public void setCloseText(java.lang.String text)
Sets this dialog's close icon's tooltip text.

Parameters:
text - the text of the close button tooltip

replaceTitle

public void replaceTitle(java.lang.String title)
Replaces the inner text of the title. Note: This can only be called if the dialog is showing because otherwise it will be null.

Parameters:
title - - the new title

addButton

public Button addButton(java.lang.String id,
                        java.lang.String text,
                        java.lang.String buttonClickedValue,
                        ClickHandler handler)
A convenient way to add a button to the button bar. Every button will hide and the CloseHandler can get the value of the button and do the processing. If you want your own handling done, you can optionally pass in a ClickHandler, or if null, then does the default handling.

Parameters:
id - - id of the element
text - - the text shown on the button
buttonClickedValue - - the value of the button returned
handler - - ClickHandler, if null, just hides dialog and sets the button clicked value
Returns:
Button - the Button just added

addButton

public void addButton(java.lang.String id,
                      java.lang.String text,
                      java.lang.String buttonClickedValue)
A convenient way to add a button to the button bar. Every button will hide and the CloseHandler can get the value of the button and do the processing.

Parameters:
id - - id of the element
text - - the text shown on the button
buttonClickedValue - - the value of the button returned

setButtonClicked

public void setButtonClicked(java.lang.String buttonClicked)
Parameters:
buttonClicked - The buttonClicked to set.

getButtonClicked

public java.lang.String getButtonClicked()
Returns:
Returns the buttonClicked.

setDefaultButton

public void setDefaultButton(int index)
Set the focus to the button added to the button bar at the index specified. 0 is the first button. If not set, then defaults to the first button.

Parameters:
index - - the button position in the bar, 0 is first.

show

public void show()
Overriding show so that the default button can have focus and thereby be keyboard accessible. If the dialog has an input that should have focus instead, feel free to override.


getButtonBar

public FlowPanel getButtonBar()
Returns:
Returns the buttonBar.

setButtonBar

public void setButtonBar(FlowPanel buttonBar)
Parameters:
buttonBar - The buttonBar to set.

getDialogBody

public HTMLPanel getDialogBody()
Returns:
Returns the dialogBody.

setDialogBody

public void setDialogBody(HTMLPanel dialogBody)
Parameters:
dialogBody - The dialogBody to set.

getId

public java.lang.String getId()
Returns:
Returns the id.

setId

public void setId(java.lang.String id)
Parameters:
id - The id to set.

getDefaultButton

public int getDefaultButton()
Returns:
Returns the defaultButton.

replaceDialogBodyContents

public void replaceDialogBodyContents(Widget w)
Replace the entire contents of the dialog body with the Widget

Parameters:
w - - Widget to use

onPreviewNativeEvent

protected void onPreviewNativeEvent(Event.NativePreviewEvent event)
Overriding to close on pressing Esc key or clicking the close anchor.

Parameters:
event - - the Event.NativePreviewEvent

Spiffy UI Framework