com.izforge.izpack.panels
Class UserInputPanel.SearchField

java.lang.Object
  extended by com.izforge.izpack.panels.UserInputPanel.SearchField
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener
Enclosing class:
UserInputPanel

private class UserInputPanel.SearchField
extends java.lang.Object
implements java.awt.event.ActionListener

This class encapsulates a lot of search field functionality.

A search field supports searching directories and files on the target system. This is a helper class to manage all data belonging to a search field.


Field Summary
private  javax.swing.JButton autodetectButton
           
private  javax.swing.JButton browseButton
           
private  java.lang.String checkFilename
           
private  java.lang.String filename
           
private  InstallerFrame parent
           
private  javax.swing.JComboBox pathComboBox
           
static int RESULT_DIRECTORY
          used in constructor - result of search is the directory.
static int RESULT_FILE
          used in constructor - result of search is the whole file name.
static int RESULT_PARENTDIR
          used in constructor - result of search is the parent directory.
private  int resultType
           
private  int searchType
           
static int TYPE_DIRECTORY
          used in constructor - we search for a directory.
static int TYPE_FILE
          used in constructor - we search for a file.
 
Constructor Summary
UserInputPanel.SearchField(java.lang.String filename, java.lang.String checkFilename, InstallerFrame parent, javax.swing.JComboBox combobox, javax.swing.JButton autobutton, javax.swing.JButton browsebutton, int search_type, int result_type)
          Constructor - initializes the object, adds it as action listener to the "autodetect" button.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          This is called if one of the buttons has been pressed.
 boolean autodetect()
          perform autodetection
 boolean belongsTo(javax.swing.JComboBox combobox)
          Check whether the given combobox belongs to this searchfield.
private  InstallerFrame getInstallerFrame()
          convenient method
 java.lang.String getResult()
          Return the result of the search according to result type.
private  boolean pathMatches(java.lang.String path)
          check whether the given path matches
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_DIRECTORY

public static final int TYPE_DIRECTORY
used in constructor - we search for a directory.

See Also:
Constant Field Values

TYPE_FILE

public static final int TYPE_FILE
used in constructor - we search for a file.

See Also:
Constant Field Values

RESULT_DIRECTORY

public static final int RESULT_DIRECTORY
used in constructor - result of search is the directory.

See Also:
Constant Field Values

RESULT_FILE

public static final int RESULT_FILE
used in constructor - result of search is the whole file name.

See Also:
Constant Field Values

RESULT_PARENTDIR

public static final int RESULT_PARENTDIR
used in constructor - result of search is the parent directory.

See Also:
Constant Field Values

filename

private java.lang.String filename

checkFilename

private java.lang.String checkFilename

autodetectButton

private javax.swing.JButton autodetectButton

browseButton

private javax.swing.JButton browseButton

pathComboBox

private javax.swing.JComboBox pathComboBox

searchType

private int searchType

resultType

private int resultType

parent

private InstallerFrame parent
Constructor Detail

UserInputPanel.SearchField

public UserInputPanel.SearchField(java.lang.String filename,
                                  java.lang.String checkFilename,
                                  InstallerFrame parent,
                                  javax.swing.JComboBox combobox,
                                  javax.swing.JButton autobutton,
                                  javax.swing.JButton browsebutton,
                                  int search_type,
                                  int result_type)
Constructor - initializes the object, adds it as action listener to the "autodetect" button.

Parameters:
filename - the name of the file to search for (might be null for searching directories)
checkFilename - the name of the file to check when searching for directories (the checkFilename is appended to a found directory to figure out whether it is the right directory)
combobox - the JComboBox holding the list of choices; it should be editable and contain only Strings
autobutton - the autodetection button for triggering autodetection
browsebutton - the browse button to look for the file
search_type - what to search for - TYPE_FILE or TYPE_DIRECTORY
result_type - what to return as the result - RESULT_FILE or RESULT_DIRECTORY or RESULT_PARENTDIR
Method Detail

getInstallerFrame

private InstallerFrame getInstallerFrame()
convenient method


belongsTo

public boolean belongsTo(javax.swing.JComboBox combobox)
Check whether the given combobox belongs to this searchfield. This is used when reading the results.


pathMatches

private boolean pathMatches(java.lang.String path)
check whether the given path matches


autodetect

public boolean autodetect()
perform autodetection


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
This is called if one of the buttons has been pressed.

It checks, which button caused the action and acts accordingly.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

getResult

public java.lang.String getResult()
Return the result of the search according to result type.

Sometimes, the whole path of the file is wanted, sometimes only the directory where the file is in, sometimes the parent directory.

Returns:
null on error