Package com.storedobject.ui
Class ScrollingContent
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.HtmlComponent
com.vaadin.flow.component.HtmlContainer
com.vaadin.flow.component.html.Div
com.storedobject.ui.ScrollingContent
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.html.Div>,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasOrderedComponents,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasText,Serializable
- Direct Known Subclasses:
CardDashboard
public class ScrollingContent
extends com.vaadin.flow.component.html.Div
Represents a container component that manages a scrolling content area
along with an optional header. It is designed to handle both the header
and content sections flexibly, where the content area supports scrolling
and the header has a fixed height.
- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for the ScrollingContent class.ScrollingContent(com.vaadin.flow.component.Component content) Constructs aScrollingContentinstance with a scrollable content area and an optional header component.ScrollingContent(com.vaadin.flow.component.Component header, com.vaadin.flow.component.Component content) A UI component that organizes content with a scrollable area and a header. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(com.vaadin.flow.component.Component... components) Adds the specified components to the content-container.voidAdds the specified text to the content-container.voidadd(Collection<com.vaadin.flow.component.Component> components) Adds a collection of components to the content-container.voidaddComponentAsFirst(com.vaadin.flow.component.Component component) Adds a given component to the content-container as the first component.voidaddComponentAtIndex(int index, com.vaadin.flow.component.Component component) Adds a component to the specified index within the content-container.Stream<com.vaadin.flow.component.Component> Retrieves a stream of child components contained within the content-container.com.vaadin.flow.component.ComponentgetComponentAt(int index) Retrieves the component located at the specified index within the content-container.intReturns the total number of components present in the content-container.com.vaadin.flow.component.ComponentRetrieves the content component of the container.com.vaadin.flow.component.ComponentRetrieves the first component from the header container if it exists.intRetrieves the margin value.intindexOf(com.vaadin.flow.component.Component component) Returns the index of the specified component within the content-container.voidremove(com.vaadin.flow.component.Component... components) Removes the specified components from the content-container.voidremove(Collection<com.vaadin.flow.component.Component> components) Removes the specified collection of components from the content-container.voidRemoves all components from the content-container maintained within this instance.voidreplace(com.vaadin.flow.component.Component oldComponent, com.vaadin.flow.component.Component newComponent) Replaces an existing component with a new component in the content-container.voidsetContent(com.vaadin.flow.component.Component content) Updates the content of the container by removing all existing components and adding the specified component as the new content.voidsetHeader(com.vaadin.flow.component.Component header) Sets the header component of the container.voidsetHeaderHeight(int headerHeight) Sets the height of the header section in the container.voidsetMargin(int margin) Sets the margin size for the container and header container.Methods inherited from class com.vaadin.flow.component.HtmlComponent
getTitle, setTitleMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasText
getText, getWhiteSpace, setText, setWhiteSpace
-
Constructor Details
-
ScrollingContent
public ScrollingContent()Default constructor for the ScrollingContent class. This constructor initializes an instance of ScrollingContent without any pre-defined header or content. By default, it configures the internal layout and styles for the scrollable content area and header section, ensuring a consistent appearance and behavior. -
ScrollingContent
public ScrollingContent(com.vaadin.flow.component.Component content) Constructs aScrollingContentinstance with a scrollable content area and an optional header component.- Parameters:
content- the scrollable content. Ifnull, no content is set initially.
-
ScrollingContent
public ScrollingContent(com.vaadin.flow.component.Component header, com.vaadin.flow.component.Component content) A UI component that organizes content with a scrollable area and a header.- Parameters:
header- the header component to be displayed at the top of the scrolling areacontent- the main content component to be displayed inside the scrollable container
-
-
Method Details
-
getContent
public com.vaadin.flow.component.Component getContent()Retrieves the content component of the container. If the container does not contain any components, this method returnsnull.- Returns:
- the first component in the container, or
nullif the container is empty
-
setContent
public void setContent(com.vaadin.flow.component.Component content) Updates the content of the container by removing all existing components and adding the specified component as the new content. If the provided content is null, the container will be cleared and left empty.- Parameters:
content- The new content to be set in the container. If null, the container is cleared and no content is added.
-
getHeader
public com.vaadin.flow.component.Component getHeader()Retrieves the first component from the header container if it exists.- Returns:
- the first component in the header container if available, otherwise null
-
setHeader
public void setHeader(com.vaadin.flow.component.Component header) Sets the header component of the container. This method removes all existing components from the header container and adds the specified header component if it is not null.- Parameters:
header- the component to set as the header; if null, the header container will remain empty
-
setHeaderHeight
public void setHeaderHeight(int headerHeight) Sets the height of the header section in the container. This method updates the CSS flex property to ensure the header occupies the specified height and maintains a fixed size within the layout.- Parameters:
headerHeight- the height of the header, in pixels; must be a non-negative integer
-
getMargin
public int getMargin()Retrieves the margin value.- Returns:
- the margin value as an integer
-
setMargin
public void setMargin(int margin) Sets the margin size for the container and header container.- Parameters:
margin- the desired margin size in pixels. If the provided value is negative, it will be adjusted to 0.
-
add
public void add(com.vaadin.flow.component.Component... components) Adds the specified components to the content-container.- Parameters:
components- the array of components to be added to the content-container.
-
add
Adds the specified text to the content-container.- Parameters:
text- the text to be added to the content-container
-
add
Adds a collection of components to the content-container.- Parameters:
components- the collection of components to be added to the content-container
-
remove
public void remove(com.vaadin.flow.component.Component... components) Removes the specified components from the content-container.- Parameters:
components- the components to be removed from the content-container
-
remove
Removes the specified collection of components from the content-container.- Parameters:
components- the collection of components to be removed from the content-container; if the collection is null or empty, no action is performed
-
removeAll
public void removeAll()Removes all components from the content-container maintained within this instance. This operation clears all content currently present in the content-container, leaving it empty. This method overrides theremoveAll()implementation from the parent class to specifically target the components stored in the internalcontainer. -
addComponentAsFirst
public void addComponentAsFirst(com.vaadin.flow.component.Component component) Adds a given component to the content-container as the first component.- Parameters:
component- the component to add as the first element in the content-container; must not be null
-
addComponentAtIndex
public void addComponentAtIndex(int index, com.vaadin.flow.component.Component component) Adds a component to the specified index within the content-container. This method allows for precise placement of the component at the given index.- Parameters:
index- the position at which the component should be inserted. Must be a valid index within the content-container.component- the component to be added to the content-container. Cannot be null.
-
replace
public void replace(com.vaadin.flow.component.Component oldComponent, com.vaadin.flow.component.Component newComponent) Replaces an existing component with a new component in the content-container.- Parameters:
oldComponent- the component to be replacednewComponent- the component to replace with
-
indexOf
public int indexOf(com.vaadin.flow.component.Component component) Returns the index of the specified component within the content-container.- Parameters:
component- the component whose index is to be determined- Returns:
- the index of the component within the content-container, or -1 if the component is not found
-
getComponentAt
public com.vaadin.flow.component.Component getComponentAt(int index) Retrieves the component located at the specified index within the content-container. If the index is out of bounds or the specified position does not contain a component, this method may throw an exception.- Parameters:
index- the position of the desired component within the content-container, zero-based. Must be a valid index, ranging from 0 to the total component count minus one.- Returns:
- the component at the specified index; null may be returned based on the container's implementation if no component exists.
-
getComponentCount
public int getComponentCount()Returns the total number of components present in the content-container.- Returns:
- the count of components currently contained in the content-container
-
getChildren
Retrieves a stream of child components contained within the content-container.- Specified by:
getChildrenin interfacecom.vaadin.flow.component.HasComponents- Overrides:
getChildrenin classcom.vaadin.flow.component.Component- Returns:
- a Stream of Component objects representing the child components.
-