Package com.vaadin.ui

Class AbstractOrderedLayout

    • Field Detail

      • ALIGNMENT_DEFAULT

        public static final Alignment ALIGNMENT_DEFAULT
      • components

        protected LinkedList<Component> components
        Custom layout slots containing the components.
    • Constructor Detail

      • AbstractOrderedLayout

        public AbstractOrderedLayout()
        Constructs an empty AbstractOrderedLayout.
    • Method Detail

      • getState

        protected AbstractOrderedLayoutState getState()
        Description copied from class: AbstractComponent
        Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
        Overrides:
        getState in class AbstractLayout
        Returns:
        updated component shared state
      • addComponentAsFirst

        public void addComponentAsFirst​(Component c)
        Adds a component into this container. The component is added to the left or on top of the other components.
        Parameters:
        c - the component to be added.
      • addComponent

        public void addComponent​(Component c,
                                 int index)
        Adds a component into indexed position in this container.
        Parameters:
        c - the component to be added.
        index - the index of the component position. The components currently in and after the position are shifted forwards.
      • replaceComponent

        public void replaceComponent​(Component oldComponent,
                                     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.
      • setComponentAlignment

        public void setComponentAlignment​(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
      • setSpacing

        public void setSpacing​(boolean spacing)
        Description copied from interface: Layout.SpacingHandler
        Enable spacing between child components within this layout.

        NOTE: This will only affect the space between components, not the space around all the components in the layout (i.e. do not confuse this with the cellspacing attribute of a HTML Table). Use #setMargin(boolean) to add space around the layout.

        See the reference manual for more information about CSS rules for defining the amount of spacing to use.

        Specified by:
        setSpacing in interface Layout.SpacingHandler
        Parameters:
        spacing - true if spacing should be turned on, false if it should be turned off
      • isSpacing

        public boolean isSpacing()
        Specified by:
        isSpacing in interface Layout.SpacingHandler
        Returns:
        true if spacing between child components within this layout is enabled, false otherwise
      • setExpandRatio

        public void setExpandRatio​(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:
        IllegalArgumentException - if the expand ratio is negative or the component is not a direct child of the layout
        See Also:
        Sizeable
      • getExpandRatio

        public float getExpandRatio​(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.
      • getComponentIndex

        public int getComponentIndex​(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.
      • getComponent

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

        public void setMargin​(boolean enabled)
        Description copied from interface: Layout.MarginHandler
        Enable layout margins. Affects all four sides of the layout. This will tell the client-side implementation to leave extra space around the layout. The client-side implementation decides the actual amount, and it can vary between themes.
        Specified by:
        setMargin in interface Layout.MarginHandler
        Parameters:
        enabled - true if margins should be enabled on all sides, false to disable all margins
      • setMargin

        public void setMargin​(MarginInfo marginInfo)
        Description copied from interface: Layout.MarginHandler
        Enable margins for this layout.

        NOTE: This will only affect the space around the components in the layout, not space between the components in the layout. Use #setSpacing(boolean) to add space between the components in the layout.

        See the reference manual for more information about CSS rules for defining the size of the margin.

        Specified by:
        setMargin in interface Layout.MarginHandler
        Parameters:
        marginInfo - MarginInfo object containing the new margins.
      • readDesign

        public void readDesign​(org.jsoup.nodes.Element design,
                               DesignContext designContext)
        Description copied from interface: Component
        Reads the component state from the given design.

        The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.

        It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.

        This method must not modify the design.

        Specified by:
        readDesign in interface Component
        Overrides:
        readDesign in class AbstractComponent
        Parameters:
        design - The element to obtain the state from
        designContext - The DesignContext instance used for parsing the design
      • writeDesign

        public void writeDesign​(org.jsoup.nodes.Element design,
                                DesignContext designContext)
        Description copied from interface: Component
        Writes the component state to the given design.

        The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.

        This method must not modify the component state.

        Specified by:
        writeDesign in interface Component
        Overrides:
        writeDesign in class AbstractComponent
        Parameters:
        design - The element to write the component state to. Any previous attributes or child nodes are not cleared.
        designContext - The DesignContext instance used for writing the design