Class AbstractSingleComponentContainer
- java.lang.Object
-
- com.vaadin.flow.component.Component
-
- com.vaadin.classic.v8.server.AbstractClientConnector
-
- com.vaadin.classic.v8.ui.AbstractComponent
-
- com.vaadin.classic.v8.ui.AbstractSingleComponentContainer
-
- All Implemented Interfaces:
ClientConnector,Sizeable,HasComponents,HasComponents.ComponentAttachDetachNotifier,SingleComponentContainer,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,java.io.Serializable,java.lang.Iterable<com.vaadin.flow.component.Component>
- Direct Known Subclasses:
Panel
public abstract class AbstractSingleComponentContainer extends AbstractComponent implements SingleComponentContainer
Abstract base class for legacy Vaadin framework version 7/8 component containers that have only one child component.For component containers that support multiple children, inherit
AbstractComponentContainerinstead of this class.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.classic.v8.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.classic.v8.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.classic.v8.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from interface com.vaadin.classic.v8.server.Sizeable
SIZE_UNDEFINED
-
-
Constructor Summary
Constructors Constructor Description AbstractSingleComponentContainer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.vaadin.flow.shared.RegistrationaddComponentAttachListener(HasComponents.ComponentAttachListener listener)Listens the component attach events.com.vaadin.flow.shared.RegistrationaddComponentDetachListener(HasComponents.ComponentDetachListener listener)Listens the component detach events.protected voidfireComponentAttachEvent(com.vaadin.flow.component.Component component)Fires the component attached event.protected voidfireComponentDetachEvent(com.vaadin.flow.component.Component component)Fires the component detached event.intgetComponentCount()Gets the number of children thisSingleComponentContainerhas.com.vaadin.flow.component.ComponentgetContent()Gets the content of this container.protected com.vaadin.flow.dom.ElementgetContentWrapper()Get the wrapper to be used as parent of the content element.java.util.Iterator<com.vaadin.flow.component.Component>iterator()Gets an iterator to the collection of contained components.protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent)static voidremoveFromParent(com.vaadin.flow.component.Component content)Utility method for removing a component from its parent (if possible).voidsetContent(com.vaadin.flow.component.Component content)Sets the content of this container.protected voidsetContentWrapper(com.vaadin.flow.dom.Element wrapper)Sets the element that will be used as the content wrapper.voidsetHeight(float height, Sizeable.Unit unit)Sets the height of the object.voidsetWidth(float width, Sizeable.Unit unit)Sets the width of the object.-
Methods inherited from class com.vaadin.classic.v8.ui.AbstractComponent
addInternalStyles, addListener, addShortcutListener, addStyleName, addStyleNames, beforeClientResponse, doSetHeight, doSetWidth, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getCustomAttributes, getCustomStyles, getData, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getInternalStyles, getLocale, getPrimaryStyleName, getState, getState, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, notifyParentAboutStyleChanges, onEnabledStateChanged, removeInternalStyles, removeStyleName, removeStyleNames, setCaption, setCaptionAsHtml, setComponentError, setData, setDescription, setDescription, setEnabled, setHeight, setHeightFull, setHeightUndefined, setIcon, setLocale, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidthFull, setWidthUndefined
-
Methods inherited from class com.vaadin.classic.v8.server.AbstractClientConnector
addExtension, addLegacyAttachListener, addLegacyDetachListener, addListener, addListener, addMethodInvocationToQueue, attach, createState, detach, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getResource, getSession, handleConnectorRequest, hasListeners, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, onDetach, registerRpc, registerRpc, removeExtension, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, scrollIntoView, set, setElement, setId
-
-
-
-
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 java.util.Iterator<com.vaadin.flow.component.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.The iterator is typically unmodifiable, and calls to
Iterator.remove()throw an exception.- Specified by:
iteratorin interfaceHasComponents- Specified by:
iteratorin interfacejava.lang.Iterable<com.vaadin.flow.component.Component>- Returns:
- the component iterator.
-
addComponentAttachListener
public com.vaadin.flow.shared.Registration 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, not null- Returns:
- a registration object for removing the listener
- See Also:
Registration
-
addComponentDetachListener
public com.vaadin.flow.shared.Registration addComponentDetachListener(HasComponents.ComponentDetachListener listener)
Description copied from interface:HasComponents.ComponentAttachDetachNotifierListens the component detach events.- Specified by:
addComponentDetachListenerin interfaceHasComponents.ComponentAttachDetachNotifier
-
fireComponentAttachEvent
protected void fireComponentAttachEvent(com.vaadin.flow.component.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(com.vaadin.flow.component.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 com.vaadin.flow.component.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(com.vaadin.flow.component.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
VerticalLayoutwith 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
-
setContentWrapper
protected void setContentWrapper(com.vaadin.flow.dom.Element wrapper)
Sets the element that will be used as the content wrapper.By default, the content component defined through
setContent(Component)is attached as a direct child ofAbstractSingleComponentContainer. That's sometimes not the desired behavior if, for instance, the container wants to define a different slot on which the content will be attached to.Note that it might have a side effect where
Component.getParent()from the content component returns the wrapper instead of theAbstractSingleComponentContainerinstance. To avoid this, theElementAPI can be used to create the element andComponentUtil.componentFromElement(Element, Class, boolean)to get the component passingfalseto themapComponentproperty, so it won't map the component to the element. Or use theElementFactorymethods.The wrapper can only be set once and if no content is already set to the container.
- Parameters:
wrapper- the wrapper element to be used to attach the content to
-
getContentWrapper
protected com.vaadin.flow.dom.Element getContentWrapper()
Get the wrapper to be used as parent of the content element. If no wrapper is set,this.getElement()is returned.- Returns:
- the wrapper or
this.getElement()element.
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
- Overrides:
onAttachin classAbstractClientConnector
-
removeFromParent
public static void removeFromParent(com.vaadin.flow.component.Component content) throws java.lang.IllegalArgumentExceptionUtility method for removing a component from its parent (if possible).- Parameters:
content- component to remove- Throws:
java.lang.IllegalArgumentException
-
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.
-
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.
-
-