Class MasterDetailLayout
- All Implemented Interfaces:
AttachNotifier,DetachNotifier,HasElement,HasSize,HasStyle,RouterLayout,Serializable
- 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 classEvent that is fired when the Escape key is pressed within the details area.static enumSupported orientation values forMasterDetailLayout.static enumSupported overlay containment values forMasterDetailLayout. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty Master Detail Layout.MasterDetailLayout(float masterSize, Unit masterUnit, float detailSize, Unit detailUnit) Creates a Master Detail Layout with the given master and detail sizes.MasterDetailLayout(String masterSize, String detailSize) Creates a Master Detail Layout with the given master and detail sizes. -
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 component currently in the detail area.Gets the component currently in the detail placeholder area.Gets the size of the detail area.Gets the component currently in the master area.Gets the size of the master area.Gets the orientation of the layout.Gets the overlay containment of the layout.Gets the size of the detail area when shown as an overlay.booleanGets whether the layout animation is enabled.booleanGets whether the detail area expands to fill available space.booleanGets whether the master area expands to fill available space.booleanGets whether the layout forces the detail area to be shown as an overlay, even if there is enough space for master and detail to be shown next to each other using the default (split) mode.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.voidSets the component to be displayed in the detail area.voidsetDetailPlaceholder(Component component) Sets the component to be displayed in the detail placeholder area.voidsetDetailSize(float size, Unit unit) Sets the size of the detail area in CSS length units.voidsetDetailSize(float size, Unit unit, boolean expand) Sets the size of the detail area in CSS length units and whether the detail area expands to fill available space.voidsetDetailSize(float size, Unit unit, boolean expand, float overlaySize, Unit overlayUnit) Sets the size of the detail area, whether the detail area expands to fill available space, and the size of the detail area when shown as an overlay.voidsetDetailSize(float size, Unit unit, float overlaySize, Unit overlayUnit) Sets the size of the detail area and the size of the detail area when shown as an overlay, both in CSS length units.voidsetDetailSize(String size) Sets the size of the detail area in CSS length units.voidsetDetailSize(String size, boolean expand) Sets the size of the detail area in CSS length units and whether the detail area expands to fill available space.voidsetDetailSize(String size, boolean expand, String overlaySize) Sets the size of the detail area in CSS length units, whether the detail area expands to fill available space, and the size of the detail area when shown as an overlay.voidsetDetailSize(String size, String overlaySize) Sets the size of the detail area and the size of the detail area when shown as an overlay, both in CSS length units.voidsetExpandDetail(boolean expandDetail) Sets whether the detail area expands to fill available space.voidsetExpandMaster(boolean expandMaster) Sets whether the master area expands to fill available space.voidsetForceOverlay(boolean forceOverlay) Sets whether the layout forces the detail area to be shown as an overlay, even if there is enough space for master and detail to be shown next to each other using the default (split) mode.voidSets the component to be displayed in the master area.voidsetMasterSize(float size, Unit unit) Sets the size of the master area in CSS length units.voidsetMasterSize(float size, Unit unit, boolean expand) Sets the size of the master area in CSS length units and whether the master area expands to fill available space.voidsetMasterSize(String size) Sets the size of the master area in CSS length units.voidsetMasterSize(String size, boolean expand) Sets the size of the master area in CSS length units and whether the master area expands to fill available space.voidsetOrientation(MasterDetailLayout.Orientation orientation) Sets the orientation of the layout.voidsetOverlayContainment(MasterDetailLayout.OverlayContainment overlayContainment) Sets the containment of the detail area when the layout is in overlay mode.voidsetOverlaySize(float size, Unit unit) Sets the size of the detail area when shown as an overlay.voidsetOverlaySize(String size) Sets the size of the detail area when shown as an overlay.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, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, 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
bindHeight, bindWidth, 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, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Field Details
-
MASTER_SLOT
- See Also:
-
DETAIL_PLACEHOLDER_SLOT
- See Also:
-
-
Constructor Details
-
MasterDetailLayout
public MasterDetailLayout()Creates an empty Master Detail Layout. -
MasterDetailLayout
Creates a Master Detail Layout with the given master and detail sizes.- Parameters:
masterSize- the size of the master area in CSS length unitsdetailSize- the size of the detail area in CSS length units
-
MasterDetailLayout
Creates a Master Detail Layout with the given master and detail sizes.- Parameters:
masterSize- the size of the master areamasterUnit- the unit for the master sizedetailSize- the size of the detail areadetailUnit- the unit for the detail size
-
-
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
-
getDetailPlaceholder
Gets the component currently in the detail placeholder area.- Returns:
- the component in the detail placeholder area, or
nullif there is no component in the detail placeholder area
-
setDetailPlaceholder
Sets the component to be displayed in the detail placeholder area. The placeholder is shown when no detail content is set, and is hidden when the layout is in overlay mode. Unlike the detail content, the placeholder does not become an overlay when there is not enough space.- Parameters:
component- the component to display in the detail placeholder area, ornullto clear the detail placeholder area
-
onAttach
Description copied from class:ComponentCalled when the component is attached to a UI.This method is invoked before the
AttachEventis fired for the component. Make sure to callsuper.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. If there is not enough space to show master and detail areas next to each other, the detail area is shown as an overlay. Defaults to 30em.- Parameters:
size- the size of the master area in CSS length units
-
setMasterSize
Sets the size of the master area in CSS length units. If there is not enough space to show master and detail areas next to each other, the detail area is shown as an overlay. Defaults to 30em.- Parameters:
size- the size of the master areaunit- the unit
-
setMasterSize
Sets the size of the master area in CSS length units and whether the master area expands to fill available space.- Parameters:
size- the size of the master area in CSS length unitsexpand-trueto expand the master area,falseotherwise- See Also:
-
setMasterSize
Sets the size of the master area in CSS length units and whether the master area expands to fill available space.- Parameters:
size- the size of the master areaunit- the unitexpand-trueto expand the master area,falseotherwise- See Also:
-
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 there is not enough space to show master and detail areas next to each other, the detail area is shown as an overlay.If not specified, the size is determined automatically by measuring the detail content whenever new content is provided via
setDetail(com.vaadin.flow.component.Component). The measured intrinsic size is then cached until the nextsetDetail(com.vaadin.flow.component.Component)call.- 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 there is not enough space to show master and detail areas next to each other, the detail area is shown as an overlay.If not specified, the size is determined automatically by measuring the detail content whenever new content is provided via
setDetail(com.vaadin.flow.component.Component). The measured intrinsic size is then cached until the nextsetDetail(com.vaadin.flow.component.Component)call.- Parameters:
size- the size of the detail areaunit- the unit
-
setDetailSize
Sets the size of the detail area in CSS length units and whether the detail area expands to fill available space.- Parameters:
size- the size of the detail area in CSS length unitsexpand-trueto expand the detail area,falseotherwise- See Also:
-
setDetailSize
Sets the size of the detail area in CSS length units and whether the detail area expands to fill available space.- Parameters:
size- the size of the detail areaunit- the unitexpand-trueto expand the detail area,falseotherwise- See Also:
-
setDetailSize
Sets the size of the detail area and the size of the detail area when shown as an overlay, both in CSS length units.- Parameters:
size- the size of the detail area in CSS length unitsoverlaySize- the overlay size in CSS length units- See Also:
-
setDetailSize
Sets the size of the detail area and the size of the detail area when shown as an overlay, both in CSS length units.- Parameters:
size- the size of the detail areaunit- the unit for the detail sizeoverlaySize- the overlay sizeoverlayUnit- the unit for the overlay size- See Also:
-
setDetailSize
Sets the size of the detail area in CSS length units, whether the detail area expands to fill available space, and the size of the detail area when shown as an overlay.- Parameters:
size- the size of the detail area in CSS length unitsexpand-trueto expand the detail area,falseotherwiseoverlaySize- the overlay size in CSS length units- See Also:
-
setDetailSize
public void setDetailSize(float size, Unit unit, boolean expand, float overlaySize, Unit overlayUnit) Sets the size of the detail area, whether the detail area expands to fill available space, and the size of the detail area when shown as an overlay.- Parameters:
size- the size of the detail areaunit- the unit for the detail sizeexpand-trueto expand the detail area,falseotherwiseoverlaySize- the overlay sizeoverlayUnit- the unit for the overlay size- See Also:
-
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 is applied as width or height.- Parameters:
orientation- the orientation
-
getOverlayContainment
Gets the overlay containment of the layout. Defaults toMasterDetailLayout.OverlayContainment.LAYOUT.- Returns:
- the overlay containment
-
setOverlayContainment
Sets the containment of the detail area when the layout is in overlay mode. When set toMasterDetailLayout.OverlayContainment.LAYOUT, the overlay is confined to the layout. When set toMasterDetailLayout.OverlayContainment.PAGE, the overlay is confined to the browser's viewport. Defaults toMasterDetailLayout.OverlayContainment.LAYOUT.- Parameters:
overlayContainment- the overlay containment
-
getOverlaySize
Gets the size of the detail area when shown as an overlay.- Returns:
- the overlay size in CSS length units, or
nullif the overlay size is not set
-
setOverlaySize
Sets the size of the detail area when shown as an overlay. When not set, falls back to the detail size. Set to"100%"to make the detail cover the full layout.- Parameters:
size- the overlay size in CSS length units
-
setOverlaySize
Sets the size of the detail area when shown as an overlay. When not set, falls back to the detail size. Set to100withto make the detail cover the full layout.invalid reference
Unit#PCT- Parameters:
size- the overlay sizeunit- the unit
-
isExpandMaster
public boolean isExpandMaster()Gets whether the master area expands to fill available space. Defaults tofalse.- Returns:
trueif the master area expands,falseotherwise
-
setExpandMaster
public void setExpandMaster(boolean expandMaster) Sets whether the master area expands to fill available space. When bothsetExpandMaster(boolean)andsetExpandDetail(boolean)are set totrue, the master and detail areas share the available space equally.- Parameters:
expandMaster-trueto expand the master area,falseotherwise
-
isExpandDetail
public boolean isExpandDetail()Gets whether the detail area expands to fill available space. Defaults tofalse.- Returns:
trueif the detail area expands,falseotherwise
-
setExpandDetail
public void setExpandDetail(boolean expandDetail) Sets whether the detail area expands to fill available space. When bothsetExpandMaster(boolean)andsetExpandDetail(boolean)are set totrue, the master and detail areas share the available space equally.- Parameters:
expandDetail-trueto expand the detail area,falseotherwise
-
isForceOverlay
public boolean isForceOverlay()Gets whether the layout forces the detail area to be shown as an overlay, even if there is enough space for master and detail to be shown next to each other using the default (split) mode.- Returns:
trueif the overlay mode is enforced,falseotherwise
-
setForceOverlay
public void setForceOverlay(boolean forceOverlay) Sets whether the layout forces the detail area to be shown as an overlay, even if there is enough space for master and detail to be shown next to each other using the default (split) mode.- 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 overlay 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
-