|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openstreetmap.josm.gui.widgets.JFileChooserManager
public class JFileChooserManager
A chained utility class used to create and open JFileChooser
dialogs.
Use only this class if you need to control specifically your JFileChooser dialog.
A simpler usage is to call the DiskAccessAction.createAndOpenFileChooser(boolean, boolean, java.lang.String)
methods.
Field Summary | |
---|---|
private java.lang.String |
curDir
|
private javax.swing.JFileChooser |
fc
|
private java.lang.String |
lastDirProperty
|
private boolean |
open
|
Constructor Summary | |
---|---|
JFileChooserManager(boolean open)
Creates a new JFileChooserManager . |
|
JFileChooserManager(boolean open,
java.lang.String lastDirProperty)
Creates a new JFileChooserManager . |
|
JFileChooserManager(boolean open,
java.lang.String lastDirProperty,
java.lang.String defaultDir)
Creates a new JFileChooserManager . |
Method Summary | |
---|---|
JFileChooserManager |
createFileChooser()
Creates a new JFileChooser with default settings. |
JFileChooserManager |
createFileChooser(boolean multiple,
java.lang.String title,
java.util.Collection<? extends javax.swing.filechooser.FileFilter> filters,
javax.swing.filechooser.FileFilter defaultFilter,
int selectionMode)
Creates a new JFileChooser with given settings for a collection of FileFilter s. |
JFileChooserManager |
createFileChooser(boolean multiple,
java.lang.String title,
javax.swing.filechooser.FileFilter filter,
int selectionMode)
Creates a new JFileChooser with given settings for a single FileFilter . |
JFileChooserManager |
createFileChooser(boolean multiple,
java.lang.String title,
java.lang.String extension,
boolean allTypes,
int selectionMode)
Creates a new JFileChooser with given settings for a file extension. |
private JFileChooserManager |
doCreateFileChooser(boolean multiple,
java.lang.String title,
java.util.Collection<? extends javax.swing.filechooser.FileFilter> filters,
javax.swing.filechooser.FileFilter defaultFilter,
java.lang.String extension,
int selectionMode,
boolean allTypes)
|
javax.swing.JFileChooser |
getFileChooser()
Replies the JFileChooser that has been previously created. |
java.lang.String |
getInitialDirectory()
Replies the initial directory used to construct the JFileChooser . |
javax.swing.JFileChooser |
openFileChooser()
Opens the JFileChooser that has been created. |
javax.swing.JFileChooser |
openFileChooser(java.awt.Component parent)
Opens the JFileChooser that has been created and waits for the user to choose a file/directory, or cancel the dialog.Nothing happens if the dialog has not been created yet. When the user choses a file or directory, the lastDirProperty is updated to the chosen directory path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private final boolean open
private final java.lang.String lastDirProperty
private final java.lang.String curDir
private javax.swing.JFileChooser fc
Constructor Detail |
---|
public JFileChooserManager(boolean open)
JFileChooserManager
.
open
- If true, "Open File" dialogs will be created. If false, "Save File" dialogs will be created.createFileChooser()
public JFileChooserManager(boolean open, java.lang.String lastDirProperty)
JFileChooserManager
.
open
- If true, "Open File" dialogs will be created. If false, "Save File" dialogs will be created.lastDirProperty
- The name of the property used to get the last directory. This directory is used to initialize the JFileChooser.
Then, if the user effetively choses a file or a directory, this property will be updated to the directory path.createFileChooser()
public JFileChooserManager(boolean open, java.lang.String lastDirProperty, java.lang.String defaultDir)
JFileChooserManager
.
open
- If true, "Open File" dialogs will be created. If false, "Save File" dialogs will be created.lastDirProperty
- The name of the property used to get the last directory. This directory is used to initialize the JFileChooser.
Then, if the user effetively choses a file or a directory, this property will be updated to the directory path.defaultDir
- The default directory used to initialize the JFileChooser if the lastDirProperty
property value is missing.createFileChooser()
Method Detail |
---|
public final javax.swing.JFileChooser getFileChooser()
JFileChooser
that has been previously created.
JFileChooser
that has been previously created, or null
if it has not been created yet.createFileChooser()
public final java.lang.String getInitialDirectory()
JFileChooser
.
JFileChooser
.public final JFileChooserManager createFileChooser()
JFileChooser
with default settings. All files will be accepted.
public final JFileChooserManager createFileChooser(boolean multiple, java.lang.String title, javax.swing.filechooser.FileFilter filter, int selectionMode)
JFileChooser
with given settings for a single FileFilter
.
multiple
- If true, makes the dialog allow multiple file selectionstitle
- The string that goes in the dialog window's title barfilter
- The only file filter that will be proposed by the dialogselectionMode
- The selection mode that allows the user to:JFileChooser.FILES_ONLY
)JFileChooser.DIRECTORIES_ONLY
)JFileChooser.FILES_AND_DIRECTORIES
)DiskAccessAction.createAndOpenFileChooser(boolean, boolean, String, FileFilter, int, String)
public final JFileChooserManager createFileChooser(boolean multiple, java.lang.String title, java.util.Collection<? extends javax.swing.filechooser.FileFilter> filters, javax.swing.filechooser.FileFilter defaultFilter, int selectionMode)
JFileChooser
with given settings for a collection of FileFilter
s.
multiple
- If true, makes the dialog allow multiple file selectionstitle
- The string that goes in the dialog window's title barfilters
- The file filters that will be proposed by the dialogdefaultFilter
- The file filter that will be selected by defaultselectionMode
- The selection mode that allows the user to:JFileChooser.FILES_ONLY
)JFileChooser.DIRECTORIES_ONLY
)JFileChooser.FILES_AND_DIRECTORIES
)DiskAccessAction.createAndOpenFileChooser(boolean, boolean, String, Collection, FileFilter, int, String)
public final JFileChooserManager createFileChooser(boolean multiple, java.lang.String title, java.lang.String extension, boolean allTypes, int selectionMode)
JFileChooser
with given settings for a file extension.
multiple
- If true, makes the dialog allow multiple file selectionstitle
- The string that goes in the dialog window's title barextension
- The file extension that will be selected as the default file filterallTypes
- If true, all the files types known by JOSM will be proposed in the "file type" combobox.
If false, only the file filters that include extension
will be proposedselectionMode
- The selection mode that allows the user to:JFileChooser.FILES_ONLY
)JFileChooser.DIRECTORIES_ONLY
)JFileChooser.FILES_AND_DIRECTORIES
)DiskAccessAction.createAndOpenFileChooser(boolean, boolean, String, FileFilter, int, String)
private final JFileChooserManager doCreateFileChooser(boolean multiple, java.lang.String title, java.util.Collection<? extends javax.swing.filechooser.FileFilter> filters, javax.swing.filechooser.FileFilter defaultFilter, java.lang.String extension, int selectionMode, boolean allTypes)
public final javax.swing.JFileChooser openFileChooser()
JFileChooser
that has been created. Nothing happens if it has not been created yet.
JFileChooser
if the user effectively choses a file or directory. null
if the user cancelled the dialog.public javax.swing.JFileChooser openFileChooser(java.awt.Component parent)
JFileChooser
that has been created and waits for the user to choose a file/directory, or cancel the dialog.lastDirProperty
is updated to the chosen directory path.
parent
- The Component used as the parent of the JFileChooser. If null, uses Main.parent
.
JFileChooser
if the user effectively choses a file or directory. null
if the user cancelled the dialog.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |