Package com.storedobject.ui
Class ObjectViewer
java.lang.Object
com.storedobject.ui.Executor
com.storedobject.ui.ObjectViewer
- All Implemented Interfaces:
Executable
,ObjectSetter<StoredObject>
,AlertHandler
,Runnable
,Consumer<StoredObject>
The ObjectViewer class is a utility for viewing
StoredObject
instances within an application.
This class extends Executor
to provide execution functionalities and implements
ObjectSetter
to set objects for viewing and AlertHandler
to handle alerts associated
with StoredObject
.- Author:
- Syam
-
Field Summary
Fields inherited from class com.storedobject.ui.Executor
application
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an ObjectViewer instance with the specified application. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the ObjectViewer by releasing associated resources and setting relevant fields to null.void
execute()
Executes the primary action associated with the ObjectViewer by invoking the view method.boolean
Checks if the viewer is currently executing an action.Get the caption name to be used on the alert action button.Retrieves the icon associated with alert notifications for the ObjectViewer.void
handleAlert
(StoredObject object) Handles the alert action for the givenStoredObject
.void
Sets the object for the viewer using the given object ID.void
setObject
(StoredObject object) Sets the specifiedStoredObject
instance for this ObjectViewer.void
view()
Triggers the default view behavior for the object or content managed by the viewer without any specific parameters.void
Displays the view associated with the specified object ID.void
view
(Id objectId, ObjectViewerButton<?>... buttons) Opens a view for a specific object identified by its ID and allows optional buttons to be added for interaction.void
view
(Id objectId, String actionName, Consumer<StoredObject> action) Executes an action on a stored object identified by the provided objectId.void
view
(StoredObject object) Displays the specified stored object.void
view
(StoredObject object, ObjectViewerButton<?>... buttons) Triggers the viewing process for the givenStoredObject
instance and optional viewer buttons.void
view
(StoredObject object, String actionName, Consumer<StoredObject> action) Displays the specifiedStoredObject
with an associated action.void
view
(ObjectViewerButton<?>... buttons) Triggers the view functionality using the specified buttons for the ObjectViewer.void
Initiates the view process with the specified caption.void
Displays a view based on the given caption and object ID.void
view
(String caption, Id objectId, ObjectViewerButton<?>... buttons) Displays a view of the specified object, identified by its ID, with the provided caption and optional buttons for additional actions.void
Displays a view with the specified parameters.void
view
(String caption, StoredObject object) Displays a view using the specified caption and stored object.void
view
(String caption, StoredObject object, ObjectViewerButton<?>... buttons) Displays the specifiedStoredObject
in the ObjectViewer with a given caption and optional action buttons.void
view
(String caption, StoredObject object, String actionName, Consumer<StoredObject> action) Displays a view with the specified caption and an action on the given stored object.void
view
(String caption, ObjectViewerButton<?>... buttons) Opens a viewer for the specified object with the provided caption and optional buttons.void
view
(String caption, String actionName, Consumer<StoredObject> action) Initiates the process of viewing an object with a specified action.void
view
(String actionName, Consumer<StoredObject> action) Initiates a view operation using a specified action name and action logic.Methods inherited from class com.storedobject.ui.Executor
getApplication, getTransactionManager
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.storedobject.ui.AlertHandler
handleAlert
Methods inherited from interface com.storedobject.common.Executable
act, run
Methods inherited from interface com.storedobject.core.ObjectSetter
accept, getObjectClass, isAllowAny
-
Constructor Details
-
ObjectViewer
Constructs an ObjectViewer instance with the specified application.- Parameters:
a
- The application instance used to initialize the ObjectViewer.
-
-
Method Details
-
execute
public void execute()Executes the primary action associated with the ObjectViewer by invoking the view method. This method triggers the default view behavior for the object or content managed by the viewer.- Specified by:
execute
in interfaceExecutable
-
setObject
Sets the specifiedStoredObject
instance for this ObjectViewer.- Specified by:
setObject
in interfaceObjectSetter<StoredObject>
- Parameters:
object
- TheStoredObject
instance to be set.
-
setObject
Sets the object for the viewer using the given object ID.- Specified by:
setObject
in interfaceObjectSetter<StoredObject>
- Parameters:
objectId
- The ID of the object to set.
-
view
Initiates the process of viewing an object with a specified action.- Parameters:
caption
- the title or heading for the viewactionName
- the name of the action to perform in the viewaction
- the operation to be executed, provided as a Consumer of StoredObject
-
view
Opens a viewer for the specified object with the provided caption and optional buttons. If a viewer instance corresponding to the caption is found, it invokes the view mechanism on the associated object, adding the specified buttons to the interface.- Parameters:
caption
- The caption to display for the object viewer. It is used to lookup or initialize the viewer instance.buttons
- Optional buttons of typeObjectViewerButton
to enhance the viewer's functionality.
-
view
public void view()Triggers the default view behavior for the object or content managed by the viewer without any specific parameters. Delegates to the overloadedview(String, String, Consumer<StoredObject>)
method with all parameters set tonull
. -
view
Triggers the view functionality using the specified buttons for the ObjectViewer. This method invokes a secondary view method with anull
caption and the provided buttons.- Parameters:
buttons
- An array ofObjectViewerButton
instances that define actions or behaviors during the view operation.
-
view
Initiates a view operation using a specified action name and action logic.- Parameters:
actionName
- The name of the action to be performed.action
- AConsumer
representing the logic to be executed on theStoredObject
.
-
view
Initiates the view process with the specified caption. This method is a convenience method that internally calls the overloadedview
method with the given caption, anull
action name, and no action.- Parameters:
caption
- The caption to be displayed for the view.
-
view
Displays the specified stored object.- Parameters:
object
- the StoredObject instance to be displayed. If null is passed, the method may handle it as per its implementation.
-
view
Displays the specifiedStoredObject
with an associated action.- Parameters:
object
- TheStoredObject
instance to be displayed.actionName
- The name of the action associated with the displayed object.action
- AConsumer
that defines the action to be performed on theStoredObject
.
-
view
Triggers the viewing process for the givenStoredObject
instance and optional viewer buttons. The additional buttons can allow for extended actions or interactions during the viewing process.- Parameters:
object
- TheStoredObject
instance to be viewed.buttons
- OptionalObjectViewerButton
instances to include additional actions or controls.
-
view
Displays a view using the specified caption and stored object.- Parameters:
caption
- the title or label of the viewobject
- the stored object to be displayed in the view
-
view
public void view(String caption, StoredObject object, String actionName, Consumer<StoredObject> action) Displays a view with the specified caption and an action on the given stored object.- Parameters:
caption
- the title or label for the viewobject
- the stored object to be displayed in the viewactionName
- the name of the action to be performedaction
- a consumer defining the action to be executed on the stored object
-
view
Displays the specifiedStoredObject
in the ObjectViewer with a given caption and optional action buttons.- Parameters:
caption
- The caption to display in the viewer.object
- TheStoredObject
instance to be viewed.buttons
- Optional buttons of typeObjectViewerButton
to add custom actions in the viewer.
-
view
-
view
Displays a view with the specified parameters.- Parameters:
caption
- The caption to be displayed in the view.objectId
- The ID of the object to set for the view.actionName
- The name of the action to be associated with the view.action
- A consumer that defines the action to be performed on theStoredObject
.
-
view
Displays a view of the specified object, identified by its ID, with the provided caption and optional buttons for additional actions.- Parameters:
caption
- The caption to display in the view.objectId
- The ID of the object to be viewed.buttons
- Optional buttons to provide additional actions to perform in the view.
-
view
Displays the view associated with the specified object ID. This method utilizes the default caption for the view.- Parameters:
objectId
- The ID of the object to be viewed.
-
view
Executes an action on a stored object identified by the provided objectId. Delegates the actual processing by invoking an overloaded version of the view method.- Parameters:
objectId
- the identifier of the stored object to be acted uponactionName
- the name of the action to be performed on the stored objectaction
- the consumer that defines the specific action to apply to the stored object
-
view
Opens a view for a specific object identified by its ID and allows optional buttons to be added for interaction.- Parameters:
objectId
- the ID of the object to be viewedbuttons
- a varargs parameter allowing optional interactive buttons to be included in the view
-
executing
public boolean executing()Checks if the viewer is currently executing an action.- Returns:
true
if a viewer exists and it is executing an action,false
otherwise.
-
close
public void close()Closes the ObjectViewer by releasing associated resources and setting relevant fields to null. If the underlying viewer is not null, it will invoke the `close()` method of the viewer before resetting the viewer and related object fields to null. -
handleAlert
Handles the alert action for the givenStoredObject
.- Specified by:
handleAlert
in interfaceAlertHandler
- Parameters:
object
- TheStoredObject
instance for which the alert is handled.
-
getAlertIcon
Retrieves the icon associated with alert notifications for the ObjectViewer.- Specified by:
getAlertIcon
in interfaceAlertHandler
- Returns:
- A string representing the identifier of the alert icon.
-
getAlertCaption
Description copied from interface:AlertHandler
Get the caption name to be used on the alert action button. By default, "Process" is used.- Specified by:
getAlertCaption
in interfaceAlertHandler
- Returns:
- Alert button caption.
-