Package org.openstreetmap.josm.actions
Class OpenFileAction.OpenFileTask
- java.lang.Object
-
- org.openstreetmap.josm.gui.PleaseWaitRunnable
-
- org.openstreetmap.josm.actions.OpenFileAction.OpenFileTask
-
- All Implemented Interfaces:
java.lang.Runnable
,ProgressMonitor.CancelListener
- Enclosing class:
- OpenFileAction
public static class OpenFileAction.OpenFileTask extends PleaseWaitRunnable
Task to open files.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
canceled
private java.util.Set<java.lang.String>
failedAll
private javax.swing.filechooser.FileFilter
fileFilter
private java.util.Set<java.lang.String>
fileHistory
private java.util.List<java.io.File>
files
private java.util.EnumSet<Options>
options
private java.util.List<java.io.File>
successfullyOpenedFiles
-
Fields inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
progressMonitor
-
-
Constructor Summary
Constructors Constructor Description OpenFileTask(java.util.List<java.io.File> files, javax.swing.filechooser.FileFilter fileFilter)
Constructs a newOpenFileTask
.OpenFileTask(java.util.List<java.io.File> files, javax.swing.filechooser.FileFilter fileFilter, java.lang.String title)
Constructs a newOpenFileTask
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
alertFilesNotMatchingWithImporter(java.util.Collection<java.io.File> files, FileImporter importer)
protected void
alertFilesWithUnknownImporter(java.util.Collection<java.io.File> files)
protected void
cancel()
User pressed cancel button.private static void
checkNewLayers(java.util.List<Layer> oldLayers)
protected void
finish()
Finish up the data work.java.util.Set<Options>
getOptions()
Get the options for this taskjava.util.List<java.io.File>
getSuccessfullyOpenedFiles()
Replies the list of files that have been successfully opened.void
importData(FileImporter importer, java.util.List<java.io.File> files)
Import data files with the given importer.boolean
isRecordHistory()
Determines if filename must be saved in history (for list of recently opened files).protected void
realRun()
Called in the worker thread to do the actual work.void
setOptions(Options... options)
Set the options for the task.-
Methods inherited from class org.openstreetmap.josm.gui.PleaseWaitRunnable
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
-
-
-
-
Field Detail
-
files
private final java.util.List<java.io.File> files
-
successfullyOpenedFiles
private final java.util.List<java.io.File> successfullyOpenedFiles
-
fileHistory
private final java.util.Set<java.lang.String> fileHistory
-
failedAll
private final java.util.Set<java.lang.String> failedAll
-
fileFilter
private final javax.swing.filechooser.FileFilter fileFilter
-
canceled
private boolean canceled
-
-
Constructor Detail
-
OpenFileTask
public OpenFileTask(java.util.List<java.io.File> files, javax.swing.filechooser.FileFilter fileFilter, java.lang.String title)
Constructs a newOpenFileTask
.- Parameters:
files
- files to openfileFilter
- file filtertitle
- message for the user
-
OpenFileTask
public OpenFileTask(java.util.List<java.io.File> files, javax.swing.filechooser.FileFilter fileFilter)
Constructs a newOpenFileTask
.- Parameters:
files
- files to openfileFilter
- file filter
-
-
Method Detail
-
setOptions
public void setOptions(Options... options)
Set the options for the task.- Parameters:
options
- The options to set- Since:
- 17556
- See Also:
Options
-
isRecordHistory
public boolean isRecordHistory()
Determines if filename must be saved in history (for list of recently opened files).- Returns:
true
if filename must be saved in history
-
getOptions
public java.util.Set<Options> getOptions()
Get the options for this task- Returns:
- A set of options
- Since:
- 17534
-
cancel
protected void cancel()
Description copied from class:PleaseWaitRunnable
User pressed cancel button.- Specified by:
cancel
in classPleaseWaitRunnable
-
finish
protected void finish()
Description copied from class:PleaseWaitRunnable
Finish up the data work. Is guaranteed to be called if realRun is called. Finish is called in the gui thread just after the dialog disappeared.- Specified by:
finish
in classPleaseWaitRunnable
-
alertFilesNotMatchingWithImporter
protected void alertFilesNotMatchingWithImporter(java.util.Collection<java.io.File> files, FileImporter importer)
-
alertFilesWithUnknownImporter
protected void alertFilesWithUnknownImporter(java.util.Collection<java.io.File> files)
-
realRun
protected void realRun() throws org.xml.sax.SAXException, java.io.IOException, OsmTransferException
Description copied from class:PleaseWaitRunnable
Called in the worker thread to do the actual work. When any of the exception is thrown, a message box will be displayed and closeDialog is called. finish() is called in any case.- Specified by:
realRun
in classPleaseWaitRunnable
- Throws:
org.xml.sax.SAXException
- if a SAX error occursjava.io.IOException
- if an I/O error occursOsmTransferException
- if a communication error with the OSM server occurs
-
checkNewLayers
private static void checkNewLayers(java.util.List<Layer> oldLayers)
-
importData
public void importData(FileImporter importer, java.util.List<java.io.File> files)
Import data files with the given importer.- Parameters:
importer
- file importerfiles
- data files to import
-
getSuccessfullyOpenedFiles
public java.util.List<java.io.File> getSuccessfullyOpenedFiles()
Replies the list of files that have been successfully opened.- Returns:
- The list of files that have been successfully opened.
-
-