public class OkCancelDialog
extends com.vaadin.ui.Window
addContent(Component).
To create a dialog with fixed dimensions, use the method setSize(String, String). This
is useful if:
setSize(String, String).
To validate the data in the dialog or give the user warning or information messages, set a
validation service via (setValidationService(ValidationService)). The first message with
the highest ErrorLevel reported during the
validation via the ValidationService.getValidationMessages() is displayed at the bottom
of the dialog, between its content and the OK and cancel buttons. (see
MessageList.getFirstMessage(ErrorMessage.ErrorLevel))
| Modifier and Type | Class and Description |
|---|---|
static class |
OkCancelDialog.ButtonOption
Options to choose the buttons.
|
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.WindowModeChangeListenercom.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listenercom.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListenercom.vaadin.server.Sizeable.Unitcom.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener| Constructor and Description |
|---|
OkCancelDialog(String caption)
Creates a new dialog with the given caption that displays both the OK and Cancel button and
uses a handler that does nothing when the OK button is clicked.
|
OkCancelDialog(String caption,
com.vaadin.ui.Component content,
Handler okHandler,
OkCancelDialog.ButtonOption buttonOption)
Creates a new dialog with the given caption.
|
OkCancelDialog(String caption,
Handler okHandler)
Creates a new dialog with the given caption that displays both the OK and Cancel button.
|
OkCancelDialog(String caption,
Handler okHandler,
OkCancelDialog.ButtonOption buttonOption)
Creates a new dialog with the given caption.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addContent(com.vaadin.ui.Component c)
Adds the given component to be displayed in the dialog.
|
void |
addContent(com.vaadin.ui.Component c,
float expandRatio)
Adds the given component to be displayed in the dialog with the given expand ratio.
|
protected void |
cancel()
Called when the user clicks the cancel button or closes the window.
|
MessageList |
getMessages()
Returns the messages from which a message is displayed in the dialog (if the list is not
empty).
|
ValidationDisplayState |
getValidationDisplayState()
Returns the state regarding the displayed validation messages.
|
ValidationService |
getValidationService()
Returns the validation service that validates data in the dialog.
|
boolean |
isCancelPressed()
Returns
true if the cancel button was pressed. |
boolean |
isOkEnabled()
Returns whether or not the OK button is enabled.
|
boolean |
isOkPressed()
Returns
true if the OK button was pressed. |
protected void |
ok()
Called when the user clicks the OK button and
validate() does not return any error
messages. |
void |
setContent(com.vaadin.ui.Component content)
Overrides
AbstractSingleComponentContainer.setContent(Component) as the OkCancelDialog does not allow replacing
its entire content (e.g. |
void |
setSize(String width,
String height)
Use this method to create a dialog with fixed size.
|
void |
setValidationService(ValidationService validationService)
Sets the validation service that validates data in the dialog.
|
MessageList |
validate()
Retrieves the message list from the validation service and filters it according to its
getValidationDisplayState(). |
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, writeDesignaddAction, addActionHandler, addClickListener, addListener, getActionManager, getScrollLeft, getScrollTop, getTabIndex, removeAction, removeActionHandler, removeAllActionHandlers, removeClickListener, removeListener, setCaption, setScrollLeft, setScrollTop, setTabIndexaddComponentAttachListener, addComponentDetachListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentCount, getContent, iterator, removeComponentAttachListener, removeComponentDetachListener, removeFromParent, setHeight, setWidthaddContextClickListener, 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, setStyleName, setVisible, setWidth, setWidthUndefinedaddAttachListener, 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, setResourceclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitaddListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setPrimaryStyleName, setReadOnly, setStyleName, setVisibleaddAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefinedforEach, spliteratorpublic OkCancelDialog(String caption)
caption - the dialog's captionpublic OkCancelDialog(String caption, Handler okHandler)
caption - the dialog's captionokHandler - okHandler the handler that handles clicks on the OK buttonpublic OkCancelDialog(String caption, Handler okHandler, OkCancelDialog.ButtonOption buttonOption)
caption - the dialog's captionokHandler - the handler that handles clicks on the OK buttonbuttonOption - whether to show both buttons (OK and Cancel) or only the OK buttonpublic OkCancelDialog(String caption, @Nullable com.vaadin.ui.Component content, Handler okHandler, OkCancelDialog.ButtonOption buttonOption)
caption - the dialog's captionokHandler - the handler that handle clicks on the OK buttonbuttonOption - whether to show both buttons (OK and Cancel) or only the OK buttonpublic void setContent(@Nullable com.vaadin.ui.Component content)
AbstractSingleComponentContainer.setContent(Component) as the OkCancelDialog does not allow replacing
its entire content (e.g. the OK and Cancel buttons). Instead, only the content of the main
area is replaced.
Note that this also removes any components that were added using
addContent(Component).
setContent in interface com.vaadin.ui.SingleComponentContainersetContent in class com.vaadin.ui.AbstractSingleComponentContainerpublic void setSize(String width, String height)
If you specify the height and add multiple components using addContent(Component)
all added components will have the same expand ratio by default (which is 0). This causes all
components to be assigned equal space. Use addContent(Component, float) to assign a
specific expand ratios to a component. For example, if you want to have all components to use
only as much space as they need and the last component to consume all excess space, add the
last component using addContent(component, 1) and all other components without
expand ratio (using addContent(component)).
When calculating the correct height always consider that there might be validation messages below your content. If the dialog's height is too small the components may overlap or be cropped.
The dialog will never create scroll bars. If you want scroll bars, add a single panel as root content, and configure it to use scroll bars. The header, the button(s) and the validation messages will then always be visible.
Note: If you have multiple nested layout components (like tab sheet
areas, pages or vaadin layouts you have to make sure that every component is
set to full size (AbstractComponentAbstractComponent.setSizeFull().
If you need a dialog with dynamic height you must not call this method.
width - the width of the dialog including the unit (for example 700px or 65%)height - the height of the dialog including the unit (for example 700px or 65%)AbstractOrderedLayout.setExpandRatio(Component, float)public MessageList validate()
getValidationDisplayState(). The filtered messages are returned. If needed, a
message from the list is displayed and the OK button is disabled.
A previously displayed message is removed if the message list does not contain any messages. If the message list contains a message, the first message with the highest errorLevel is displayed. If the message list contains an error message the OK button is disabled.
public MessageList getMessages()
public ValidationService getValidationService()
public void setValidationService(ValidationService validationService)
public void addContent(com.vaadin.ui.Component c)
setSize(String, String) you might want to use
addContent(Component, float) to assign specific expand ratios to components.public void addContent(com.vaadin.ui.Component c,
float expandRatio)
AbstractOrderedLayout.setExpandRatio(Component, float)AbstractOrderedLayout.setExpandRatio(Component, float)public boolean isOkEnabled()
getMessages() does not contain an error message.public boolean isOkPressed()
true if the OK button was pressed.public ValidationDisplayState getValidationDisplayState()
public boolean isCancelPressed()
true if the cancel button was pressed.protected void ok()
validate() does not return any error
messages. Delegates to the dialog's OkHandler.protected void cancel()
Copyright © 2017. All rights reserved.