org.norvelle.textcite
Class Application

java.lang.Object
  extended by org.norvelle.textcite.Application

public class Application
extends java.lang.Object

Title: Application.java

Description: Startup class for the TextCite GUI. Also provides a universal point of access for a number of global objects, including the CiteBook object.

Copyright: Copyright (c) 2006 by Erik Norvelle

Version:
0.1
Author:
Erik Norvelle

Field Summary
static double APPLICATION_VERSION_NUMBER
           
static java.lang.String APPLICATION_VERSION_STRING
           
static java.lang.String CATEGORY_CLIPBOARD_TPROP
           
static java.lang.String CATEGORY_EXPANSION_TPROP
           
static java.lang.String ENGLISH_INTERFACE
           
static int EXPORT_FILE_CHOOSER
           
static int LOAD_FILE_CHOOSER
           
static java.util.logging.Logger logger
          A global Logger instance
static int OS_OSX
           
static int OS_UNIX
           
static int OS_WINDOWS
           
static java.lang.String OUTLINE_EXPANSION_TPROP
           
static int SAVE_FILE_CHOOSER
           
static java.lang.String SPANISH_INTERFACE
           
static java.lang.String[] supportedLocales
           
static java.util.HashMap<java.lang.String,java.lang.Object> transientProperties
          A HashMap that stores transient data for the application... not saved or restored from disk
 
Constructor Summary
Application(boolean useGUI)
          Construct and show the application.
 
Method Summary
static void exit()
          Terminate the application, first saving the global preferences.
static CiteBook getCiteBook()
          Getter method for the application CiteBook
static Clipboard getClipboard()
           
static javax.swing.JFileChooser getFileChooser(int chooserType)
          Returns our global JFileChooser instance.
static HelpBroker getHelpBroker()
          Access to the global HelpBroker object
static java.lang.String getLocaleIdentifier()
          Returns the current locale identifier
static java.lang.String getLocalizedString(java.lang.String stringName)
          Returns a localized string, given the string's identifier
static MainFrame getMainFrame()
          Returns the main JFrame of the application
static int getNextId()
          Allow other objects to request an id that is unique for a given CiteBook.
static int getOS()
          Returns an integer corresponding to the operating system we are running under.
static PreferenceManager getPrefs()
          Access to the global preferences container
static void initCiteBook()
          Used for setting up an empty CiteBook
static boolean initializing()
          Returns true if the application is in the process of initializing.
static boolean isLocaleSupported(java.lang.String localeId)
          Determines whether a given locale is supported.
static void load(java.io.File file, SaveLoadStatusListener status)
          Read the CiteBook from the specified file.
static void logError(java.lang.String message)
          Log a given message to the Logger, with the level SEVERE
static void logInfo(java.lang.String message)
          Log a given message to the Logger, with the level INFO
static void main(java.lang.String[] args)
          Application entry point.
static void save(java.io.File file, SaveLoadStatusListener status)
          Save the CiteBook to a given file.
static void setCiteBook(CiteBook cb)
          Setter method for the application CiteBook... to be used in order to run the TextCite engine without the GUI.
static void setLanguage(java.lang.String langId)
          Change the language of the GUI.
static void setNextId(int i)
          Allows the global id generator to be reset to a given value upon loading a different CiteBook.
static void testInit()
          Initialize all aspects of the Application that are required for running JUnit tests
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLICATION_VERSION_STRING

public static final java.lang.String APPLICATION_VERSION_STRING
See Also:
Constant Field Values

APPLICATION_VERSION_NUMBER

public static final double APPLICATION_VERSION_NUMBER
See Also:
Constant Field Values

ENGLISH_INTERFACE

public static final java.lang.String ENGLISH_INTERFACE
See Also:
Constant Field Values

SPANISH_INTERFACE

public static final java.lang.String SPANISH_INTERFACE
See Also:
Constant Field Values

supportedLocales

public static final java.lang.String[] supportedLocales

OUTLINE_EXPANSION_TPROP

public static final java.lang.String OUTLINE_EXPANSION_TPROP
See Also:
Constant Field Values

CATEGORY_EXPANSION_TPROP

public static final java.lang.String CATEGORY_EXPANSION_TPROP
See Also:
Constant Field Values

CATEGORY_CLIPBOARD_TPROP

public static final java.lang.String CATEGORY_CLIPBOARD_TPROP
See Also:
Constant Field Values

SAVE_FILE_CHOOSER

public static final int SAVE_FILE_CHOOSER
See Also:
Constant Field Values

EXPORT_FILE_CHOOSER

public static final int EXPORT_FILE_CHOOSER
See Also:
Constant Field Values

LOAD_FILE_CHOOSER

public static final int LOAD_FILE_CHOOSER
See Also:
Constant Field Values

OS_WINDOWS

public static final int OS_WINDOWS
See Also:
Constant Field Values

OS_OSX

public static final int OS_OSX
See Also:
Constant Field Values

OS_UNIX

public static final int OS_UNIX
See Also:
Constant Field Values

logger

public static java.util.logging.Logger logger
A global Logger instance


transientProperties

public static java.util.HashMap<java.lang.String,java.lang.Object> transientProperties
A HashMap that stores transient data for the application... not saved or restored from disk

Constructor Detail

Application

public Application(boolean useGUI)
Construct and show the application.

Method Detail

initCiteBook

public static void initCiteBook()
Used for setting up an empty CiteBook


testInit

public static void testInit()
Initialize all aspects of the Application that are required for running JUnit tests


initializing

public static boolean initializing()
Returns true if the application is in the process of initializing. Needed to prevent infinite loops during the initialization of the CiteBook object.

Returns:
True if initializing, false otherwise.

logInfo

public static void logInfo(java.lang.String message)
Log a given message to the Logger, with the level INFO


logError

public static void logError(java.lang.String message)
Log a given message to the Logger, with the level SEVERE


load

public static void load(java.io.File file,
                        SaveLoadStatusListener status)
                 throws java.io.FileNotFoundException,
                        java.io.IOException,
                        java.lang.ClassNotFoundException
Read the CiteBook from the specified file. The CiteBook is serialized in XML format, so that the files can be edited by hand.

Parameters:
file - The File object to be opened and loaded from
Throws:
java.io.FileNotFoundException - Thrown if the file cannot be located
java.io.IOException - Thrown if a general IO error occurs
java.lang.ClassNotFoundException - Thrown if a class mentioned in the serialization cannot be instantiated

save

public static void save(java.io.File file,
                        SaveLoadStatusListener status)
                 throws java.io.FileNotFoundException,
                        java.io.IOException
Save the CiteBook to a given file. Uses the XStream object serializing library to store the CiteBook in XML format.

Parameters:
file - The File object to write to.
Throws:
java.io.FileNotFoundException - Thrown if the file cannot be opened for writing
java.io.IOException - Thrown if an unspecified output error occurs

exit

public static void exit()
Terminate the application, first saving the global preferences.


getNextId

public static int getNextId()
Allow other objects to request an id that is unique for a given CiteBook.


setNextId

public static void setNextId(int i)
Allows the global id generator to be reset to a given value upon loading a different CiteBook.


getCiteBook

public static CiteBook getCiteBook()
Getter method for the application CiteBook

Returns:
CiteBook

setCiteBook

public static void setCiteBook(CiteBook cb)
Setter method for the application CiteBook... to be used in order to run the TextCite engine without the GUI.

Parameters:
cb - The CiteBook to be set as the default CiteBook.

getClipboard

public static Clipboard getClipboard()
Returns:
The global Clipboard object.

getLocalizedString

public static java.lang.String getLocalizedString(java.lang.String stringName)
Returns a localized string, given the string's identifier


getLocaleIdentifier

public static java.lang.String getLocaleIdentifier()
Returns the current locale identifier


isLocaleSupported

public static boolean isLocaleSupported(java.lang.String localeId)
Determines whether a given locale is supported.

Parameters:
localeId - The string identifier for the locale to be tested
Returns:
True if the locale has a messageProperties file, otherwise false

setLanguage

public static void setLanguage(java.lang.String langId)
Change the language of the GUI. This routine is located here, because it involves creating a whole new MainFrame object, which is owned by the Application.

Parameters:
langId - The identifier of the language chosen (one of the constants defined in the Application class)

getHelpBroker

public static HelpBroker getHelpBroker()
Access to the global HelpBroker object


getPrefs

public static PreferenceManager getPrefs()
Access to the global preferences container


getFileChooser

public static javax.swing.JFileChooser getFileChooser(int chooserType)
Returns our global JFileChooser instance.

Parameters:
chooserType - Indicate the file chooser to be returned.
Returns:

getOS

public static int getOS()
Returns an integer corresponding to the operating system we are running under. (Windows, OS X, Other Unix)


getMainFrame

public static MainFrame getMainFrame()
Returns the main JFrame of the application


main

public static void main(java.lang.String[] args)
Application entry point.

Parameters:
args - String[]