Changeset 10444 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-06-21T00:05:47+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r10386 r10444 24 24 import java.util.Timer; 25 25 import java.util.TimerTask; 26 import java.util.concurrent.ExecutionException; 27 import java.util.concurrent.Future; 26 28 import java.util.regex.Pattern; 27 29 … … 108 110 } 109 111 112 /** 113 * Starts the autosave background task. 114 */ 110 115 public void schedule() { 111 116 if (PROP_INTERVAL.get() > 0) { … … 129 134 timer = new Timer(true); 130 135 timer.schedule(this, 1000L, PROP_INTERVAL.get() * 1000L); 131 Main.getLayerManager().addLayerChangeListener(this); 132 if (Main.isDisplayingMapView()) { 133 for (OsmDataLayer l: Main.getLayerManager().getLayersOfType(OsmDataLayer.class)) { 134 registerNewlayer(l); 135 } 136 } 136 Main.getLayerManager().addLayerChangeListener(this, true); 137 137 } 138 138 } … … 357 357 } 358 358 359 public void recoverUnsavedLayers() { 359 /** 360 * Recover the unsaved layers and open them asynchronously. 361 * @return A future that can be used to wait for the completion of this task. 362 */ 363 public Future<?> recoverUnsavedLayers() { 360 364 List<File> files = getUnsavedLayersFiles(); 361 365 final OpenFileTask openFileTsk = new OpenFileTask(files, null, tr("Restoring files")); 362 Main.worker.submit(openFileTsk);363 Main.worker.submit(new Runnable() {366 final Future<?> openFilesFuture = Main.worker.submit(openFileTsk); 367 return Main.worker.submit(new Runnable() { 364 368 @Override 365 369 public void run() { 366 for (File f: openFileTsk.getSuccessfullyOpenedFiles()) { 367 moveToDeletedLayersFolder(f); 370 try { 371 // Wait for opened tasks to be generated. 372 openFilesFuture.get(); 373 for (File f: openFileTsk.getSuccessfullyOpenedFiles()) { 374 moveToDeletedLayersFolder(f); 375 } 376 } catch (InterruptedException | ExecutionException e) { 377 Main.error(e); 368 378 } 369 379 } … … 406 416 } 407 417 418 /** 419 * Mark all unsaved layers as deleted. They are still preserved in the deleted layers folder. 420 */ 408 421 public void discardUnsavedLayers() { 409 422 for (File f: getUnsavedLayersFiles()) { -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r10442 r10444 410 410 final MainFrame mainFrame = new MainFrame(contentPanePrivate, mainPanel, geometry); 411 411 Main.parent = mainFrame; 412 mainPanel.reAddListeners(); 412 413 413 414 if (args.containsKey(Option.LOAD_PREFERENCES)) { -
trunk/src/org/openstreetmap/josm/gui/MainPanel.java
r10432 r10444 41 41 super(new BorderLayout()); 42 42 this.layerManager = layerManager; 43 reAddListeners();44 43 } 45 44
Note:
See TracChangeset
for help on using the changeset viewer.