Changeset 7453 in josm
- Timestamp:
- 2014-08-28T19:43:57+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r7315 r7453 42 42 43 43 /** 44 * Open a file chooser dialog and select an file to import. Then call the gpx-import driver. Finally 45 * open an internal frame into the main window with the gpx data shown. 44 * Open a file chooser dialog and select a file to import. 46 45 * 47 46 * @author imi 47 * @since 1146 48 48 */ 49 49 public class OpenFileAction extends DiskAccessAction { … … 94 94 95 95 public static class OpenFileTask extends PleaseWaitRunnable { 96 private List<File> files; 97 private List<File> successfullyOpenedFiles = new ArrayList<>(); 98 private FileFilter fileFilter; 96 private final List<File> files; 97 private final List<File> successfullyOpenedFiles = new ArrayList<>(); 98 private final Set<String> fileHistory = new LinkedHashSet<>(); 99 private final Set<String> failedAll = new HashSet<>(); 100 private final FileFilter fileFilter; 99 101 private boolean canceled; 100 102 private boolean recordHistory = false; … … 269 271 Collections.reverse(importers); 270 272 271 Set<String> fileHistory = new LinkedHashSet<>();272 Set<String> failedAll = new HashSet<>();273 274 273 for (FileImporter importer : importers) { 275 List<File> files = new ArrayList<>(importerMap.get(importer)); 276 importData(importer, files); 277 // suppose all files will fail to load 278 List<File> failedFiles = new ArrayList<>(files); 279 280 if (recordHistory && !importer.isBatchImporter()) { 281 // remove the files which didn't fail to load from the failed list 282 failedFiles.removeAll(successfullyOpenedFiles); 283 for (File f : successfullyOpenedFiles) { 284 fileHistory.add(f.getCanonicalPath()); 285 } 286 for (File f : failedFiles) { 287 failedAll.add(f.getCanonicalPath()); 288 } 289 } 274 importData(importer, new ArrayList<>(importerMap.get(importer))); 290 275 } 291 276 … … 304 289 } 305 290 } 306 307 if (recordHistory) { 308 Collection<String> oldFileHistory = Main.pref.getCollection("file-open.history");309 fileHistory.addAll(oldFileHistory);310 // remove the files which failed to load from the list311 fileHistory.removeAll(failedAll);312 int maxsize = Math.max(0, Main.pref.getInteger("file-open.history.max-size", 15));313 Main.pref.putCollectionBounded("file-open.history", maxsize, fileHistory);314 }291 } 292 293 if (recordHistory) { 294 Collection<String> oldFileHistory = Main.pref.getCollection("file-open.history"); 295 fileHistory.addAll(oldFileHistory); 296 // remove the files which failed to load from the list 297 fileHistory.removeAll(failedAll); 298 int maxsize = Math.max(0, Main.pref.getInteger("file-open.history.max-size", 15)); 299 Main.pref.putCollectionBounded("file-open.history", maxsize, fileHistory); 315 300 } 316 301 } … … 334 319 } 335 320 } 321 if (recordHistory && !importer.isBatchImporter()) { 322 for (File f : files) { 323 try { 324 if (successfullyOpenedFiles.contains(f)) { 325 fileHistory.add(f.getCanonicalPath()); 326 } else { 327 failedAll.add(f.getCanonicalPath()); 328 } 329 } catch (IOException e) { 330 Main.warn(e); 331 } 332 } 333 } 336 334 } 337 335
Note:
See TracChangeset
for help on using the changeset viewer.