Package net.sf.jguiraffe.gui.app
Interface ApplicationContext
-
- All Superinterfaces:
TransformerContext
- All Known Implementing Classes:
ApplicationContextImpl
public interface ApplicationContext extends TransformerContext
Definition of an interface for accessing application global information.
This interface defines a context of the actual running application. This context stores some important information and helper objects that are usually needed by many components in the application. The main application class of this framework will provide access to the global context object so the information stored here can be obtained from everywhere.
- Version:
- $Id: ApplicationContext.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ActionStore
getActionStore()
Returns the application'sActionStore
.BeanContext
getBeanContext()
Returns the application globalBeanContext
.ClassLoaderProvider
getClassLoaderProvider()
Returns theClassLoaderProvider
to be used.org.apache.commons.configuration.Configuration
getConfiguration()
Returns a reference to the configuration data of the running application.GUISynchronizer
getGUISynchronizer()
Returns the GUI synchronizer.Window
getMainWindow()
Returns the application's main window.MessageOutput
getMessageOutput()
Returns a reference to the object for displaying messages.Object
getResource(Object resID)
Convenience method for looking up a resource.Object
getResource(Object groupID, Object resID)
Convenience method for looking up a resource specified as group and resource ID.Object
getResource(Message msg)
Convenience method for looking up a resource that is specified as aMessage
object.String
getResourceText(Object resID)
Convenience method for looking up the text of a specified resource.String
getResourceText(Object groupID, Object resID)
Convenience method for looking up the text of a resource specified as group and resource ID.String
getResourceText(Message msg)
Convenience method for looking up the text of a resource specified as aMessage
object.ApplicationBuilderData
initBuilderData()
Returns an initializedApplicationBuilderData
object that can be used for calling the GUI builder.int
messageBox(Object resMsg, Object resTitle, int msgType, int btnType)
A convenience method for displaying a message box.Builder
newBuilder()
Returns a new
instance.Builder
void
setActionStore(ActionStore actionStore)
Sets the application'sActionStore
.void
setClassLoaderProvider(ClassLoaderProvider provider)
Sets theClassLoaderProvider
to be used.void
setConfiguration(org.apache.commons.configuration.Configuration configuration)
Sets the global configuration object of this application.void
setLocale(Locale locale)
Allows to set the current locale.void
setMainWindow(Window mainWindow)
Allows to set the application's main window.void
setMessageOutput(MessageOutput msg)
Sets the message output object to be used by this application.void
setResourceManager(ResourceManager rm)
Sets the resource manager.<T> void
setTypedProperty(Class<T> propCls, T value)
Sets the value of a typed property.-
Methods inherited from interface net.sf.jguiraffe.transform.TransformerContext
getLocale, getResourceManager, getTypedProperty, getValidationMessageHandler, properties
-
-
-
-
Method Detail
-
setLocale
void setLocale(Locale locale)
Allows to set the current locale. This locale can be used for internationalization purposes, e.g. for resolving resources.- Parameters:
locale
- the locale of the actual user
-
setResourceManager
void setResourceManager(ResourceManager rm)
Sets the resource manager. All accesses to system resources are performed using this object.- Parameters:
rm
- the resource manager to use
-
getConfiguration
org.apache.commons.configuration.Configuration getConfiguration()
Returns a reference to the configuration data of the running application. All configuration information can be obtained using this object.- Returns:
- the global configuration object
-
setConfiguration
void setConfiguration(org.apache.commons.configuration.Configuration configuration)
Sets the global configuration object of this application.- Parameters:
configuration
- the configuration object
-
getBeanContext
BeanContext getBeanContext()
Returns the application globalBeanContext
. This is the main entry point into the dependency injection framework. From this object the globally defined beans can be obtained.- Returns:
- the global bean context
-
getClassLoaderProvider
ClassLoaderProvider getClassLoaderProvider()
Returns theClassLoaderProvider
to be used.- Returns:
- the
ClassLoaderProvider
-
setClassLoaderProvider
void setClassLoaderProvider(ClassLoaderProvider provider)
Sets theClassLoaderProvider
to be used. This object is consulted when a class is to be resolved by name.- Parameters:
provider
- the class loader provider to be used
-
getMessageOutput
MessageOutput getMessageOutput()
Returns a reference to the object for displaying messages. This object can be used to create message boxes.- Returns:
- the object for displaying messages
-
setMessageOutput
void setMessageOutput(MessageOutput msg)
Sets the message output object to be used by this application.- Parameters:
msg
- the newMessageOutput
object
-
messageBox
int messageBox(Object resMsg, Object resTitle, int msgType, int btnType)
A convenience method for displaying a message box. This method invokes the application's associatedMessageOutput
object. Before that the passed in resource IDs (which can be either resource IDs or instances of theMessage
class) will be resolved.- Parameters:
resMsg
- the resource defining the message to be displayedresTitle
- the resource defining the message box's title (can be null)msgType
- the message type (one of theMESSAGE_XXX
constants ofMessageOutput
)btnType
- the button type (one of theBTN_XXX
constants ofMessageOutput
)- Returns:
- the message box's return value (one of the
RET_XXX
constants ofMessageOutput
) - See Also:
MessageOutput
-
getGUISynchronizer
GUISynchronizer getGUISynchronizer()
Returns the GUI synchronizer. This object is needed for updating the GUI in a different thread than the main event dispatch thread.- Returns:
- the
GUISynchronizer
object
-
getMainWindow
Window getMainWindow()
Returns the application's main window.- Returns:
- the main window of this application
-
setMainWindow
void setMainWindow(Window mainWindow)
Allows to set the application's main window.- Parameters:
mainWindow
- the new main window
-
newBuilder
Builder newBuilder()
Returns a new
instance. This instance can be used for processing a builder definition file. Note that the returnedBuilder
Builder
object should only be used by a single thread.- Returns:
- the new
Builder
instance
-
initBuilderData
ApplicationBuilderData initBuilderData()
Returns an initializedApplicationBuilderData
object that can be used for calling the GUI builder. Most of the properties of the returned object are already set to default values, so only specific settings must be performed.- Returns:
- an initialized GUI builder parameter object
-
getResource
Object getResource(Object groupID, Object resID)
Convenience method for looking up a resource specified as group and resource ID.- Parameters:
groupID
- the resource group IDresID
- the resource ID- Returns:
- the found resource
- Throws:
MissingResourceException
- if the resource cannot be found
-
getResource
Object getResource(Message msg)
Convenience method for looking up a resource that is specified as aMessage
object.- Parameters:
msg
- the resource definition (must not be null)- Returns:
- the found resource
- Throws:
MissingResourceException
- if the resource cannot be foundIllegalArgumentException
- if then message is undefined
-
getResource
Object getResource(Object resID)
Convenience method for looking up a resource. The passed in object is checked to be an instance ofMessage
. If this is the case, the resource group and the resource ID are extracted from this object. Otherwise the passed in object is interpreted as resource ID and the default resource group will be used.- Parameters:
resID
- the resource ID- Returns:
- the found resource
- Throws:
MissingResourceException
- if the resource cannot be found
-
getResourceText
String getResourceText(Object groupID, Object resID)
Convenience method for looking up the text of a resource specified as group and resource ID.- Parameters:
groupID
- the resource group IDresID
- the resource ID- Returns:
- the found resource text
- Throws:
MissingResourceException
- if the resource cannot be found
-
getResourceText
String getResourceText(Message msg)
Convenience method for looking up the text of a resource specified as aMessage
object.- Parameters:
msg
- defines the resource (must not be null)- Returns:
- the found resource
- Throws:
MissingResourceException
- if the resource cannot be foundIllegalArgumentException
- if the message is undefined
-
getResourceText
String getResourceText(Object resID)
Convenience method for looking up the text of a specified resource. This method works analogous togetResourceText(Object)
, especially the passed in object can be an instance of
.Message
- Parameters:
resID
- defines the requested resource- Returns:
- the found resource
- Throws:
MissingResourceException
- if the resource cannot be found
-
getActionStore
ActionStore getActionStore()
Returns the application'sActionStore
.- Returns:
- the application's action store
-
setActionStore
void setActionStore(ActionStore actionStore)
Sets the application'sActionStore
. This object contains the definitions for all top level actions known to the application.- Parameters:
actionStore
- the new action store
-
setTypedProperty
<T> void setTypedProperty(Class<T> propCls, T value)
Sets the value of a typed property. With this method properties can be set that can later be queried using theTransformerContext.getTypedProperty(Class)
method. This provides type-safe access to arbitrary properties. A use case for this method is the storage of application-global data in theApplicationContext
. All components that have access to anApplicationContext
can also obtain or manipulate the data stored in these properties. Because theApplicationContext
can be accessed from multiple threads (e.g. the event dispatch thread and the worker thread used by the application to execute background tasks) an implementation should ensure a proper synchronization. A typed property can be cleared by passing the value null. The property class must not be null, otherwise an exception is thrown.- Type Parameters:
T
- the type of the property- Parameters:
propCls
- the property classvalue
- the new value for this property- Throws:
IllegalArgumentException
- if the property class is null
-
-