de.esprit.appsuite.launch

## Class ApplicationContext

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.common.log.LogSupportAdapter
    - - de.esprit.appsuite.launch.ApplicationContext

- All Implemented Interfaces:
    ErrorHandler, Initializable, Exitable, LogSupport, Dumpable, java.io.Closeable, java.lang.AutoCloseable
  Direct Known Subclasses:
    AppStarterContext, ClientContext, ServerContext, TableEditContext

      public class ApplicationContext
      extends LogSupportAdapter
      implements ErrorHandler, Exitable, java.io.Closeable, Initializable

  This is the application context which provides access to all application globals such as `LogChannel`, `Version`, `ErrorHandler` etc...
  Author:
    Rainer Buesch

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static boolean` | `isExitOnClose`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ApplicationContext()`
    `ApplicationContext(ApplicationConfig appCfg)`
    `ApplicationContext(java.lang.String applicationName)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `cancelTask(TaskId taskId)` Cancels the async task.
    `void` | `checkInitialized()` Checks whether initialization has yet been done and throws an `NotInitializedException` if not.
    `void` | `close()`
    `boolean` | `confirmCancelAllAsyncActivity()` Checks for current async activity.
    `protected ErrorHandler` | `createErrorHandler()`
    `protected License` | `createLicense()`
    `protected TaskManager` | `createTaskManager()`
    `protected java.lang.Thread.UncaughtExceptionHandler` | `createUncaughtExceptionHandler()` Creates a Handler for uncaught system exceptions such as OutOfMemoryError
    `boolean` | `exit()` Exits the VM by default.
    `ApplicationConfig` | `getApplicationConfig()`
    `java.lang.String` | `getApplicationName()`
    `<V extends Version> V` | `getCustomVersion()` Returns the custom Version of this application.
    `Database` | `getDatabase()`
    `ErrorHandler` | `getErrorHandler()`
    `<V extends Version> V` | `getEspritVersion()` Returns the esprit software Version of this application.
    `JavaVersionManager` | `getJavaVersionManager()`
    `License` | `getLicense()`
    `<F extends ApplicationMainFrame> F` | `getMainFrame()` Returns the main-frame of the application as the central access point to it's GUI.
    `java.util.EnumSet<Language>` | `getSupportedLanguages()`
    `TaskManager` | `getTaskManager()`
    `TextEditorFrame` | `getTextEditor(boolean isCreateNew)`
    `boolean` | `hasMainFrame()` Tells whether the main-frame is set, and thus this is a GUI application
    `void` | `init()` Performs the initialization of this class.
    `boolean` | `isClosed()` Returns true when the client was terminated.
    `protected boolean` | `isDefaultContext()` If there are several contexts within the same VM then only one of them can be the default-context.
    `boolean` | `isGuiClient()` Tells whether this client has a GUI
    `boolean` | `isInitialized()` Tells whether initialization has yet been done.
    `void` | `loadTranslations(Language language)` Loads the translation tables for this context.
    `void` | `registerForClose(CloseableComponent comp)`
    `void` | `setDatabase(Database database)`
    `static void` | `setExitOnClose(boolean isExitOnClose)` Tells whether the VM will exit when close() is called.
    `void` | `setMainFrame(ApplicationMainFrame mainFrame)` Sets the MainFrame for this application.
    `void` | `showError(java.lang.Object caller, java.lang.Exception e)`
    `void` | `showError(java.lang.Object caller, java.lang.String message, java.lang.Exception e)`
    `void` | `showError(java.lang.Object caller, java.lang.String message, java.lang.String details, java.lang.Exception e)`
    `void` | `showInfo(java.lang.Object caller, java.lang.String message)`
    `void` | `showInfo(java.lang.Object caller, java.lang.String message, java.lang.String details)`
    `void` | `showWarning(java.lang.Object caller, java.lang.String message)`
    `void` | `showWarning(java.lang.Object caller, java.lang.String message, java.lang.String details)`
    `DumpString` | `toDumpString(DumpString s)` This method allows subclasses to add values to the existing DumpString of the superclass.
    `ToString` | `toString(ToString s)` This method allows subclasses to add values to the existing ToString of the superclass.

    - ### Methods inherited from class de.esprit.common.log.LogSupportAdapter

      `getLogChannel, getLogLevel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel, setLogLevel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### isExitOnClose

          protected static boolean isExitOnClose

  - ### Constructor Detail

    - #### ApplicationContext

          public ApplicationContext()

    - #### ApplicationContext

          public ApplicationContext(java.lang.String applicationName)

    - #### ApplicationContext

          public ApplicationContext(ApplicationConfig appCfg)

  - ### Method Detail

    - #### setExitOnClose

          public static void setExitOnClose(boolean isExitOnClose)

      Tells whether the VM will exit when close() is called. The default is true!

    - #### init

          public void init()
                    throws java.lang.Exception

      Description copied from interface: `Initializable`
      Performs the initialization of this class. Note that the implementation should maintain an isInitialized flag which must be set when initialization has completed.
      Specified by:
        `init` in interface `Initializable`
      Throws:
        `java.lang.Exception`

    - #### isInitialized

          public final boolean isInitialized()

      Description copied from interface: `Initializable`
      Tells whether initialization has yet been done.
      Specified by:
        `isInitialized` in interface `Initializable`

    - #### checkInitialized

          public void checkInitialized()
                                throws NotInitializedException

      Description copied from interface: `Initializable`
      Checks whether initialization has yet been done and throws an `NotInitializedException` if not.
      Specified by:
        `checkInitialized` in interface `Initializable`
      Throws:
        `NotInitializedException`

    - #### isClosed

          public final boolean isClosed()

      Returns true when the client was terminated.

    - #### close

          public void close()

      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### exit

          public boolean exit()

      Exits the VM by default. Should return false if the exit was anyhow prevented.
      Specified by:
        `exit` in interface `Exitable`
      Returns:
        false if the exit was actually prevented by any check

    - #### isGuiClient

          public boolean isGuiClient()

      Tells whether this client has a GUI

    - #### getApplicationName

          public java.lang.String getApplicationName()

    - #### getApplicationConfig

          public ApplicationConfig getApplicationConfig()

    - #### getEspritVersion

          public final <V extends Version> V getEspritVersion()

      Returns the esprit software Version of this application.

    - #### getCustomVersion

          public final <V extends Version> V getCustomVersion()

      Returns the custom Version of this application.

    - #### getSupportedLanguages

          public java.util.EnumSet<Language> getSupportedLanguages()

    - #### loadTranslations

          public void loadTranslations(Language language)

      Loads the translation tables for this context.

    - #### getLicense

          public License getLicense()

    - #### setDatabase

          public final void setDatabase(Database database)

    - #### getDatabase

          public Database getDatabase()

    - #### getTaskManager

          public TaskManager getTaskManager()

    - #### getJavaVersionManager

          public JavaVersionManager getJavaVersionManager()

    - #### getTextEditor

          public TextEditorFrame getTextEditor(boolean isCreateNew)

    - #### cancelTask

          public boolean cancelTask(TaskId taskId)

      Cancels the async task.
      Returns:
        true if the task was actually hit for cancellation

    - #### registerForClose

          public final void registerForClose(CloseableComponent comp)

    - #### getMainFrame

          public <F extends ApplicationMainFrame> F getMainFrame()

      Returns the main-frame of the application as the central access point to it's GUI. The main-frame may be null if the application has no GUI.

    - #### setMainFrame

          public void setMainFrame(ApplicationMainFrame mainFrame)

      Sets the MainFrame for this application.

    - #### hasMainFrame

          public final boolean hasMainFrame()

      Tells whether the main-frame is set, and thus this is a GUI application

    - #### getErrorHandler

          public ErrorHandler getErrorHandler()

    - #### showError

          public void showError(java.lang.Object caller,
                       java.lang.Exception e)

      Specified by:
        `showError` in interface `ErrorHandler`

    - #### showError

          public void showError(java.lang.Object caller,
                       java.lang.String message,
                       java.lang.Exception e)

      Specified by:
        `showError` in interface `ErrorHandler`

    - #### showError

          public void showError(java.lang.Object caller,
                       java.lang.String message,
                       java.lang.String details,
                       java.lang.Exception e)

      Specified by:
        `showError` in interface `ErrorHandler`

    - #### showWarning

          public void showWarning(java.lang.Object caller,
                         java.lang.String message)

      Specified by:
        `showWarning` in interface `ErrorHandler`

    - #### showWarning

          public void showWarning(java.lang.Object caller,
                         java.lang.String message,
                         java.lang.String details)

      Specified by:
        `showWarning` in interface `ErrorHandler`

    - #### showInfo

          public void showInfo(java.lang.Object caller,
                      java.lang.String message)

      Specified by:
        `showInfo` in interface `ErrorHandler`

    - #### showInfo

          public void showInfo(java.lang.Object caller,
                      java.lang.String message,
                      java.lang.String details)

      Specified by:
        `showInfo` in interface `ErrorHandler`

    - #### isDefaultContext

          protected boolean isDefaultContext()

      If there are several contexts within the same VM then only one of them can be the default-context. All logging output of Util.log* methods will be passed to the default-context.
      See Also:
        `AppUtil.getDefaultContext()`

    - #### createLicense

          protected License createLicense()
                                   throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### createTaskManager

          protected TaskManager createTaskManager()

    - #### createErrorHandler

          protected ErrorHandler createErrorHandler()

    - #### createUncaughtExceptionHandler

          protected java.lang.Thread.UncaughtExceptionHandler createUncaughtExceptionHandler()

      Creates a Handler for uncaught system exceptions such as OutOfMemoryError

    - #### confirmCancelAllAsyncActivity

          public boolean confirmCancelAllAsyncActivity()

      Checks for current async activity. If any it creates a `ConfirmDialog` listing what the current async activity is.
      Returns:
        true if the dialog was confirmed or no async activity exists.

    - #### toString

          public ToString toString(ToString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing ToString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toString` in interface `Dumpable`
      Overrides:
        `toString` in class `DumpableObject`

    - #### toDumpString

          public DumpString toDumpString(DumpString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing DumpString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toDumpString` in interface `Dumpable`
      Overrides:
        `toDumpString` in class `DumpableObject`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.