Class CommonGUI

java.lang.Object
  |
  +--CommonGUI

public class CommonGUI
extends java.lang.Object

Provides some common UI objects (file pickers and error dialogs).

Version:
$2006-11-04 08:20:27 mdh$
Author:
Malcolm D. Hyman

Field Summary
static java.lang.String DIR_MAPPINGS
           
static java.lang.String DIR_MORPH
           
static java.lang.String DIR_TEXTS
           
static int SAVED_URLS
           
 
Constructor Summary
CommonGUI()
           
 
Method Summary
protected static void addFileToCatalog(java.io.File file, ArborPanel panel)
          Adds a file to the editable catalog.
static void addURLtoOpenHistory(java.net.URL url)
          Adds a URL to the getURL() open history.
static boolean confirmOverwrite(java.awt.Component parent)
          Confirms a file overwrite.
static void doLogin()
          Allows the user to login with a user ID.
static void errorDialog(java.lang.String message)
          Displays an error dialog.
static void errorDialog(java.lang.String messageID, java.lang.Object[] args)
          Displays an error dialog.
static void errorDialogP(java.lang.String message, java.awt.Component parent)
          Displays an error dialog.
static void errorDialogP(java.lang.String messageID, java.lang.Object[] args, java.awt.Component parent)
          Displays an error dialog.
protected static java.net.URL filePicker(java.lang.String title, java.lang.String extension, java.lang.String desc, boolean allowCatAdd, ArborPanel panel, java.lang.String defaultDir)
          Returns the URL of a file the user has chosen.
static java.io.File getDefaultNamedDirectory(java.lang.String defaultDir)
          Returns the a file specification for the specified directory, if it exists at either the sibling or the parent level.
static javax.swing.JFileChooser getFileChooser()
          Returns a file chooser, set to the current working directory, which is preserved as a stored property (key "cwd").
static java.net.URL getURL(java.lang.String title, java.lang.String extension, java.lang.String desc)
          Allows the user to enter a URL or to select a file from a chooser dialog.
static java.net.URL getURL(java.lang.String title, java.lang.String extension, java.lang.String desc, java.lang.String defaultDir)
          Allows the user to enter a URL or to select a file from a chooser dialog.
static java.net.URL getURL(java.lang.String title, java.lang.String extension, java.lang.String desc, java.lang.String defaultDir, javax.swing.JComponent accessory, boolean allowCatAdd, ArborPanel panel)
          Allows the user to enter a URL or to select a file from a chooser dialog.
static java.lang.String getUserID()
          Returns the user ID with which the user has logged in.
static void initAddCatalogEntryWidgets()
          Initially creates the widgets for the "Add to catalog" dialog.
static void saveURLHistory()
          Saves URL history for this session.
static void storeCWD(java.io.File cwd)
          Saves the current working directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIR_TEXTS

public static final java.lang.String DIR_TEXTS

DIR_MORPH

public static final java.lang.String DIR_MORPH

DIR_MAPPINGS

public static final java.lang.String DIR_MAPPINGS

SAVED_URLS

public static final int SAVED_URLS
Constructor Detail

CommonGUI

public CommonGUI()
Method Detail

getFileChooser

public static javax.swing.JFileChooser getFileChooser()
Returns a file chooser, set to the current working directory, which is preserved as a stored property (key "cwd").
Returns:
Swing file picker widget

storeCWD

public static void storeCWD(java.io.File cwd)
Saves the current working directory.
Parameters:
cwd - current working directory

getDefaultNamedDirectory

public static java.io.File getDefaultNamedDirectory(java.lang.String defaultDir)
Returns the a file specification for the specified directory, if it exists at either the sibling or the parent level.
Parameters:
defaultDir - default for last path component
Returns:
File object

filePicker

protected static java.net.URL filePicker(java.lang.String title,
                                         java.lang.String extension,
                                         java.lang.String desc,
                                         boolean allowCatAdd,
                                         ArborPanel panel,
                                         java.lang.String defaultDir)
Returns the URL of a file the user has chosen.
Parameters:
title - title for dialog
extension - file extension (for chooser filter)
desc - description for choosable file filter
allowCatAdd - allows files to be added to the catalog
panel - ArborPanel (needed if allowCatAdd)
defaultDir - default for last path component
Returns:
URL for selected file

addFileToCatalog

protected static void addFileToCatalog(java.io.File file,
                                       ArborPanel panel)
Adds a file to the editable catalog.
Parameters:
file - file to be added
panel - current ArborPanel

initAddCatalogEntryWidgets

public static void initAddCatalogEntryWidgets()
Initially creates the widgets for the "Add to catalog" dialog.

getURL

public static java.net.URL getURL(java.lang.String title,
                                  java.lang.String extension,
                                  java.lang.String desc,
                                  java.lang.String defaultDir,
                                  javax.swing.JComponent accessory,
                                  boolean allowCatAdd,
                                  ArborPanel panel)
Allows the user to enter a URL or to select a file from a chooser dialog. This version allows an accessory component (which will be displayed at the top of the dialog) to be passed in.
Parameters:
title - input prompt
extension - file extension (for chooser filter)
desc - description for choosable file filter
defaultDir - default directory name for file picker
accessory - accessory component
allowCatAdd - allows files to be added to the catalog
panel - ArborPanel (needed if allowCatAdd)
Returns:
entered URL

getURL

public static java.net.URL getURL(java.lang.String title,
                                  java.lang.String extension,
                                  java.lang.String desc)
Allows the user to enter a URL or to select a file from a chooser dialog.
Parameters:
title - input prompt
extension - file extension (for chooser filter)
desc - description for choosable file filter
Returns:
entered URL

getURL

public static java.net.URL getURL(java.lang.String title,
                                  java.lang.String extension,
                                  java.lang.String desc,
                                  java.lang.String defaultDir)
Allows the user to enter a URL or to select a file from a chooser dialog.
Parameters:
title - input prompt
extension - file extension (for chooser filter)
desc - description for choosable file filter
defaultDir - default directory name for file picker
Returns:
entered URL

addURLtoOpenHistory

public static void addURLtoOpenHistory(java.net.URL url)
Adds a URL to the getURL() open history.
Parameters:
url - URL to be added to history

saveURLHistory

public static void saveURLHistory()
Saves URL history for this session.

errorDialogP

public static void errorDialogP(java.lang.String messageID,
                                java.lang.Object[] args,
                                java.awt.Component parent)
Displays an error dialog. The message is obtained from a resource bundle.
Parameters:
messageID - ID for message in ResourceBundle
args - arguments for message format
parent - parent frame (or null)

errorDialog

public static void errorDialog(java.lang.String messageID,
                               java.lang.Object[] args)
Displays an error dialog. The message is obtained from a resource bundle. No parent frame is specified.
Parameters:
messageID - ID for message in ResourceBundle
args - arguments for message format

errorDialogP

public static void errorDialogP(java.lang.String message,
                                java.awt.Component parent)
Displays an error dialog. The message is specified as a string.
Parameters:
message - text to display
parent - parent frame (or null)

errorDialog

public static void errorDialog(java.lang.String message)
Displays an error dialog. The message is specified as a string. No parent frame is specified.
Parameters:
message - text to display

confirmOverwrite

public static boolean confirmOverwrite(java.awt.Component parent)
Confirms a file overwrite. Returns true if the overwrite is to proceed
Parameters:
parent - parent component (or null)
Returns:
true to overwrite; false to cancel

doLogin

public static void doLogin()
Allows the user to login with a user ID.

getUserID

public static java.lang.String getUserID()
Returns the user ID with which the user has logged in.
Returns:
creator ID