org.fopps.share
Class UIUtils

java.lang.Object
  |
  +--org.fopps.share.UIUtils

public class UIUtils
extends java.lang.Object

UIUtils provides useful methods for UI purposes and persistent properties


Field Summary
static int BOTTOM
           
static java.lang.String BUILD
           
static java.io.File[] EMPTY_FILE_ARRAY
           
static int GAP
           
static int HCENTER
           
static java.lang.String LASTDIR_KEY
           
static int LEFT
           
static java.lang.String PROPERTY_FILENAME
           
static java.lang.String RELEASE
           
static int RIGHT
           
static java.lang.String SYSTEM_PROPERTY_FILENAME
           
static int TOP
           
static java.util.PropertyResourceBundle UI_RESOURCES
           
static int VCENTER
           
 
Constructor Summary
UIUtils()
           
 
Method Summary
static java.lang.String applyArgument(java.lang.String pResourceString, java.lang.String pArg, int pArgNumber)
           
static java.lang.String askForString(java.lang.String pTitle)
          Pops up a dialog to ask for a string
static java.lang.String askForString(java.lang.String pTitle, java.lang.String pDefault)
          Pops up a dialog to ask for a string with default value
static void centerWindow(java.awt.Window window)
          Centers a window on the screen
static void drawString(java.awt.Graphics g, java.awt.Rectangle r, java.lang.String text)
          Draws a centered string
static void drawString(java.awt.Graphics g, java.awt.Rectangle r, java.lang.String text, int valign, int halign)
          Draws an aligned string
static java.lang.String getBuildNumber()
          Returns the current build number
static java.lang.String getReleaseNumber()
          Returns the current release number
static java.io.InputStream getSystemFile(java.lang.String pName)
          Loads an icon from the classpath
static javax.swing.Icon getSystemIcon(java.lang.String pName)
          Loads an icon from the classpath
static java.lang.String getUIString(java.lang.String pKey)
          Returns a (localized) string resource without parameters
static java.lang.String getUIString(java.lang.String pKey, java.lang.String arg0)
          Returns a (localized) string resource with one parameter.
static java.lang.String getUIString(java.lang.String pKey, java.lang.String arg0, java.lang.String arg1)
          Returns a (localized) string resource with two parameters.
static java.lang.String getUIString(java.lang.String pKey, java.lang.String arg0, java.lang.String arg1, java.lang.String arg2)
          Returns a (localized) string resource with two parameters.
static java.lang.String getUserProperty(java.lang.String pKey)
          Retrieves an user specific property without default
static java.lang.String getUserProperty(java.lang.String pKey, java.lang.String pDefault)
          Retrieves an user specific property
static java.io.File[] selectFilesDialog(java.lang.String pTitle)
          Opens a dialog to select multiple files.
static java.io.File[] selectFilesDialog(java.lang.String pTitle, java.io.File pWorkDir)
          Opens a dialog to select multiple files.
static java.io.File[] selectFilesDialog(java.lang.String pTitle, java.io.File pWorkDir, javax.swing.filechooser.FileFilter pFilter)
          Opens a dialog to select multiple files
static java.io.File[] selectFilesDialog(java.lang.String pTitle, javax.swing.filechooser.FileFilter pFilter)
          Opens a dialog to select multiple files.
static void setUserProperty(java.lang.String pKey, java.lang.String pValue)
          Sets an user specific property
static int showConfirmMessage(java.lang.String pMsg)
          Shows an confirmation dialog on the screen with default title
static int showConfirmMessage(java.lang.String pTitle, java.lang.String pMsg)
          Shows an confirmation dialog on the screen
static int showConfirmQuitMessage(java.lang.String pMsg)
          Shows an confirmation dialog with additional cancel button on the screen with default title
static int showConfirmQuitMessage(java.lang.String pTitle, java.lang.String pMsg)
          Shows an confirmation dialog on the screen
static java.io.File showDirDialog(java.lang.String pTitle)
          Generic method to select a directory
static java.io.File showDirDialog(java.lang.String pTitle, java.io.File pWorkDir)
          Generic method to select a directory
static void showErrorMessage(java.lang.String pMsg)
          Shows an error message on the screen with default title
static void showErrorMessage(java.lang.String pTitle, java.lang.String pMsg)
          Shows an error message on the screen
static java.io.File showFileDialog(java.lang.String pTitle, java.io.File pWorkDir, javax.swing.filechooser.FileFilter pFilter, boolean pShowAsSave)
          Generic method to select files
static java.io.File showFileDialog(java.lang.String pTitle, java.io.File pWorkDir, javax.swing.filechooser.FileFilter pFilter, boolean pShowAsSave, boolean pFilesOnly)
          Generic method for open/save dialog
static void showInfoMessage(java.lang.String pMsg)
          Shows an information dialog on the screen with default title
static void showInfoMessage(java.lang.String pTitle, java.lang.String pMsg)
          Shows an information dialog on the screen
static java.io.File showOpenDialog(java.lang.String pTitle, javax.swing.filechooser.FileFilter pFilter)
          Dialog for opening a file.
static java.io.File showSaveDialog(java.lang.String pTitle, javax.swing.filechooser.FileFilter pFilter)
          Dialog for saving a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UI_RESOURCES

public static java.util.PropertyResourceBundle UI_RESOURCES

VCENTER

public static final int VCENTER
See Also:
Constant Field Values

TOP

public static final int TOP
See Also:
Constant Field Values

BOTTOM

public static final int BOTTOM
See Also:
Constant Field Values

HCENTER

public static final int HCENTER
See Also:
Constant Field Values

LEFT

public static final int LEFT
See Also:
Constant Field Values

RIGHT

public static final int RIGHT
See Also:
Constant Field Values

GAP

public static final int GAP
See Also:
Constant Field Values

PROPERTY_FILENAME

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

SYSTEM_PROPERTY_FILENAME

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

BUILD

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

RELEASE

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

LASTDIR_KEY

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

EMPTY_FILE_ARRAY

public static final java.io.File[] EMPTY_FILE_ARRAY
Constructor Detail

UIUtils

public UIUtils()
Method Detail

showOpenDialog

public static java.io.File showOpenDialog(java.lang.String pTitle,
                                          javax.swing.filechooser.FileFilter pFilter)
Dialog for opening a file. The last directory is the default


showSaveDialog

public static java.io.File showSaveDialog(java.lang.String pTitle,
                                          javax.swing.filechooser.FileFilter pFilter)
Dialog for saving a file. The last directory is the default


showFileDialog

public static java.io.File showFileDialog(java.lang.String pTitle,
                                          java.io.File pWorkDir,
                                          javax.swing.filechooser.FileFilter pFilter,
                                          boolean pShowAsSave)
Generic method to select files


showDirDialog

public static java.io.File showDirDialog(java.lang.String pTitle,
                                         java.io.File pWorkDir)
Generic method to select a directory


showDirDialog

public static java.io.File showDirDialog(java.lang.String pTitle)
Generic method to select a directory


showFileDialog

public static java.io.File showFileDialog(java.lang.String pTitle,
                                          java.io.File pWorkDir,
                                          javax.swing.filechooser.FileFilter pFilter,
                                          boolean pShowAsSave,
                                          boolean pFilesOnly)
Generic method for open/save dialog

Parameters:
pTitle - Title of dialog
pWorkDir - Initial directory to show
pFilter - File filter to use
pShowAsSave - If true, dialog is shown as save dialog, otherwise it is shown as open dialog
pFilesOnly - If true, the user is only able to select files. If set to false, only directories are allowed
Returns:
Selected file

selectFilesDialog

public static java.io.File[] selectFilesDialog(java.lang.String pTitle,
                                               java.io.File pWorkDir,
                                               javax.swing.filechooser.FileFilter pFilter)
Opens a dialog to select multiple files

Parameters:
pTitle - Title of dialog
pWorkDir - Initial directory to show
pFilter - File filter to use
Returns:
Selected files or an empty array, if no file was selcted

selectFilesDialog

public static java.io.File[] selectFilesDialog(java.lang.String pTitle,
                                               java.io.File pWorkDir)
Opens a dialog to select multiple files. All files are displayed. Overloaded for convenience

Parameters:
pTitle - Title of dialog
pWorkDir - Initial directory to show
Returns:
Selected files or an empty array, if no file was selected

selectFilesDialog

public static java.io.File[] selectFilesDialog(java.lang.String pTitle,
                                               javax.swing.filechooser.FileFilter pFilter)
Opens a dialog to select multiple files. The last directory is used as default. Overloaded for convenience

Parameters:
pTitle - Title of dialog
pFilter - File filter to use
Returns:
Selected files or an empty array, if no file was selected

selectFilesDialog

public static java.io.File[] selectFilesDialog(java.lang.String pTitle)
Opens a dialog to select multiple files. The last directory is used as default and all files are selectable. Overloaded for convenience

Parameters:
pTitle - Title of dialog
Returns:
Selected files or an empty array, if no file was selected

drawString

public static void drawString(java.awt.Graphics g,
                              java.awt.Rectangle r,
                              java.lang.String text)
Draws a centered string


drawString

public static void drawString(java.awt.Graphics g,
                              java.awt.Rectangle r,
                              java.lang.String text,
                              int valign,
                              int halign)
Draws an aligned string

Parameters:
g - Graphics where to paint to
r - Rectangle to which the text should aligned to
text - Text to display
valign - Vertical alignment (top, center, bottom)
halign - Horizontal alignment (left, middle, right)

getUIString

public static java.lang.String getUIString(java.lang.String pKey)
Returns a (localized) string resource without parameters

Parameters:
pKey - Key of resource entry

getUIString

public static java.lang.String getUIString(java.lang.String pKey,
                                           java.lang.String arg0)
Returns a (localized) string resource with one parameter. The returned string of a string resource 'Operation {0} succeeded' will be 'Operation arg0 succeeded'

Parameters:
pKey - Key of resource entry
arg0 - First argument

getUIString

public static java.lang.String getUIString(java.lang.String pKey,
                                           java.lang.String arg0,
                                           java.lang.String arg1)
Returns a (localized) string resource with two parameters.

Parameters:
pKey - Key of resource entry
arg0 - First argument
arg1 - Second argument
See Also:
getUIString(String,String)

getUIString

public static java.lang.String getUIString(java.lang.String pKey,
                                           java.lang.String arg0,
                                           java.lang.String arg1,
                                           java.lang.String arg2)
Returns a (localized) string resource with two parameters.

Parameters:
pKey - Key of resource entry
arg0 - First argument
arg1 - Second argument
arg2 - Third argument
See Also:
getUIString(String,String)

applyArgument

public static java.lang.String applyArgument(java.lang.String pResourceString,
                                             java.lang.String pArg,
                                             int pArgNumber)

getBuildNumber

public static java.lang.String getBuildNumber()
Returns the current build number


getReleaseNumber

public static java.lang.String getReleaseNumber()
Returns the current release number


setUserProperty

public static void setUserProperty(java.lang.String pKey,
                                   java.lang.String pValue)
Sets an user specific property

See Also:
Properties.setProperty(String,String)

getUserProperty

public static java.lang.String getUserProperty(java.lang.String pKey,
                                               java.lang.String pDefault)
Retrieves an user specific property

See Also:
Properties.getProperty(String,String)

getUserProperty

public static java.lang.String getUserProperty(java.lang.String pKey)
Retrieves an user specific property without default

See Also:
Properties.getProperty(String)

showErrorMessage

public static void showErrorMessage(java.lang.String pTitle,
                                    java.lang.String pMsg)
Shows an error message on the screen


showErrorMessage

public static void showErrorMessage(java.lang.String pMsg)
Shows an error message on the screen with default title


showInfoMessage

public static void showInfoMessage(java.lang.String pTitle,
                                   java.lang.String pMsg)
Shows an information dialog on the screen


showInfoMessage

public static void showInfoMessage(java.lang.String pMsg)
Shows an information dialog on the screen with default title


showConfirmMessage

public static int showConfirmMessage(java.lang.String pTitle,
                                     java.lang.String pMsg)
Shows an confirmation dialog on the screen


showConfirmMessage

public static int showConfirmMessage(java.lang.String pMsg)
Shows an confirmation dialog on the screen with default title


showConfirmQuitMessage

public static int showConfirmQuitMessage(java.lang.String pTitle,
                                         java.lang.String pMsg)
Shows an confirmation dialog on the screen


showConfirmQuitMessage

public static int showConfirmQuitMessage(java.lang.String pMsg)
Shows an confirmation dialog with additional cancel button on the screen with default title


askForString

public static java.lang.String askForString(java.lang.String pTitle)
Pops up a dialog to ask for a string


askForString

public static java.lang.String askForString(java.lang.String pTitle,
                                            java.lang.String pDefault)
Pops up a dialog to ask for a string with default value


centerWindow

public static void centerWindow(java.awt.Window window)
Centers a window on the screen


getSystemFile

public static java.io.InputStream getSystemFile(java.lang.String pName)
Loads an icon from the classpath


getSystemIcon

public static javax.swing.Icon getSystemIcon(java.lang.String pName)
Loads an icon from the classpath



Fopps 0.19 - Copyright © 2002 Oliver Wieland. All Rights Reserved.