org.geotools.swt.control
Class JFileDataStoreChooser

Object
  extended by JFileDataStoreChooser

public class JFileDataStoreChooser
extends Object

A file chooser dialog to get user choices for data stores.

Examples of use:

// prompt the user for a shapefile
 File file = JFileDataStoreChooser.showOpenFile("shp", parentFrame);
 if (file != null) {
    ...
 }

 // prompt the user for a given data format

 

Author:
Jody Garnett, Andrea Antonello (www.hydrologis.com)

Constructor Summary
JFileDataStoreChooser(Shell parent, int style, FileDataStoreFactorySpi format)
          Creates a dialog that filters for files matching the specified data format.
JFileDataStoreChooser(Shell parent, int style, List<String> extensions)
          Create a dialog that filters for files with the specified extensions.
JFileDataStoreChooser(Shell parent, int style, Map<String,String> fileAssociations)
          Creates a dialog based on the given file associations.
JFileDataStoreChooser(Shell parent, int style, String extension)
          Create a dialog that filters for files with the specified extension.
JFileDataStoreChooser(Shell parent, int style, String[] extensions)
          Create a dialog that filters for files with the specified extensions.
 
Method Summary
 FileDialog getFileDialog()
           
static void main(String[] arg)
          Demonstrates the file data store dialog by prompting for a shapefile
 void setSaveFile(File file)
          Consider the provided file as a candidate for a new filename.
static File showOpenFile(FileDataStoreFactorySpi format, File initialDir, Shell parent)
          Show a file open dialog that filters for files that match a given file data store format
static File showOpenFile(FileDataStoreFactorySpi format, Shell parent)
          Show a file open dialog that filters for files that match a given file data store format
static File showOpenFile(String[] extensions, File initialDir, Shell parent)
          Show a file open dialog that filters for files with the given extensions.
static File showOpenFile(String[] extensions, Shell parent)
          Show a file open dialog that filters for files with the given extensions.
static File showOpenFile(String extension, File initialDir, Shell parent)
          Show a file open dialog that filters for files with the given extension.
static File showOpenFile(String extension, Shell parent)
          Show a file open dialog that filters for files with the given extension.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JFileDataStoreChooser

public JFileDataStoreChooser(Shell parent,
                             int style,
                             String extension)
Create a dialog that filters for files with the specified extension.

Parameters:
extension - the file extension, with or without the leading '.'

JFileDataStoreChooser

public JFileDataStoreChooser(Shell parent,
                             int style,
                             List<String> extensions)
Create a dialog that filters for files with the specified extensions.

Parameters:
extensions - the file extensions, with or without the leading '.'

JFileDataStoreChooser

public JFileDataStoreChooser(Shell parent,
                             int style,
                             String[] extensions)
Create a dialog that filters for files with the specified extensions.

Parameters:
extensions - the file extensions, with or without the leading '.'

JFileDataStoreChooser

public JFileDataStoreChooser(Shell parent,
                             int style,
                             Map<String,String> fileAssociations)
Creates a dialog based on the given file associations.

 Map assoc = new HashMap();
 assoc.put(".foo", "Foo data files (*.foo)");
 assoc.put(".bar", "Bar data files (*.bar)");
 JFileDataStoreChooser chooser = new JFileDataStoreChooser(assoc);
 

Parameters:
fileAssociations - a Map where keys are extensions (with or wirhout the leading dot) and values are descriptions.

JFileDataStoreChooser

public JFileDataStoreChooser(Shell parent,
                             int style,
                             FileDataStoreFactorySpi format)
Creates a dialog that filters for files matching the specified data format.

Parameters:
format - data file format
Method Detail

getFileDialog

public FileDialog getFileDialog()

showOpenFile

public static File showOpenFile(String extension,
                                Shell parent)
Show a file open dialog that filters for files with the given extension.

Parameters:
extension - file extension, with or without leading '.'
parent - parent GUI component (may be null)
Returns:
the selected file or null if the user cancelled the selection
Throws:
HeadlessException - if run in an unsupported environment

showOpenFile

public static File showOpenFile(String extension,
                                File initialDir,
                                Shell parent)
Show a file open dialog that filters for files with the given extension.

Parameters:
extension - file extension, with or without leading '.'
initialDir - initial directory to display; if null the initial directory will be the user's default directory
parent - parent GUI component (may be null)
Returns:
the selected file or null if the user cancelled the selection
Throws:
HeadlessException - if run in an unsupported environment

showOpenFile

public static File showOpenFile(String[] extensions,
                                Shell parent)
Show a file open dialog that filters for files with the given extensions.

Parameters:
extensions - array of file extension, with or without leading '.'
parent - parent GUI component (may be null)
Returns:
the selected file or null if the user cancelled the selection
Throws:
HeadlessException - if run in an unsupported environment

showOpenFile

public static File showOpenFile(String[] extensions,
                                File initialDir,
                                Shell parent)
Show a file open dialog that filters for files with the given extensions.

Parameters:
extensions - array of file extension, with or without leading '.'
initialDir - initial directory to display; if null the initial directory will be the user's default directory
parent - parent GUI component (may be null)
Returns:
the selected file or null if the user cancelled the selection
Throws:
HeadlessException - if run in an unsupported environment

showOpenFile

public static File showOpenFile(FileDataStoreFactorySpi format,
                                Shell parent)
Show a file open dialog that filters for files that match a given file data store format

Parameters:
format - the file data store format
parent - parent GUI component (may be null)
Returns:
the selected file or null if the user cancelled the selection
Throws:
HeadlessException - if run in an unsupported environment

showOpenFile

public static File showOpenFile(FileDataStoreFactorySpi format,
                                File initialDir,
                                Shell parent)
Show a file open dialog that filters for files that match a given file data store format

Parameters:
format - the file data store format
initialDir - initial directory to display; if null the initial directory will be the user's default directory
parent - parent GUI component (may be null)
Returns:
the selected file or null if the user cancelled the selection
Throws:
HeadlessException - if run in an unsupported environment

main

public static void main(String[] arg)
Demonstrates the file data store dialog by prompting for a shapefile

Parameters:
arg - ignored

setSaveFile

public void setSaveFile(File file)
Consider the provided file as a candidate for a new filename. A number will be appended to the filename if there is a conflict.

Parameters:
file - the candidate file name


Copyright © 1996-2014 Geotools. All Rights Reserved.