com.vaadin.ui
Class AbstractComponentContainer

java.lang.Object
  extended by com.vaadin.terminal.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractComponentContainer
All Implemented Interfaces:
MethodEventSource, Connector, ClientConnector, RpcTarget, Sizeable, Component, ComponentContainer, HasComponents, Serializable, Iterable<Component>
Direct Known Subclasses:
AbstractLayout, AbstractSplitPanel, CustomComponent, Panel, PopupView, Root, TabSheet

public abstract class AbstractComponentContainer
extends AbstractComponent
implements ComponentContainer

Extension to AbstractComponent that defines the default implementation for the methods in ComponentContainer. Basic UI components that need to contain other components inherit this class to easily qualify as a component container.

Since:
3.0
Version:
7.0.0.alpha3
Author:
Vaadin Ltd
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.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
 
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
AbstractComponentContainer()
          Constructs a new component container.
 
Method Summary
 void addComponent(Component c)
          This only implements the events and component parent calls.
 void addListener(ComponentContainer.ComponentAttachListener listener)
          Listens the component attach events.
 void addListener(ComponentContainer.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.
 boolean isComponentVisible(Component childComponent)
          Checks if the child component is visible.
 Iterator<Component> iterator()
           
 void moveComponentsFrom(ComponentContainer source)
          Moves all components from an another container into this container.
 void removeAllComponents()
          Removes all components from the container.
 void removeComponent(Component c)
          This only implements the events and component parent calls.
 void removeListener(ComponentContainer.ComponentAttachListener listener)
          Stops the listening component attach events.
 void removeListener(ComponentContainer.ComponentDetachListener listener)
          Stops the listening component detach events.
 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, 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, getState, 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
getComponentCount, replaceComponent
 
Methods inherited from interface com.vaadin.ui.HasComponents
getComponentIterator
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getApplication, getCaption, getDebugId, getIcon, getLocale, getParent, getRoot, getState, getStyleName, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setDebugId, setEnabled, setIcon, setReadOnly, setStyleName, 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, setSizeFull, setSizeUndefined, setWidth
 

Constructor Detail

AbstractComponentContainer

public AbstractComponentContainer()
Constructs a new component container.

Method Detail

removeAllComponents

public void removeAllComponents()
Removes all components from the container. This should probably be re-implemented in extending classes for a more powerful implementation.

Specified by:
removeAllComponents in interface ComponentContainer

moveComponentsFrom

public void moveComponentsFrom(ComponentContainer source)
Description copied from interface: ComponentContainer
Moves all components from an another container into this container. The components are removed from source.

Specified by:
moveComponentsFrom in interface ComponentContainer
Parameters:
source - the container which contains the components that are to be moved to this container.

addListener

public void addListener(ComponentContainer.ComponentAttachListener listener)
Description copied from interface: ComponentContainer
Listens the component attach events.

Specified by:
addListener in interface ComponentContainer
Parameters:
listener - the listener to add.

addListener

public void addListener(ComponentContainer.ComponentDetachListener listener)
Description copied from interface: ComponentContainer
Listens the component detach events.

Specified by:
addListener in interface ComponentContainer

removeListener

public void removeListener(ComponentContainer.ComponentAttachListener listener)
Description copied from interface: ComponentContainer
Stops the listening component attach events.

Specified by:
removeListener in interface ComponentContainer
Parameters:
listener - the listener to removed.

removeListener

public void removeListener(ComponentContainer.ComponentDetachListener listener)
Description copied from interface: ComponentContainer
Stops the listening component detach events.

Specified by:
removeListener in interface ComponentContainer

fireComponentAttachEvent

protected void fireComponentAttachEvent(Component component)
Fires the component attached event. This should be called by the addComponent methods after the component have been added to this container.

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

fireComponentDetachEvent

protected void fireComponentDetachEvent(Component component)
Fires the component detached event. This should be called by the removeComponent methods after the component have been removed from this container.

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

addComponent

public void addComponent(Component c)
This only implements the events and component parent calls. The extending classes must implement component list maintenance and call this method after component list maintenance.

Specified by:
addComponent in interface ComponentContainer
Parameters:
c - the component to be added.
See Also:
ComponentContainer.addComponent(Component)

removeComponent

public void removeComponent(Component c)
This only implements the events and component parent calls. The extending classes must implement component list maintenance and call this method before component list maintenance.

Specified by:
removeComponent in interface ComponentContainer
Parameters:
c - the component to be removed.
See Also:
ComponentContainer.removeComponent(Component)

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

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.

iterator

public Iterator<Component> iterator()
Specified by:
iterator in interface Iterable<Component>

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


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