BrowseActionListener.java revision a395dd575518d9e5280fc5d5d5ef47c61b174647
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
*/
/**
* This class is an action listener used to update a text component. When the
* class receives an ActionEvent it will display a File Browser Dialog and will
* update the text field depending on what the user chooses in the browser
* dialog.
*
* The class is used generally by adding it as ActionListener of a 'Browse'
* button.
*
*/
public class BrowseActionListener implements ActionListener
{
private JFileChooser fc;
private JTextComponent field;
private BrowseType type;
/**
* Enumeration used to specify which kind of file browser dialog must be
* displayed.
*
*/
public enum BrowseType
{
/**
* The Browser is used to retrieve a directory.
*/
/**
* The Browser is used to retrieve an LDIF file.
*/
/**
* The Browser is used to retrieve a .zip file.
*/
/**
* The Browser is used to retrieve a generic file.
*/
}
/**
* Constructor for the BrowseActionListener.
*
* @param field
* the text component that will be updated when the user selects
* something in the file browser dialog.
* @param type
* the type of file browse dialog that will be displayed.
* @param parent
* component that will be used as reference to display the file
* browse dialog.
*/
{
fc = new JFileChooser();
switch (type)
{
case LOCATION_DIRECTORY:
break;
case OPEN_LDIF_FILE:
new ExtensionFileFilter("ldif",
break;
case OPEN_ZIP_FILE:
new ExtensionFileFilter("zip",
break;
case GENERIC_FILE:
break;
default:
}
}
/**
* ActionListener implementation. It will display a file browser dialog and
* then will update the text component if the user selects something on the
* dialog.
*
* @param e the ActionEvent we receive.
*
*/
public void actionPerformed(ActionEvent e)
{
int returnVal;
/* If we can get the current field parent directory set to it */
{
{
while ((f != null) && !f.isDirectory())
{
f = f.getParentFile();
}
if (f != null)
{
}
}
}
switch (type)
{
case LOCATION_DIRECTORY:
break;
case OPEN_LDIF_FILE:
break;
case OPEN_ZIP_FILE:
break;
case GENERIC_FILE:
break;
default:
}
{
}
}
}