Changeset 3924 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-02-21T21:44:31+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r3815 r3924 476 476 if(!fileList.isEmpty()) 477 477 { 478 OpenFileAction.openFiles(fileList );478 OpenFileAction.openFiles(fileList, true); 479 479 } 480 480 } -
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r3758 r3924 14 14 import java.util.Collection; 15 15 import java.util.Collections; 16 import java.util.HashSet; 16 17 import java.util.LinkedHashSet; 17 18 import java.util.LinkedList; … … 73 74 */ 74 75 static public void openFiles(List<File> fileList) { 76 openFiles(fileList, false); 77 } 78 79 static public void openFiles(List<File> fileList, boolean recordHistory) { 75 80 OpenFileTask task = new OpenFileTask(fileList, null); 81 task.setRecordHistory(recordHistory); 76 82 Main.worker.submit(task); 77 83 } … … 225 231 } else { 226 232 // find appropriate importer 227 MultiMap<FileImporter, File> map = new MultiMap<FileImporter, File>();233 MultiMap<FileImporter, File> importerMap = new MultiMap<FileImporter, File>(); 228 234 List<File> filesWithUnknownImporter = new LinkedList<File>(); 229 235 FILES: for (File f : files) { 230 236 for (FileImporter importer : ExtensionFileFilter.importers) { 231 237 if (importer.acceptFile(f)) { 232 map.put(importer, f);238 importerMap.put(importer, f); 233 239 continue FILES; 234 240 } … … 239 245 alertFilesWithUnknownImporter(filesWithUnknownImporter); 240 246 } 241 List<FileImporter> im s = new ArrayList<FileImporter>(map.keySet());242 Collections.sort(im s);243 Collections.reverse(im s);247 List<FileImporter> importers = new ArrayList<FileImporter>(importerMap.keySet()); 248 Collections.sort(importers); 249 Collections.reverse(importers); 244 250 245 251 Set<String> fileHistory = new LinkedHashSet<String>(); 246 247 for (FileImporter importer : ims) { 248 List<File> files = new ArrayList<File>(map.get(importer)); 252 Set<String> failedAll = new HashSet<String>(); 253 254 for (FileImporter importer : importers) { 255 List<File> files = new ArrayList<File>(importerMap.get(importer)); 249 256 importData(importer, files); 257 // suppose all files will fail to load 258 List<File> failedFiles = new ArrayList<File>(files); 250 259 251 260 if (recordHistory && !importer.isBatchImporter()) { 252 for (File f : files) { 261 // remove the files which didn't fail to load from the failed list 262 failedFiles.removeAll(successfullyOpenedFiles); 263 for (File f : successfullyOpenedFiles) { 253 264 fileHistory.add(f.getPath()); 265 } 266 for (File f : failedFiles) { 267 failedAll.add(f.getPath()); 254 268 } 255 269 } … … 259 273 Collection<String> oldFileHistory = Main.pref.getCollection("file-open.history"); 260 274 fileHistory.addAll(oldFileHistory); 275 // remove the files which failed to load from the list 276 fileHistory.removeAll(failedAll); 261 277 int maxsize = Math.max(0, Main.pref.getInteger("file-open.history.max-size", 15)); 262 278 Collection<String> trimmedFileHistory = new ArrayList<String>(Math.min(maxsize, fileHistory.size()));
Note:
See TracChangeset
for help on using the changeset viewer.