Package com.storedobject.ui
Class CardDashboard<T>
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
com.storedobject.ui.CardDashboard<T>
- Type Parameters:
T- The type of object associated with the cards in the dashboard.
- All Implemented Interfaces:
ClickHandler,CloseableView,ExecutableView,ValueChangeHandler,com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.ClickNotifier<com.vaadin.flow.component.html.Div>,com.vaadin.flow.component.ComponentEventListener<com.vaadin.flow.component.ClickEvent<? extends com.vaadin.flow.component.Component>>,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,com.vaadin.flow.component.HasValue.ValueChangeListener,Serializable,Runnable,EventListener
- Direct Known Subclasses:
ModuleMenu,ObjectCardDashboard
The CardDashboard class represents a dashboard composed of interactive cards laid out on a grid.
It extends the functionality of the ScrollingContent class and implements the ExecutableView
and CloseableView interfaces. This allows the dashboard to be part of an application's interactive
view system with capabilities to execute and manage its lifecycle.
The CardDashboard is designed to display a collection of cards organized using a grid layout,
and its caption can be dynamically set. It also includes an inner view component that manages
display-specific details and interactions related to its content. The caption updates are propagated
to the view if it exists.
- Author:
- Syam
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.storedobject.vaadin.ClickHandler
ClickHandler.ModifiedClickEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasText
com.vaadin.flow.component.HasText.WhiteSpace -
Constructor Summary
ConstructorsConstructorDescriptionCardDashboard(String caption, CardGrid<T> grid) Constructs a newCardDashboardinstance with the specified caption and grid layout. -
Method Summary
Modifier and TypeMethodDescriptionfinal com.vaadin.flow.shared.RegistrationaddCardSelectedListener(Consumer<Card<T>> listener) Adds a card selection listener to the dashboard's associatedCardGrid.voidExecute the associated view by locking another view (the locked view will not be selectable until this view is closed).Get the caption for this view.getCards()Retrieves a stream ofCardobjects managed by the associatedCardGrid.getGrid()Retrieves theCardGridassociated with thisCardDashboard.Retrieves the currently selected card from the associated grid.Retrieves a stream of the currently selected cards from the associatedCardGrid.final com.vaadin.flow.component.grid.Grid.SelectionModeRetrieves the current selection mode of theGridassociated with this dashboard.getView(boolean create) Get the View.voidDisables card selection in the associated grid.booleanChecks whether card selection is currently being ignored in the associated grid.voidselectAllCards(boolean select) Toggles the selection state of all cards within the dashboard's grid.voidsetCaption(String caption) Set the captionfinal voidsetSelectionMode(com.vaadin.flow.component.grid.Grid.SelectionMode selectionMode) Configures the selection mode for the grid within theCardDashboard.Methods inherited from class com.storedobject.ui.ScrollingContent
add, add, add, addComponentAsFirst, addComponentAtIndex, getChildren, getComponentAt, getComponentCount, getContent, getHeader, getMargin, indexOf, remove, remove, removeAll, replace, setContent, setHeader, setHeaderHeight, setMarginMethods 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.storedobject.vaadin.ClickHandler
clicked, doubleClicked, onComponentEvent, rightClickedMethods 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.storedobject.vaadin.ExecutableView
abort, clean, clearAlerts, clicked, close, createMenuItem, error, execute, getApplication, getMenuIconName, getMenuItem, getView, invoke, isCloseable, isFullScreen, isHomeView, log, log, message, returnedFrom, run, setClickable, speak, trackValueChange, tray, valueChanged, warningMethods 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, setWhiteSpaceMethods inherited from interface com.storedobject.vaadin.ValueChangeHandler
valueChanged
-
Constructor Details
-
CardDashboard
Constructs a newCardDashboardinstance with the specified caption and grid layout. This constructor initializes the dashboard by associating it with the givenCardGrid. The provided grid is set as the scrollable content of the dashboard, and it is linked back to the dashboard using thesetDashboardmethod. Additionally, the caption for the dashboard is set, and it can be dynamically modified later.- Parameters:
caption- the display caption for the dashboard. Ifnullor blank, a default value ("Dashboard") is used.grid- theCardGridthat organizes and manages the cards displayed in the dashboard. This grid is essential for layout and content management within the dashboard.
-
-
Method Details
-
setCaption
Description copied from interface:ExecutableViewSet the caption- Specified by:
setCaptionin interfaceExecutableView- Parameters:
caption- Caption
-
getCaption
Description copied from interface:ExecutableViewGet the caption for this view.- Specified by:
getCaptionin interfaceExecutableView- Returns:
- Caption.
-
getGrid
-
execute
Description copied from interface:ExecutableViewExecute the associated view by locking another view (the locked view will not be selectable until this view is closed). The locked view acts as its "parent" and it will automatically get selected when this view closes.- Specified by:
executein interfaceExecutableView- Parameters:
lock- View to be locked.
-
getView
Description copied from interface:ExecutableViewGet the View. Create it if it doesn't exist.- Specified by:
getViewin interfaceExecutableView- Parameters:
create- Whether to create or not.- Returns:
- View.
-
setSelectionMode
public final void setSelectionMode(com.vaadin.flow.component.grid.Grid.SelectionMode selectionMode) Configures the selection mode for the grid within theCardDashboard. The selection mode determines how cards in the grid can be selected (e.g., single, multi, or none).- Parameters:
selectionMode- theGrid.SelectionModethat specifies the card selection behavior in the grid. Must not be null.
-
getSelectionMode
public final com.vaadin.flow.component.grid.Grid.SelectionMode getSelectionMode()Retrieves the current selection mode of theGridassociated with this dashboard. The selection mode determines how items within the grid can be selected (e.g., single, multiple, or none).- Returns:
- the current
Grid.SelectionModeof the associatedGrid.
-
addCardSelectedListener
public final com.vaadin.flow.shared.Registration addCardSelectedListener(Consumer<Card<T>> listener) Adds a card selection listener to the dashboard's associatedCardGrid. The listener is triggered whenever a card is selected in the grid.- Parameters:
listener- aConsumerthat processes theCardselected by the user. This listener is invoked with the selected card as its input.- Returns:
- a
Registrationobject that can be used to remove the listener if it is no longer needed.
-
selectAllCards
public void selectAllCards(boolean select) Toggles the selection state of all cards within the dashboard's grid. This method delegates the operation to theCardGridassociated with theCardDashboard. It allows for selecting or deselecting all cards simultaneously based on the specified parameter. This operation is only effective if the grid's selection mode is set toGrid.SelectionMode.MULTI.- Parameters:
select- a boolean value indicating the desired selection state for all cards. Iftrue, all cards in the grid will be selected; iffalse, all cards will be deselected.
-
getSelectedCard
-
getSelectedCards
-
getCards
Retrieves a stream ofCardobjects managed by the associatedCardGrid. This method is used to access and iterate through all the cards currently organized within the grid layout of the dashboard.- Returns:
- a
StreamofCard<T>instances representing the cards in the grid.
-
ignoreSelection
public void ignoreSelection()Disables card selection in the associated grid. When this method is invoked, it prevents the grid from processing any card selection events, effectively ignoring selection input or state changes. This can be useful in scenarios where card selection functionality needs to be temporarily suspended without altering the grid's selection state. Use case: When you have clickable components inside the cards, you may not want to fire the selection events when the user clicks on them. In such cases, you can temporarily suspend card selection to avoid unintended behavior. This is typically achieved by invoking this method from within your click-handlers. It will be automatically enabled again when your click-handlers complete their execution. -
isIgnoreSelection
public boolean isIgnoreSelection()Checks whether card selection is currently being ignored in the associated grid. When this method returnstrue, card selection events are not processed, effectively disabling selection functionality for the grid.- Returns:
trueif card selection is being ignored;falseotherwise
-