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 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 global BeanContext. 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 the ClassLoaderProvider to be used.
        Returns:
        the ClassLoaderProvider
      • setClassLoaderProvider

        void setClassLoaderProvider​(ClassLoaderProvider provider)
        Sets the ClassLoaderProvider 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 new MessageOutput 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 associated MessageOutput object. Before that the passed in resource IDs (which can be either resource IDs or instances of the Message class) will be resolved.
        Parameters:
        resMsg - the resource defining the message to be displayed
        resTitle - the resource defining the message box's title (can be null)
        msgType - the message type (one of the MESSAGE_XXX constants of MessageOutput)
        btnType - the button type (one of the BTN_XXX constants of MessageOutput)
        Returns:
        the message box's return value (one of the RET_XXX constants of MessageOutput)
        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 Builder instance. This instance can be used for processing a builder definition file. Note that the returned Builder object should only be used by a single thread.
        Returns:
        the new Builder instance
      • initBuilderData

        ApplicationBuilderData initBuilderData()
        Returns an initialized ApplicationBuilderData 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 ID
        resID - 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 a Message object.
        Parameters:
        msg - the resource definition (must not be null)
        Returns:
        the found resource
        Throws:
        MissingResourceException - if the resource cannot be found
        IllegalArgumentException - 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 of Message. 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 ID
        resID - 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 a Message object.
        Parameters:
        msg - defines the resource (must not be null)
        Returns:
        the found resource
        Throws:
        MissingResourceException - if the resource cannot be found
        IllegalArgumentException - 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 to getResourceText(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's ActionStore.
        Returns:
        the application's action store
      • setActionStore

        void setActionStore​(ActionStore actionStore)
        Sets the application's ActionStore. 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 the TransformerContext.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 the ApplicationContext. All components that have access to an ApplicationContext can also obtain or manipulate the data stored in these properties. Because the ApplicationContext 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 class
        value - the new value for this property
        Throws:
        IllegalArgumentException - if the property class is null