de.axelwernicke.mypod.gui
Class GuiUtils

java.lang.Object
  extended byde.axelwernicke.mypod.gui.GuiUtils

public class GuiUtils
extends java.lang.Object

This class provides some helpers to remove code from the core GUI classes.

Author:
axel wernicke

Field Summary
static int ABORT_OPTION
           
static int RETRY_OPTION
           
static int SKIP_OPTION
           
static int UNKNOWN_OPTION
           
 
Method Summary
static java.awt.Rectangle calcCenteredBounds(java.awt.Rectangle mainFrame, java.awt.Rectangle dialog)
          calculates bound to show dialog in the center of mainFrame
static boolean checkVMVersion(java.awt.Component component)
          Checks if the current java vm version is > 1.4
static java.lang.String formatFilesize(long filesize)
          Formats filesize in bytes as appropriate to Bytes, KB, MB or GB
static java.lang.String formatFilesizeKB(long filesize)
          Formats filesize in bytes to KB
static java.lang.String formatTime(long time)
          Formats time string from seconds.
static java.lang.String formatTransferSpeedKB(long filesize, int fractionDigits)
          Formats transfer speed in bytes/s to KB/s
static java.lang.String formatTransferSpeedMB(long filesize, int fractionDigits)
          Formats transfer speed in bytes/s to MB/s
static javax.swing.tree.DefaultMutableTreeNode getAutoPlaylistPropertyTreeModel()
          Gets the tree model for autoplaylist filter properties.
 GuiUtils getInstance()
          This is a singleton class, so use getInstance to get in instance :)
static java.util.Hashtable getLookAndFeelInfo()
          Gets all accasseble look and feels.
static javax.swing.tree.DefaultMutableTreeNode getPlaylistPropertyTreeModel()
          Gets the tree model for playlist properties.
static java.util.Vector getSelectedClips(Frontend frontend)
          Gets the selected clips
- get current clips table view
- get oids for selected clips from the view
static java.lang.String getStringLocalized(java.lang.String key)
          Gets a string from the resource bundle - localized for the current default language
static java.lang.String getStringLocalized(java.lang.String bundle, java.lang.String key)
          Gets a string from the resource bundle - localized for the current default language
static java.lang.String limitFilename(java.io.File file, int limit)
          Reformats a filename to be limited in lenght.
static void setLookAndFeel(javax.swing.LookAndFeel lfClass, java.awt.Frame frame)
          Sets the look and feel for myPod.
static void setLookAndFeel(java.lang.String lookAndFeelInfo, java.awt.Frame frame)
          Sets the look and feel from an info string as used in the preferences dialog class.
static MP3MetaV2 showClipPropertiesDialog(Frontend frontend, java.util.Vector clips)
          Prepares and shows clip properties dialog and evaulates result.
static void showHelpBrowser(java.lang.String anchor)
          Shows a swing browser for a given URL
static boolean showPlaylistPropertyDialog(Playlist playlist, Frontend frontend, Backend backend)
          Creates and shows the playlist property dialog.
static Preferences showPreferencesDialog(Frontend frontend, Preferences prefs)
          Prepares and shows preferences dialog and evaulates result.
static int showRSADialog(java.lang.String title, java.lang.String message)
          Shows an retry, skip, abort dialog.
static void updateStatusLine(Frontend frontend)
          sets the status line
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_OPTION

public static final int UNKNOWN_OPTION
See Also:
Constant Field Values

RETRY_OPTION

public static final int RETRY_OPTION
See Also:
Constant Field Values

SKIP_OPTION

public static final int SKIP_OPTION
See Also:
Constant Field Values

ABORT_OPTION

public static final int ABORT_OPTION
See Also:
Constant Field Values
Method Detail

getInstance

public GuiUtils getInstance()
This is a singleton class, so use getInstance to get in instance :)

Returns:
GuiUtils instance

checkVMVersion

public static boolean checkVMVersion(java.awt.Component component)
Checks if the current java vm version is > 1.4

Parameters:
component - to show the message dialog at
Returns:
true, if version is > 1.4

getSelectedClips

public static java.util.Vector getSelectedClips(Frontend frontend)
Gets the selected clips
- get current clips table view
- get oids for selected clips from the view

Parameters:
frontend - to get the clips table view from
Returns:
vector, containing the oids of the selected clips

getStringLocalized

public static java.lang.String getStringLocalized(java.lang.String bundle,
                                                  java.lang.String key)
Gets a string from the resource bundle - localized for the current default language

Parameters:
bundle - name of the resource bundle
key - in the bundle
Returns:
value for the key

getStringLocalized

public static java.lang.String getStringLocalized(java.lang.String key)
Gets a string from the resource bundle - localized for the current default language

Parameters:
key - in the bundle
Returns:
value for the key

getAutoPlaylistPropertyTreeModel

public static javax.swing.tree.DefaultMutableTreeNode getAutoPlaylistPropertyTreeModel()
Gets the tree model for autoplaylist filter properties.

Returns:
tree model to be used in the property dialog

getPlaylistPropertyTreeModel

public static javax.swing.tree.DefaultMutableTreeNode getPlaylistPropertyTreeModel()
Gets the tree model for playlist properties.

Returns:
tree model to be used in the property dialog

showPlaylistPropertyDialog

public static boolean showPlaylistPropertyDialog(Playlist playlist,
                                                 Frontend frontend,
                                                 Backend backend)
Creates and shows the playlist property dialog.
- create property dialog
- set tree model
- set data from playlist to the dialog
- show dialog

Parameters:
playlist - to show a property dialog for
frontend - myPods main window
backend - myPods application logic
Returns:
true, if the dialog was confirmed by the user

showPreferencesDialog

public static Preferences showPreferencesDialog(Frontend frontend,
                                                Preferences prefs)
Prepares and shows preferences dialog and evaulates result.
- create preferences dialog
- set tree model
- set data from prefs to the dialog
- show dialog
- copy data from dialog to prefs

Parameters:
prefs - for myPod
frontend - of myPod
Returns:
true, if the dialog was confirmed by the user

showClipPropertiesDialog

public static MP3MetaV2 showClipPropertiesDialog(Frontend frontend,
                                                 java.util.Vector clips)
Prepares and shows clip properties dialog and evaulates result.

Parameters:
clips - clips to change properties for
frontend - used to calculate the dialogs position
Returns:
set of mp3 meta data, changed by the user

updateStatusLine

public static void updateStatusLine(Frontend frontend)
sets the status line

Parameters:
frontend - where the status line is placed

calcCenteredBounds

public static java.awt.Rectangle calcCenteredBounds(java.awt.Rectangle mainFrame,
                                                    java.awt.Rectangle dialog)
calculates bound to show dialog in the center of mainFrame

Parameters:
mainFrame - bounds
dialog - bounds
Returns:
bounds of dialog in the center of mainFrame

formatFilesize

public static java.lang.String formatFilesize(long filesize)
Formats filesize in bytes as appropriate to Bytes, KB, MB or GB

Parameters:
filesize - in bytes
Returns:
formatted filesize

formatFilesizeKB

public static java.lang.String formatFilesizeKB(long filesize)
Formats filesize in bytes to KB

Parameters:
filesize - in bytes
Returns:
formatted filesize

formatTransferSpeedKB

public static java.lang.String formatTransferSpeedKB(long filesize,
                                                     int fractionDigits)
Formats transfer speed in bytes/s to KB/s

Parameters:
filesize - to format in bytes
fractionDigits - ...
Returns:
formatted transfer speed

formatTransferSpeedMB

public static java.lang.String formatTransferSpeedMB(long filesize,
                                                     int fractionDigits)
Formats transfer speed in bytes/s to MB/s

Parameters:
filesize - to format in bytes
fractionDigits - ...
Returns:
formatted transfer speed

formatTime

public static java.lang.String formatTime(long time)
Formats time string from seconds.

Parameters:
time - to format in seconds
Returns:
time formatted as hh:mm:ss

getLookAndFeelInfo

public static java.util.Hashtable getLookAndFeelInfo()
Gets all accasseble look and feels.

Returns:
hashtable containing name and info string for all available l&f

setLookAndFeel

public static void setLookAndFeel(java.lang.String lookAndFeelInfo,
                                  java.awt.Frame frame)
Sets the look and feel from an info string as used in the preferences dialog class.

Parameters:
lookAndFeelInfo - describing the look and feel to set
frame - to set the look and feel for

setLookAndFeel

public static void setLookAndFeel(javax.swing.LookAndFeel lfClass,
                                  java.awt.Frame frame)
Sets the look and feel for myPod.

Parameters:
lfClass - the look and feel class to activate
frame - root frame that is reinitialized after changing the l&f

showHelpBrowser

public static void showHelpBrowser(java.lang.String anchor)
Shows a swing browser for a given URL

Parameters:
anchor - in the help file to show in the browser

showRSADialog

public static int showRSADialog(java.lang.String title,
                                java.lang.String message)
Shows an retry, skip, abort dialog.

Parameters:
title - to set in the dialog
message - to show in the dialog
Returns:
user reaction as Gui.*_OPTION value

limitFilename

public static java.lang.String limitFilename(java.io.File file,
                                             int limit)
Reformats a filename to be limited in lenght.
c:\fooooooo\faaaaaaaa\feee.foo -> C:\fooo...feee.foo

Parameters:
file - to format path and name
limit - max. length of formatted name
Returns:
reformatted filename