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/master-detail-layout",
version="25.0.0-alpha20")
@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 classEvent that is fired when the backdrop of the details overlay is clicked.static enumSupported containment values forMasterDetailLayout.static classEvent that is fired when the Escape key is pressed within the details area.static enumSupported orientation values forMasterDetailLayout.static enumSupported 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.booleanGets whether the layout animation is enabled.booleanGets whether the layout overlay mode is enforced.protected voidonAttach(AttachEvent attachEvent) Called when the component is attached to a UI.protected voidonDetach(DetachEvent detachEvent) Called when the component is detached from a UI.voidremoveRouterLayoutContent(HasElement oldContent) Removes content that should no longer be shown in this router layout.voidsetAnimationEnabled(boolean enabled) Sets whether the layout animation is enabled.voidsetContainment(MasterDetailLayout.Containment containment) Sets the containment of the layout.When set toMasterDetailLayout.Containment.LAYOUT, the overlay is confined to the layout.voidSets the component to be displayed in the detail area.voidsetDetailMinSize(float minSize, Unit unit) Sets the minimum size of the detail area in CSS length units.voidsetDetailMinSize(String minSize) Sets the minimum size of the detail area in CSS length units.voidsetDetailSize(float size, Unit unit) Sets the size of the detail area in CSS length units.voidsetDetailSize(String size) Sets the size of the detail area in CSS length units.voidsetForceOverlay(boolean forceOverlay) Sets whether the layout overlay mode is enforced.voidSets the component to be displayed in the master area.voidsetMasterMinSize(float minSize, Unit unit) Sets the minimum size of the master area in CSS length units.voidsetMasterMinSize(String minSize) Sets the minimum size of the master area in CSS length units.voidsetMasterSize(float size, Unit unit) Sets the size of the master area in CSS length units.voidsetMasterSize(String size) Sets the size of the master area in CSS length units.voidsetOrientation(MasterDetailLayout.Orientation orientation) Sets the orientation of the layout.voidSets the overlay mode of the layout.voidshowRouterLayoutContent(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, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods 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, setWidthFullMethods 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
nullif 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
nullif 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, ornullto clear the detail area
-
onAttach
Description copied from class:ComponentCalled when the component is attached to a UI.This method is invoked before the
Make sure to callAttachEventis fired for the component.super.onAttachwhen overriding this method. -
onDetach
Description copied from class:ComponentCalled when the component is detached from a UI.This method is invoked before the
DetachEventis fired for the component.Make sure to call
super.onDetachwhen overriding this method. -
getMasterSize
Gets the size of the master area.- Returns:
- the size of the master area in CSS length units, or
nullif 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
nullif 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
nullif 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
nullif 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:
trueif the overlay mode is enforced,falseotherwise
-
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-trueif the overlay mode is enforced,falseotherwise
-
isAnimationEnabled
public boolean isAnimationEnabled()Gets whether the layout animation is enabled.- Returns:
trueif the animation is enabled,falseotherwise
-
setAnimationEnabled
public void setAnimationEnabled(boolean enabled) Sets whether the layout animation is enabled.- Parameters:
enabled-trueif the animation is enabled,falseotherwise
-
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:RouterLayoutShows the content of the layout which is the router target component annotated with a@Route.Note implementors should not care about old
@Routecontent, since it's handled separately byRouterLayout.removeRouterLayoutContent(HasElement)which by default simply removes the old content.- Specified by:
showRouterLayoutContentin interfaceRouterLayout- Parameters:
content- the content component ornullif the layout content is to be cleared.
-
removeRouterLayoutContent
Description copied from interface:RouterLayoutRemoves 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:
removeRouterLayoutContentin interfaceRouterLayout- Parameters:
oldContent- the old content to remove, notnull
-