Class AbstractOrderedLayout

    • Constructor Detail

      • AbstractOrderedLayout

        public AbstractOrderedLayout​(boolean isVertical)
        Constructs an ordered layout with the indicated orientation.
        Parameters:
        isVertical - true if it should be vertically oriented, false for horizontally oriented
      • AbstractOrderedLayout

        public AbstractOrderedLayout()
        Constructs an ordered layout with the horizontal orientation.
    • Method Detail

      • beforeClientResponse

        public void beforeClientResponse​(boolean initial)
        Description copied from interface: ClientConnector
        Called before the response is written to client side. Gives the legacy connector an opportunity to set computed/dynamic state values.

        This is implemented for the legacy components to keep consistent behavior and e.g. legaze size calculations working.

        NOTE: the parameter initial is false when the component is attached again to a new UI when PreserveOnRefresh is used.

        Specified by:
        beforeClientResponse in interface ClientConnector
        Overrides:
        beforeClientResponse in class AbstractComponent
        Parameters:
        initial - true if the client-side connector will be created and initialized after this method has been invoked. false if there is already an initialized client-side connector.
      • add

        public void add​(com.vaadin.flow.component.Component... components)
        Specified by:
        add in interface com.vaadin.flow.component.HasComponents
        Overrides:
        add in class AbstractComponentContainer
      • addComponentsAndExpand

        public void addComponentsAndExpand​(com.vaadin.flow.component.Component... components)
        Adds the given components to this layout and sets them as expanded. The main layout dimension is set to 100% if it is currently undefined.

        The components are added in the provided order to the end of this layout. Any components that are already children of this layout will be moved to new positions.

        Parameters:
        components - the components to set, not null
      • setSpacing

        public void setSpacing​(boolean spacing)
        Enable spacing between child components within this layout.
        Parameters:
        spacing - true if spacing should be turned on, false if it should be turned off
      • isSpacing

        public boolean isSpacing()
        get the state of spacing in this layout
        Returns:
        true if spacing between child components within this layout is enabled, false otherwise
      • remove

        public void remove​(com.vaadin.flow.component.Component... components)
        Specified by:
        remove in interface com.vaadin.flow.component.HasComponents
        Overrides:
        remove in class AbstractComponentContainer
      • setExpandRatio

        public void setExpandRatio​(com.vaadin.flow.component.Component component,
                                   float ratio)

        This method is used to control how excess space in layout is distributed among components. Excess space may exist if layout is sized and contained non relatively sized components don't consume all available space.

        Example how to distribute 1:3 (33%) for component1 and 2:3 (67%) for component2 : layout.setExpandRatio(component1, 1);
        layout.setExpandRatio(component2, 2);

        If no ratios have been set, the excess space is distributed evenly among all components.

        Note, that width or height (depending on orientation) needs to be defined for this method to have any effect.

        Parameters:
        component - the component in this layout which expand ratio is to be set
        ratio - new expand ratio (greater or equal to 0)
        Throws:
        java.lang.IllegalArgumentException - if the expand ratio is negative or the component is not a direct child of the layout
      • getExpandRatio

        public float getExpandRatio​(com.vaadin.flow.component.Component component)
        Returns the expand ratio of given component.
        Parameters:
        component - which expand ratios is requested
        Returns:
        expand ratio of given component, 0.0f by default.
      • getChildren

        public java.util.stream.Stream<com.vaadin.flow.component.Component> getChildren()
        Overrides:
        getChildren in class com.vaadin.flow.component.Component
      • addComponentAtIndex

        public void addComponentAtIndex​(int index,
                                        com.vaadin.flow.component.Component component)
        Specified by:
        addComponentAtIndex in interface com.vaadin.flow.component.HasComponents
      • addComponent

        public void addComponent​(com.vaadin.flow.component.Component component,
                                 int index)
                          throws java.lang.IndexOutOfBoundsException
        Adds a component into indexed position in this container.
        Parameters:
        component - the component to be added.
        index - the index of the component position. The components currently in and after the position are shifted forwards.
        Throws:
        java.lang.IndexOutOfBoundsException
      • addComponentAsFirst

        public void addComponentAsFirst​(com.vaadin.flow.component.Component component)
        Adds a component into this container. The component is added to the left or on top of the other components.
        Specified by:
        addComponentAsFirst in interface com.vaadin.flow.component.HasComponents
        Parameters:
        component - the component to be added.
      • replaceComponent

        public void replaceComponent​(com.vaadin.flow.component.Component oldComponent,
                                     com.vaadin.flow.component.Component newComponent)
        Description copied from interface: ComponentContainer
        Replaces the component in the container with another one without changing position.

        This method replaces component with another one is such way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If the both component are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.

        Specified by:
        replaceComponent in interface ComponentContainer
        Parameters:
        oldComponent - the old component that will be replaced.
        newComponent - the new component to be replaced.
      • getComponentCount

        public int getComponentCount()
        Gets the number of contained components.
        Specified by:
        getComponentCount in interface ComponentContainer
        Returns:
        the number of contained components
      • getComponent

        public com.vaadin.flow.component.Component getComponent​(int index)
                                                         throws java.lang.IndexOutOfBoundsException
        Returns the component at the given position.
        Parameters:
        index - The position of the component.
        Returns:
        The component at the given index.
        Throws:
        java.lang.IndexOutOfBoundsException - If the index is out of range.
      • getComponentIndex

        public int getComponentIndex​(com.vaadin.flow.component.Component component)
        Returns the index of the given component.
        Parameters:
        component - The component to look up.
        Returns:
        The index of the component or -1 if the component is not a child.
      • setSlotClasses

        protected void setSlotClasses()
      • setComponentAlignment

        public void setComponentAlignment​(com.vaadin.flow.component.Component childComponent,
                                          Alignment alignment)
        Description copied from interface: Layout.AlignmentHandler
        Set alignment for one contained component in this layout. Use predefined alignments from Alignment class.

        Example: layout.setComponentAlignment(myComponent, Alignment.TOP_RIGHT);

        Specified by:
        setComponentAlignment in interface Layout.AlignmentHandler
        Parameters:
        childComponent - the component to align within it's layout cell.
        alignment - the Alignment value to be set
      • addLayoutClickListener

        public com.vaadin.flow.shared.Registration addLayoutClickListener​(LayoutEvents.LayoutClickListener listener)
        Description copied from interface: LayoutEvents.LayoutClickNotifier
        Add a click listener to the layout. The listener is called whenever the user clicks inside the layout. An event is also triggered when the click targets a component inside a nested layout or Panel, provided the targeted component does not prevent the click event from propagating. A caption is not considered part of a component.

        The child component that was clicked is included in the LayoutEvents.LayoutClickEvent.

        Specified by:
        addLayoutClickListener in interface LayoutEvents.LayoutClickNotifier
        Parameters:
        listener - The listener to add
        Returns:
        a registration object for removing the listener
        See Also:
        Registration