Class ApplicationContext
Applications
.
Applications
use the ApplicationContext
singleton to find global values and services. The majority of the
Swing Application Framework API can be accessed through
ApplicationContext
. The static getInstance
method returns
the singleton Typically it's only called after the application has
been launched
, however it is always safe
to call getInstance
.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTaskService
(TaskService taskService) final ActionManager
final ApplicationActionMap
Returns the sharedActionMap
chain for the entireApplication
.final ApplicationActionMap
getActionMap
(Class actionsClass, Object actionsObject) Returns theApplicationActionMap
chain for the specified actions class and target object.final ApplicationActionMap
getActionMap
(Object actionsObject) Defined asgetActionMap(actionsObject.getClass(), actionsObject)
.final Application
TheApplication
singleton, or null iflaunch
hasn't been called yet.final Class
Returns the application's class or null if the application hasn't been launched and this property hasn't been set.A sharedClipboard
.The application's focus owner.final LocalStorage
The sharedLocalStorage
object.final ResourceManager
The application'sResourceManager
provides read-only cached access to resources in ResourceBundles via theResourceMap
class.final ResourceMap
Returns thechain
of ResourceMaps that's shared by the entire application, beginning with the one defined for the Application class, i.e.final ResourceMap
getResourceMap
(Class cls) Returns achain
of two or more ResourceMaps.final ResourceMap
getResourceMap
(Class startClass, Class stopClass) Returns achain
of two or more ResourceMaps.final SessionStorage
The sharedSessionStorage
object.final TaskMonitor
Returns a shared TaskMonitor object.final TaskService
Returns the default TaskService, i.e.getTaskService
(String name) Returns a read-only view of the complete list of TaskServices.void
removeTaskService
(TaskService taskService) protected void
setActionManager
(ActionManager actionManager) Change this application'sActionManager
.final void
setApplicationClass
(Class applicationClass) Called byApplication.launch()
to record the application's class.protected void
setLocalStorage
(LocalStorage localStorage) The sharedLocalStorage
object.protected void
setResourceManager
(ResourceManager resourceManager) Change this application'sResourceManager
.protected void
setSessionStorage
(SessionStorage sessionStorage) The sharedSessionStorage
object.Methods inherited from class org.jdesktop.application.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
ApplicationContext
protected ApplicationContext()
-
-
Method Details
-
getApplicationClass
Returns the application's class or null if the application hasn't been launched and this property hasn't been set. Once the application has been launched, the value returned by this method is the same asgetApplication().getClass()
.- Returns:
- the application's class or null
- See Also:
-
setApplicationClass
Called byApplication.launch()
to record the application's class.This method is only intended for testing, or design time configuration. Normal applications shouldn't need to call it directly.
- See Also:
-
getApplication
TheApplication
singleton, or null iflaunch
hasn't been called yet.- Returns:
- the launched Application singleton.
- See Also:
-
getResourceManager
The application'sResourceManager
provides read-only cached access to resources in ResourceBundles via theResourceMap
class.- Returns:
- this application's ResourceManager.
- See Also:
-
setResourceManager
Change this application'sResourceManager
. AnApplicationContext
subclass that wanted to fundamentally change the wayResourceMaps
were created and cached could replace this property in its constructor.Throws an IllegalArgumentException if resourceManager is null.
- Parameters:
resourceManager
- the new value of the resourceManager property.- See Also:
-
getResourceMap
Returns achain
of two or more ResourceMaps. The first encapsulates the ResourceBundles defined for the specified class, and its parent encapsulates the ResourceBundles defined for the entire application.This is just a convenience method that calls
ResourceManager.getResourceMap()
. It's defined as:return getResourceManager().getResourceMap(cls, cls);
- Parameters:
cls
- the class that defines the location of ResourceBundles- Returns:
- a
ResourceMap
that contains resources loaded fromResourceBundles
found in the resources subpackage of the specified class's package. - See Also:
-
getResourceMap
Returns achain
of two or more ResourceMaps. The first encapsulates the ResourceBundles defined for the all of the classes betweenstartClass
andstopClass
inclusive. It's parent encapsulates the ResourceBundles defined for the entire application.This is just a convenience method that calls
ResourceManager.getResourceMap()
. It's defined as:return getResourceManager().getResourceMap(startClass, stopClass);
- Parameters:
startClass
- the first class whose ResourceBundles will be includedstopClass
- the last class whose ResourceBundles will be included- Returns:
- a
ResourceMap
that contains resources loaded fromResourceBundles
found in the resources subpackage of the specified class's package. - See Also:
-
getResourceMap
Returns thechain
of ResourceMaps that's shared by the entire application, beginning with the one defined for the Application class, i.e. the value of theapplicationClass
property.This is just a convenience method that calls
ResourceManager.getResourceMap()
. It's defined as:return getResourceManager().getResourceMap();
- Returns:
- the Application's ResourceMap
- See Also:
-
getActionManager
- Returns:
- this application's ActionManager.
- See Also:
-
setActionManager
Change this application'sActionManager
. AnApplicationContext
subclass that wanted to fundamentally change the wayActionManagers
were created and cached could replace this property in its constructor.Throws an IllegalArgumentException if actionManager is null.
- Parameters:
actionManager
- the new value of the actionManager property.- See Also:
-
getActionMap
Returns the sharedActionMap
chain for the entireApplication
.This is just a convenience method that calls
ActionManager.getActionMap()
. It's defined as:return getActionManager().getActionMap()
- Returns:
- the
ActionMap
chain for the entireApplication
. - See Also:
-
getActionMap
Returns theApplicationActionMap
chain for the specified actions class and target object.This is just a convenience method that calls
ActionManager.getActionMap(Class, Object)
. It's defined as:return getActionManager().getActionMap(actionsClass, actionsObject)
- Returns:
- the
ActionMap
chain for the entireApplication
. - See Also:
-
getActionMap
Defined asgetActionMap(actionsObject.getClass(), actionsObject)
.- Returns:
- the
ActionMap
for the specified object - See Also:
-
getLocalStorage
The sharedLocalStorage
object.- Returns:
- the shared
LocalStorage
object.
-
setLocalStorage
The sharedLocalStorage
object.- Parameters:
localStorage
- the sharedLocalStorage
object.
-
getSessionStorage
The sharedSessionStorage
object.- Returns:
- the shared
SessionStorage
object.
-
setSessionStorage
The sharedSessionStorage
object.- Parameters:
sessionStorage
- the sharedSessionStorage
object.
-
getClipboard
A sharedClipboard
. -
getFocusOwner
The application's focus owner. -
addTaskService
-
removeTaskService
-
getTaskService
-
getTaskService
Returns the default TaskService, i.e. the one named "default":return getTaskService("default")
. TheApplicationAction actionPerformed
method executes backgroundTasks
on the default TaskService. Application's can launch Tasks in the same way, e.g.ApplicationContext.getInstance().getTaskService().execute(myTask);
- Returns:
- the default TaskService.
- See Also:
-
getTaskServices
Returns a read-only view of the complete list of TaskServices.- Returns:
- a list of all of the TaskServices.
- See Also:
-
getTaskMonitor
Returns a shared TaskMonitor object. Most applications only need one TaskMonitor for the sake of status bars and other status indicators.- Returns:
- the shared TaskMonitor object.
-