public abstract class AbstractSingleComponentContainer extends AbstractComponent implements SingleComponentContainer
AbstractComponentContainer
instead of this class.HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
DESIGN_ATTR_PLAIN_TEXT
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
Constructor and Description |
---|
AbstractSingleComponentContainer() |
Modifier and Type | Method and 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 this
SingleComponentContainer 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.
|
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
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
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
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
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidthUndefined
forEach, spliterator
public int getComponentCount()
SingleComponentContainer
SingleComponentContainer
has.
This must be symmetric with what HasComponents.iterator()
returns and thus
typically return 1 if the content is set, 0 otherwise.getComponentCount
in interface SingleComponentContainer
public Iterator<Component> iterator()
HasComponents
iterator
in interface HasComponents
iterator
in interface Iterable<Component>
public void addComponentAttachListener(HasComponents.ComponentAttachListener listener)
HasComponents.ComponentAttachDetachNotifier
addComponentAttachListener
in interface HasComponents.ComponentAttachDetachNotifier
listener
- the listener to add.public void removeComponentAttachListener(HasComponents.ComponentAttachListener listener)
HasComponents.ComponentAttachDetachNotifier
removeComponentAttachListener
in interface HasComponents.ComponentAttachDetachNotifier
listener
- the listener to removed.public void addComponentDetachListener(HasComponents.ComponentDetachListener listener)
HasComponents.ComponentAttachDetachNotifier
addComponentDetachListener
in interface HasComponents.ComponentAttachDetachNotifier
public void removeComponentDetachListener(HasComponents.ComponentDetachListener listener)
HasComponents.ComponentAttachDetachNotifier
removeComponentDetachListener
in interface HasComponents.ComponentAttachDetachNotifier
protected void fireComponentAttachEvent(Component component)
setContent(Component)
method after the component has been set as
the content.component
- the component that has been added to this container.protected void fireComponentDetachEvent(Component component)
setContent(Component)
method after the content component has
been replaced by other content.component
- the component that has been removed from this container.public Component getContent()
SingleComponentContainer
getContent
in interface SingleComponentContainer
SingleComponentContainer.setContent(Component)
public void setContent(Component content)
VerticalLayout
with margins
enabled as the default content but that is no longer the case.setContent
in interface SingleComponentContainer
content
- a component (typically a layout) to use as contentpublic static void removeFromParent(Component content) throws IllegalArgumentException
content
- component to removeIllegalArgumentException
public void setWidth(float width, Sizeable.Unit unit)
Sizeable
setWidth
in interface Sizeable
setWidth
in class AbstractComponent
width
- the width of the object.unit
- the unit used for the width.public void setHeight(float height, Sizeable.Unit unit)
Sizeable
setHeight
in interface Sizeable
setHeight
in class AbstractComponent
height
- the height of the object.unit
- the unit used for the width.public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
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.
readDesign
in interface Component
readDesign
in class AbstractComponent
design
- The element to obtain the state fromdesignContext
- The DesignContext instance used for parsing the designprotected void readDesignChildren(org.jsoup.select.Elements children, DesignContext context)
children
- the child elements of the design that is being readcontext
- the DesignContext instance used to parse the designDesignException
- if there are multiple child elementsDesignException
- if a child element could not be parsed as a Componentpublic void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
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.
writeDesign
in interface Component
writeDesign
in class AbstractComponent
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 designCopyright © 2019 Vaadin Ltd. All rights reserved.