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, inheritAbstractComponentContainerinstead 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 voidaddComponentAttachListener(HasComponents.ComponentAttachListener listener)Listens the component attach events.voidaddComponentDetachListener(HasComponents.ComponentDetachListener listener)Listens the component detach events.protected voidfireComponentAttachEvent(Component component)Fires the component attached event.protected voidfireComponentDetachEvent(Component component)Fires the component detached event.intgetComponentCount()Gets the number of children thisSingleComponentContainerhas.ComponentgetContent()Gets the content of this container.Iterator<Component>iterator()Gets an iterator to the collection of contained components.voidreadDesign(org.jsoup.nodes.Element design, DesignContext designContext)Reads the component state from the given design.protected voidreadDesignChildren(org.jsoup.select.Elements children, DesignContext context)Reads the content component from the list of child elements of a design.voidremoveComponentAttachListener(HasComponents.ComponentAttachListener listener)Stops the listening component attach events.voidremoveComponentDetachListener(HasComponents.ComponentDetachListener listener)Stops the listening component detach events.static voidremoveFromParent(Component content)Utility method for removing a component from its parent (if possible).voidsetContent(Component content)Sets the content of this container.voidsetHeight(float height, Sizeable.Unit unit)Sets the height of the object.voidsetWidth(float width, Sizeable.Unit unit)Sets the width of the object.voidwriteDesign(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 java.lang.Iterable
forEach, spliterator
-
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:SingleComponentContainerGets the number of children thisSingleComponentContainerhas. This must be symmetric with whatHasComponents.iterator()returns and thus typically return 1 if the content is set, 0 otherwise.- Specified by:
getComponentCountin interfaceSingleComponentContainer- Returns:
- The number of child components this container has.
-
iterator
public Iterator<Component> iterator()
Description copied from interface:HasComponentsGets 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:
iteratorin interfaceHasComponents- Specified by:
iteratorin interfaceIterable<Component>- Returns:
- the component iterator.
-
addComponentAttachListener
public void addComponentAttachListener(HasComponents.ComponentAttachListener listener)
Description copied from interface:HasComponents.ComponentAttachDetachNotifierListens the component attach events.- Specified by:
addComponentAttachListenerin interfaceHasComponents.ComponentAttachDetachNotifier- Parameters:
listener- the listener to add.
-
removeComponentAttachListener
public void removeComponentAttachListener(HasComponents.ComponentAttachListener listener)
Description copied from interface:HasComponents.ComponentAttachDetachNotifierStops the listening component attach events.- Specified by:
removeComponentAttachListenerin interfaceHasComponents.ComponentAttachDetachNotifier- Parameters:
listener- the listener to removed.
-
addComponentDetachListener
public void addComponentDetachListener(HasComponents.ComponentDetachListener listener)
Description copied from interface:HasComponents.ComponentAttachDetachNotifierListens the component detach events.- Specified by:
addComponentDetachListenerin interfaceHasComponents.ComponentAttachDetachNotifier
-
removeComponentDetachListener
public void removeComponentDetachListener(HasComponents.ComponentDetachListener listener)
Description copied from interface:HasComponents.ComponentAttachDetachNotifierStops the listening component detach events.- Specified by:
removeComponentDetachListenerin 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:SingleComponentContainerGets the content of this container. The content is a component that serves as the outermost item of the visual contents.- Specified by:
getContentin 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 aVerticalLayoutwith margins enabled as the default content but that is no longer the case.- Specified by:
setContentin 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:SizeableSets the width of the object. Negative number implies unspecified size (terminal is free to set the size).- Specified by:
setWidthin interfaceSizeable- Overrides:
setWidthin 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:SizeableSets the height of the object. Negative number implies unspecified size (terminal is free to set the size).- Specified by:
setHeightin interfaceSizeable- Overrides:
setHeightin 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:ComponentReads 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:
readDesignin interfaceComponent- Overrides:
readDesignin 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:ComponentWrites 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:
writeDesignin interfaceComponent- Overrides:
writeDesignin 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
-
-