edu.northwestern.at.wordhoard.swing
Class WordHoardSettings

java.lang.Object
  extended by edu.northwestern.at.wordhoard.swing.WordHoardSettings

public class WordHoardSettings
extends java.lang.Object

Global settings for WordHoard.

This class holds the static values of global settings used by many other WordHoard classes. This includes the global string resource bundle and the current user information, including the user ID of the currently logged in user. All of these settings are stored in protected variables to allow access but disallow changes once they are initialized at start up.

The WordHoard resource bundle contains definitions for all the string constants used in WordHoardCalc. Once the resource strings have been initialized in the initializeSettings method you can access the strings by calling getString:

String s = WordHoardSettings.getString( "mystring" , "my string" );

To get the userID of the currently logged in user, use

String userID = WordHoardSettings.getUserID();

The userID is null if the user is not logged in.


Field Summary
protected static int botSlop
          Bottom window slop.
protected static boolean buildProgramRunning
          True if a WordHoard build program is running and needs to access the main WordHoard database directly.
protected static int growSlop
          Grow box slop.
protected static java.lang.String programBanner
          The program banner (title and version number)
protected static java.lang.String programCodebase
          The WebStart code base.
protected static javax.swing.ImageIcon programIcon
          The WordHoard large icon.
protected static java.lang.String programIconFileName
          The WordHoard large icon file name.
protected static javax.swing.ImageIcon programLogo
          The WordHoard logo.
protected static java.lang.String programLogoFileName
          The WordHoard logo file name.
protected static java.lang.String programPrompt
          The script interpreter prompt.
protected static javax.swing.ImageIcon programSmallIcon
          The WordHoard small icon.
protected static java.lang.String programSmallIconFileName
          The WordHoard small icon file name.
protected static java.lang.String programTitle
          The program name.
protected static java.lang.String programVersion
          The program version.
protected static java.lang.String programWebSite
          The program web site.
protected static java.util.ResourceBundle resourceBundle
          The resource strings.
protected static java.lang.String resourceName
          Resource bundle path/name.
protected static int topSlop
          Top window slop.
protected static boolean useScreenMenuBar
          True to use screen menu bar on Mac OS.
protected static boolean warnWhenQuitting
          True to issue warning when quitting WordHoard.
 
Constructor Summary
protected WordHoardSettings()
          Can't instantiate but can override.
 
Method Summary
static int getBotSlop()
          Gets the bottom window slop.
static boolean getBuildProgramRunning()
          Get flag telling if build program is running or not.
static boolean getCanManageAccounts()
          Get the user's account manager status.
static int getGrowSlop()
          Gets the grow box slop.
static Account getLoginAccount()
          Gets the login account.
static java.lang.String getName()
          Get the user's name.
static java.lang.String getProgramBanner()
          Get the program banner.
static javax.swing.ImageIcon getProgramIcon()
          Get the program icon.
static javax.swing.ImageIcon getProgramLogo()
          Get the program logo.
static java.lang.String getProgramPrompt()
          Get the program prompt.
static javax.swing.ImageIcon getProgramSmallIcon()
          Get the small program icon.
static java.lang.String getProgramTitle()
          Get the program title.
static java.lang.String getProgramVersion()
          Get the program version.
static java.lang.String getString(java.lang.String resourceName)
          Get string from ResourceBundle.
static java.lang.String getString(java.lang.String resourceName, java.lang.String defaultValue)
          Get string from ResourceBundle.
static java.lang.String[] getStrings(java.lang.String resourceName, java.lang.String[] defaults)
          Parse ResourceBundle for a String array.
static int getTopSlop()
          Gets the top window slop.
static java.lang.String getUserID()
          Get the user ID.
static boolean getUseScreenMenuBar()
          Returns true to use the screen menu bar on Mac OS X.
static boolean getWarnWhenQuitting()
          Get "warn when quitting" flag.
static java.lang.String getWebSiteURL()
          Get the WordHoard web site URL.
static void initializeSettings(boolean noAWT)
          Initialize WordHoard settings.
static boolean isCurrentUser(java.lang.String userID)
          Check if a user ID is for the currently logged in user.
static boolean isEmptyUserID(java.lang.String userID)
          Check for null or empty user ID.
static boolean isLoggedIn()
          Check if user logged in.
static void loadPreferences()
          Read preferences.
static void savePreferences()
          Save preferences.
static void setBuildProgramRunning(boolean isBuild)
          Enable or disable build program running.
static java.lang.String[] tokenize(java.lang.String input)
          Split string into a series of substrings on whitespace boundries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourceBundle

protected static java.util.ResourceBundle resourceBundle
The resource strings.


programTitle

protected static java.lang.String programTitle
The program name.


programVersion

protected static java.lang.String programVersion
The program version.


programBanner

protected static java.lang.String programBanner
The program banner (title and version number)


programWebSite

protected static java.lang.String programWebSite
The program web site.


programPrompt

protected static java.lang.String programPrompt
The script interpreter prompt.


programLogoFileName

protected static java.lang.String programLogoFileName
The WordHoard logo file name.


programLogo

protected static javax.swing.ImageIcon programLogo
The WordHoard logo.


programIconFileName

protected static java.lang.String programIconFileName
The WordHoard large icon file name.


programIcon

protected static javax.swing.ImageIcon programIcon
The WordHoard large icon.


programSmallIconFileName

protected static java.lang.String programSmallIconFileName
The WordHoard small icon file name.


programSmallIcon

protected static javax.swing.ImageIcon programSmallIcon
The WordHoard small icon.


programCodebase

protected static java.lang.String programCodebase
The WebStart code base. Actual code base set by WebStart, or from hibernate.properties if not running under WebStart.


topSlop

protected static int topSlop
Top window slop.


botSlop

protected static int botSlop
Bottom window slop.


growSlop

protected static int growSlop
Grow box slop.


warnWhenQuitting

protected static boolean warnWhenQuitting
True to issue warning when quitting WordHoard.


buildProgramRunning

protected static boolean buildProgramRunning
True if a WordHoard build program is running and needs to access the main WordHoard database directly.


resourceName

protected static java.lang.String resourceName
Resource bundle path/name.


useScreenMenuBar

protected static boolean useScreenMenuBar
True to use screen menu bar on Mac OS.

Constructor Detail

WordHoardSettings

protected WordHoardSettings()
Can't instantiate but can override.

Method Detail

initializeSettings

public static void initializeSettings(boolean noAWT)
Initialize WordHoard settings.

Parameters:
noAWT - Avoid any class that might require AWT or Swing.

getString

public static java.lang.String getString(java.lang.String resourceName,
                                         java.lang.String defaultValue)
Get string from ResourceBundle. If no string is found, a default string is used.

Parameters:
resourceName - Name of resource to retrieve.
defaultValue - Default value for resource.
Returns:
String value from resource bundle if resourceName found there, otherwise defaultValue.

Underline "_" characters are replaced by spaces.


getString

public static java.lang.String getString(java.lang.String resourceName)
Get string from ResourceBundle. If no string is found, an empty string is returned.

Parameters:
resourceName - Name of resource to retrieve.
Returns:
String value from resource bundle if resourceName found there, otherwise empty string.

Underline "_" characters are replaced by spaces.


getStrings

public static java.lang.String[] getStrings(java.lang.String resourceName,
                                            java.lang.String[] defaults)
Parse ResourceBundle for a String array.

Parameters:
resourceName - Name of resource.
defaults - Array of default string values.
Returns:
Array of strings if resource name found in resources, otherwise default values.

getLoginAccount

public static Account getLoginAccount()
Gets the login account.

Returns:
Login account, or null if none.

getUserID

public static java.lang.String getUserID()
Get the user ID.

Returns:
The user ID of the currently logged in user. Null if the user is not logged in. The value is stored in the Account object in LoginDialog .

If "buildProgramRunning" is true, return "system" as the user ID. This is for use by build programs only.


getName

public static java.lang.String getName()
Get the user's name.

Returns:
The name of the currently logged in user. Null if the user is not logged in. The value is stored in the Account object in LoginDialog .

isCurrentUser

public static boolean isCurrentUser(java.lang.String userID)
Check if a user ID is for the currently logged in user.

Parameters:
userID - The user ID to check.
Returns:
true if the user ID matches that of the currently logged-in user.

isLoggedIn

public static boolean isLoggedIn()
Check if user logged in.

Returns:
True if user currently logged in.

isEmptyUserID

public static boolean isEmptyUserID(java.lang.String userID)
Check for null or empty user ID.

Parameters:
userID - User ID to check.
Returns:
true if userID is null or empty.

getCanManageAccounts

public static boolean getCanManageAccounts()
Get the user's account manager status.

Returns:
true if the user has account manamagement priviledges, false otherwise. The value is stored in the Account object in LoginDialog .

getProgramBanner

public static java.lang.String getProgramBanner()
Get the program banner.

Returns:
The program banner.

getProgramPrompt

public static java.lang.String getProgramPrompt()
Get the program prompt.

Returns:
The program prompt.

getProgramTitle

public static java.lang.String getProgramTitle()
Get the program title.

Returns:
The program title.

getProgramLogo

public static javax.swing.ImageIcon getProgramLogo()
Get the program logo.

Returns:
The program logo.

getProgramIcon

public static javax.swing.ImageIcon getProgramIcon()
Get the program icon.

Returns:
The program icon.

getProgramSmallIcon

public static javax.swing.ImageIcon getProgramSmallIcon()
Get the small program icon.

Returns:
The small program icon.

getProgramVersion

public static java.lang.String getProgramVersion()
Get the program version.

Returns:
The program version strings (e.g., "0.55").

tokenize

public static java.lang.String[] tokenize(java.lang.String input)
Split string into a series of substrings on whitespace boundries.

Parameters:
input - Input string.
Returns:
The array of strings after splitting input.

This is useful for retrieving an array of strings from the resource file. Underline "_" characters are replaced by spaces.


savePreferences

public static void savePreferences()
Save preferences.


loadPreferences

public static void loadPreferences()
Read preferences.


getWebSiteURL

public static java.lang.String getWebSiteURL()
Get the WordHoard web site URL.

Returns:
The WordHoard web site URL.

getTopSlop

public static int getTopSlop()
Gets the top window slop.

Returns:
The top window slop.

getBotSlop

public static int getBotSlop()
Gets the bottom window slop.

Returns:
The bottom window slop.

getGrowSlop

public static int getGrowSlop()
Gets the grow box slop.

Returns:
The grow box slop.

getWarnWhenQuitting

public static boolean getWarnWhenQuitting()
Get "warn when quitting" flag.

Returns:
true to issue warning when quitting WordHoard.

setBuildProgramRunning

public static void setBuildProgramRunning(boolean isBuild)
Enable or disable build program running.

Parameters:
isBuild - Set to true to use direct database access for create/modify/update oprations instead of going through WordHoard server. Set to false for normal WordHoard client use.

getBuildProgramRunning

public static boolean getBuildProgramRunning()
Get flag telling if build program is running or not.

Returns:
true if a build program is running.

getUseScreenMenuBar

public static boolean getUseScreenMenuBar()
Returns true to use the screen menu bar on Mac OS X.

Returns:
True to use the screen menu bar on Mac OS X.