com.jgoodies.uif.application
Class AbstractUIFApplication

java.lang.Object
  extended by com.jgoodies.binding.beans.Model
      extended by com.jgoodies.uif.application.Application
          extended by com.jgoodies.uif.application.AbstractUIFApplication
All Implemented Interfaces:
com.jgoodies.binding.beans.Observable, Serializable

public abstract class AbstractUIFApplication
extends Application

An abstract class that organizes the application startup process. It therefore defines a default startup sequence and provides some convenience code, useful for this task.

This class uses the JGoodies foundation classes only. In contrast, the DefaultApplicationStarter uses more of the JGoodies convenience classes.

Since:
1.8
Version:
$Revision: 1.24 $
Author:
Karsten Lentzsch
See Also:
Application, Splash, Serialized Form

Constructor Summary
AbstractUIFApplication()
           
 
Method Summary
protected  void addLogFileHandler(File logDirectory, String logFilePattern)
          Adds a FileHandler to the root Logger that writes log files with the specified pattern to the given directory.
protected abstract  void configureHelp()
          Configures the application wide help.
protected abstract  void configureLogging()
          Configures the logging.
protected  void configureLoggingFromProperties(String configurationFileName)
          Reads the specified logging configuration properties file and configures the LogManager.
protected abstract  void configureSplash()
          Configures the splash component.
protected abstract  void configureUI()
          Configures all UI related properties: look&feel, system properties, etc.
protected  void disposeFramesAndWindows()
          Disposes all frames and their owned windows.
protected  void ensureParentDirectoryExists(String pattern)
          Ensures that the parent directory exists for the file associated with the specified logging pattern.
protected  void exitSystem()
           
 File getApplicationDataDirectory()
          Lazily looks up and returns the directory that shall be used to store and retrieve application data.
protected  ResourceMap getAppResourceMap()
          Returns the application's application resource map chain.
protected abstract  void launchApplication()
          Brings up the application, it therefore initializes the main frame, checks the setup process, initializes all actions, then builds the main frame, and finally opens it.
protected  void load()
          Loads, configures, initializes, and brings up the application.
protected  File lookupApplicationDataBaseDirectory()
          Looks up and returns the base directory for application data such as log files,project data, etc.
protected  File lookupApplicationDataDirectory()
          Looks up and returns the directory for application data such as log files, project data, etc.
protected  void shutdown()
          Performs cleanup tasks when the application exits.
protected  void startup(String[] args)
          Does a minimal preparation before running the application load process: initializes fields and catches errors.
 
Methods inherited from class com.jgoodies.uif.application.Application
addExitListener, clearActionMap, end, exit, exit, exitAllowed, fireApplicationExiting, getAction, getActionMap, getApplicationExitOnWindowClosingHandler, getResourceMap, launch, removeExitListener
 
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
 

Constructor Detail

AbstractUIFApplication

public AbstractUIFApplication()
Method Detail

startup

protected void startup(String[] args)
Does a minimal preparation before running the application load process: initializes fields and catches errors.

Specified by:
startup in class Application
See Also:
Application.launch(Class, String[]), Application.shutdown()

shutdown

protected void shutdown()
Description copied from class: Application
Performs cleanup tasks when the application exits. This default implementation does nothing; subclasses may override. This method runs on the event dispatching thread.

Overrides:
shutdown in class Application
See Also:
Application.startup(String[]), Application.exit(EventObject), Application.addExitListener(ExitListener)

load

protected void load()
Loads, configures, initializes, and brings up the application.


exitSystem

protected void exitSystem()

configureLogging

protected abstract void configureLogging()
Configures the logging.


configureSplash

protected abstract void configureSplash()
Configures the splash component.


configureHelp

protected abstract void configureHelp()
Configures the application wide help.


configureUI

protected abstract void configureUI()
Configures all UI related properties: look&feel, system properties, etc.


launchApplication

protected abstract void launchApplication()
Brings up the application, it therefore initializes the main frame, checks the setup process, initializes all actions, then builds the main frame, and finally opens it.

TODO: Consider renaming this method to #createAndShowGUI to make it consistent with the examples used in Kathy's Java Tutorial.


getApplicationDataDirectory

public final File getApplicationDataDirectory()
Lazily looks up and returns the directory that shall be used to store and retrieve application data. The real work is delegated to lookupApplicationDataDirectory() which in turn gets the base dir from lookupApplicationDataBaseDirectory().

The default implementation of lookupApplicationDataDirectory() requires the following application resource values: application.id and application.vendor.id.

Examples for the default implementation:

 application.id=Skeleton Pro
 application.vendor.id=JGoodies

 C:\Documents and Files\Karsten\AppData\JGoodies\Skeleton Pro\                  # XP
 C:\Dokumente und Einstellungen\Karsten\Anwendungsdaten\JGoodies\Skeleton Pro\  # XP German
 C:\Users\Karsten\AppData\JGoodies\Skeleton Pro\                                # Vista
 C:\Users\Karsten\Anwendungsdaten\JGoodies\Skeleton Pro\                        # Vista German

 /Users/Karsten/Library/Application Support/JGoodies/Skeleton Pro/              # Mac OS X

 /users/karsten/.jgoodies/skeletonpro/                                          # Solaris, Linux, all other OS
 

Returns:
the application data directory
Since:
1.9.1

getAppResourceMap

protected final ResourceMap getAppResourceMap()
Returns the application's application resource map chain.

Returns:
the application's application resource map chain
See Also:
ApplicationContext.getResourceMap()

ensureParentDirectoryExists

protected final void ensureParentDirectoryExists(String pattern)
Ensures that the parent directory exists for the file associated with the specified logging pattern.

Parameters:
pattern - a pattern as used with the Java logging

disposeFramesAndWindows

protected final void disposeFramesAndWindows()
Disposes all frames and their owned windows.


lookupApplicationDataDirectory

protected File lookupApplicationDataDirectory()
Looks up and returns the directory for application data such as log files, project data, etc. This default implementation returns a platform-specific value. Subclasses may override.

On Windows and Mac the ${application.vendor.id} and ${application.id} are appended to the application base directory. On all other platforms whitespace characters are stripped from the vendor id and application id, and both are in lower case. Also, the path aims to result in a hidden directory by prepending a dot ('.'). Examples:

 <basedir>/JGoodies/Skeleton Pro/   # Windows, Mac
 <basedir>/.jgoodies/skeletonpro/   # Other platforms
 

Returns:
the path to the application data
Throws:
MissingResourceException - if ${application.id} or ${application.vendor.id} is undefined
Since:
1.9.1

lookupApplicationDataBaseDirectory

protected File lookupApplicationDataBaseDirectory()
Looks up and returns the base directory for application data such as log files,project data, etc. This default implementation returns a platform-specific value. Subclasses may override.

On Windows the %APPDATA% environment variable is requested from the System. On the Mac the user home directory is appended by Libraries/Application Support. All other platforms just use the user home dir. Examples:

 C:\Documents and Files\Karsten\AppData\                 # XP
 C:\Dokumente und Einstellungen\Karsten\Anwendungsdaten\ # XP German
 C:\Users\Karsten\AppData\                               # Vista
 C:\Users\Karsten\Anwendungsdaten\                       # Vista German

 /users/Karsten/Library/Application Support/             # Mac OS X

 /users/karsten/                                         # Other OS
 

Returns:
the base directory for application data
Since:
1.9.1

configureLoggingFromProperties

protected void configureLoggingFromProperties(String configurationFileName)
Reads the specified logging configuration properties file and configures the LogManager.

Parameters:
configurationFileName - a properties file to configure the LogManager.
Since:
1.9.1
See Also:
LogManager.readConfiguration(InputStream)

addLogFileHandler

protected void addLogFileHandler(File logDirectory,
                                 String logFilePattern)
Adds a FileHandler to the root Logger that writes log files with the specified pattern to the given directory.

Parameters:
logDirectory - the directory where log files shall be located
logFilePattern - a pattern that shall not contain path information, for example "console%u.log".
Since:
1.9.1


Copyright © 2000-2008 JGoodies Karsten Lentzsch. All Rights Reserved.