Class AbstractOrderedLayout
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractComponentContainer
-
- com.vaadin.ui.AbstractLayout
-
- com.vaadin.ui.AbstractOrderedLayout
-
- All Implemented Interfaces:
ContextClickEvent.ContextClickNotifier,LayoutEvents.LayoutClickNotifier,MethodEventSource,ClientConnector,Sizeable,Connector,Component,ComponentContainer,HasComponents,HasComponents.ComponentAttachDetachNotifier,Layout,Layout.AlignmentHandler,Layout.MarginHandler,Layout.SpacingHandler,Serializable,Iterable<Component>
- Direct Known Subclasses:
FormLayout,HorizontalLayout,VerticalLayout
public abstract class AbstractOrderedLayout extends AbstractLayout implements Layout.AlignmentHandler, Layout.SpacingHandler, LayoutEvents.LayoutClickNotifier, Layout.MarginHandler
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Layout
Layout.AlignmentHandler, Layout.MarginHandler, Layout.SpacingHandler
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
Fields Modifier and Type Field Description static AlignmentALIGNMENT_DEFAULTprotected LinkedList<Component>componentsCustom layout slots containing the components.-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description AbstractOrderedLayout()Constructs an empty AbstractOrderedLayout.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddComponent(Component c)Add a component into this container.voidaddComponent(Component c, int index)Adds a component into indexed position in this container.voidaddComponentAsFirst(Component c)Adds a component into this container.RegistrationaddLayoutClickListener(LayoutEvents.LayoutClickListener listener)Add a click listener to the layout.ComponentgetComponent(int index)Returns the component at the given position.AlignmentgetComponentAlignment(Component childComponent)Returns the current Alignment of given component.intgetComponentCount()Gets the number of contained components.intgetComponentIndex(Component component)Returns the index of the given component.protected Collection<String>getCustomAttributes()Returns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(Element, DesignContext)andAbstractComponent.writeDesign(Element, DesignContext)methods.AlignmentgetDefaultComponentAlignment()Returns the alignment used for new components added to this layout.floatgetExpandRatio(Component component)Returns the expand ratio of given component.MarginInfogetMargin()protected AbstractOrderedLayoutStategetState()Returns the shared state bean with information to be sent from the server to the client.protected AbstractOrderedLayoutStategetState(boolean markAsDirty)Returns the shared state for this connector.booleanisSpacing()Iterator<Component>iterator()Gets the component container iterator for going trough all the components in the container.voidreadDesign(org.jsoup.nodes.Element design, DesignContext designContext)Reads the component state from the given design.voidremoveComponent(Component c)Removes the component from this container.voidremoveLayoutClickListener(LayoutEvents.LayoutClickListener listener)Deprecated.voidreplaceComponent(Component oldComponent, Component newComponent)Replaces the component in the container with another one without changing position.voidsetComponentAlignment(Component childComponent, Alignment alignment)Set alignment for one contained component in this layout.voidsetDefaultComponentAlignment(Alignment defaultAlignment)Sets the alignment used for new components added to this layout.voidsetExpandRatio(Component component, float ratio)This method is used to control how excess space in layout is distributed among components.voidsetMargin(boolean enabled)Enable layout margins.voidsetMargin(MarginInfo marginInfo)Enable margins for this layout.voidsetSpacing(boolean spacing)Enable spacing between child components within this layout.voidwriteDesign(org.jsoup.nodes.Element design, DesignContext designContext)Writes the component state to the given design.-
Methods inherited from class com.vaadin.ui.AbstractLayout
readMargin, writeMargin
-
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addComponentAttachListener, addComponentDetachListener, addComponents, fireComponentAttachEvent, fireComponentDetachEvent, getComponentIterator, moveComponentsFrom, removeAllComponents, removeComponentAttachListener, removeComponentDetachListener, setHeight, setWidth
-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.ui.ComponentContainer
addComponents, getComponentIterator, moveComponentsFrom, removeAllComponents
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier
addComponentAttachListener, addComponentDetachListener, removeComponentAttachListener, removeComponentDetachListener
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Field Detail
-
ALIGNMENT_DEFAULT
public static final Alignment ALIGNMENT_DEFAULT
-
components
protected LinkedList<Component> components
Custom layout slots containing the components.
-
-
Method Detail
-
getState
protected AbstractOrderedLayoutState getState()
Description copied from class:AbstractComponentReturns 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:
getStatein classAbstractLayout- Returns:
- updated component shared state
-
getState
protected AbstractOrderedLayoutState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnectorReturns the shared state for this connector.- Overrides:
getStatein classAbstractLayout- Parameters:
markAsDirty- true if the connector should automatically be marked dirty, false otherwise- Returns:
- The shared state for this connector. Never null.
- See Also:
AbstractClientConnector.getState()
-
addComponent
public void addComponent(Component c)
Add a component into this container. The component is added to the right or under the previous component.- Specified by:
addComponentin interfaceComponentContainer- Overrides:
addComponentin classAbstractComponentContainer- Parameters:
c- the component to be added.- See Also:
ComponentContainer.addComponent(Component)
-
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.
-
removeComponent
public void removeComponent(Component c)
Removes the component from this container.- Specified by:
removeComponentin interfaceComponentContainer- Overrides:
removeComponentin classAbstractComponentContainer- Parameters:
c- the component to be removed.- See Also:
ComponentContainer.removeComponent(Component)
-
iterator
public Iterator<Component> iterator()
Gets the component container iterator for going trough all the components in the container.- Specified by:
iteratorin interfaceHasComponents- Specified by:
iteratorin interfaceIterable<Component>- Returns:
- the Iterator of the components inside the container.
-
getComponentCount
public int getComponentCount()
Gets the number of contained components. Consistent with the iterator returned byAbstractComponentContainer.getComponentIterator().- Specified by:
getComponentCountin interfaceComponentContainer- Returns:
- the number of contained components
-
replaceComponent
public void replaceComponent(Component oldComponent, 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.
-
setComponentAlignment
public void setComponentAlignment(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(Component childComponent)
Description copied from interface:Layout.AlignmentHandlerReturns the current Alignment of given component.- Specified by:
getComponentAlignmentin interfaceLayout.AlignmentHandler- Returns:
- the
Alignment
-
setSpacing
public void setSpacing(boolean spacing)
Description copied from interface:Layout.SpacingHandlerEnable 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
Layout.MarginHandler.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:
setSpacingin interfaceLayout.SpacingHandler- Parameters:
spacing- true if spacing should be turned on, false if it should be turned off
-
isSpacing
public boolean isSpacing()
- Specified by:
isSpacingin interfaceLayout.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 setratio- 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.
-
addLayoutClickListener
public 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 theLayoutEvents.LayoutClickEvent.- Specified by:
addLayoutClickListenerin interfaceLayoutEvents.LayoutClickNotifier- Parameters:
listener- The listener to add- Returns:
- a registration object for removing the listener
- See Also:
Registration
-
removeLayoutClickListener
@Deprecated public void removeLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Deprecated.Description copied from interface:LayoutEvents.LayoutClickNotifierRemoves an LayoutClickListener.- Specified by:
removeLayoutClickListenerin interfaceLayoutEvents.LayoutClickNotifier- Parameters:
listener- LayoutClickListener to be removed
-
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.MarginHandlerEnable 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:
setMarginin interfaceLayout.MarginHandler- Parameters:
enabled- true if margins should be enabled on all sides, false to disable all margins
-
getMargin
public MarginInfo getMargin()
- Specified by:
getMarginin interfaceLayout.MarginHandler- Returns:
- MarginInfo containing the currently enabled margins.
-
setMargin
public void setMargin(MarginInfo marginInfo)
Description copied from interface:Layout.MarginHandlerEnable 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
Layout.SpacingHandler.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:
setMarginin interfaceLayout.MarginHandler- Parameters:
marginInfo- MarginInfo object containing the new margins.
-
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
-
setDefaultComponentAlignment
public void setDefaultComponentAlignment(Alignment defaultAlignment)
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:
defaultAlignment- The new default alignment
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)Description copied from interface:ComponentReads 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:
readDesignin interfaceComponent- Overrides:
readDesignin classAbstractComponent- Parameters:
design- The element to obtain the state fromdesignContext- The DesignContext instance used for parsing the design
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)Description copied from interface:ComponentWrites 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:
writeDesignin interfaceComponent- Overrides:
writeDesignin classAbstractComponent- 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
-
getCustomAttributes
protected Collection<String> getCustomAttributes()
Description copied from class:AbstractComponentReturns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(Element, DesignContext)andAbstractComponent.writeDesign(Element, DesignContext)methods. Typically these are handled in a custom way in the overridden versions of the above methods- Overrides:
getCustomAttributesin classAbstractComponent- Returns:
- the collection of attributes that are not handled by the basic implementation
-
-