com.vaadin.ui.


Class AbstractComponentContainer

java.lang.Object
  com.vaadin.ui.AbstractComponent
      com.vaadin.ui.AbstractComponentContainer

All Implemented Interfaces:

MethodEventSource, Paintable, Sizeable, VariableOwner, Component, ComponentContainer, Serializable, EventListener

Direct Known Subclasses:

AbstractLayout, CustomComponent, Panel, PopupView, 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:

6.8.18

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.Paintable
Paintable.RepaintRequestEvent, Paintable.RepaintRequestListener
 
Field Summary
 
Fields inherited from interface com.vaadin.terminal.Sizeable
SIZE_UNDEFINED, UNIT_SYMBOLS, 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.
 void attach()
          Notifies all contained components that the container is attached to a window.
 void detach()
          Notifies all contained components that the container is detached from a window.
protected  void fireComponentAttachEvent(Component component)
          Fires the component attached event.
protected  void fireComponentDetachEvent(Component component)
          Fires the component detached event.
 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 requestRepaintAll()
          Causes a repaint of this component, and all components below it.
 void setEnabled(boolean enabled)
          Enables or disables the component.
 void setHeight(float height, int unit)
          Sets the height of the object.
 void setWidth(float width, int unit)
          Sets the width of the object.
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addListener, addStyleName, changeVariables, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, focus, getApplication, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getErrorMessage, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, hasListeners, isEnabled, isImmediate, isReadOnly, isVisible, paint, paintContent, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setErrorHandler, setHeight, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setReadOnly, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidth, setWidthUnits
 
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
getComponentIterator, replaceComponent
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, childRequestedRepaint, getApplication, getCaption, getIcon, getLocale, getParent, getStyleName, getWindow, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setIcon, setParent, setReadOnly, setStyleName, setVisible
 
Methods inherited from interface com.vaadin.terminal.Paintable
addListener, getDebugId, paint, removeListener, requestRepaint, requestRepaintRequests, setDebugId
 
Methods inherited from interface com.vaadin.terminal.VariableOwner
changeVariables, isImmediate
 
Methods inherited from interface com.vaadin.terminal.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUnits, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUnits
 

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.

attach

public void attach()

Notifies all contained components that the container is attached to a window.

Specified by:
attach in interface Component
Overrides:
attach in class AbstractComponent

See Also:
Component.attach()

detach

public void detach()

Notifies all contained components that the container is detached from a window.

Specified by:
detach in interface Component
Overrides:
detach in class AbstractComponent

See Also:
Component.detach()

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)

setEnabled

public void setEnabled(boolean enabled)

Description copied from interface: Component

Enables or disables the component. The user can not interact disabled components, which are shown with a style that indicates the status, usually shaded in light gray color. Components are enabled by default. Children of a disabled component are automatically disabled; if a child component is explicitly set as disabled, changes in the disabled status of its parents do not change its status.

 Button enabled = new Button("Enabled");
 enabled.setEnabled(true); // The default
 layout.addComponent(enabled);
 
 Button disabled = new Button("Disabled");
 disabled.setEnabled(false);
 layout.addComponent(disabled);
 

This method will trigger a RepaintRequestEvent for the component and, if it is a ComponentContainer, for all its children recursively.

Specified by:
setEnabled in interface Component
Overrides:
setEnabled in class AbstractComponent

Parameters:
enabled - a boolean value specifying if the component should be enabled or not

setWidth

public void setWidth(float width,
                     int 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. Possible values include Sizeable.UNITS_PIXELS, Sizeable.UNITS_POINTS, Sizeable.UNITS_PICAS, Sizeable.UNITS_EM, Sizeable.UNITS_EX, Sizeable.UNITS_MM, Sizeable.UNITS_CM, Sizeable.UNITS_INCH, Sizeable.UNITS_PERCENTAGE.

setHeight

public void setHeight(float height,
                      int 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. Possible values include Sizeable.UNITS_PIXELS, Sizeable.UNITS_POINTS, Sizeable.UNITS_PICAS, Sizeable.UNITS_EM, Sizeable.UNITS_EX, Sizeable.UNITS_MM, Sizeable.UNITS_CM, Sizeable.UNITS_INCH, Sizeable.UNITS_PERCENTAGE.

requestRepaintAll

public void requestRepaintAll()

Description copied from interface: ComponentContainer

Causes a repaint of this component, and all components below it. This should only be used in special cases, e.g when the state of a descendant depends on the state of a ancestor.

Specified by:
requestRepaintAll in interface ComponentContainer