Class MasterDetailLayout

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.masterdetaillayout.MasterDetailLayout
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.shared.HasThemeVariant<MasterDetailLayoutVariant>, com.vaadin.flow.router.RouterLayout, Serializable

@Tag("vaadin-master-detail-layout") @NpmPackage(value="@vaadin/master-detail-layout", version="25.1.0-alpha9") @JsModule("@vaadin/master-detail-layout/src/vaadin-master-detail-layout.js") public class MasterDetailLayout extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasSize, com.vaadin.flow.component.shared.HasThemeVariant<MasterDetailLayoutVariant>, com.vaadin.flow.router.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 Classes
    Modifier and Type
    Class
    Description
    static class 
    Event that is fired when the backdrop of the details overlay is clicked.
    static enum 
    Supported containment values for MasterDetailLayout.
    static class 
    Event that is fired when the Escape key is pressed within the details area.
    static enum 
    Supported orientation values for MasterDetailLayout.
    static enum 
    Supported overlay mode values for MasterDetailLayout.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty Master Detail Layout.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addBackdropClickListener(com.vaadin.flow.component.ComponentEventListener<MasterDetailLayout.BackdropClickEvent> listener)
    Adds a listener for when the backdrop of the details overlay is clicked.
    com.vaadin.flow.shared.Registration
    addDetailEscapePressListener(com.vaadin.flow.component.ComponentEventListener<MasterDetailLayout.DetailEscapePressEvent> listener)
    Adds a listener for when the Escape key is pressed within the details area.
    Gets the containment of the layout.
    com.vaadin.flow.component.Component
    Gets the component currently in the detail area.
    Gets the minimum size of the detail area.
    Gets the size of the detail area.
    com.vaadin.flow.component.Component
    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(com.vaadin.flow.component.AttachEvent attachEvent)
     
    protected void
    onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
     
    void
    removeRouterLayoutContent(com.vaadin.flow.component.HasElement oldContent)
     
    void
    setAnimationEnabled(boolean enabled)
    Sets whether the layout animation is enabled.
    void
    Sets the containment of the layout.When set to MasterDetailLayout.Containment.LAYOUT, the overlay is confined to the layout.
    void
    setDetail(com.vaadin.flow.component.Component component)
    Sets the component to be displayed in the detail area.
    void
    setDetailMinSize(float minSize, com.vaadin.flow.component.Unit unit)
    Sets the minimum size of the detail area in CSS length units.
    void
    Sets the minimum size of the detail area in CSS length units.
    void
    setDetailSize(float size, com.vaadin.flow.component.Unit unit)
    Sets the size of the detail area in CSS length units.
    void
    Sets the size of the detail area in CSS length units.
    void
    setForceOverlay(boolean forceOverlay)
    Sets whether the layout overlay mode is enforced.
    void
    setMaster(com.vaadin.flow.component.Component component)
    Sets the component to be displayed in the master area.
    void
    setMasterMinSize(float minSize, com.vaadin.flow.component.Unit unit)
    Sets the minimum size of the master area in CSS length units.
    void
    Sets the minimum size of the master area in CSS length units.
    void
    setMasterSize(float size, com.vaadin.flow.component.Unit unit)
    Sets the size of the master area in CSS length units.
    void
    Sets the size of the master area in CSS length units.
    void
    Sets the orientation of the layout.
    void
    Sets the overlay mode of the layout.
    void
    showRouterLayoutContent(com.vaadin.flow.component.HasElement content)
     

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, 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

    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, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.HasTheme

    addThemeName, addThemeNames, bindThemeName, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName

    Methods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant

    addThemeVariants, bindThemeVariant, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariants
  • Field Details

  • Constructor Details

    • MasterDetailLayout

      public MasterDetailLayout()
      Creates an empty Master Detail Layout.
  • Method Details

    • getMaster

      public com.vaadin.flow.component.Component 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

      public void setMaster(com.vaadin.flow.component.Component component)
      Sets the component to be displayed in the master area.
      Parameters:
      component - the component to display in the master area, not null
    • getDetail

      public com.vaadin.flow.component.Component 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

      public void setDetail(com.vaadin.flow.component.Component component)
      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 to null.
      Parameters:
      component - the component to display in the detail area, or null to clear the detail area
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • onDetach

      protected void onDetach(com.vaadin.flow.component.DetachEvent detachEvent)
      Overrides:
      onDetach in class com.vaadin.flow.component.Component
    • getMasterSize

      public String 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

      public void setMasterSize(String size)
      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 by setOverlayMode(OverlayMode).
      Parameters:
      size - the size of the master area in CSS length units
    • setMasterSize

      public void setMasterSize(float size, com.vaadin.flow.component.Unit unit)
      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 by setOverlayMode(OverlayMode).
      Parameters:
      size - the size of the master area
      unit - the unit
    • getMasterMinSize

      public String 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

      public void setMasterMinSize(String minSize)
      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 by setOverlayMode(OverlayMode).
      Parameters:
      minSize - the minimum size of the master area in CSS length units
    • setMasterMinSize

      public void setMasterMinSize(float minSize, com.vaadin.flow.component.Unit unit)
      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 by setOverlayMode(OverlayMode).
      Parameters:
      minSize - the minimum size of the master area
      unit - the unit
    • getDetailSize

      public String 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

      public void setDetailSize(String size)
      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 by setOverlayMode(OverlayMode).
      Parameters:
      size - the size of the detail area in CSS length units
    • setDetailSize

      public void setDetailSize(float size, com.vaadin.flow.component.Unit unit)
      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 by setOverlayMode(OverlayMode).
      Parameters:
      size - the size of the detail area
      unit - the unit
    • getDetailMinSize

      public String 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

      public void setDetailMinSize(String minSize)
      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 by setOverlayMode(OverlayMode).
      Parameters:
      minSize - the minimum size of the detail area in CSS length units
    • setDetailMinSize

      public void setDetailMinSize(float minSize, com.vaadin.flow.component.Unit unit)
      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 by setOverlayMode(OverlayMode).
      Parameters:
      minSize - the minimum size of the detail area
      unit - the unit
    • getOrientation

      public MasterDetailLayout.Orientation getOrientation()
      Gets the orientation of the layout. Defaults to MasterDetailLayout.Orientation.HORIZONTAL.
      Returns:
      the orientation
    • setOrientation

      public void setOrientation(MasterDetailLayout.Orientation orientation)
      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

      public MasterDetailLayout.Containment getContainment()
      Gets the containment of the layout. Defaults to MasterDetailLayout.Containment.LAYOUT.
      Returns:
      the containment
    • setContainment

      public void setContainment(MasterDetailLayout.Containment containment)
      Sets the containment of the layout.When set to MasterDetailLayout.Containment.LAYOUT, the overlay is confined to the layout. When set to MasterDetailLayout.Containment.VIEWPORT, the overlay is confined to the browser's viewport.
      Parameters:
      containment - the containment
    • getOverlayMode

      public MasterDetailLayout.OverlayMode getOverlayMode()
      Gets the overlay mode of the layout. Defaults to MasterDetailLayout.OverlayMode.DRAWER.
      Returns:
      the overlay mode
    • setOverlayMode

      public void setOverlayMode(MasterDetailLayout.OverlayMode mode)
      Sets the overlay mode of the layout. When set to MasterDetailLayout.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 to MasterDetailLayout.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 by setOverlayMode(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 by setOverlayMode(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 com.vaadin.flow.shared.Registration addBackdropClickListener(com.vaadin.flow.component.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, not null
      Returns:
      a registration for removing the listener
    • addDetailEscapePressListener

      public com.vaadin.flow.shared.Registration addDetailEscapePressListener(com.vaadin.flow.component.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, not null
      Returns:
      a registration for removing the listener
    • showRouterLayoutContent

      public void showRouterLayoutContent(com.vaadin.flow.component.HasElement content)
      Specified by:
      showRouterLayoutContent in interface com.vaadin.flow.router.RouterLayout
    • removeRouterLayoutContent

      public void removeRouterLayoutContent(com.vaadin.flow.component.HasElement oldContent)
      Specified by:
      removeRouterLayoutContent in interface com.vaadin.flow.router.RouterLayout