com.vaadin.ui
Class CustomLayout

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.CustomLayout
All Implemented Interfaces:
MethodEventSource, Connector, ClientConnector, RpcTarget, Sizeable, Vaadin6Component, VariableOwner, Component, ComponentContainer, HasComponents, Layout, Layout.MarginHandler, Serializable, Iterable<Component>, EventListener

public class CustomLayout
extends AbstractLayout
implements Vaadin6Component

A container component with freely designed layout and style. The layout consists of items with textually represented locations. Each item contains one sub-component, which can be any Vaadin component, such as a layout. The adapter and theme are responsible for rendering the layout with a given style by placing the items in the defined locations.

The placement of the locations is not fixed - different themes can define the locations in a way that is suitable for them. One typical example would be to create visual design for a web site as a custom layout: the visual design would define locations for "menu", "body", and "title", for example. The layout would then be implemented as an XHTML template for each theme.

The default theme handles the styles that are not defined by drawing the subcomponents just as in OrderedLayout.

Since:
3.0
Version:
7.0.0.alpha3
Author:
Vaadin Ltd., Duy B. Vo (devduy@gmail.com)
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.terminal.VariableOwner
VariableOwner.ErrorEvent
 
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
 
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
 
Field Summary
 
Fields inherited from class com.vaadin.ui.AbstractLayout
margins
 
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
protected CustomLayout()
          Default constructor only used by subclasses.
  CustomLayout(InputStream templateStream)
          Constructs a custom layout with the template given in the stream.
  CustomLayout(String template)
          Constructor for custom layout with given template name.
 
Method Summary
 void addComponent(Component c)
          Adds the component into this container.
 void addComponent(Component c, String location)
          Adds the component into this container to given location.
 void changeVariables(Object source, Map<String,Object> variables)
          Called when one or more variables handled by the implementing class are changed.
 Component getComponent(String location)
          Gets the child-component by its location.
 int getComponentCount()
          Gets the number of contained components.
 Iterator<Component> getComponentIterator()
          Gets the component container iterator for going trough all the components in the container.
 CustomLayoutState getState()
          Returns the shared state bean with information to be sent from the server to the client.
 String getTemplateContents()
          Get the contents of the template
 String getTemplateName()
          Get the name of the template
protected  void initTemplateContentsFromInputStream(InputStream templateStream)
           
 void paintContent(PaintTarget target)
           Paints the Paintable into a UIDL stream.
 void removeComponent(Component c)
          Removes the component from this container.
 void removeComponent(String location)
          Removes the component from this container from given location.
 void replaceComponent(Component oldComponent, Component newComponent)
          Replaces the component in the container with another one without changing position.
 void setMargin(boolean enabled)
          Although most layouts support margins, CustomLayout does not.
 void setMargin(boolean topEnabled, boolean rightEnabled, boolean bottomEnabled, boolean leftEnabled)
          Although most layouts support margins, CustomLayout does not.
 void setTemplateContents(String templateContents)
          Set the contents of the template used to draw the custom layout.
 void setTemplateName(String templateName)
          Set the name of the template used to draw custom layout.
 
Methods inherited from class com.vaadin.ui.AbstractLayout
getMargin, 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.terminal.VariableOwner
isEnabled, isImmediate
 
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 com.vaadin.ui.ComponentContainer
addListener, addListener, moveComponentsFrom, removeAllComponents, removeListener, removeListener
 
Methods inherited from interface com.vaadin.ui.HasComponents
isComponentVisible
 
Methods inherited from interface java.lang.Iterable
iterator
 

Constructor Detail

CustomLayout

protected CustomLayout()
Default constructor only used by subclasses. Subclasses are responsible for setting the appropriate fields. Either setTemplateName(String), that makes layout fetch the template from theme, or setTemplateContents(String).


CustomLayout

public CustomLayout(InputStream templateStream)
             throws IOException
Constructs a custom layout with the template given in the stream.

Parameters:
templateStream - Stream containing template data. Must be using UTF-8 encoding. To use a String as a template use for instance new ByteArrayInputStream("