public class ApplicationShutdownActionTask extends Object implements Runnable, ApplicationClient
A specialized action task for exiting the current application.
This action task simply calls the
Application.shutdown(Object, Object)
method, which is the default way
of terminating the currently running application. It can be associated with a
File|Exit
menu item defined by most applications.
The shutdown()
method of Application
checks whether currently
still background tasks are running. If this is the case, a message box is
displayed asking the user whether the application should shutdown anyway.
Both the title and the message displayed by this message box can be
specified. This class defines corresponding properties of type Object
according to the way resource texts are specified. Here either resource IDs
can be passed in or Message
objects. If no specific values for these
properties are set, default values are used referring to standard resources
shipped with the library.
The following example fragment shows how the action for terminating the application can be defined in a Jelly builder script:
<!-- The action task for quitting the application --> <di:bean name="exitTask" beanClass="net.sf.jguiraffe.gui.app.ApplicationShutdownActionTask"> <di:setProperty property="exitPromptMessageResource"> <di:bean beanClass="net.sf.jguiraffe.resources.Message"> <di:constructor> <di:param value="EXIT_MESSAGE"/> </di:constructor> </di:bean> </di:setProperty> </di:bean> <!-- The action itself --> <a:action name="exitAction" text="Exit" taskBean="exitTask"/>This fragment declares an
ApplicationShutdownActionTask
bean with a
custom prompt message to be displayed if there is still background activity.
A Message
object initialized with a resource ID is constructed and
passed to the exitPromptMessageResource
property (the default
resource group is used; it would also be possible to pass a resource group to
the Message
object). The resource ID for the title of the exit prompt
dialog is not set, so here the default is used.
Constructor and Description |
---|
ApplicationShutdownActionTask() |
Modifier and Type | Method and Description |
---|---|
Application |
getApplication()
Returns the central
Application object. |
Object |
getExitPromptMessageResource()
Returns the resource ID for the message of the exit prompt dialog.
|
Object |
getExitPromptTitleResource()
Returns the resource ID for the title of the exit prompt dialog.
|
void |
run()
Executes this task.
|
void |
setApplication(Application app)
Sets the central
Application object. |
void |
setExitPromptMessageResource(Object exitPromptMessageResource)
Sets the resource ID for the message of the exit prompt dialog.
|
void |
setExitPromptTitleResource(Object exitPromtTitleResource)
Sets the resource ID for the title of the exit prompt dialog.
|
public Object getExitPromptMessageResource()
public void setExitPromptMessageResource(Object exitPromptMessageResource)
Message
object. Otherwise, it is interpreted as resource ID and resolved
against the default resource group.exitPromptMessageResource
- the resource IDpublic Object getExitPromptTitleResource()
public void setExitPromptTitleResource(Object exitPromtTitleResource)
Message
object. Otherwise, it is interpreted as resource ID and resolved
against the default resource group.exitPromtTitleResource
- the resource IDpublic Application getApplication()
Application
object. This is the application
this task is going to shut down.Application
public void setApplication(Application app)
Application
object. If this bean is created by
the dependency injection framework (which is the intended default way of
using this class), this reference is automatically injected.setApplication
in interface ApplicationClient
app
- the Application
objectpublic void run()
Application.shutdown(Object, Object)
method on the Application
object passed to setApplication(Application)
. If no
Application
was set, an exception is thrown.run
in interface Runnable
IllegalStateException
- if no Application
has been setCopyright © 2016 The JGUIraffe Team. All rights reserved.