Class MasterDetailLayout
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.masterdetaillayout.MasterDetailLayout
- All Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasElement
,HasSize
,HasStyle
,RouterLayout
,Serializable
@Tag("vaadin-master-detail-layout")
@NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.8.3") @NpmPackage(value="@vaadin/master-detail-layout",version="24.8.3")
@JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/master-detail-layout/src/vaadin-master-detail-layout.js")
public class MasterDetailLayout
extends Component
implements HasSize, RouterLayout
MasterDetailLayout is a component for building UIs with a master (or primary)
area and a detail (or secondary) area that is displayed next to, or overlaid
on top of, the master area, depending on configuration and viewport size.
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Event that is fired when the backdrop of the details overlay is clicked.static enum
Supported containment values forMasterDetailLayout
.static class
Event that is fired when the Escape key is pressed within the details area.static enum
Supported orientation values forMasterDetailLayout
.static enum
Supported overlay mode values forMasterDetailLayout
. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a listener for when the backdrop of the details overlay is clicked.addDetailEscapePressListener
(ComponentEventListener<MasterDetailLayout.DetailEscapePressEvent> listener) Adds a listener for when the Escape key is pressed within the details area.Gets the containment of the layout.Gets the component currently in the detail area.Gets the minimum size of the detail area.Gets the size of the detail area.Gets the component currently in the master area.Gets the minimum size of the master area.Gets the size of the master area.Gets the orientation of the layout.Gets the overlay mode of the layout.boolean
Gets whether the layout animation is enabled.boolean
Gets whether the layout overlay mode is enforced.protected void
onAttach
(AttachEvent attachEvent) Called when the component is attached to a UI.protected void
onDetach
(DetachEvent detachEvent) Called when the component is detached from a UI.void
removeRouterLayoutContent
(HasElement oldContent) Removes content that should no longer be shown in this router layout.void
setAnimationEnabled
(boolean enabled) Sets whether the layout animation is enabled.void
setContainment
(MasterDetailLayout.Containment containment) Sets the containment of the layout.When set toMasterDetailLayout.Containment.LAYOUT
, the overlay is confined to the layout.void
Sets the component to be displayed in the detail area.void
setDetailMinSize
(float minSize, Unit unit) Sets the minimum size of the detail area in CSS length units.void
setDetailMinSize
(String minSize) Sets the minimum size of the detail area in CSS length units.void
setDetailSize
(float size, Unit unit) Sets the size of the detail area in CSS length units.void
setDetailSize
(String size) Sets the size of the detail area in CSS length units.void
setForceOverlay
(boolean forceOverlay) Sets whether the layout overlay mode is enforced.void
Sets the component to be displayed in the master area.void
setMasterMinSize
(float minSize, Unit unit) Sets the minimum size of the master area in CSS length units.void
setMasterMinSize
(String minSize) Sets the minimum size of the master area in CSS length units.void
setMasterSize
(float size, Unit unit) Sets the size of the master area in CSS length units.void
setMasterSize
(String size) Sets the size of the master area in CSS length units.void
setOrientation
(MasterDetailLayout.Orientation orientation) Sets the orientation of the layout.void
Sets the overlay mode of the layout.void
showRouterLayoutContent
(HasElement content) Shows the content of the layout which is the router target component annotated with a@Route
.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
MASTER_SLOT
- See Also:
-
-
Constructor Details
-
MasterDetailLayout
public MasterDetailLayout()Creates an empty Master Detail Layout.
-
-
Method Details
-
getMaster
Gets the component currently in the master area.- Returns:
- the component in the master area, or
null
if there is no component in the master area
-
setMaster
Sets the component to be displayed in the master area.- Parameters:
component
- the component to display in the master area, notnull
-
getDetail
Gets the component currently in the detail area.- Returns:
- the component in the detail area, or
null
if there is no component in the detail area
-
setDetail
Sets the component to be displayed in the detail area. The details area is automatically shown when the detail component is set, and hidden when the detail component is removed by setting it tonull
.- Parameters:
component
- the component to display in the detail area, ornull
to clear the detail area
-
onAttach
Description copied from class:Component
Called when the component is attached to a UI.This method is invoked before the
Make sure to callAttachEvent
is fired for the component.super.onAttach
when overriding this method. -
onDetach
Description copied from class:Component
Called when the component is detached from a UI.This method is invoked before the
DetachEvent
is fired for the component.Make sure to call
super.onDetach
when overriding this method. -
getMasterSize
Gets the size of the master area.- Returns:
- the size of the master area in CSS length units, or
null
if the size is not set
-
setMasterSize
Sets the size of the master area in CSS length units. When specified, it prevents the master area from growing or shrinking. If there is not enough space to show master and detail areas next to each other, the details are shown in an overlay, using the mode defined bysetOverlayMode(OverlayMode)
.- Parameters:
size
- the size of the master area in CSS length units
-
setMasterSize
Sets the size of the master area in CSS length units. When specified, it prevents the master area from growing or shrinking. If there is not enough space to show master and detail areas next to each other, the details are shown in an overlay, using the mode defined bysetOverlayMode(OverlayMode)
.- Parameters:
size
- the size of the master areaunit
- the unit
-
getMasterMinSize
Gets the minimum size of the master area.- Returns:
- the minimum size of the master area in CSS length units, or
null
if the minimum size is not set
-
setMasterMinSize
Sets the minimum size of the master area in CSS length units. When specified, it prevents the master area from shrinking below this size. If there is not enough space to show master and detail areas next to each other, the details are shown in an overlay, using the mode defined bysetOverlayMode(OverlayMode)
.- Parameters:
minSize
- the minimum size of the master area in CSS length units
-
setMasterMinSize
Sets the minimum size of the master area in CSS length units. When specified, it prevents the master area from shrinking below this size. If there is not enough space to show master and detail areas next to each other, the details are shown in an overlay, using the mode defined bysetOverlayMode(OverlayMode)
.- Parameters:
minSize
- the minimum size of the master areaunit
- the unit
-
getDetailSize
Gets the size of the detail area.- Returns:
- the size of the detail area in CSS length units, or
null
if the size is not set
-
setDetailSize
Sets the size of the detail area in CSS length units. When specified, it prevents the detail area from growing or shrinking. If there is not enough space to show master and detail areas next to each other, the details are shown in an overlay, using the mode defined bysetOverlayMode(OverlayMode)
.- Parameters:
size
- the size of the detail area in CSS length units
-
setDetailSize
Sets the size of the detail area in CSS length units. When specified, it prevents the detail area from growing or shrinking. If there is not enough space to show master and detail areas next to each other, the details are shown in an overlay, using the mode defined bysetOverlayMode(OverlayMode)
.- Parameters:
size
- the size of the detail areaunit
- the unit
-
getDetailMinSize
Gets the minimum size of the detail area.- Returns:
- the minimum size of the detail area in CSS length units, or
null
if the minimum size is not set
-
setDetailMinSize
Sets the minimum size of the detail area in CSS length units. When specified, it prevents the detail area from shrinking below this size. If there is not enough space to show master and detail areas next to each other, the details are shown in an overlay, using the mode defined bysetOverlayMode(OverlayMode)
.- Parameters:
minSize
- the minimum size of the detail area in CSS length units
-
setDetailMinSize
Sets the minimum size of the detail area in CSS length units. When specified, it prevents the detail area from shrinking below this size. If there is not enough space to show master and detail areas next to each other, the details are shown in an overlay, using the mode defined bysetOverlayMode(OverlayMode)
.- Parameters:
minSize
- the minimum size of the detail areaunit
- the unit
-
getOrientation
Gets the orientation of the layout. Defaults toMasterDetailLayout.Orientation.HORIZONTAL
.- Returns:
- the orientation
-
setOrientation
Sets the orientation of the layout. Defines how master and detail areas are shown next to each other, and whether size and min-size are applied as width or height.- Parameters:
orientation
- the orientation
-
getContainment
Gets the containment of the layout. Defaults toMasterDetailLayout.Containment.LAYOUT
.- Returns:
- the containment
-
setContainment
Sets the containment of the layout.When set toMasterDetailLayout.Containment.LAYOUT
, the overlay is confined to the layout. When set toMasterDetailLayout.Containment.VIEWPORT
, the overlay is confined to the browser's viewport.- Parameters:
containment
- the containment
-
getOverlayMode
Gets the overlay mode of the layout. Defaults toMasterDetailLayout.OverlayMode.DRAWER
.- Returns:
- the overlay mode
-
setOverlayMode
Sets the overlay mode of the layout. When set toMasterDetailLayout.OverlayMode.DRAWER
, the detail area is positioned on top of master area and there is a backdrop that covers the remaining part of the master area. When set toMasterDetailLayout.OverlayMode.STACK
, the detail area fully covers the master area.- Parameters:
mode
- the overlay mode
-
isForceOverlay
public boolean isForceOverlay()Gets whether the layout overlay mode is enforced. The way how the overlay is rendered is defined bysetOverlayMode(OverlayMode)
.- Returns:
true
if the overlay mode is enforced,false
otherwise
-
setForceOverlay
public void setForceOverlay(boolean forceOverlay) Sets whether the layout overlay mode is enforced. The way how the overlay is rendered is defined bysetOverlayMode(OverlayMode)
.- Parameters:
forceOverlay
-true
if the overlay mode is enforced,false
otherwise
-
isAnimationEnabled
public boolean isAnimationEnabled()Gets whether the layout animation is enabled.- Returns:
true
if the animation is enabled,false
otherwise
-
setAnimationEnabled
public void setAnimationEnabled(boolean enabled) Sets whether the layout animation is enabled.- Parameters:
enabled
-true
if the animation is enabled,false
otherwise
-
addBackdropClickListener
public Registration addBackdropClickListener(ComponentEventListener<MasterDetailLayout.BackdropClickEvent> listener) Adds a listener for when the backdrop of the details overlay is clicked. The backdrop is the area outside the detail area when it is shown in drawer mode. Can be used to hide the details when the backdrop is clicked.- Parameters:
listener
- the listener to add, notnull
- Returns:
- a registration for removing the listener
-
addDetailEscapePressListener
public Registration addDetailEscapePressListener(ComponentEventListener<MasterDetailLayout.DetailEscapePressEvent> listener) Adds a listener for when the Escape key is pressed within the details area. Can be used to hide the details when the Escape key is pressed.- Parameters:
listener
- the listener to add, notnull
- Returns:
- a registration for removing the listener
-
showRouterLayoutContent
Description copied from interface:RouterLayout
Shows the content of the layout which is the router target component annotated with a@Route
.Note implementors should not care about old
@Route
content, since it's handled separately byRouterLayout.removeRouterLayoutContent(HasElement)
which by default simply removes the old content.- Specified by:
showRouterLayoutContent
in interfaceRouterLayout
- Parameters:
content
- the content component ornull
if the layout content is to be cleared.
-
removeRouterLayoutContent
Description copied from interface:RouterLayout
Removes content that should no longer be shown in this router layout. IfRouterLayout.showRouterLayoutContent(HasElement)
was previously called with a non-null parameter, then this method will be called with the same parameter immediately before callingRouterLayout.showRouterLayoutContent(HasElement)
again.By default, the old content is removed from its parent using
Element.removeFromParent()
.- Specified by:
removeRouterLayoutContent
in interfaceRouterLayout
- Parameters:
oldContent
- the old content to remove, notnull
-