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, RpcTarget, 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 class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
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.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
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.
 boolean isComponentVisible(Component childComponent)
          Checks if the child component is visible.
 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 setVisible(boolean visible)
          Sets the visibility of the component.
 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, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getState, getStyleName, getWidth, getWidthUnits, handleError, isConnectorEnabled, isEnabled, isImmediate, isReadOnly, isVisible, removeListener, removeShortcutListener, removeStyleName, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setSizeFull, setSizeUndefined, setStyleName, setWidth
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hasListeners, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, 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
 
Methods inherited from interface com.vaadin.server.ClientConnector
beforeClientResponse, detach, encodeState, getExtensions, getStateType, handleConnectorRequest, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setParent
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.RpcTarget
getRpcManager
 
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.

isComponentVisible

public boolean isComponentVisible(Component childComponent)
Description copied from interface: HasComponents
Checks if the child component is visible. This method allows hiding a child component from updates and communication to and from the client. This is useful for components that show only a limited number of its children at any given time and want to allow updates only for the children that are visible (e.g. TabSheet has one tab open at a time).

Note that this will prevent updates from reaching the child even though the child itself is set to visible. Also if a child is set to invisible this will not force it to be visible.

Specified by:
isComponentVisible in interface HasComponents
Parameters:
childComponent - The child component to check
Returns:
true if the child component is visible to the user, false otherwise

setVisible

public void setVisible(boolean visible)
Description copied from interface: Component
Sets the visibility of the component.

Visible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent.

 TextField readonly = new TextField("Read-Only");
 readonly.setValue("You can't see this!");
 readonly.setVisible(false);
 layout.addComponent(readonly);
 

A component is visible only if all of its parents are also visible. If a component is explicitly set to be invisible, changes in the visibility of its parents will not change the visibility of the component.

Specified by:
setVisible in interface Component
Overrides:
setVisible in class AbstractComponent
Parameters:
visible - the boolean value specifying if the component should be visible after the call or not.
See Also:
Component.isVisible()

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.