org.vostok.vaadin.addon.dialog
Class ActionWindow

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractSingleComponentContainer
              extended by com.vaadin.ui.Panel
                  extended by com.vaadin.ui.Window
                      extended by org.vostok.vaadin.addon.dialog.ActionWindow
All Implemented Interfaces:
com.vaadin.event.Action.Container, com.vaadin.event.Action.Notifier, com.vaadin.event.ConnectorEventListener, com.vaadin.event.ContextClickEvent.ContextClickNotifier, com.vaadin.event.FieldEvents.BlurNotifier, com.vaadin.event.FieldEvents.FocusNotifier, com.vaadin.event.MethodEventSource, com.vaadin.server.ClientConnector, com.vaadin.server.Scrollable, com.vaadin.server.Sizeable, com.vaadin.server.VariableOwner, com.vaadin.shared.Connector, com.vaadin.ui.Component, com.vaadin.ui.Component.Focusable, com.vaadin.ui.HasComponents, com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.LegacyComponent, com.vaadin.ui.SingleComponentContainer, java.io.Serializable, java.lang.Iterable<com.vaadin.ui.Component>, java.util.EventListener
Direct Known Subclasses:
SimpleColourWindow

public class ActionWindow
extends com.vaadin.ui.Window

ActionWindow - which extend Dialog - is made of two parts, the inner, where you add your content, and the button bar.
It uses a central listener for managing all actions at once (including close/cancel), no need for a listen on each button. To do so, It expects an unique "id" for each button (action).

ActionWindow already provides several modal window for most basic cases. You can alter look and feel with simple css rules. Content is a simple string, with html allowed. You can still set your own content by passing null value and calling getInnerContent after.

Html structure :

<div class="v-window  dialog-window [YOUR CSS CLASS HERE] ">
        <div>
                <div>
                        <div class="v-window-contents">
                                <div>
                                        <div>
                                                <div class="v-slot-inner">
                                                        <div class="inner">WINDOW CONTENT</div>
                                                </div>

                                                <div class="v-slot-bp-box">
                                                        <div class="bp-box">BUTTON CONTAINER</div>
                                                </div>
                                        </div>
                                </div>
                        </div>
                </div>
        </div>
</div>
See sample at http://vaadin.vostoksystem.eu

Author:
levreau.jerome@vostoksystem.eu
See Also:
Serialized Form

Nested Class Summary
static class ActionWindow.Action
          declare a new action group.
static interface ActionWindow.DialogClickListener
          a clickListener to handle button click events.
 
Nested classes/interfaces inherited from class com.vaadin.ui.Window
com.vaadin.ui.Window.CloseEvent, com.vaadin.ui.Window.CloseListener, com.vaadin.ui.Window.CloseShortcut, com.vaadin.ui.Window.ResizeEvent, com.vaadin.ui.Window.ResizeListener, com.vaadin.ui.Window.WindowModeChangeEvent, com.vaadin.ui.Window.WindowModeChangeListener
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
com.vaadin.server.Sizeable.Unit
 
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener
 
Field Summary
protected  com.vaadin.ui.HorizontalLayout bpComponent
           
static int CANCEL
           
protected  ActionWindow.DialogClickListener clickListener
           
static int CLOSE
           
protected  boolean closed
           
protected  com.vaadin.ui.CssLayout innerComponent
           
protected  java.util.List<ActionWindow.Action> items
           
static java.lang.String MODAL
           
static int OK
           
 
Fields inherited from class com.vaadin.ui.Panel
actionManager
 
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
 
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
ActionWindow()
           
ActionWindow(java.lang.String caption)
          create a new window. with empty action box and content
ActionWindow(java.lang.String caption, ActionWindow.Action[] items)
          create an new dialog with enpy content.
ActionWindow(java.lang.String caption, com.vaadin.ui.Component content)
          create a new window. with empty action box
ActionWindow(java.lang.String caption, com.vaadin.ui.Component content, ActionWindow.Action[] items)
          create a new window.
 
Method Summary
 com.vaadin.ui.Button addAction(ActionWindow.Action item)
          Add a new action at the tail of the buttons bar
 com.vaadin.ui.Button addAction(ActionWindow.Action item, int index)
          Add a new action to the button bar at index index
 ActionWindow addStyle(java.lang.String name)
          a convenience method to allow code like new ActionWindow(...).addstyle(...).show(); sementically identical to super.addStyleName but return "this". method
static ActionWindow createBan(java.lang.String title, java.lang.String message)
          create a modal dialog window for simple denied message, same as message, just css class different, no action needed, just one button (ok) and close on click
static ActionWindow createMessage(java.lang.String title, java.lang.String message)
          create a modal dialog window for simple message, no action needed, just one button (ok) and close on click
static ActionWindow createOkCancel(java.lang.String title, java.lang.String message, ActionWindow.DialogClickListener listener)
          Create a simple modal Ok - cancel window, with 3 actions : action ActionWindow.OK and ActionWindow.CANCEL and ActionWindow.CLOSE By default, display a message (message).
static ActionWindow createSaveCancel(java.lang.String title, java.lang.String message, ActionWindow.DialogClickListener listener)
          Same as createOkCancel, but with save/cancel button style
static ActionWindow createWarning(java.lang.String title, java.lang.String message)
          create a modal dialog window for simple warning message, same as message, just css class different, no action needed, just one button (ok) and close on click
static ActionWindow createYesNo(java.lang.String title, java.lang.String message, ActionWindow.DialogClickListener listener)
          Same as createOkCancel, but with yes/no button style.
protected  void doAction(com.vaadin.ui.Component.Event event, int action)
          handle response to button response to a button events.
 ActionWindow.Action getAction(int action)
          return Action data from action id
 com.vaadin.ui.Button getButton(int action)
          return Button from action id
 ActionWindow.DialogClickListener getDialogClickListener()
          return the current button clickListener (default to none : null)
 com.vaadin.ui.AbstractLayout getInnerContent()
          the inner content, where to add message (Label), etc... current instance is a cssLayout with fullSize
 ActionWindow noIcon()
          Helper method.
 void removeAction(int action)
          remove button from button bar
 void setDialogClickListener(ActionWindow.DialogClickListener listener)
          attach a button clickListener.
 void setStyleName(java.lang.String style)
           
 void show()
          show the window on UI
if window already on screen does nothing more.
 
Methods inherited from class com.vaadin.ui.Window
addBlurListener, addCloseListener, addCloseShortcut, addFocusListener, addListener, addListener, addListener, addListener, addResizeListener, addWindowModeChangeListener, bringToFront, center, changeVariables, close, fireClose, fireResize, fireWindowWindowModeChange, focus, getAssistiveDescription, getAssistivePostfix, getAssistivePrefix, getAssistiveRole, getCloseShortcuts, getCustomAttributes, getPositionX, getPositionY, getState, getState, getTabStopBottomAssistiveText, getTabStopTopAssistiveText, getWindowMode, hasCloseShortcut, isClosable, isDraggable, isModal, isResizable, isResizeLazy, isTabStopEnabled, paintContent, readDesign, readDesignChildren, removeAllCloseShortcuts, removeBlurListener, removeCloseListener, removeCloseShortcut, removeCloseShortcut, removeFocusListener, removeListener, removeListener, removeListener, removeListener, removeResizeListener, removeWindowModeChangeListener, setAssistiveDescription, setAssistivePostfix, setAssistivePrefix, setAssistiveRole, setClosable, setCloseShortcut, setDraggable, setModal, setParent, setPosition, setPositionX, setPositionY, setResizable, setResizeLazy, setTabStopBottomAssistiveText, setTabStopEnabled, setTabStopTopAssistiveText, setWindowMode, writeDesign
 
Methods inherited from class com.vaadin.ui.Panel
addAction, addActionHandler, addClickListener, addListener, getActionManager, getScrollLeft, getScrollTop, getTabIndex, removeAction, removeActionHandler, removeAllActionHandlers, removeClickListener, removeListener, setCaption, setScrollLeft, setScrollTop, setTabIndex
 
Methods inherited from class com.vaadin.ui.AbstractSingleComponentContainer
addComponentAttachListener, addComponentDetachListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentCount, getContent, iterator, removeComponentAttachListener, removeComponentDetachListener, removeFromParent, setContent, setHeight, setWidth
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthUndefined
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.LegacyComponent
markAsDirty
 
Methods inherited from interface com.vaadin.server.VariableOwner
isEnabled, isImmediate
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setPrimaryStyleName, setReadOnly, setVisible
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
 

Field Detail

MODAL

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

OK

public static final int OK
See Also:
Constant Field Values

CANCEL

public static final int CANCEL
See Also:
Constant Field Values

CLOSE

public static final int CLOSE
See Also:
Constant Field Values

innerComponent

protected final com.vaadin.ui.CssLayout innerComponent

bpComponent

protected final com.vaadin.ui.HorizontalLayout bpComponent

items

protected final java.util.List<ActionWindow.Action> items

clickListener

protected ActionWindow.DialogClickListener clickListener

closed

protected boolean closed
Constructor Detail

ActionWindow

public ActionWindow(java.lang.String caption,
                    com.vaadin.ui.Component content,
                    ActionWindow.Action[] items)
create a new window.
NOTA : you have to add it manually to the UI or simply call "show"
by default, dialog are not resizable ; you still can override it by calling setResizable(true);

Parameters:
caption -
items - list of button
content - content for window ; can be null

ActionWindow

public ActionWindow(java.lang.String caption,
                    ActionWindow.Action[] items)
create an new dialog with enpy content.
You can access inner layout with getInnerContent() , then addContent()

Parameters:
caption -
items -

ActionWindow

public ActionWindow()
Throws:
java.lang.UnsupportedOperationException - ; always

ActionWindow

public ActionWindow(java.lang.String caption)
create a new window. with empty action box and content

Parameters:
caption -

ActionWindow

public ActionWindow(java.lang.String caption,
                    com.vaadin.ui.Component content)
create a new window. with empty action box

Parameters:
caption -
content -
Method Detail

setStyleName

public void setStyleName(java.lang.String style)
Specified by:
setStyleName in interface com.vaadin.ui.Component
Overrides:
setStyleName in class com.vaadin.ui.AbstractComponent

show

public void show()
show the window on UI
if window already on screen does nothing more.


addStyle

public ActionWindow addStyle(java.lang.String name)
a convenience method to allow code like new ActionWindow(...).addstyle(...).show(); sementically identical to super.addStyleName but return "this". method

Parameters:
name -
Returns:
this instance

getDialogClickListener

public ActionWindow.DialogClickListener getDialogClickListener()
return the current button clickListener (default to none : null)

Returns:
instance of DialogClickListener or null

setDialogClickListener

public void setDialogClickListener(ActionWindow.DialogClickListener listener)
attach a button clickListener.
Listener is also called on window close, therefore, clickListener is called at least one time, for close action.
If no listened attached to a ActionWindow, any action (button click) close the window.
To reset clickListener to default, pass null

Parameters:
listener -

getInnerContent

public final com.vaadin.ui.AbstractLayout getInnerContent()
the inner content, where to add message (Label), etc... current instance is a cssLayout with fullSize

Returns:
inner content

noIcon

public ActionWindow noIcon()
Helper method. Remove icon from modal dialog.
This helper removes the css class "modal" from main dom element (".dialog-window') which is automatically added for okCancel, YesNo, warning, Ban, Message. It's help creating modal window without icon on the left.
Take note it probable won't work for custom dialog.

Returns:

getButton

public com.vaadin.ui.Button getButton(int action)
return Button from action id

Parameters:
action - action action code for button
Returns:
Button or null

getAction

public ActionWindow.Action getAction(int action)
return Action data from action id

Parameters:
action - action action code for button
Returns:
Action or null

addAction

public com.vaadin.ui.Button addAction(ActionWindow.Action item)
Add a new action at the tail of the buttons bar

Parameters:
item -
Returns:
item.getButton(à

addAction

public com.vaadin.ui.Button addAction(ActionWindow.Action item,
                                      int index)
Add a new action to the button bar at index index

Parameters:
item -
index - button index.
Returns:
item.getButton(à

removeAction

public void removeAction(int action)
remove button from button bar

Parameters:
action - action for button to remove

doAction

protected void doAction(com.vaadin.ui.Component.Event event,
                        int action)
handle response to button response to a button events.

Parameters:
event -
action -

createOkCancel

public static ActionWindow createOkCancel(java.lang.String title,
                                          java.lang.String message,
                                          ActionWindow.DialogClickListener listener)
Create a simple modal Ok - cancel window, with 3 actions : action ActionWindow.OK and ActionWindow.CANCEL and ActionWindow.CLOSE By default, display a message (message).

Parameters:
title - title for the window
message - message to display. To set your own content, set message = null and then access inner content with this.getInnerContent()
listener - clickListener fir action. default(null) just close window
Returns:
a new Dialog

createYesNo

public static ActionWindow createYesNo(java.lang.String title,
                                       java.lang.String message,
                                       ActionWindow.DialogClickListener listener)
Same as createOkCancel, but with yes/no button style. Note action bot listement wil be ActionWindow.OK | dialogWindow.CANCEL

Parameters:
title - title for the window
message - message to display. To set your own content, set message = null and then access inner content with this.getInnerContent()
listener - clickListener fir action. default(null) just close window
Returns:
a new Dialog

createSaveCancel

public static ActionWindow createSaveCancel(java.lang.String title,
                                            java.lang.String message,
                                            ActionWindow.DialogClickListener listener)
Same as createOkCancel, but with save/cancel button style

Parameters:
title - title for the window
message - message to display. To set your own content, set message = null and then access inner content with this.getInnerContent()
listener - clickListener fir action. default(null) just close window
Returns:
a new Dialog

createMessage

public static ActionWindow createMessage(java.lang.String title,
                                         java.lang.String message)
create a modal dialog window for simple message, no action needed, just one button (ok) and close on click

Parameters:
title - title of the dialog box
message - message to display. To set your own content, set message = null and then access inner content with this.getInnerContent()
Returns:

createWarning

public static ActionWindow createWarning(java.lang.String title,
                                         java.lang.String message)
create a modal dialog window for simple warning message, same as message, just css class different, no action needed, just one button (ok) and close on click

Parameters:
title - title of the dialog box
message - message to display. To set your own content, set message = null and then access inner content with this.getInnerContent()
Returns:

createBan

public static ActionWindow createBan(java.lang.String title,
                                     java.lang.String message)
create a modal dialog window for simple denied message, same as message, just css class different, no action needed, just one button (ok) and close on click

Parameters:
title - title of the dialog box
message - message to display. To set your own content, set message = null and then access inner content with this.getInnerContent()
Returns: