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, inherit
AbstractComponentContainer
instead of this class.Since:
7.0
See Also:
-
-
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 Modifier and Type Method Description Registration
addComponentAttachListener(HasComponents.ComponentAttachListener listener)
Listens the component attach events.
Registration
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.
protected AbstractSingleComponentContainerState
getState()
Returns the shared state bean with information to be sent from the server to the client.
protected AbstractSingleComponentContainerState
getState(boolean markAsDirty)
Returns the shared state for this connector.
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)
Deprecated.
void
removeComponentDetachListener(HasComponents.ComponentDetachListener listener)
Deprecated.
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, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, 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, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
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, addStyleNames, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, 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, setHeightFull, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidthFull, setWidthUndefined
-
-
-
-
Method Detail
-
getComponentCount
public int getComponentCount()
Description copied from interface:
SingleComponentContainer
Gets the number of children this
SingleComponentContainer
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.
The iterator is typically unmodifiable, and calls to
Iterator.remove()
throw an exception.Specified by:
iterator
in interfaceHasComponents
Specified by:
iterator
in interfaceIterable<Component>
Returns:
the component iterator.
-
addComponentAttachListener
public Registration 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, not nullReturns:
a registration object for removing the listener
See Also:
-
removeComponentAttachListener
@Deprecated public void removeComponentAttachListener(HasComponents.ComponentAttachListener listener)
Deprecated.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 Registration addComponentDetachListener(HasComponents.ComponentDetachListener listener)
Description copied from interface:
HasComponents.ComponentAttachDetachNotifier
Listens the component detach events.
Specified by:
addComponentDetachListener
in interfaceHasComponents.ComponentAttachDetachNotifier
-
removeComponentDetachListener
@Deprecated public void removeComponentDetachListener(HasComponents.ComponentDetachListener listener)
Deprecated.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 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.
-
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:
-
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 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 removeThrows:
-
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 designThrows:
DesignException
- if there are multiple child elementsDesignException
- if a child element could not be parsed as a ComponentSince:
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
-
getState
protected AbstractSingleComponentContainerState getState()
Description copied from class:
AbstractComponent
Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().
Overrides:
getState
in classAbstractComponent
Returns:
updated component shared state
-
getState
protected AbstractSingleComponentContainerState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classAbstractComponent
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
-