GWT Tk 0.2.3

asquare.gwt.tk.client.ui
Class ModalDialog

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Panel
              extended by com.google.gwt.user.client.ui.SimplePanel
                  extended by com.google.gwt.user.client.ui.PopupPanel
                      extended by asquare.gwt.tk.client.ui.CPopupPanel
                          extended by asquare.gwt.tk.client.ui.ModalDialog
All Implemented Interfaces:
ControllerSupport, EventListener, EventPreview, HasWidgets, SourcesPopupEvents
Direct Known Subclasses:
AlertDialog

public class ModalDialog
extends CPopupPanel

A modal dialog featuring:

The caption has the following properties:

Usage Notes

CSS Style Rules

Example

 final Button showDialogButton = new Button("Focus management");
 showDialogButton.addClickListener(new ClickListener()
 {
        public void onClick(Widget sender)
        {
                final ModalDialog inputDialog = new ModalDialog();
                inputDialog.setCaption("Input", false);
                inputDialog.add(new Label("Enter a value"));
                inputDialog.add(new TextBox());
                inputDialog.add(new Button("OK", new ClickListener()
                {
                        public void onClick(Widget sender)
                        {
                                inputDialog.hide();
                        }
                }));
 
                inputDialog.show(showDialogButton);
        }
 });
 


Nested Class Summary
protected  class ModalDialog.CaptionWrapper
          Provides event support for the caption element.
static class ModalDialog.FocusOnCloseController
          A controller which focuses a widget when the dialog is hidden.
static class ModalDialog.InitializeFocusController
          Sets the initial focus when the dialog is shown.
static class ModalDialog.PositionDialogController
          A controller which encapsulates dialog sizing and positioning logic.
static class ModalDialog.PositionDialogControllerIE6
           
 
Field Summary
protected static com.google.gwt.user.client.ui.impl.FocusImpl s_focusImpl
           
static String STYLENAME_CAPTION
           
static String STYLENAME_CONTENT
           
static String STYLENAME_DIALOG
           
static String STYLENAME_DRAGGING
           
static String STYLENAME_GLASSPANEL
           
 
Constructor Summary
ModalDialog()
           
 
Method Summary
 void add(Widget w)
          Adds a widget to the content area of this dialog.
protected  List createCaptionControllers()
          A factory method which gives a subclass the opportunity to override default controller creation.
protected  List createControllers()
          A factory method which gives a subclass the opportunity to override default controller creation.
 Element getContentElement()
          Get the element that forms the content area of the dialog.
 int getContentMinHeight()
          Get the minimum height of the content panel.
 int getContentMinWidth()
          Get the minimum width of the content panel.
 int getContentOffsetHeight()
          Get the actual height of the content panel.
 int getContentOffsetWidth()
          Get the actual width of the content panel.
 FocusModel getFocusModel()
          Get the focus model for this dialog.
 HasFocus getFocusOnCloseWidget()
          Get the widget which will be focused after the dialog is closed.
 GlassPanel getGlassPanel()
          Get the GlassPanel which is displayed behind the dialog.
 void hide()
          Detaches the dialog from the DOM (it will be garbage collected if there are no references to it).
protected  void onAttach()
           
protected  void onDetach()
           
 boolean remove(Widget w)
          Removes a widget from the content area of this dialog.
 void setCaption(String text, boolean asHtml)
          Sets the contents of the caption to the specified text, clearing any previous contents from the caption.
 void setCaption(Widget w)
          Set a widget as the sole child of the caption, clearing any previous contents from the caption.
 void setContentHeight(String height)
          Set the desired height of the content panel.
 void setContentMinHeight(int minHeight)
          Set the minimum height of the content panel.
 void setContentMinWidth(int minWidth)
          Set the minimum width of the content panel.
 void setContentWidth(String width)
          Set the desired width of the content panel.
 void setFocusModel(FocusModel focusModel)
          Set the focus model for this dialog.
 void setWidget(Widget w)
          Not supported.
 void show()
          Shows the glasspanel and dialog then focuses the widget selected in the focus model.
 void show(HasFocus focusOnCloseWidget)
          Shows the glasspanel and dialog then focuses the widget selected in the focus model.
 
Methods inherited from class asquare.gwt.tk.client.ui.CPopupPanel
addController, getController, onBrowserEvent, onEventPreview, removeController, setControllers, sinkEvents, unsinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.PopupPanel
addPopupListener, getPopupLeft, getPopupTop, onKeyDownPreview, onKeyPressPreview, onKeyUpPreview, removePopupListener, setPopupPosition
 
Methods inherited from class com.google.gwt.user.client.ui.SimplePanel
getContainerElement, getWidget, iterator
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
adopt, clear, disown
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onLoad, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleName, getTitle, isVisible, isVisible, removeStyleName, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setTitle, setVisible, setVisible, setWidth, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STYLENAME_DIALOG

public static final String STYLENAME_DIALOG
See Also:
Constant Field Values

STYLENAME_GLASSPANEL

public static final String STYLENAME_GLASSPANEL
See Also:
Constant Field Values

STYLENAME_CAPTION

public static final String STYLENAME_CAPTION
See Also:
Constant Field Values

STYLENAME_CONTENT

public static final String STYLENAME_CONTENT
See Also:
Constant Field Values

STYLENAME_DRAGGING

public static final String STYLENAME_DRAGGING
See Also:
Constant Field Values

s_focusImpl

protected static final com.google.gwt.user.client.ui.impl.FocusImpl s_focusImpl
Constructor Detail

ModalDialog

public ModalDialog()
Method Detail

createControllers

protected List createControllers()
Description copied from class: CPopupPanel
A factory method which gives a subclass the opportunity to override default controller creation.

Overrides:
createControllers in class CPopupPanel
Returns:
a List with 0 or more controllers, or null

createCaptionControllers

protected List createCaptionControllers()
A factory method which gives a subclass the opportunity to override default controller creation.

Returns:
a List with 0 or more controllers, or null

getFocusModel

public FocusModel getFocusModel()
Get the focus model for this dialog.


setFocusModel

public void setFocusModel(FocusModel focusModel)
Set the focus model for this dialog.


getContentMinHeight

public int getContentMinHeight()
Get the minimum height of the content panel.

Returns:
the minimum height in pixels

setContentMinHeight

public void setContentMinHeight(int minHeight)
Set the minimum height of the content panel. The default is 75 px. Set to 0 to disable this feature.

Parameters:
minHeight - the minimum height in pixels

getContentMinWidth

public int getContentMinWidth()
Get the minimum width of the content panel.

Returns:
the minimum width in pixels

setContentMinWidth

public void setContentMinWidth(int minWidth)
Set the minimum width of the content panel. The default is 200 px. Set to 0 to disable this feature.

Parameters:
minWidth - the minimum width in pixels

setContentWidth

public void setContentWidth(String width)
Set the desired width of the content panel. The minimum width property will take precedence if applicable.

Parameters:
width - the width in CSS measurements

setContentHeight

public void setContentHeight(String height)
Set the desired height of the content panel. The minimum height property will take precedence if applicable.

Parameters:
height - the height in CSS measurements

getContentOffsetWidth

public int getContentOffsetWidth()
Get the actual width of the content panel. This does not work until the dialog has been shown.

Returns:
the width in pixels

getContentOffsetHeight

public int getContentOffsetHeight()
Get the actual height of the content panel. This does not work until the dialog has been shown.

Returns:
the height in pixels

add

public void add(Widget w)
Adds a widget to the content area of this dialog. Multiple widgets may be added. The widget will be added to the focus model if it implements HasFocus and does not have a tabIndex < 0.

Specified by:
add in interface HasWidgets
Overrides:
add in class SimplePanel
Parameters:
w - a widget

setWidget

public void setWidget(Widget w)
Not supported. Use add(Widget) instead.

Overrides:
setWidget in class SimplePanel
Throws:
UnsupportedOperationException

remove

public boolean remove(Widget w)
Removes a widget from the content area of this dialog. Do not use for caption widget. Use setCaption(null) instead.

Specified by:
remove in interface HasWidgets
Overrides:
remove in class PopupPanel
Parameters:
w - the widget to remove
Throws:
IllegalArgumentException - if w is in the caption.

setCaption

public void setCaption(String text,
                       boolean asHtml)
Sets the contents of the caption to the specified text, clearing any previous contents from the caption.

Parameters:
text - the caption text
asHtml - true to treat text as html
See Also:
setCaption(Widget)

setCaption

public void setCaption(Widget w)
Set a widget as the sole child of the caption, clearing any previous contents from the caption.

Parameters:
w - a widget

getContentElement

public Element getContentElement()
Get the element that forms the content area of the dialog.


getGlassPanel

public GlassPanel getGlassPanel()
Get the GlassPanel which is displayed behind the dialog.


getFocusOnCloseWidget

public HasFocus getFocusOnCloseWidget()
Get the widget which will be focused after the dialog is closed. This property is only available while the dialog is visible.

Returns:
a widget or null

show

public void show()
Shows the glasspanel and dialog then focuses the widget selected in the focus model.

Overrides:
show in class PopupPanel

show

public void show(HasFocus focusOnCloseWidget)
Shows the glasspanel and dialog then focuses the widget selected in the focus model.

Parameters:
focusOnCloseWidget - a widget to focus after this dialog is closed

hide

public void hide()
Detaches the dialog from the DOM (it will be garbage collected if there are no references to it). Has no effect if the dialog is not showing.

Overrides:
hide in class PopupPanel
See Also:
PopupPanel.hide()

onAttach

protected void onAttach()
Overrides:
onAttach in class CPopupPanel

onDetach

protected void onDetach()
Overrides:
onDetach in class CPopupPanel

GWT Tk 0.2.3

© 2007 Mat Gessel