Package com.storedobject.ui.iot
Class GUI
java.lang.Object
com.storedobject.ui.iot.GUI
- All Implemented Interfaces:
Executable
,Runnable
- Direct Known Subclasses:
DevelopmentGUI
GUI helper class. It provides various functionalities such as managing IoT sites, blocks, units, and resources.
The GUI also contains features to display different views, charts, dashboards, and the ability to execute
specific commands and operations.
- Author:
- Syam
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the specified unit is present in the collection of units.void
Initiates the process to download data for the block associated with the current context.void
execute()
Executes the default action for the GUI by displaying the site view.getBlock()
Retrieves the current block.getSite()
Retrieves the current site associated with this instance.Retrieves the label associated with the site view.getUnit()
Retrieves the currently set unit.boolean
isEmpty()
Checks if the collection of units is empty.boolean
Checks whether the site is fixed.void
selectBlock
(Consumer<Block> blockConsumer) Selects a block and performs an action defined by the provided Consumer.void
Sends a command to the currently selected block.void
setAllowCommand
(boolean allowCommand) Set whether commands are allowed or not.void
setAllowDownload
(boolean allowDownload) Set whether data download is allowed or not.void
setAllowStatus
(boolean allowStatus) Set whether viewing status (alarm) screen is possible or not.void
Sets the block for the GUI instance.void
setBlockView
(BlockView blockView) Sets the active block view instance.void
Sets the site for the current instance.void
setSiteViewLabel
(String siteViewLabel) Sets the label for the site view.void
Sets the current unit for the GUI instance.void
Displays a chart for the currently selected site.void
Displays the dashboard interface for the application.void
Displays the site view within the graphical user interface (GUI).void
Displays the status grid within the GUI.void
viewData()
Triggers the viewing of data associated with a specific block.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.storedobject.common.Executable
act, run
-
Constructor Details
-
GUI
public GUI()Default constructor for the GUI class. Initializes the GUI with default settings and without enabling development mode. -
GUI
public GUI(boolean devMode) Constructs a GUI instance with the specified development mode setting.- Parameters:
devMode
- a boolean indicating whether the GUI should operate in development mode. If true, the GUI will run in development mode; otherwise, it will operate in production mode.
-
GUI
Constructs a GUI instance associated with a specific site.- Parameters:
site
- The site to associate with the GUI.
-
GUI
Constructs a GUI object with the specified site and development mode flag.- Parameters:
site
- The site associated with this GUI. This determines the fixed site status.devMode
- A flag indicating whether the GUI is in development mode.
-
-
Method Details
-
isFixedSite
public boolean isFixedSite()Checks whether the site is fixed.- Returns:
- true if the site is a fixed site, false otherwise.
-
execute
public void execute()Executes the default action for the GUI by displaying the site view. This method overrides the execute() method of the parent class and ensures that the appropriate site-related view is initialized and displayed. It delegates the task to theshowSiteView()
method.- Specified by:
execute
in interfaceExecutable
-
getUnit
-
setUnit
Sets the current unit for the GUI instance. If the specified unit is null, or it is the same as the current unit (based on unit ID), the method will return without making any changes. If the specified unit belongs to the list of available units, it updates the current unit and its associated site.- Parameters:
unit
- The unit to set as the current unit. It must not be null and should differ from the currently set unit. The unit is set only if it exists in the list of available units.
-
setSite
Sets the site for the current instance. This method updates the associated block and units based on the provided site. If the site is null or matches the currently set site (based on the site ID), the operation is ignored. If a corresponding active block for the given site exists, the units are loaded; otherwise, the units are cleared.- Parameters:
site
- The new site to set. If it differs from the current site, the associated block, units, and the selected unit are updated accordingly.
-
getSite
Retrieves the current site associated with this instance.- Returns:
- The site object currently set for this instance.
-
showDashboard
public void showDashboard()Displays the dashboard interface for the application.
If the dashboard instance has not been initialized, this method will create and instantiate a new Dashboard object using the current GUI context.
Currently, the method displays a message indicating that the dashboard functionality is under development, as the dashboard execution logic has been commented out. -
showChart
public void showChart()Displays a chart for the currently selected site.
If no site is selected or set, a message will be displayed indicating that there is no site selected. If the chart has not been created yet, it initializes a new instance of theValueChart
class.
If the chart is ready or created successfully, it will execute the display of the chart. -
showSiteView
public void showSiteView()Displays the site view within the graphical user interface (GUI). Initializes the site view if it has not been created yet. The site view is constructed using the current instance and the developer mode flag. Once initialized or retrieved, it executes the logic associated with the site view. -
showStatusGrid
public void showStatusGrid()Displays the status grid within the GUI. If the status grid is not initialized, the method will create a new instance and execute it.
This method ensures the status grid is properly initialized and executed, providing an interface for monitoring or interacting with the current system status. -
sendCommand
public void sendCommand()Sends a command to the currently selected block.
If no block is selected or set, a warning is displayed, and the operation is aborted. Otherwise, a new command execution is initiated for the selected block. -
downloadData
public void downloadData()Initiates the process to download data for the block associated with the current context. This method triggers the execution of theDownloadData
class, which handles the data retrieval and processing tasks.
The block to download data for is retrieved using thegetBlock()
method. This method provides a high-level entry point for initiating data download operations. -
viewData
public void viewData()Triggers the viewing of data associated with a specific block.
This method executes aViewData
operation for the block currently associated with the instance. If no block is explicitly set, it attempts to retrieve the block through thegetBlock()
method, which provides the default block based on the available units. TheViewData
operation further initiates data processing and viewing within the associated framework. -
contains
Checks if the specified unit is present in the collection of units.- Parameters:
unit
- the unit to be checked for presence in the collection- Returns:
- true if the unit is present in the collection, false otherwise
-
isEmpty
public boolean isEmpty()Checks if the collection of units is empty.- Returns:
true
if the collection of units is empty,false
otherwise.
-
setBlock
Sets the block for the GUI instance. Depending on the provided block, it may update the associated units, site, and selected unit of the GUI. If the block is null, all associated units and related properties are cleared.- Parameters:
block
- The block to set. A null value clears the current block and associated properties. If the block is the same as the current block, no action is performed.
-
getBlock
Retrieves the current block. If the block is not already set and the list of units is not empty, the block is initialized using the block from the first unit in the list.- Returns:
- The current block, or the block from the first unit if not already set and available.
-
selectBlock
-
setSiteViewLabel
Sets the label for the site view.- Parameters:
siteViewLabel
- the label to assign to the site view
-
getSiteViewLabel
Retrieves the label associated with the site view.- Returns:
- the site view label as a String
-
setBlockView
Sets the active block view instance.- Parameters:
blockView
- The BlockView instance to be set.
-
setAllowCommand
public void setAllowCommand(boolean allowCommand) Set whether commands are allowed or not.- Parameters:
allowCommand
- True/false.
-
setAllowDownload
public void setAllowDownload(boolean allowDownload) Set whether data download is allowed or not.- Parameters:
allowDownload
- True/false.
-
setAllowStatus
public void setAllowStatus(boolean allowStatus) Set whether viewing status (alarm) screen is possible or not.- Parameters:
allowStatus
- True/false
-