com.vaadin.ui
Class AbstractOrderedLayout

java.lang.Object
  extended by com.vaadin.terminal.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, Connector, ClientConnector, RpcTarget, Sizeable, Component, ComponentContainer, HasComponents, 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

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Layout
Layout.AlignmentHandler, Layout.MarginHandler, Layout.MarginInfo, Layout.SpacingHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.ComponentContainer
ComponentContainer.ComponentAttachEvent, ComponentContainer.ComponentAttachListener, ComponentContainer.ComponentDetachEvent, ComponentContainer.ComponentDetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.terminal.Sizeable
Sizeable.Unit
 
Field Summary
static Alignment ALIGNMENT_DEFAULT
           
protected  LinkedList<Component> components
          Custom layout slots containing the components.
 
Fields inherited from class com.vaadin.ui.AbstractLayout
margins
 
Fields inherited from interface com.vaadin.ui.Layout.AlignmentHandler
ALIGNMENT_BOTTOM, ALIGNMENT_HORIZONTAL_CENTER, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TOP, ALIGNMENT_VERTICAL_CENTER
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
AbstractOrderedLayout()
          Mapping from components to alignments (horizontal + vertical).
 
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 addListener(LayoutEvents.LayoutClickListener listener)
          Add a click listener to the layout.
 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.
 Iterator<Component> getComponentIterator()
          Gets the component container iterator for going trough all the components in the container.
 float getExpandRatio(Component component)
          Returns the expand ratio of given component.
 AbstractOrderedLayoutState getState()
          Returns the shared state bean with information to be sent from the server to the client.
 boolean isSpacing()
           
 void removeComponent(Component c)
          Removes the component from this container.
 void removeListener(LayoutEvents.LayoutClickListener listener)
          Removes an 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 setComponentAlignment(Component childComponent, int horizontalAlignment, int verticalAlignment)
          Set alignment for one contained component in this layout.
 void setExpandRatio(Component component, float ratio)
           This method is used to control how excess space in layout is distributed among components.
 void setSpacing(boolean spacing)
          Enable spacing between child components within this layout.
 
Methods inherited from class com.vaadin.ui.AbstractLayout
getMargin, setMargin, setMargin, setMargin
 
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, isComponentVisible, iterator, moveComponentsFrom, removeAllComponents, removeListener, removeListener, setHeight, setVisible, setWidth
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addShortcutListener, addStyleName, attach, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireEvent, focus, getActionManager, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getRoot, getStyle, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isConnectorEnabled, isEnabled, isImmediate, isReadOnly, isVisible, removeListener, removeListener, removeListener, removeListener, removeListener, removeShortcutListener, removeStyleName, requestRepaint, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setWidth, updateState
 
Methods inherited from class com.vaadin.terminal.AbstractClientConnector
addExtension, addMethodInvocationToQueue, createState, getAllChildrenIterable, getConnectorId, getExtensions, getRpcManager, getRpcProxy, getStateType, registerRpc, registerRpc, removeExtension, requestRepaintAll, retrievePendingRpcCalls
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.ComponentContainer
addListener, addListener, moveComponentsFrom, removeAllComponents, removeListener, removeListener
 
Methods inherited from interface com.vaadin.ui.HasComponents
isComponentVisible
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getApplication, getCaption, getDebugId, getIcon, getLocale, getParent, getRoot, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setDebugId, setEnabled, setIcon, setReadOnly, setStyleName, setVisible, updateState
 
Methods inherited from interface com.vaadin.terminal.gwt.server.ClientConnector
detach, getExtensions, getStateType, isConnectorEnabled, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setParent
 
Methods inherited from interface com.vaadin.terminal.gwt.client.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.terminal.gwt.server.RpcTarget
getRpcManager
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth
 
Methods inherited from interface java.lang.Iterable
iterator
 

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()
Mapping from components to alignments (horizontal + vertical).

Method Detail

getState

public 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().

Specified by:
getState in interface Connector
Specified by:
getState in interface Component
Overrides:
getState in class AbstractLayout
Returns:
updated component shared state

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)

getComponentIterator

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

Specified by:
getComponentIterator in interface HasComponents
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 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,
                                  int horizontalAlignment,
                                  int verticalAlignment)
Description copied from interface: Layout.AlignmentHandler
Set alignment for one contained component in this layout. Alignment is calculated as a bit mask of the two passed values.

Specified by:
setComponentAlignment in interface Layout.AlignmentHandler
Parameters:
childComponent - the component to align within it's layout cell.
horizontalAlignment - the horizontal alignment for the child component (left, center, right). Use ALIGNMENT constants.
verticalAlignment - the vertical alignment for the child component (top, center, bottom). Use ALIGNMENT constants.

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 Layout.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.

addListener

public void addListener(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:
addListener in interface LayoutEvents.LayoutClickNotifier
Parameters:
listener - The listener to add

removeListener

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

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


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