|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.binding.beans.Model
com.jgoodies.uif.application.ApplicationContext
public final class ApplicationContext
Provides shared access for Swing application data. Addresses the following topics:
@Action
annotation.
TODO: Consider re-reading action values to enable users to switch the Locale and update action views automatically. The current code just invalidates the ActionMap cache and requires to rebuild the UI.
Method Summary | |
---|---|
void |
clearActionMap(Object target)
Clears the ActionMap cache entry for the given target. |
protected ResourceMap |
createApplicationResourceMap()
Creates and returns the application-level ResourceMap. |
static Action |
getAction(Object target,
String actionName)
Deprecated. Replaced by Application.getAction(Object, String) |
ActionMap |
getActionMap(Object target)
Looks up and returns the ActionMap for the given target. |
ActionMap |
getActionMap(Object target,
ResourceMap resourceMap)
Looks up and returns the ActionMap for the given target. |
Application |
getApplication()
Returns this context's Application. |
Class<? extends Application> |
getApplicationClass()
Returns the class of this context's application. |
protected String |
getApplicationPreferencesNodeName()
Returns the preferences path name for this application. |
static ApplicationContext |
getInstance()
Lazily creates and returns the single instance of this application context. |
ResourceMap |
getResourceMap()
Lazily creates and returns the application-level ResourceMap. |
ResourceMap |
getResourceMap(Class<?> type)
Looks up and returns a ResourceMap for the given class. |
Preferences |
getSystemPreferences()
Returns this application's root preference node for the system. |
Preferences |
getUserPreferences()
Returns this application's root preference node for the calling user. |
Methods inherited from class com.jgoodies.binding.beans.Model |
---|
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, equals, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, fireMultiplePropertiesChanged, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ApplicationContext getInstance()
public Class<? extends Application> getApplicationClass()
public Application getApplication()
public ResourceMap getResourceMap()
public ResourceMap getResourceMap(Class<?> type)
The class-level and package-level ResourceBundles are optional, the application-level bundle is mandatory. The application-level ResourceMap is the parent of all package-level ResourceMaps. A package-level ResourceMap - if any - is the parent of the class-level ResourceMaps for all classes in that package. If the package-level bundle is absent, the application-wide ResourceMap is used as direct parent for the class-level ResourceMap - if any.
For class mypackage.MyClass and Application apppackage.MyApplication the following resource bundles are searched to build ResourceMaps: mypackage.resources.MyClass (optional class-level), mypackage.resources.Package (optional package-level), apppackage.resources.MyApplication (mandatory application-level).
When looking for a resource, the ResourceMap first uses its own ResourceBundle. In case the resource is missing there, the lookup continues with the ResourceMap's parent ResourceMap. A resource lookup fails, if all ResourceMaps in this path miss the resource.
type
- a class to lookup resources for
type
is not null
, otherwise this application's resource mapResourceMap
protected ResourceMap createApplicationResourceMap()
If the application has not been launched, this methods returns the resource map for Application.class.
Subclasses may override this method to set a parent ResourceMap that is shared by multiple applications.
@Deprecated public static Action getAction(Object target, String actionName)
Application.getAction(Object, String)
actionName
of the given target object.
This a convenience method for
ApplicationContext.getInstance().getActionMap(target).get(actionName)
.
Note: Requesting an Action will create
a hard reference to the given target, so it cannot be cleared
by the garbage collector until the ActionMap entry is cleared
using clearActionMap(Object)
.
target
- the instance that will perform the ActionactionName
- used to look up the associated Action method
actionName
of the given target.
IllegalArgumentException
- if the action is absent.public ActionMap getActionMap(Object target)
@Action
annotation.
The actions text, icon, description, etc. are initialized
from the target's resource map. If you want to use a custom
resource map, use getActionMap(Object, ResourceMap)
instead.
Note: Requesting an ActionMap will create
a hard reference to the given target, so it cannot be cleared
by the garbage collector until the ActionMap entry is cleared
using clearActionMap(Object)
.
target
- the object that shall execute the Actions
public ActionMap getActionMap(Object target, ResourceMap resourceMap)
@Action
annotation.
The actions text, icon, description, etc. are initialized
from the given resource map. If you can use the target's
resource map, use getActionMap(Object)
instead.
Note: Requesting an ActionMap will create
a hard reference to the given target, so it cannot be cleared
by the garbage collector until the ActionMap entry is cleared
using clearActionMap(Object)
.
target
- the object that shall execute the ActionsresourceMap
- used to initialize the action text, icon, etc
public void clearActionMap(Object target)
target
- the key in the ActionMap cache
NullPointerException
- if target
is null
public Preferences getUserPreferences()
Preferences.userRoot()
instead.For example the user preferences root of the Application class com.package1.MyApp uses the path <user-root>/<application-root> which is <user-root>/com/package1/MyApp by default.
SecurityException
- if a security manager is present and
it denies RuntimePermission("preferences").RuntimePermission
,
Preferences
public Preferences getSystemPreferences()
Preferences.systemRoot()
instead.For example the system preferences root of the Application class com.package1.MyApp uses the path <system-root>/<application-root> which is <system-root>/com/package1/MyApp by default.
SecurityException
- if a security manager is present and
it denies RuntimePermission("preferences").RuntimePermission
,
Preferences
protected String getApplicationPreferencesNodeName()
Subclasses may override to use a simpler name
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |