Class AbstractOrderedLayout
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.classic.v8.server.AbstractClientConnector
-
- com.vaadin.classic.v8.ui.AbstractComponent
-
- com.vaadin.classic.v8.ui.AbstractComponentContainer
-
- com.vaadin.classic.v8.ui.AbstractLayout
-
- com.vaadin.classic.v8.ui.AbstractOrderedLayout
-
- All Implemented Interfaces:
LayoutEvents.LayoutClickNotifier,ClientConnector,Sizeable,ComponentContainer,HasComponents,HasComponents.ComponentAttachDetachNotifier,Layout.AlignmentHandler,Layout.MarginHandler,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,java.io.Serializable,java.lang.Iterable<com.vaadin.flow.component.Component>
- Direct Known Subclasses:
FormLayout,HorizontalLayout,VerticalLayout
public abstract class AbstractOrderedLayout extends AbstractLayout implements Layout.AlignmentHandler, Layout.MarginHandler, LayoutEvents.LayoutClickNotifier
Legacy version of AbstractOrderedLayout that resembles Vaadin 7/8's AbstractOrderedLayout API as closely as possible in order to facilitate migration to newer versions of Vaadin.Base class for ordered layouts.
- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.classic.v8.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.classic.v8.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.classic.v8.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from interface com.vaadin.classic.v8.server.Sizeable
SIZE_UNDEFINED
-
-
Constructor Summary
Constructors Constructor Description AbstractOrderedLayout()Constructs an ordered layout with the horizontal orientation.AbstractOrderedLayout(boolean isVertical)Constructs an ordered layout with the indicated orientation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(com.vaadin.flow.component.Component... components)voidaddComponent(com.vaadin.flow.component.Component component)Adds the component into this container.voidaddComponent(com.vaadin.flow.component.Component component, int index)Adds a component into indexed position in this container.voidaddComponentAsFirst(com.vaadin.flow.component.Component component)Adds a component into this container.voidaddComponentAtIndex(int index, com.vaadin.flow.component.Component component)Delegates toaddComponent(Component, int).voidaddComponentsAndExpand(com.vaadin.flow.component.Component... components)Adds the given components to this layout and sets them as expanded.com.vaadin.flow.shared.RegistrationaddLayoutClickListener(LayoutEvents.LayoutClickListener listener)Add a click listener to the layout.voidbeforeClientResponse(boolean initial)Called before the response is written to client side.protected voiddoSetHeight(SizeWithUnit height)Internal method for reacting to height changes.protected voiddoSetWidth(SizeWithUnit width)Internal method for reacting to width changes.java.util.stream.Stream<com.vaadin.flow.component.Component>getChildren()com.vaadin.flow.component.ComponentgetComponent(int index)Returns the component at the given position.AlignmentgetComponentAlignment(com.vaadin.flow.component.Component childComponent)Returns the current Alignment of given component.intgetComponentCount()Gets the number of contained components.intgetComponentIndex(com.vaadin.flow.component.Component component)Returns the index of the given component.AlignmentgetDefaultComponentAlignment()Returns the alignment used for new components added to this layout.floatgetExpandRatio(com.vaadin.flow.component.Component component)Returns the expand ratio of given component.MarginInfogetMargin()(non-Javadoc)booleanisSpacing()get the state of spacing in this layoutvoidremove(com.vaadin.flow.component.Component... components)voidremoveComponent(com.vaadin.flow.component.Component component)Removes the component from this container.voidreplaceComponent(com.vaadin.flow.component.Component oldComponent, com.vaadin.flow.component.Component newComponent)Replaces the component in the container with another one without changing position.voidsetComponentAlignment(com.vaadin.flow.component.Component childComponent, Alignment alignment)Set alignment for one contained component in this layout.voidsetDefaultComponentAlignment(Alignment defaultComponentAlignment)Sets the alignment used for new components added to this layout.voidsetExpandRatio(com.vaadin.flow.component.Component component, float ratio)This method is used to control how excess space in layout is distributed among components.voidsetMargin(boolean enabled)(non-Javadoc)voidsetMargin(MarginInfo marginInfo)(non-Javadoc)protected voidsetSlotClasses()voidsetSpacing(boolean spacing)Enable spacing between child components within this layout.-
Methods inherited from class com.vaadin.classic.v8.ui.AbstractComponentContainer
addComponentAttachListener, addComponentDetachListener, addComponents, fireComponentAttachEvent, fireComponentDetachEvent, iterator, moveComponentsFrom, removeAll, removeAllComponents, setHeight, setWidth
-
Methods inherited from class com.vaadin.classic.v8.ui.AbstractComponent
addInternalStyles, addListener, addShortcutListener, addStyleName, addStyleNames, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getCustomAttributes, getCustomStyles, getData, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getInternalStyles, getLocale, getPrimaryStyleName, getState, getState, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, notifyParentAboutStyleChanges, onEnabledStateChanged, removeInternalStyles, removeStyleName, removeStyleNames, setCaption, setCaptionAsHtml, setComponentError, setData, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.classic.v8.server.AbstractClientConnector
addExtension, addLegacyAttachListener, addLegacyDetachListener, addListener, addListener, addMethodInvocationToQueue, attach, createState, detach, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getResource, getSession, handleConnectorRequest, hasListeners, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, onAttach, onDetach, registerRpc, registerRpc, removeExtension, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getElement, getEventBus, getId, getListeners, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, scrollIntoView, set, setElement, setId
-
-
-
-
Constructor Detail
-
AbstractOrderedLayout
public AbstractOrderedLayout(boolean isVertical)
Constructs an ordered layout with the indicated orientation.- Parameters:
isVertical-trueif it should be vertically oriented,falsefor 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:ClientConnectorCalled 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
initialisfalsewhen the component is attached again to a newUIwhenPreserveOnRefreshis used.- Specified by:
beforeClientResponsein interfaceClientConnector- Overrides:
beforeClientResponsein classAbstractComponent- Parameters:
initial-trueif the client-side connector will be created and initialized after this method has been invoked.falseif there is already an initialized client-side connector.
-
addComponent
public void addComponent(com.vaadin.flow.component.Component component)
Description copied from interface:ComponentContainerAdds the component into this container.- Specified by:
addComponentin interfaceComponentContainer- Overrides:
addComponentin classAbstractComponentContainer- Parameters:
component- the component to be added.
-
add
public void add(com.vaadin.flow.component.Component... components)
- Specified by:
addin interfacecom.vaadin.flow.component.HasComponents- Overrides:
addin classAbstractComponentContainer
-
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, notnull
-
doSetHeight
protected void doSetHeight(SizeWithUnit height)
Description copied from class:AbstractComponentInternal method for reacting to height changes.- Overrides:
doSetHeightin classAbstractComponent- Parameters:
height- the changed height to set
-
doSetWidth
protected void doSetWidth(SizeWithUnit width)
Description copied from class:AbstractComponentInternal method for reacting to width changes.- Overrides:
doSetWidthin classAbstractComponent- Parameters:
width- the changed width to set
-
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
-
setMargin
public void setMargin(boolean enabled)
(non-Javadoc)- Specified by:
setMarginin interfaceLayout.MarginHandler- Parameters:
enabled- true if margins should be enabled on all sides, false to disable all margins- See Also:
Layout.MarginHandler.setMargin(boolean)
-
setMargin
public void setMargin(MarginInfo marginInfo)
(non-Javadoc)- Specified by:
setMarginin interfaceLayout.MarginHandler- Parameters:
marginInfo- MarginInfo object containing the new margins.- See Also:
Layout.MarginHandler.setMargin(MarginInfo)
-
getMargin
public MarginInfo getMargin()
(non-Javadoc)- Specified by:
getMarginin interfaceLayout.MarginHandler- Returns:
- MarginInfo containing the currently enabled margins.
- See Also:
Layout.MarginHandler.getMargin()
-
remove
public void remove(com.vaadin.flow.component.Component... components)
- Specified by:
removein interfacecom.vaadin.flow.component.HasComponents- Overrides:
removein classAbstractComponentContainer
-
removeComponent
public void removeComponent(com.vaadin.flow.component.Component component)
Description copied from interface:ComponentContainerRemoves the component from this container.- Specified by:
removeComponentin interfaceComponentContainer- Overrides:
removeComponentin classAbstractComponentContainer- Parameters:
component- the component to be removed.
-
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 setratio- 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:
getChildrenin classcom.vaadin.flow.component.Component
-
addComponentAtIndex
public void addComponentAtIndex(int index, com.vaadin.flow.component.Component component)Delegates toaddComponent(Component, int).- Specified by:
addComponentAtIndexin interfacecom.vaadin.flow.component.HasComponents
-
addComponent
public void addComponent(com.vaadin.flow.component.Component component, int index) throws java.lang.IndexOutOfBoundsExceptionAdds 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:
addComponentAsFirstin interfacecom.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:ComponentContainerReplaces 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:
replaceComponentin interfaceComponentContainer- 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:
getComponentCountin interfaceComponentContainer- Returns:
- the number of contained components
-
getComponent
public com.vaadin.flow.component.Component getComponent(int index) throws java.lang.IndexOutOfBoundsExceptionReturns 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.AlignmentHandlerSet alignment for one contained component in this layout. Use predefined alignments from Alignment class.Example:
layout.setComponentAlignment(myComponent, Alignment.TOP_RIGHT);- Specified by:
setComponentAlignmentin interfaceLayout.AlignmentHandler- Parameters:
childComponent- the component to align within it's layout cell.alignment- the Alignment value to be set
-
getComponentAlignment
public Alignment getComponentAlignment(com.vaadin.flow.component.Component childComponent)
Description copied from interface:Layout.AlignmentHandlerReturns the current Alignment of given component.- Specified by:
getComponentAlignmentin interfaceLayout.AlignmentHandler- Returns:
- the
Alignment
-
setDefaultComponentAlignment
public void setDefaultComponentAlignment(Alignment defaultComponentAlignment)
Description copied from interface:Layout.AlignmentHandlerSets the alignment used for new components added to this layout. The default isAlignment.TOP_LEFT.- Specified by:
setDefaultComponentAlignmentin interfaceLayout.AlignmentHandler- Parameters:
defaultComponentAlignment- The new default alignment
-
getDefaultComponentAlignment
public Alignment getDefaultComponentAlignment()
Description copied from interface:Layout.AlignmentHandlerReturns the alignment used for new components added to this layout.- Specified by:
getDefaultComponentAlignmentin interfaceLayout.AlignmentHandler- Returns:
- The default alignment
-
addLayoutClickListener
public com.vaadin.flow.shared.Registration addLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Description copied from interface:LayoutEvents.LayoutClickNotifierAdd 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:
addLayoutClickListenerin interfaceLayoutEvents.LayoutClickNotifier- Parameters:
listener- The listener to add- Returns:
- a registration object for removing the listener
- See Also:
Registration
-
-