com.vaadin.ui
Class AbstractOrderedLayout

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractComponentContainer
              extended by com.vaadin.ui.AbstractLayout
                  extended by com.vaadin.ui.AbstractOrderedLayout
All Implemented Interfaces:
LayoutEvents.LayoutClickNotifier, MethodEventSource, ClientConnector, Sizeable, com.vaadin.shared.Connector, Component, ComponentContainer, HasComponents, HasComponents.ComponentAttachDetachNotifier, Layout, Layout.AlignmentHandler, Layout.MarginHandler, Layout.SpacingHandler, java.io.Serializable, java.lang.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.ui.Layout
Layout.AlignmentHandler, Layout.MarginHandler, Layout.SpacingHandler
 
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.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
 
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.server.Sizeable
Sizeable.Unit
 
Field Summary
static Alignment ALIGNMENT_DEFAULT
           
protected  java.util.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
AbstractOrderedLayout()
          Constructs an empty AbstractOrderedLayout.
 
Method Summary
 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 by #addLayoutClickListener(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  java.util.Collection<java.lang.String> getCustomAttributes()
          Returns a collection of attributes that should not be handled by the basic implementation of the readDesign and writeDesign methods.
 Alignment getDefaultComponentAlignment()
          Returns the alignment used for new components added to this layout
 float getExpandRatio(Component component)
          Returns the expand ratio of given component.
 com.vaadin.shared.ui.MarginInfo getMargin()
           
protected  com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState getState()
          Returns the shared state bean with information to be sent from the server to the client.
protected  com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState getState(boolean markAsDirty)
          Returns the shared state for this connector.
 boolean isSpacing()
           
 java.util.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 by #removeLayoutClickListener(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(com.vaadin.shared.ui.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.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
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, isImmediate, isOrHasAncestor, isReadOnly, isVisible, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setSizeFull, setSizeUndefined, 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.ui.ComponentContainer
addComponents, addListener, addListener, getComponentIterator, moveComponentsFrom, removeAllComponents, removeListener, removeListener
 
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.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.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
 
Methods inherited from interface com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier
addComponentAttachListener, addComponentDetachListener, removeComponentAttachListener, removeComponentDetachListener
 

Field Detail

ALIGNMENT_DEFAULT

public static final Alignment ALIGNMENT_DEFAULT

components

protected java.util.LinkedList<Component> components
Custom layout slots containing the components.

Constructor Detail

AbstractOrderedLayout

public AbstractOrderedLayout()
Constructs an empty AbstractOrderedLayout.

Method Detail

getState

protected com.vaadin.shared.ui.orderedlayout.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

getState

protected com.vaadin.shared.ui.orderedlayout.AbstractOrderedLayoutState getState(boolean markAsDirty)
Description copied from class: AbstractClientConnector
Returns the shared state for this connector.

Overrides:
getState in class AbstractComponent
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 interface ComponentContainer
Overrides:
addComponent in class AbstractComponentContainer
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 interface ComponentContainer
Overrides:
removeComponent in class AbstractComponentContainer
Parameters:
c - the component to be removed.
See Also:
ComponentContainer.removeComponent(Component)

iterator

public java.util.Iterator<Component> iterator()
Gets the component container iterator for going trough all the components in the container.

Specified by:
iterator in interface HasComponents
Specified by:
iterator in interface java.lang.Iterable<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 by AbstractComponentContainer.getComponentIterator().

Specified by:
getComponentCount in interface ComponentContainer
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 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

getComponentAlignment

public Alignment getComponentAlignment(Component childComponent)
Description copied from interface: Layout.AlignmentHandler
Returns the current Alignment of given component.

Specified by:
getComponentAlignment in interface Layout.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 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 -
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 the LayoutEvents.LayoutClickEvent. Use #removeListener(LayoutClickListener) to remove the listener.

Specified by:
addLayoutClickListener in interface LayoutEvents.LayoutClickNotifier
Parameters:
listener - The listener to add

addListener

@Deprecated
public void addListener(LayoutEvents.LayoutClickListener listener)
Deprecated. As of 7.0, replaced by #addLayoutClickListener(LayoutClickListener)

Specified by:
addListener in interface LayoutEvents.LayoutClickNotifier

removeLayoutClickListener

public void removeLayoutClickListener(LayoutEvents.LayoutClickListener listener)
Description copied from interface: LayoutEvents.LayoutClickNotifier
Removes an LayoutClickListener.

Specified by:
removeLayoutClickListener in interface LayoutEvents.LayoutClickNotifier
Parameters:
listener - LayoutClickListener to be removed

removeListener

@Deprecated
public void removeListener(LayoutEvents.LayoutClickListener listener)
Deprecated. As of 7.0, replaced by #removeLayoutClickListener(LayoutClickListener)

Specified by:
removeListener in interface LayoutEvents.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 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.

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

getMargin

public com.vaadin.shared.ui.MarginInfo getMargin()
Specified by:
getMargin in interface Layout.MarginHandler
Returns:
MarginInfo containing the currently enabled margins.

setMargin

public void setMargin(com.vaadin.shared.ui.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.

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 interface Layout.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 is Alignment.TOP_LEFT.

Specified by:
setDefaultComponentAlignment in interface Layout.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 interface Component
Overrides:
readDesign in class AbstractComponent
Parameters:
design - The design as HTML 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 design as HTML to update with the current state

getCustomAttributes

protected java.util.Collection<java.lang.String> getCustomAttributes()
Description copied from class: AbstractComponent
Returns a collection of attributes that should not be handled by the basic implementation of the readDesign and writeDesign methods. Typically these are handled in a custom way in the overridden versions of the above methods

Overrides:
getCustomAttributes in class AbstractComponent
Returns:
the collection of attributes that are not handled by the basic implementation


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.