Package com.storedobject.ui.iot
Class AbstractBlockView
java.lang.Object
com.vaadin.flow.component.Component
com.storedobject.ui.util.HtmlTemplate
com.storedobject.ui.TemplateLayout
com.storedobject.ui.TemplateView
com.storedobject.ui.iot.AbstractBlockView
- All Implemented Interfaces:
Executable
,Reentrant
,HasLogic
,Transactional
,ClickHandler
,CloseableView
,ExecutableView
,ValueChangeHandler
,com.vaadin.flow.component.AttachNotifier
,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.HasElement
,com.vaadin.flow.component.HasSize
,com.vaadin.flow.component.HasStyle
,com.vaadin.flow.component.HasValue.ValueChangeListener
,Serializable
,Runnable
,EventListener
- Direct Known Subclasses:
BlockView
public abstract class AbstractBlockView
extends TemplateView
implements Transactional, CloseableView
AbstractBlockView serves as the foundational class for creating specific block
views in applications. It is designed to manage and visualize blocks and associated
data within a transactional and closeable context. This class also integrates
with the application's polling mechanisms, providing periodic updates and relevant
functionalities for managing block-related operations.
Key Features:
- Automatically integrates refresher mechanisms to update block data periodically. - Provides a template for rendering blocks, requiring subclasses to implement specific methods for block representation. - Manages site association for blocks with appropriate checks and updates. - Handles resources and polling cleanup upon view termination.Core Responsibilities:
- Initiates the application menu closure and polling services. - Refreshes the block's status using a polling mechanism. - Offers utility methods to retrieve or format the last update time.
Subclasses are required to implement methods like drawBlocks()
and
reloadBlock(Id blockId)
to define specific rendering and reloading logic.
Transactional
to support transactional operations.
- CloseableView
to handle resources and cleanup processes.
Extends:
- TemplateView
to use templating support for the UI.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.storedobject.ui.util.HtmlTemplate
HtmlTemplate.ComponentCreator, HtmlTemplate.StreamSupplier, HtmlTemplate.StyleSupplier
Nested classes/interfaces inherited from interface com.storedobject.vaadin.ClickHandler
ClickHandler.ModifiedClickEvent<C extends com.vaadin.flow.component.Component>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clean()
Cleans up resources used by the view and stops any associated polling operations.protected com.vaadin.flow.component.Component
Creates a component based on the provided identifier.protected abstract void
An abstract method responsible for drawing initial blocks in the view.final void
Executes the operation for the view.Retrieves the last update of the view formatted as a string.Retrieves the timestamp of the last update for the view.getSite()
Returns the associatedSite
instance for this view.protected abstract void
redrawBlock
(Id blockId) Redraws the specified block within the view.void
Sets the site associated with this view.Methods inherited from class com.storedobject.ui.TemplateView
decorateComponent, getComponent, getView, setCaption, viewConstructed
Methods inherited from class com.storedobject.ui.TemplateLayout
center
Methods inherited from class com.storedobject.ui.util.HtmlTemplate
build, clearCache, createComponentForId, isCreated, onAttach, setComponentCreator, setView
Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.storedobject.vaadin.ClickHandler
clicked, doubleClicked, onComponentEvent, rightClicked
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.storedobject.common.Executable
act
Methods inherited from interface com.storedobject.vaadin.ExecutableView
abort, clearAlerts, clicked, close, createMenuItem, error, execute, getApplication, getCaption, getMenuIconName, getMenuItem, getView, getView, invoke, isCloseable, isFullScreen, isHomeView, log, log, message, returnedFrom, run, setCaption, setClickable, speak, trackValueChange, tray, valueChanged, warning
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods 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, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods inherited from interface com.storedobject.common.Reentrant
isReentrant
Methods inherited from interface com.storedobject.ui.Transactional
commit, execute, getLogic, getTransactionManager, run, setLogic, transact, transact, transactControl, transactControl
Methods inherited from interface com.storedobject.vaadin.ValueChangeHandler
valueChanged
-
Field Details
-
application
-
site
-
-
Constructor Details
-
AbstractBlockView
public AbstractBlockView()Constructs a new instance of AbstractBlockView. This constructor initializes the class by invoking the parent constructor and performs additional setup tasks. Specifically, it obtains the current instance of the application and closes any open menus associated with it. This ensures that the view is prepared in a defined state for subsequent operations or interactions.
-
-
Method Details
-
clean
public void clean()Cleans up resources used by the view and stops any associated polling operations. This method unregisters the refresher, if it was previously set, ensuring it is properly disposed of and set to null. Additionally, it stops the polling operation associated with the current view through the application. Finally, it delegates further cleanup actions to the parent class by invoking the superclass's clean method.- Specified by:
clean
in interfaceExecutableView
-
execute
Executes the operation for the view. This method ensures the proper setup of a refresher mechanism and block association prior to execution. It also invokes the parent class's execute method to perform the additional painting actions required.- Specified by:
execute
in interfaceExecutableView
- Parameters:
lock
- AView
object used to control the execution context and ensure thread safety.
-
drawBlocks
protected abstract void drawBlocks()An abstract method responsible for drawing initial blocks in the view. Subclasses must provide a concrete implementation of this method to define the specific behavior for rendering or handling block-related functionality. This method is called during the lifecycle of the view to perform block-specific operations. -
setSite
-
getSite
-
getLastUpdateTime
-
getLastUpdate
Retrieves the last update of the view formatted as a string. If the last update time is not available, returns "UNKNOWN".- Returns:
- A string representing the last update time in "HH:MM" format, or "UNKNOWN" if the update time is not set.
-
redrawBlock
Redraws the specified block within the view. This method is responsible for updating or re-rendering a specific block identified by the given block ID. It is an abstract method that subclasses must implement to define the exact behavior of block redrawing. This operation is typically invoked when a specific block needs to be refreshed due to changes in its state or external triggers.- Parameters:
blockId
- The unique identifier of the block to be redrawn.
-
createComponentForId
Creates a component based on the provided identifier. If the identifier matches "lastUpdate", a newSpan
component is created and returned. Otherwise, the method delegates the creation to the superclass implementation.- Overrides:
createComponentForId
in classHtmlTemplate
- Parameters:
id
- the identifier of the component to be created- Returns:
- the component associated with the given identifier
-