Package com.vaadin.ui
Class AbstractSingleComponentContainer
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.AbstractSingleComponentContainer
-
- All Implemented Interfaces:
ContextClickEvent.ContextClickNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,Connector
,Component
,HasComponents
,HasComponents.ComponentAttachDetachNotifier
,SingleComponentContainer
,Serializable
,Iterable<Component>
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, inheritAbstractComponentContainer
instead of this class.- Since:
- 7.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
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.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
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
Constructors Constructor Description AbstractSingleComponentContainer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 thisSingleComponentContainer
has.Component
getContent()
Gets the content of this container.Iterator<Component>
iterator()
Gets an iterator to the collection of contained components.void
readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Reads the component state from the given design.protected void
readDesignChildren(org.jsoup.select.Elements children, DesignContext context)
Reads the content component from the list of child elements of a design.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.void
writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Writes the component state to the given design.-
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getState, getState, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
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, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidthUndefined
-
-
-
-
Method Detail
-
getComponentCount
public int getComponentCount()
Description copied from interface:SingleComponentContainer
Gets the number of children thisSingleComponentContainer
has. This must be symmetric with whatHasComponents.iterator()
returns and thus typically return 1 if the content is set, 0 otherwise.- Specified by:
getComponentCount
in interfaceSingleComponentContainer
- Returns:
- The number of child components this container has.
-
iterator
public 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 interfaceHasComponents
- Specified by:
iterator
in interfaceIterable<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 interfaceHasComponents.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 interfaceHasComponents.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 interfaceHasComponents.ComponentAttachDetachNotifier
-
removeComponentDetachListener
public void removeComponentDetachListener(HasComponents.ComponentDetachListener listener)
Description copied from interface:HasComponents.ComponentAttachDetachNotifier
Stops the listening component detach events.- Specified by:
removeComponentDetachListener
in interfaceHasComponents.ComponentAttachDetachNotifier
-
fireComponentAttachEvent
protected void fireComponentAttachEvent(Component component)
Fires the component attached event. This is called by thesetContent(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 thesetContent(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 interfaceSingleComponentContainer
- 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 aVerticalLayout
with margins enabled as the default content but that is no longer the case.- Specified by:
setContent
in interfaceSingleComponentContainer
- Parameters:
content
- a component (typically a layout) to use as content
-
removeFromParent
public static void removeFromParent(Component content) throws IllegalArgumentException
Utility method for removing a component from its parent (if possible).- Parameters:
content
- component to remove- Throws:
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 interfaceSizeable
- Overrides:
setWidth
in classAbstractComponent
- 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 interfaceSizeable
- Overrides:
setHeight
in classAbstractComponent
- Parameters:
height
- the height of the object.unit
- the unit used for the width.
-
readDesign
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Description copied from interface:Component
Reads the component state from the given design.The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
- Specified by:
readDesign
in interfaceComponent
- Overrides:
readDesign
in classAbstractComponent
- Parameters:
design
- The element to obtain the state fromdesignContext
- The DesignContext instance used for parsing the design
-
readDesignChildren
protected void readDesignChildren(org.jsoup.select.Elements children, DesignContext context)
Reads the content component from the list of child elements of a design. The list must be empty or contain a single element; if the design contains multiple child elements, a DesignException is thrown. This method should be overridden by subclasses whose design may contain non-content child elements.- Parameters:
children
- the child elements of the design that is being readcontext
- the DesignContext instance used to parse the design- Throws:
DesignException
- if there are multiple child elementsDesignException
- if a child element could not be parsed as a Component- Since:
- 7.5.0
-
writeDesign
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Description copied from interface:Component
Writes the component state to the given design.The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
- Specified by:
writeDesign
in interfaceComponent
- Overrides:
writeDesign
in classAbstractComponent
- Parameters:
design
- The element to write the component state to. Any previous attributes or child nodes are not cleared.designContext
- The DesignContext instance used for writing the design
-
-