Mp3dings 
20100427

de.mospace.swing
Class ExtensionInstaller

java.lang.Object
  extended by de.mospace.swing.ExtensionInstaller
Direct Known Subclasses:
LaFInstaller

public class ExtensionInstaller
extends Object

Description of the Class

Author:
ringler

Field Summary
protected  Component parent
           
 
Constructor Summary
ExtensionInstaller(Component parent)
          Constructs a new ExtensionInstaller.
 
Method Summary
protected  boolean ask(String question, String title)
          Asks the user to answer yes or no to the given question.
static boolean canWrite(File test)
          Tests whether we can write to the given file or directory.
 File getFallbackTargetDirectory()
          Returns this installer's fallback target directory.
 File getTargetDirectory()
          Returns the value of the target directory property.
 String getWritableExtensionDirectory()
           
 boolean installExtension(File extjar)
          Installs a Java extension.
 boolean installExtension(File extjar, ClassLoaderProvider clp)
           
 boolean installExtension(File zip, String extjars)
          Installs a Java extension contained in a zip file.
 boolean installExtension(File zip, String extjars, ClassLoaderProvider clp)
           
static boolean isTemporary(File file)
          Deprecated. use DefaultClassLoaderProvider.isTemporary(java.io.File) instead.
protected  File queryFile(String message, String title, int selectionmode)
          Asks the user to provide a File path.
 void setFallbackTargetDirectory(File dir)
          Sets this installer's fallback target directory.
 void setTargetDirectory(File dir)
          Sets this installer's target directory.
protected  void warn(String message, String title)
          Displays a warning dialog with the given title and message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected final Component parent
Constructor Detail

ExtensionInstaller

public ExtensionInstaller(Component parent)
Constructs a new ExtensionInstaller.

Parameters:
parent - a parent component for dialogs opened by this installer
Method Detail

isTemporary

public static boolean isTemporary(File file)
Deprecated. use DefaultClassLoaderProvider.isTemporary(java.io.File) instead.


getTargetDirectory

public File getTargetDirectory()
Returns the value of the target directory property. If the target directory is not currently set it will be set by this method call as follows. If a writable extension directory can be found it is used. If no such directory exists the fallbackTargetDirectory is used if it has been set and is writable. Otherwise, the user is prompted to specify a writable extension directory.

Returns:
this installer's target directory if it is writable or null otherwise

setTargetDirectory

public void setTargetDirectory(File dir)
Sets this installer's target directory.

Parameters:
dir - the new value for the target directory property
Throws:
IllegalArgumentException - if dir exists and is not a directory
See Also:
getTargetDirectory()

setFallbackTargetDirectory

public void setFallbackTargetDirectory(File dir)
Sets this installer's fallback target directory.

Parameters:
dir - the new value for the fallback target directory
Throws:
IllegalArgumentException - if dir exists and is not a directory
See Also:
getTargetDirectory()

getFallbackTargetDirectory

public File getFallbackTargetDirectory()
Returns this installer's fallback target directory.

Returns:
the fallback target directory or null if it has not been set
See Also:
getTargetDirectory()

getWritableExtensionDirectory

public String getWritableExtensionDirectory()
Returns:
an existing, user-writable extension directory or null if the user cancelled the dialog

canWrite

public static boolean canWrite(File test)
Tests whether we can write to the given file or directory.

Parameters:
test - the file to test
Returns:
wether we can modify or create the given file

queryFile

protected File queryFile(String message,
                         String title,
                         int selectionmode)
Asks the user to provide a File path.

Parameters:
message - the message text of the input dialog.
title - the title of the input dialog
selectionmode - one of JFileChooser.FILES_ONLY, FileChooser.DIRECTORIES_ONLY and JFileChooser.FILES_AND_DIRECTORIES
Returns:
A new File object or null if the user cancelled the dialog.

warn

protected void warn(String message,
                    String title)
Displays a warning dialog with the given title and message.

Parameters:
message - the warning message
title - the dialog title

ask

protected boolean ask(String question,
                      String title)
Asks the user to answer yes or no to the given question.

Parameters:
question - the dialog message
title - the dialog title
Returns:
true for yes and false for no or if the user cancelled the dialog

installExtension

public boolean installExtension(File extjar)
Installs a Java extension.

Parameters:
extjar - the jar file containing the extension classes you want to install
Returns:
true if the jar file was successfully installed

installExtension

public boolean installExtension(File extjar,
                                ClassLoaderProvider clp)

installExtension

public boolean installExtension(File zip,
                                String extjars)
Installs a Java extension contained in a zip file.

Parameters:
zip - the zip archive that contains the extension jar file
extjars - the path to the extension jar file relative to the zip root
Returns:
whether the installation succeeded

installExtension

public boolean installExtension(File zip,
                                String extjars,
                                ClassLoaderProvider clp)

Mp3dings 
20100427