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 Alignment
ALIGNMENT_DEFAULT
protected LinkedList<Component>
components
Custom 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 void
addComponent(Component c)
Add a component into this container.void
addComponent(Component c, int index)
Adds a component into indexed position in this container.void
addComponentAsFirst(Component c)
Adds a component into this container.void
addLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Add a click listener to the layout.void
addListener(LayoutEvents.LayoutClickListener listener)
Deprecated.As of 7.0, replaced byaddLayoutClickListener(LayoutClickListener)
Component
getComponent(int index)
Returns the component at the given position.Alignment
getComponentAlignment(Component childComponent)
Returns the current Alignment of given component.int
getComponentCount()
Gets the number of contained components.int
getComponentIndex(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(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
andAbstractComponent.writeDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
methods.Alignment
getDefaultComponentAlignment()
Returns the alignment used for new components added to this layoutfloat
getExpandRatio(Component component)
Returns the expand ratio of given component.MarginInfo
getMargin()
protected AbstractOrderedLayoutState
getState()
Returns the shared state bean with information to be sent from the server to the client.protected AbstractOrderedLayoutState
getState(boolean markAsDirty)
Returns the shared state for this connector.boolean
isSpacing()
Iterator<Component>
iterator()
Gets the component container iterator for going trough all the components in the container.void
readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Reads the component state from the given design.void
removeComponent(Component c)
Removes the component from this container.void
removeLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Removes an LayoutClickListener.void
removeListener(LayoutEvents.LayoutClickListener listener)
Deprecated.As of 7.0, replaced byremoveLayoutClickListener(LayoutClickListener)
void
replaceComponent(Component oldComponent, Component newComponent)
Replaces the component in the container with another one without changing position.void
setComponentAlignment(Component childComponent, Alignment alignment)
Set alignment for one contained component in this layout.void
setDefaultComponentAlignment(Alignment defaultAlignment)
Sets the alignment used for new components added to this layout.void
setExpandRatio(Component component, float ratio)
This method is used to control how excess space in layout is distributed among components.void
setMargin(boolean enabled)
Enable layout margins.void
setMargin(MarginInfo marginInfo)
Enable margins for this layout.void
setSpacing(boolean spacing)
Enable spacing between child components within this layout.void
writeDesign(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, addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentIterator, moveComponentsFrom, removeAllComponents, removeComponentAttachListener, removeComponentDetachListener, removeListener, removeListener, 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, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, 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, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
-
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, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.ui.ComponentContainer
addComponents, addListener, addListener, getComponentIterator, moveComponentsFrom, removeAllComponents, removeListener, removeListener
-
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 com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, 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: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 classAbstractLayout
- Returns:
- updated component shared state
-
getState
protected AbstractOrderedLayoutState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnector
Returns the shared state for this connector.- Overrides:
getState
in classAbstractComponent
- 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:
addComponent
in interfaceComponentContainer
- Overrides:
addComponent
in 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:
removeComponent
in interfaceComponentContainer
- Overrides:
removeComponent
in 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:
iterator
in interfaceHasComponents
- Specified by:
iterator
in 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:
getComponentCount
in interfaceComponentContainer
- Returns:
- the number of contained components
-
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 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.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 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.AlignmentHandler
Returns the current Alignment of given component.- Specified by:
getComponentAlignment
in interfaceLayout.AlignmentHandler
- Returns:
- the
Alignment
-
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 interfaceLayout.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 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 void 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 theLayoutEvents.LayoutClickEvent
. UseLayoutEvents.LayoutClickNotifier.removeListener(LayoutClickListener)
to remove the listener.- Specified by:
addLayoutClickListener
in interfaceLayoutEvents.LayoutClickNotifier
- Parameters:
listener
- The listener to add
-
addListener
@Deprecated public void addListener(LayoutEvents.LayoutClickListener listener)
Deprecated.As of 7.0, replaced byaddLayoutClickListener(LayoutClickListener)
- Specified by:
addListener
in interfaceLayoutEvents.LayoutClickNotifier
-
removeLayoutClickListener
public void removeLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Description copied from interface:LayoutEvents.LayoutClickNotifier
Removes an LayoutClickListener.- Specified by:
removeLayoutClickListener
in interfaceLayoutEvents.LayoutClickNotifier
- Parameters:
listener
- LayoutClickListener to be removed
-
removeListener
@Deprecated public void removeListener(LayoutEvents.LayoutClickListener listener)
Deprecated.As of 7.0, replaced byremoveLayoutClickListener(LayoutClickListener)
- Specified by:
removeListener
in interfaceLayoutEvents.LayoutClickNotifier
-
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 interfaceLayout.MarginHandler
- Parameters:
enabled
- true if margins should be enabled on all sides, false to disable all margins
-
getMargin
public MarginInfo getMargin()
- Specified by:
getMargin
in interfaceLayout.MarginHandler
- Returns:
- MarginInfo containing the currently enabled 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 interfaceLayout.MarginHandler
- Parameters:
marginInfo
- MarginInfo object containing the new margins.
-
getDefaultComponentAlignment
public Alignment getDefaultComponentAlignment()
Description copied from interface:Layout.AlignmentHandler
Returns the alignment used for new components added to this layout- Specified by:
getDefaultComponentAlignment
in interfaceLayout.AlignmentHandler
- Returns:
- The default alignment
-
setDefaultComponentAlignment
public void setDefaultComponentAlignment(Alignment defaultAlignment)
Description copied from interface:Layout.AlignmentHandler
Sets the alignment used for new components added to this layout. The default isAlignment.TOP_LEFT
.- Specified by:
setDefaultComponentAlignment
in interfaceLayout.AlignmentHandler
- Parameters:
defaultAlignment
- The new default alignment
-
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 interfaceComponent
- Overrides:
readDesign
in 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: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 interfaceComponent
- Overrides:
writeDesign
in 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:AbstractComponent
Returns a collection of attributes that should not be handled by the basic implementation of theAbstractComponent.readDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
andAbstractComponent.writeDesign(org.jsoup.nodes.Element,com.vaadin.ui.declarative.DesignContext)
methods. Typically these are handled in a custom way in the overridden versions of the above methods- Overrides:
getCustomAttributes
in classAbstractComponent
- Returns:
- the collection of attributes that are not handled by the basic implementation
-
-