/*
* 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 legal-notices/CDDLv1_0.txt
* 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 legal-notices/CDDLv1_0.txt.
* 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 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2015 ForgeRock AS
*/
/**
* This is a class that automates the update of a text field with what the user
* selects in a file chooser. The class is not in charge of creating the
* components or of updating the layout, it simply adds the required listeners
* in the buttons and text fields so that a file chooser will be displayed
* when the user clicks on the button and if the user chooses a file or a
* directory the text field will be updated accordingly.
*
*/
{
/**
* 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.
*/
/**
* The Browser is used to create a generic file.
*/
/**
* The Browser is used to create an LDIF file.
*/
/**
* The Browser is used to create a generic directory.
*/
}
/**
* 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 CREATE_DIRECTORY:
break;
case OPEN_LDIF_FILE:
new ExtensionFileFilter("ldif",
break;
case CREATE_LDIF_FILE:
break;
case OPEN_ZIP_FILE:
new ExtensionFileFilter("zip",
break;
case OPEN_GENERIC_FILE:
break;
case CREATE_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.
*
*/
{
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 OPEN_GENERIC_FILE:
break;
case CREATE_GENERIC_FILE:
break;
case CREATE_LDIF_FILE:
break;
case CREATE_DIRECTORY:
break;
default:
}
{
fieldUpdated();
}
}
/**
* The method that is called after the text field is updated.
*
*/
protected void fieldUpdated()
{
}
}