com.vaadin.ui
Class AbstractSingleComponentContainer

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractSingleComponentContainer
All Implemented Interfaces:
MethodEventSource, ClientConnector, Sizeable, com.vaadin.shared.Connector, Component, HasComponents, HasComponents.ComponentAttachDetachNotifier, SingleComponentContainer, java.io.Serializable, java.lang.Iterable<Component>
Direct Known Subclasses:
Panel, UI

public abstract class AbstractSingleComponentContainer
extends AbstractComponent
implements SingleComponentContainer

Abstract base class for component containers that have only one child component. For component containers that support multiple children, inherit AbstractComponentContainer instead of this class.

Since:
7.0
See Also:
Serialized Form

Nested Class Summary
 
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
 
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
AbstractSingleComponentContainer()
           
 
Method Summary
 void addComponentAttachListener(HasComponents.ComponentAttachListener listener)
          Listens the component attach events.
 void addComponentDetachListener(HasComponents.ComponentDetachListener listener)
          Listens the component detach events.
protected  void fireComponentAttachEvent(Component component)
          Fires the component attached event.
protected  void fireComponentDetachEvent(Component component)
          Fires the component detached event.
 int getComponentCount()
          Gets the number of children this SingleComponentContainer has.
 Component getContent()
          Gets the content of this container.
 java.util.Iterator<Component> iterator()
          Gets an iterator to the collection of contained components.
 void removeComponentAttachListener(HasComponents.ComponentAttachListener listener)
          Stops the listening component attach events.
 void removeComponentDetachListener(HasComponents.ComponentDetachListener listener)
          Stops the listening component detach events.
static void removeFromParent(Component content)
          Utility method for removing a component from its parent (if possible).
 void setContent(Component content)
          Sets the content of this container.
 void setHeight(float height, Sizeable.Unit unit)
          Sets the height of the object.
 void setWidth(float width, Sizeable.Unit unit)
          Sets the width of the object.
 
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, getState, getState, getStyleName, getWidth, getWidthUnits, isConnectorEnabled, isEnabled, isImmediate, isReadOnly, isVisible, removeListener, removeShortcutListener, removeStyleName, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hasListeners, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
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.Component
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setPrimaryStyleName, setReadOnly, setStyleName, setVisible
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setParent
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setSizeFull, setSizeUndefined, setWidth
 

Constructor Detail

AbstractSingleComponentContainer

public AbstractSingleComponentContainer()
Method Detail

getComponentCount

public int getComponentCount()
Description copied from interface: SingleComponentContainer
Gets the number of children this SingleComponentContainer has. This must be symmetric with what HasComponents.iterator() returns and thus typically return 1 if the content is set, 0 otherwise.

Specified by:
getComponentCount in interface SingleComponentContainer
Returns:
The number of child components this container has.

iterator

public java.util.Iterator<Component> iterator()
Description copied from interface: HasComponents
Gets an iterator to the collection of contained components. Using this iterator it is possible to step through all components contained in this container.

Specified by:
iterator in interface HasComponents
Specified by:
iterator in interface java.lang.Iterable<Component>
Returns:
the component iterator.

addComponentAttachListener

public void addComponentAttachListener(HasComponents.ComponentAttachListener listener)
Description copied from interface: HasComponents.ComponentAttachDetachNotifier
Listens the component attach events.

Specified by:
addComponentAttachListener in interface HasComponents.ComponentAttachDetachNotifier
Parameters:
listener - the listener to add.

removeComponentAttachListener

public void removeComponentAttachListener(HasComponents.ComponentAttachListener listener)
Description copied from interface: HasComponents.ComponentAttachDetachNotifier
Stops the listening component attach events.

Specified by:
removeComponentAttachListener in interface HasComponents.ComponentAttachDetachNotifier
Parameters:
listener - the listener to removed.

addComponentDetachListener

public void addComponentDetachListener(HasComponents.ComponentDetachListener listener)
Description copied from interface: HasComponents.ComponentAttachDetachNotifier
Listens the component detach events.

Specified by:
addComponentDetachListener in interface HasComponents.ComponentAttachDetachNotifier

removeComponentDetachListener

public void removeComponentDetachListener(HasComponents.ComponentDetachListener listener)
Description copied from interface: HasComponents.ComponentAttachDetachNotifier
Stops the listening component detach events.

Specified by:
removeComponentDetachListener in interface HasComponents.ComponentAttachDetachNotifier

fireComponentAttachEvent

protected void fireComponentAttachEvent(Component component)
Fires the component attached event. This is called by the setContent(Component) method after the component has been set as the content.

Parameters:
component - the component that has been added to this container.

fireComponentDetachEvent

protected void fireComponentDetachEvent(Component component)
Fires the component detached event. This is called by the setContent(Component) method after the content component has been replaced by other content.

Parameters:
component - the component that has been removed from this container.

getContent

public Component getContent()
Description copied from interface: SingleComponentContainer
Gets the content of this container. The content is a component that serves as the outermost item of the visual contents.

Specified by:
getContent in interface SingleComponentContainer
Returns:
a component to use as content
See Also:
SingleComponentContainer.setContent(Component)

setContent

public void setContent(Component content)
Sets the content of this container. The content is a component that serves as the outermost item of the visual contents. The content must always be set, either with a constructor parameter or by calling this method. Previous versions of Vaadin used a VerticalLayout with margins enabled as the default content but that is no longer the case.

Specified by:
setContent in interface SingleComponentContainer
Parameters:
content - a component (typically a layout) to use as content

removeFromParent

public static void removeFromParent(Component content)
                             throws java.lang.IllegalArgumentException
Utility method for removing a component from its parent (if possible).

Parameters:
content - component to remove
Throws:
java.lang.IllegalArgumentException

setWidth

public void setWidth(float width,
                     Sizeable.Unit unit)
Description copied from interface: Sizeable
Sets the width of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
setWidth in interface Sizeable
Overrides:
setWidth in class AbstractComponent
Parameters:
width - the width of the object.
unit - the unit used for the width.

setHeight

public void setHeight(float height,
                      Sizeable.Unit unit)
Description copied from interface: Sizeable
Sets the height of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
setHeight in interface Sizeable
Overrides:
setHeight in class AbstractComponent
Parameters:
height - the height of the object.
unit - the unit used for the width.


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