Package com.storedobject.ui.iot
Class BlockView
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.BlockView
- 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
BlockView represents a view specifically designed to handle block entities and relevant updates in the IoT system.
It extends TemplateView to provide an interface for block-related operations and manages the state and updates
on block entities, their associated units, and various data statuses such as limits and alarms.
Implements both Transactional and CloseableView interfaces to ensure proper state management and transactional handling of its operations.
Implements both Transactional and CloseableView interfaces to ensure proper state management and transactional handling of its operations.
- Author:
- Syam
- 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>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clean()
Cleans up resources and releases references related to the BlockView instance.protected void
clicked
(DataSet.AlarmStatus alarmStatus) This method is invoked when aSiteView
is active and someone clicked on an item that is an alarm switch.protected void
clicked
(DataSet.LimitStatus limitStatus) This method is invoked when aSiteView
is active and someone clicked on an item that is a limit value.protected com.vaadin.flow.component.Component
Creates and returns a component based on the specified id.void
Executes the operation for the current block view.getBlock()
Retrieves the Block object associated with this instance.Retrieves the formatted timestamp for the last update of the block view.Retrieves the last update time of the block view.getSite()
Retrieves the Site associated with this BlockView instance.protected void
Paints the specified Block in the view or graphical component.protected void
paint
(DataSet.AlarmStatus alarmStatus) Paints the visual representation of the specified alarm status.protected void
paint
(DataSet.LimitStatus limitStatus) Paints the visual representation related to the provided limit status.protected void
Renders or updates the visual representation of the given unit.final void
reload()
Reloads the view.protected void
Performs the operation necessary for updating or refreshing internal states related to the BlockView instance.void
Sets the specifiedBlock
to this view.void
Updates the associated site for the block field and reloads the view if necessary.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
-
Constructor Details
-
BlockView
public BlockView()Constructor for the BlockView class.
Initializes the BlockView instance by performing the following tasks:- Sets the caption for the view as "Block View". - Closes the menu of the current application instance. - Registers a content resize listener to detect changes in content size and triggers a reload of the view upon size changes.
-
-
Method Details
-
clean
public void clean()Cleans up resources and releases references related to the BlockView instance. This method removes the associated size attribute, unregisters any linked data refresher, stops polling from the associated application, and invokes the superclasses clean method. If a refresher is currently active, it will be unregistered before being set to null.Note: Do not call this method anywhere from your logic.
- Specified by:
clean
in interfaceExecutableView
-
execute
Executes the operation for the current block 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 any additional actions required.- Specified by:
execute
in interfaceExecutableView
- Parameters:
lock
- AView
object used to control the execution context and ensure thread safety.
-
getBlock
Retrieves the Block object associated with this instance.- Returns:
- the Block object currently set in this instance
-
setBlock
Sets the specifiedBlock
to this view. If the block is null or the block is already set with the same ID, the method returns without any action. Clears all existing units, retrieves the new block's units, and adds them to the unit collection. If the view is in a created state, the block is painted. Finally, reloads the view.- Parameters:
block
- TheBlock
to be set.
-
setSite
Updates the associated site for the block field and reloads the view if necessary. The method ensures that the new site is compatible with the block's current site ID before proceeding with the update.- Parameters:
site
- The site to be set. If null or not matching the conditions, the operation is ignored.
-
getSite
Retrieves the Site associated with this BlockView instance. If a block is set, it will return the site associated with the block. If no block is set, it will return the site associated with the blockField, or null if blockField is not available.- Returns:
- The associated Site object, or null if no site is available.
-
reload
public final void reload()Reloads the view. This is a manual call and "last update" time is not updated.Note: The
reloading()
method will not be invoked. -
reloading
protected void reloading()Performs the operation necessary for updating or refreshing internal states related to the BlockView instance.The method is designed for subclass usage or internal logic flow, ensuring that specific elements or data related to the view can be re-initialized or recalculated. Its exact behavior is expected to be defined or overridden in subclasses or through internal calls in the containing class.
-
getLastUpdateTime
Retrieves the last update time of the block view.- Returns:
- the date and time of the last update as a
Date
object
-
getLastUpdate
Retrieves the formatted timestamp for the last update of the block view. If no update has been recorded, it returns "UNKNOWN".- Returns:
- A formatted string representing the last update timestamp, or "UNKNOWN" if no update exists.
-
paint
Paints the specified Block in the view or graphical component.- Parameters:
block
- The Block object to be painted.
-
paint
Renders or updates the visual representation of the given unit.- Parameters:
unit
- the unit object to paint or render within the context of this view
-
paint
Paints the visual representation related to the provided limit status. This method customizes and updates the display based on the given limit status, ensuring consistency with the dataset constraints or thresholds.- Parameters:
limitStatus
- the limit status to be reflected in the visual display
-
paint
Paints the visual representation of the specified alarm status.- Parameters:
alarmStatus
- The alarm status to be painted, providing information about the current state of the alarm for visualization.
-
clicked
This method is invoked when aSiteView
is active and someone clicked on an item that is an alarm switch.- Parameters:
alarmStatus
- The respective alarm status.
-
clicked
This method is invoked when aSiteView
is active and someone clicked on an item that is a limit value.- Parameters:
limitStatus
- The respective limit status.
-
createComponentForId
Creates and returns a component based on the specified id. If the id equals "block", aBlockComboField
is created and configured with a value change listener to update the block. For other ids, the method delegates the component creation to the superclass implementation.- Overrides:
createComponentForId
in classHtmlTemplate
- Parameters:
id
- the identifier used to determine the type of component to create- Returns:
- the created
Component
based on the id
-