com.vaadin.ui.
Class Window
-
All Implemented Interfaces:
Action.Container
,Action.Notifier
,ConnectorEventListener
,ContextClickEvent.ContextClickNotifier
,FieldEvents.BlurNotifier
,FieldEvents.FocusNotifier
,MethodEventSource
,SerializableEventListener
,ClientConnector
,Scrollable
,Sizeable
,VariableOwner
,Connector
,Component
,Component.Focusable
,HasComponents
,HasComponents.ComponentAttachDetachNotifier
,LegacyComponent
,SingleComponentContainer
,Serializable
,Iterable<Component>
,EventListener
Direct Known Subclasses:
public class Window extends Panel implements FieldEvents.FocusNotifier, FieldEvents.BlurNotifier
A component that represents a floating popup window that can be added to a
UI
. A window is added to aUI
usingUI.addWindow(Window)
.The contents of a window is set using
AbstractSingleComponentContainer.setContent(Component)
or by using theWindow(String, Component)
constructor.A window can be positioned on the screen using absolute coordinates (pixels) or set to be centered using
center()
The caption is displayed in the window header.
In Vaadin versions prior to 7.0.0, Window was also used as application level windows. This function is now covered by the
UI
class.Since:
3.0
Author:
Vaadin Ltd.
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Window.CloseEvent
static interface
Window.CloseListener
An interface used for listening to Window close events.
static class
Window.CloseShortcut
A
ShortcutListener
specifically made to define a keyboard shortcut that closes the window.static class
Window.ResizeEvent
Resize events are fired whenever the client-side fires a resize-event (e.g.
static interface
Window.ResizeListener
Listener for window resize events.
static class
Window.WindowModeChangeEvent
Event which is fired when the mode of the Window changes.
static interface
Window.WindowModeChangeListener
An interface used for listening to Window maximize / restore events.
static class
Window.WindowOrderChangeEvent
Event which is fired when the window order position is changed.
static interface
Window.WindowOrderChangeListener
An interface used for listening to Window order change events.
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
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
-
-
Method Summary
All Methods Modifier and Type Method Description Registration
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener
to the Component which gets fired when aField
loses keyboard focus.Registration
addCloseListener(Window.CloseListener listener)
Adds a CloseListener to the window.
void
addCloseShortcut(int keyCode, int... modifiers)
Adds a close shortcut - pressing this key while holding down all (if any) modifiers specified while this Window is in focus will close the Window.
Registration
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener
to the Component which gets fired when aField
receives keyboard focus.Registration
addResizeListener(Window.ResizeListener listener)
Add a resize listener.
Registration
addWindowModeChangeListener(Window.WindowModeChangeListener listener)
Adds a WindowModeChangeListener to the window.
Registration
addWindowOrderChangeListener(Window.WindowOrderChangeListener listener)
Adds a WindowOrderChangeListener to the window.
void
bringToFront()
If there are currently several windows visible, calling this method makes this window topmost.
void
center()
Sets this window to be centered relative to its parent window.
void
changeVariables(Object source, Map<String,Object> variables)
Called when one or more variables handled by the implementing class are changed.
void
close()
Method that handles window closing (from UI).
protected void
fireClose()
protected void
fireResize()
Fire the resize event.
protected void
fireWindowOrderChange(Integer order)
protected void
fireWindowWindowModeChange()
void
focus()
Moves keyboard focus to the component.
Component[]
getAssistiveDescription()
Gets the components that are used as assistive description.
String
getAssistivePostfix()
Gets the accessibility postfix for the window caption.
String
getAssistivePrefix()
Gets the accessibility prefix for the window caption.
WindowRole
getAssistiveRole()
Gets the WAI-ARIA role the window.
Collection<Window.CloseShortcut>
getCloseShortcuts()
Returns an unmodifiable collection of
Window.CloseShortcut
objects currently registered with thisWindow
.protected Collection<String>
getCustomAttributes()
Returns a collection of attributes that should not be handled by the basic implementation of the
AbstractComponent.readDesign(Element, DesignContext)
andAbstractComponent.writeDesign(Element, DesignContext)
methods.int
getOrderPosition()
Returns the position of this window in the order of all open windows for this UI.
int
getPositionX()
Gets the distance of Window left border in pixels from left border of the containing (main window) when the window is in
WindowMode.NORMAL
.int
getPositionY()
Gets the distance of Window top border in pixels from top border of the containing (main window) when the window is in
WindowMode.NORMAL
state, or when next set to that state.protected WindowState
getState()
Returns the shared state bean with information to be sent from the server to the client.
protected WindowState
getState(boolean markAsDirty)
Returns the shared state for this connector.
String
getTabStopBottomAssistiveText()
Gets the message that is provided to users of assistive devices when the user reaches the bottom of the window when leaving a window with the tab key is prevented.
String
getTabStopTopAssistiveText()
Gets the message that is provided to users of assistive devices when the user reaches the top of the window when leaving a window with the tab key is prevented.
WindowMode
getWindowMode()
Gets the current mode of the window.
boolean
hasCloseShortcut(int keyCode, int... modifiers)
Checks if a close window shortcut key has already been registered.
boolean
isClosable()
Returns the closable status of the window.
boolean
isDraggable()
Indicates whether a window can be dragged or not.
boolean
isModal()
boolean
isResizable()
boolean
isResizeLazy()
boolean
isTabStopEnabled()
Get if it is prevented to leave a window with the tab key.
void
paintContent(PaintTarget target)
Paints the Paintable into a UIDL stream.
void
readDesign(org.jsoup.nodes.Element design, DesignContext context)
Reads the component state from the given design.
protected void
readDesignChildren(org.jsoup.select.Elements children, DesignContext context)
Reads the content and possible assistive descriptions from the list of child elements of a design.
void
removeAllCloseShortcuts()
Removes all close shortcuts.
void
removeCloseListener(Window.CloseListener listener)
Deprecated.
void
removeCloseShortcut()
Deprecated.
UseremoveCloseShortcut(int, int...)
instead.void
removeCloseShortcut(int keyCode, int... modifiers)
Removes a close shortcut previously added with
addCloseShortcut(int, int...)
.void
removeResizeListener(Window.ResizeListener listener)
Deprecated.
void
removeWindowModeChangeListener(Window.WindowModeChangeListener listener)
Deprecated.
void
setAssistiveDescription(Component... components)
Allows to specify which components contain the description for the window.
void
setAssistivePostfix(String assistivePostfix)
Sets the accessibility postfix for the window caption.
void
setAssistivePrefix(String prefix)
Sets the accessibility prefix for the window caption.
void
setAssistiveRole(WindowRole role)
Sets the WAI-ARIA role the window.
void
setClosable(boolean closable)
Sets the closable status for the window.
void
setCloseShortcut(int keyCode, int... modifiers)
Deprecated.
UseaddCloseShortcut(int, int...)
instead.void
setDraggable(boolean draggable)
Enables or disables that a window can be dragged (moved) by the user.
void
setModal(boolean modal)
Sets window modality.
void
setParent(HasComponents parent)
Sets the parent connector of the component.
void
setPosition(int x, int y)
Sets the position of the window on the screen using
setPositionX(int)
andsetPositionY(int)
.void
setPositionX(int positionX)
Sets the distance of Window left border in pixels from left border of the containing (main window).
void
setPositionY(int positionY)
Sets the distance of Window top border in pixels from top border of the containing (main window).
void
setResizable(boolean resizable)
Sets window resizable.
void
setResizeLazy(boolean resizeLazy)
Should resize operations be lazy, i.e.
void
setTabStopBottomAssistiveText(String bottomMessage)
Sets the message that is provided to users of assistive devices when the user reaches the bottom of the window when leaving a window with the tab key is prevented.
void
setTabStopEnabled(boolean tabStop)
Set if it should be prevented to set the focus to a component outside a non-modal window with the tab key.
void
setTabStopTopAssistiveText(String topMessage)
Sets the message that is provided to users of assistive devices when the user reaches the top of the window when leaving a window with the tab key is prevented.
void
setWindowMode(WindowMode windowMode)
Sets the mode for the window.
void
writeDesign(org.jsoup.nodes.Element design, DesignContext context)
Writes the component state to the given design.
-
Methods inherited from class com.vaadin.ui.Panel
addAction, addActionHandler, addClickListener, getActionManager, getScrollLeft, getScrollTop, getTabIndex, removeAction, removeActionHandler, removeAllActionHandlers, removeClickListener, 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, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, 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, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
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.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setEnabled, setIcon, setId, setPrimaryStyleName, setStyleName, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.vaadin.ui.LegacyComponent
markAsDirty
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from interface com.vaadin.server.VariableOwner
isEnabled
-
-
-
-
Constructor Detail
-
Window
public Window()
Creates a new, empty window.
-
Window
public Window(String caption)
Creates a new, empty window with a given title.
Parameters:
caption
- the title of the window.
-
-
Method Detail
-
paintContent
public void paintContent(PaintTarget target) throws PaintException
Description copied from interface:
LegacyComponent
Paints the Paintable into a UIDL stream. This method creates the UIDL sequence describing it and outputs it to the given UIDL stream.
It is called when the contents of the component should be painted in response to the component first being shown or having been altered so that its visual representation is changed.
Specified by:
paintContent
in interfaceLegacyComponent
Overrides:
paintContent
in classPanel
Parameters:
target
- the target UIDL stream where the component should paint itself to.Throws:
PaintException
- if the paint operation failed.
-
setParent
public void setParent(HasComponents parent)
Description copied from interface:
Component
Sets the parent connector of the component.
This method automatically calls
Component.attach()
if the component becomes attached to the session, regardless of whether it was attached previously. Conversely, if the component currently is attached to the session,ClientConnector.detach()
is called for the connector before attaching it to a new parent.This method is rarely called directly.
ComponentContainer.addComponent(Component)
or aHasComponents
specific method is normally used for adding components to a parent and the used method will call this method implicitly.Specified by:
setParent
in interfaceComponent
Overrides:
setParent
in classAbstractComponent
Parameters:
parent
- the parent connector
-
changeVariables
public void changeVariables(Object source, Map<String,Object> variables)
Description copied from class:
Panel
Called when one or more variables handled by the implementing class are changed.
Specified by:
changeVariables
in interfaceVariableOwner
Overrides:
changeVariables
in classPanel
Parameters:
source
- the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.variables
- the Mapping from variable names to new variable values.See Also:
-
close
public void close()
Method that handles window closing (from UI).
By default, windows are removed from their respective UIs and thus visually closed on browser-side.
To react to a window being closed (after it is closed), register a
Window.CloseListener
.
-
getPositionX
public int getPositionX()
Gets the distance of Window left border in pixels from left border of the containing (main window) when the window is in
WindowMode.NORMAL
.Returns:
the Distance of Window left border in pixels from left border of the containing (main window).or -1 if unspecified
Since:
4.0.0
-
setPosition
public void setPosition(int x, int y)
Sets the position of the window on the screen using
setPositionX(int)
andsetPositionY(int)
.Parameters:
x
- The new x coordinate for the windowy
- The new y coordinate for the windowSince:
7.5
-
setPositionX
public void setPositionX(int positionX)
Sets the distance of Window left border in pixels from left border of the containing (main window). Has effect only if in
WindowMode.NORMAL
mode.Parameters:
positionX
- the Distance of Window left border in pixels from left border of the containing (main window). or -1 if unspecified.Since:
4.0.0
-
getPositionY
public int getPositionY()
Gets the distance of Window top border in pixels from top border of the containing (main window) when the window is in
WindowMode.NORMAL
state, or when next set to that state.Returns:
Distance of Window top border in pixels from top border of the containing (main window). or -1 if unspecified
Since:
4.0.0
-
getOrderPosition
public int getOrderPosition()
Returns the position of this window in the order of all open windows for this UI.
Window with position 0 is on the bottom, and window with greatest position is at the top. If window has no position (it's not yet attached or hidden) then position is
-1
.Returns:
window order position.
Since:
8.0
See Also:
UI.addWindowOrderUpdateListener(com.vaadin.ui.UI.WindowOrderUpdateListener)
-
setPositionY
public void setPositionY(int positionY)
Sets the distance of Window top border in pixels from top border of the containing (main window). Has effect only if in
WindowMode.NORMAL
mode.Parameters:
positionY
- the Distance of Window top border in pixels from top border of the containing (main window). or -1 if unspecifiedSince:
4.0.0
-
addWindowOrderChangeListener
public Registration addWindowOrderChangeListener(Window.WindowOrderChangeListener listener)
Adds a WindowOrderChangeListener to the window.
The WindowOrderChangeEvent is fired when the order position is changed. It can happen when some window (this or other) is brought to front or detached.
The other way to listen positions of all windows in UI is
UI.addWindowOrderUpdateListener(com.vaadin.ui.UI.WindowOrderUpdateListener)
Parameters:
listener
- the WindowModeChangeListener to add.Since:
8.0
See Also:
UI.addWindowOrderUpdateListener(com.vaadin.ui.UI.WindowOrderUpdateListener)
-
fireWindowOrderChange
protected void fireWindowOrderChange(Integer order)
-
addCloseListener
public Registration addCloseListener(Window.CloseListener listener)
Adds a CloseListener to the window. For a window the CloseListener is fired when the user closes it (clicks on the close button). For a browser level window the CloseListener is fired when the browser level window is closed. Note that closing a browser level window does not mean it will be destroyed. Also note that Opera does not send events like all other browsers and therefore the close listener might not be called if Opera is used.
Parameters:
listener
- the CloseListener to add, not nullSince:
8.0
-
removeCloseListener
@Deprecated public void removeCloseListener(Window.CloseListener listener)
Deprecated.Removes the CloseListener from the window.
For more information on CloseListeners see
Window.CloseListener
.Parameters:
listener
- the CloseListener to remove.
-
fireClose
protected void fireClose()
-
addWindowModeChangeListener
public Registration addWindowModeChangeListener(Window.WindowModeChangeListener listener)
Adds a WindowModeChangeListener to the window. The WindowModeChangeEvent is fired when the user changed the display state by clicking the maximize/restore button or by double clicking on the window header. The event is also fired if the state is changed using
setWindowMode(WindowMode)
.Parameters:
listener
- the WindowModeChangeListener to add.Since:
8.0
-
removeWindowModeChangeListener
@Deprecated public void removeWindowModeChangeListener(Window.WindowModeChangeListener listener)
Deprecated.Removes the WindowModeChangeListener from the window.
Parameters:
listener
- the WindowModeChangeListener to remove.
-
fireWindowWindowModeChange
protected void fireWindowWindowModeChange()
-
addResizeListener
public Registration addResizeListener(Window.ResizeListener listener)
Add a resize listener.
Parameters:
listener
- the listener to add, not nullReturns:
a registration object for removing the listener
Since:
8.0
See Also:
-
removeResizeListener
@Deprecated public void removeResizeListener(Window.ResizeListener listener)
Deprecated.Remove a resize listener.
Parameters:
listener
-
-
fireResize
protected void fireResize()
Fire the resize event.
-
bringToFront
public void bringToFront()
If there are currently several windows visible, calling this method makes this window topmost.
This method can only be called if this window connected a UI. Else an illegal state exception is thrown. Also if there are modal windows and this window is not modal, and illegal state exception is thrown.
-
setModal
public void setModal(boolean modal)
Sets window modality. When a modal window is open, components outside that window cannot be accessed.
Keyboard navigation is restricted by blocking the tab key at the top and bottom of the window by activating the tab stop function internally.
Parameters:
modal
- true if modality is to be turned on
-
isModal
public boolean isModal()
Returns:
true if this window is modal.
-
setResizable
public void setResizable(boolean resizable)
Sets window resizable.
Parameters:
resizable
- true if resizability is to be turned on
-
isResizable
public boolean isResizable()
Returns:
true if window is resizable by the end-user, otherwise false.
-
isResizeLazy
public boolean isResizeLazy()
Returns:
true if a delay is used before recalculating sizes, false if sizes are recalculated immediately.
-
setResizeLazy
public void setResizeLazy(boolean resizeLazy)
Should resize operations be lazy, i.e. should there be a delay before layout sizes are recalculated. Speeds up resize operations in slow UIs with the penalty of slightly decreased usability. Note, some browser send false resize events for the browser window and are therefore always lazy.
Parameters:
resizeLazy
- true to use a delay before recalculating sizes, false to calculate immediately.
-
center
public void center()
Sets this window to be centered relative to its parent window. Affects windows only. If the window is resized as a result of the size of its content changing, it will keep itself centered as long as its position is not explicitly changed programmatically or by the user.
NOTE: This method has several issues as currently implemented. Please refer to http://dev.vaadin.com/ticket/8971 for details.
-
isClosable
public boolean isClosable()
Returns the closable status of the window. If a window is closable, it typically shows an X in the upper right corner. Clicking on the X sends a close event to the server. Setting closable to false will remove the X from the window and prevent the user from closing the window.
Returns:
true if the window can be closed by the user.
-
setClosable
public void setClosable(boolean closable)
Sets the closable status for the window. If a window is closable it typically shows an X in the upper right corner. Clicking on the X sends a close event to the server. Setting closable to false will remove the X from the window and prevent the user from closing the window.
Parameters:
closable
- determines if the window can be closed by the user.
-
isDraggable
public boolean isDraggable()
Indicates whether a window can be dragged or not. By default a window is draggable.
Returns:
true
if window is draggable;false
if not
-
setDraggable
public void setDraggable(boolean draggable)
Enables or disables that a window can be dragged (moved) by the user. By default a window is draggable.
Parameters:
draggable
- true if the window can be dragged by the user
-
getWindowMode
public WindowMode getWindowMode()
Gets the current mode of the window.
Returns:
the mode of the window.
See Also:
-
setWindowMode
public void setWindowMode(WindowMode windowMode)
Sets the mode for the window.
Parameters:
windowMode
- The new modeSee Also:
-
setCloseShortcut
@Deprecated public void setCloseShortcut(int keyCode, int... modifiers)
Deprecated.UseaddCloseShortcut(int, int...)
instead.This is the old way of adding a keyboard shortcut to close a
Window
- to preserve compatibility with existing code under the new functionality, this method now first removes all registered close shortcuts, then adds the default ESCAPE shortcut key, and then attempts to add the shortcut provided as parameters to this method. This method, and its companionremoveCloseShortcut()
, are now considered deprecated, as their main function is to preserve exact backwards compatibility with old code. For all new code, use the new keyboard shortcuts API:addCloseShortcut(int,int...)
,removeCloseShortcut(int,int...)
,removeAllCloseShortcuts()
,hasCloseShortcut(int,int...)
andgetCloseShortcuts()
.Original description: Makes it possible to close the window by pressing the given
ShortcutAction.KeyCode
and (optional)ShortcutAction.ModifierKey
s.
Note that this shortcut only reacts while the window has focus, closing itself - if you want to close a window from a UI, useUI.addAction(com.vaadin.event.Action)
of the UI instead.Parameters:
keyCode
- the keycode for invoking the shortcutmodifiers
- the (optional) modifiers for invoking the shortcut. Can be set to null to be explicit about not having modifiers.
-
removeCloseShortcut
@Deprecated public void removeCloseShortcut()
Deprecated.UseremoveCloseShortcut(int, int...)
instead.Removes all keyboard shortcuts previously set with
setCloseShortcut(int, int...)
andaddCloseShortcut(int, int...)
, then adds the defaultShortcutAction.KeyCode.ESCAPE
shortcut.This is the old way of removing the (single) keyboard close shortcut, and is retained only for exact backwards compatibility. For all new code, use the new keyboard shortcuts API:
addCloseShortcut(int,int...)
,removeCloseShortcut(int,int...)
,removeAllCloseShortcuts()
,hasCloseShortcut(int,int...)
andgetCloseShortcuts()
.
-
addCloseShortcut
public void addCloseShortcut(int keyCode, int... modifiers)
Adds a close shortcut - pressing this key while holding down all (if any) modifiers specified while this Window is in focus will close the Window.
Parameters:
keyCode
- the keycode for invoking the shortcutmodifiers
- the (optional) modifiers for invoking the shortcut. Can be set to null to be explicit about not having modifiers.Since:
7.6
-
removeCloseShortcut
public void removeCloseShortcut(int keyCode, int... modifiers)
Removes a close shortcut previously added with
addCloseShortcut(int, int...)
.Parameters:
keyCode
- the keycode for invoking the shortcutmodifiers
- the (optional) modifiers for invoking the shortcut. Can be set to null to be explicit about not having modifiers.Since:
7.6
-
removeAllCloseShortcuts
public void removeAllCloseShortcuts()
Removes all close shortcuts. This includes the default ESCAPE shortcut. It is up to the user to add back any and all keyboard close shortcuts they may require. For more fine-grained control over shortcuts, use
removeCloseShortcut(int, int...)
.Since:
7.6
-
hasCloseShortcut
public boolean hasCloseShortcut(int keyCode, int... modifiers)
Checks if a close window shortcut key has already been registered.
Parameters:
keyCode
- the keycode for invoking the shortcutmodifiers
- the (optional) modifiers for invoking the shortcut. Can be set to null to be explicit about not having modifiers.Returns:
true, if an exactly matching shortcut has been registered.
Since:
7.6
-
getCloseShortcuts
public Collection<Window.CloseShortcut> getCloseShortcuts()
Returns an unmodifiable collection of
Window.CloseShortcut
objects currently registered with thisWindow
. This method is provided mainly so that users can implement their own serialization routines. To check if a certain combination of keys has been registered as a close shortcut, use thehasCloseShortcut(int, int...)
method instead.Returns:
an unmodifiable Collection of CloseShortcut objects.
Since:
7.6
-
addFocusListener
public Registration addFocusListener(FieldEvents.FocusListener listener)
Description copied from interface:
FieldEvents.FocusNotifier
Adds a
FocusListener
to the Component which gets fired when aField
receives keyboard focus.Specified by:
addFocusListener
in interfaceFieldEvents.FocusNotifier
Parameters:
listener
- the focus listener to add, not nullReturns:
a registration object for removing the listener
See Also:
-
addBlurListener
public Registration addBlurListener(FieldEvents.BlurListener listener)
Description copied from interface:
FieldEvents.BlurNotifier
Adds a
BlurListener
to the Component which gets fired when aField
loses keyboard focus.Specified by:
addBlurListener
in interfaceFieldEvents.BlurNotifier
Parameters:
listener
- the blur listener to add, not nullReturns:
a registration object for removing the listener
See Also:
-
focus
public void focus()
Moves keyboard focus to the component.
Component.Focusable.focus()
Cause the window to be brought on top of other windows and gain keyboard focus.Specified by:
focus
in interfaceComponent.Focusable
Overrides:
See Also:
FieldEvents
,FieldEvents.FocusEvent
,FieldEvents.FocusListener
,FieldEvents.BlurEvent
,FieldEvents.BlurListener
-
getState
protected WindowState getState()
Description copied from class:
AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
-
getState
protected WindowState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
setAssistiveDescription
public void setAssistiveDescription(Component... components)
Allows to specify which components contain the description for the window. Text contained in these components will be read by assistive devices when it is opened.
Parameters:
components
- the components to use as description
-
getAssistiveDescription
public Component[] getAssistiveDescription()
Gets the components that are used as assistive description. Text contained in these components will be read by assistive devices when the window is opened.
Returns:
array of previously set components
-
setAssistivePrefix
public void setAssistivePrefix(String prefix)
Sets the accessibility prefix for the window caption. This prefix is read to assistive device users before the window caption, but not visible on the page.
Parameters:
prefix
- String that is placed before the window caption
-
getAssistivePrefix
public String getAssistivePrefix()
Gets the accessibility prefix for the window caption. This prefix is read to assistive device users before the window caption, but not visible on the page.
Returns:
The accessibility prefix
-
setAssistivePostfix
public void setAssistivePostfix(String assistivePostfix)
Sets the accessibility postfix for the window caption. This postfix is read to assistive device users after the window caption, but not visible on the page.
Parameters:
assistivePostfix
- String that is placed after the window caption
-
getAssistivePostfix
public String getAssistivePostfix()
Gets the accessibility postfix for the window caption. This postfix is read to assistive device users after the window caption, but not visible on the page.
Returns:
The accessibility postfix
-
setAssistiveRole
public void setAssistiveRole(WindowRole role)
Sets the WAI-ARIA role the window. This role defines how an assistive device handles a window. Available roles are alertdialog and dialog (@see Roles Model). The default role is dialog.
Parameters:
role
- WAI-ARIA role to set for the window
-
getAssistiveRole
public WindowRole getAssistiveRole()
Gets the WAI-ARIA role the window. This role defines how an assistive device handles a window. Available roles are alertdialog and dialog (@see Roles Model).
Returns:
WAI-ARIA role set for the window
-
setTabStopEnabled
public void setTabStopEnabled(boolean tabStop)
Set if it should be prevented to set the focus to a component outside a non-modal window with the tab key.
This is meant to help users of assistive devices to not leaving the window unintentionally.
For modal windows, this function is activated automatically, while preserving the stored value of tabStop.
Parameters:
tabStop
- true to keep the focus inside the window when reaching the top or bottom, false (default) to allow leaving the window
-
isTabStopEnabled
public boolean isTabStopEnabled()
Get if it is prevented to leave a window with the tab key.
Returns:
true when the focus is limited to inside the window, false when focus can leave the window
-
setTabStopTopAssistiveText
public void setTabStopTopAssistiveText(String topMessage)
Sets the message that is provided to users of assistive devices when the user reaches the top of the window when leaving a window with the tab key is prevented.
This message is not visible on the screen.
Parameters:
topMessage
- String provided when the user navigates with Shift-Tab keys to the top of the window
-
setTabStopBottomAssistiveText
public void setTabStopBottomAssistiveText(String bottomMessage)
Sets the message that is provided to users of assistive devices when the user reaches the bottom of the window when leaving a window with the tab key is prevented.
This message is not visible on the screen.
Parameters:
bottomMessage
- String provided when the user navigates with the Tab key to the bottom of the window
-
getTabStopTopAssistiveText
public String getTabStopTopAssistiveText()
Gets the message that is provided to users of assistive devices when the user reaches the top of the window when leaving a window with the tab key is prevented.
Returns:
the top message
-
getTabStopBottomAssistiveText
public String getTabStopBottomAssistiveText()
Gets the message that is provided to users of assistive devices when the user reaches the bottom of the window when leaving a window with the tab key is prevented.
Returns:
the bottom message
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext context)
Description copied from interface:
Component
Reads the component state from the given design.
The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
Specified by:
readDesign
in interfaceComponent
Overrides:
readDesign
in classPanel
Parameters:
design
- The element to obtain the state fromcontext
- The DesignContext instance used for parsing the design
-
readDesignChildren
protected void readDesignChildren(org.jsoup.select.Elements children, DesignContext context)
Reads the content and possible assistive descriptions from the list of child elements of a design. If an element has an
:assistive-description
attribute, adds the parsed component to the list of components used as the assistive description of this Window. Otherwise, sets the component as the content of this Window. If there are multiple non-description elements, throws a DesignException.Overrides:
readDesignChildren
in classAbstractSingleComponentContainer
Parameters:
children
- child elements in a designcontext
- the DesignContext instance used to parse the designThrows:
DesignException
- if there are multiple non-description child elementsDesignException
- if a child element could not be parsed as a ComponentSee Also:
AbstractSingleComponentContainer.setContent(Component)
,setAssistiveDescription(Component...)
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext context)
Description copied from interface:
Component
Writes the component state to the given design.
The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
Specified by:
writeDesign
in interfaceComponent
Overrides:
writeDesign
in classPanel
Parameters:
design
- The element to write the component state to. Any previous attributes or child nodes are not cleared.context
- The DesignContext instance used for writing the design
-
getCustomAttributes
protected Collection<String> getCustomAttributes()
Description copied from class:
AbstractComponent
Returns a collection of attributes that should not be handled by the basic implementation of the
AbstractComponent.readDesign(Element, DesignContext)
andAbstractComponent.writeDesign(Element, DesignContext)
methods. Typically these are handled in a custom way in the overridden versions of the above methodsOverrides:
getCustomAttributes
in classPanel
Returns:
the collection of attributes that are not handled by the basic implementation
-
-