Class ApplicationContext
Applications.
Applications use ApplicationContext,
via Application.getContext(), to access global values and services.
The majority of the Swing Application Framework API can be accessed through
ApplicationContext.
- Author:
- Hans Muller (Hans.Muller@Sun.COM)
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTaskService(TaskService taskService) Register a new TaskService with the application.final ActionManagerReturn this application's ActionManager.final ApplicationActionMapReturns the sharedActionMapchain for the entireApplication.final ApplicationActionMapgetActionMap(Class actionsClass, Object actionsObject) Returns theApplicationActionMapchain for the specified actions class and target object.final ApplicationActionMapgetActionMap(Object actionsObject) Defined asgetActionMap(actionsObject.getClass(), actionsObject).final ApplicationTheApplicationsingleton, or null iflaunchhasn't been called yet.final ClassReturns the application's class or null if the application hasn't been launched and this property hasn't been set.Return a sharedClipboard.Returns the application's focus owner.final LocalStorageThe sharedLocalStorageobject.final ResourceManagerThe application'sResourceManagerprovides read-only cached access to resources in ResourceBundles via theResourceMapclass.final ResourceMapReturns thechainof ResourceMaps that's shared by the entire application, beginning with the one defined for the Application class, i.e.final ResourceMapgetResourceMap(Class cls) Returns achainof two or more ResourceMaps.final ResourceMapgetResourceMap(Class startClass, Class stopClass) Returns achainof two or more ResourceMaps.final SessionStorageThe sharedSessionStorageobject.final TaskMonitorReturns a shared TaskMonitor object.final TaskServiceReturns the default TaskService, i.e.getTaskService(String name) Look up a task service by name.Returns a read-only view of the complete list of TaskServices.voidremoveTaskService(TaskService taskService) Unregister a previously registered TaskService.protected voidsetActionManager(ActionManager actionManager) Change this application'sActionManager.final voidsetApplicationClass(Class applicationClass) Called byApplication.launch()to record the application's class.protected voidsetLocalStorage(LocalStorage localStorage) The sharedLocalStorageobject.protected voidsetResourceManager(ResourceManager resourceManager) Change this application'sResourceManager.protected voidsetSessionStorage(SessionStorage sessionStorage) The sharedSessionStorageobject.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.
- Parameters:
applicationClass-- See Also:
-
getApplication
TheApplicationsingleton, or null iflaunchhasn't been called yet.- Returns:
- the launched Application singleton.
- See Also:
-
getResourceManager
The application'sResourceManagerprovides read-only cached access to resources in ResourceBundles via theResourceMapclass.- Returns:
- this application's ResourceManager.
- See Also:
-
setResourceManager
Change this application'sResourceManager. AnApplicationContextsubclass that wanted to fundamentally change the wayResourceMapswere 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 achainof 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
ResourceMapthat contains resources loaded fromResourceBundlesfound in the resources subpackage of the specified class's package. - See Also:
-
getResourceMap
Returns achainof two or more ResourceMaps. The first encapsulates the ResourceBundles defined for the all of the classes betweenstartClassandstopClassinclusive. 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
ResourceMapthat contains resources loaded fromResourceBundlesfound in the resources subpackage of the specified class's package. - See Also:
-
getResourceMap
Returns thechainof ResourceMaps that's shared by the entire application, beginning with the one defined for the Application class, i.e. the value of theapplicationClassproperty.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
Return this application's ActionManager.- Returns:
- this application's ActionManager.
- See Also:
-
setActionManager
Change this application'sActionManager. AnApplicationContextsubclass that wanted to fundamentally change the wayActionManagerswere 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 sharedActionMapchain for the entireApplication.This is just a convenience method that calls
ActionManager.getActionMap(). It's defined as:return getActionManager().getActionMap()
- Returns:
- the
ActionMapchain for the entireApplication. - See Also:
-
getActionMap
Returns theApplicationActionMapchain 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)
- Parameters:
actionsClass-actionsObject-- Returns:
- the
ActionMapchain for the entireApplication. - See Also:
-
getActionMap
Defined asgetActionMap(actionsObject.getClass(), actionsObject).- Parameters:
actionsObject-- Returns:
- the
ActionMapfor the specified object - See Also:
-
getLocalStorage
The sharedLocalStorageobject.- Returns:
- the shared
LocalStorageobject.
-
setLocalStorage
The sharedLocalStorageobject.- Parameters:
localStorage- the sharedLocalStorageobject.
-
getSessionStorage
The sharedSessionStorageobject.- Returns:
- the shared
SessionStorageobject.
-
setSessionStorage
The sharedSessionStorageobject.- Parameters:
sessionStorage- the sharedSessionStorageobject.
-
getClipboard
Return a sharedClipboard.- Returns:
- A shared
Clipboard.
-
getFocusOwner
Returns the application's focus owner.- Returns:
- The application's focus owner.
-
addTaskService
Register a new TaskService with the application. The task service then be retrieved by name viagetTaskService(String).- Parameters:
taskService- Task service to register
-
removeTaskService
Unregister a previously registered TaskService. The task service is not shut down.- Parameters:
taskService- TaskService to unregister
-
getTaskService
Look up a task service by name.- Parameters:
name- Name of the task service to retrieve.- Returns:
- Task service found, or null if no service of that name found
-
getTaskService
Returns the default TaskService, i.e. the one named "default":return getTaskService("default"). TheApplicationAction actionPerformedmethod executes backgroundTaskson the default TaskService. Application's can launch Tasks in the same way, e.g.Application.getInstance().getContext().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.
-