Ticket #1425: MakeExitDialogLessHazardous (default to save).patch
File MakeExitDialogLessHazardous (default to save).patch, 2.7 KB (added by , 15 years ago) |
---|
-
src/org/openstreetmap/josm/Main.java
29 29 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask; 30 30 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 31 31 import org.openstreetmap.josm.actions.mapmode.MapMode; 32 import org.openstreetmap.josm.actions.SaveAction; 32 33 import org.openstreetmap.josm.actions.search.SearchAction; 33 34 import org.openstreetmap.josm.data.Bounds; 34 35 import org.openstreetmap.josm.data.Preferences; … … 36 37 import org.openstreetmap.josm.data.osm.DataSet; 37 38 import org.openstreetmap.josm.data.projection.Epsg4326; 38 39 import org.openstreetmap.josm.data.projection.Projection; 40 import org.openstreetmap.josm.gui.ExtendedDialog; 39 41 import org.openstreetmap.josm.gui.GettingStarted; 40 42 import org.openstreetmap.josm.gui.MainMenu; 41 43 import org.openstreetmap.josm.gui.MapFrame; … … 339 341 } 340 342 } 341 343 if (modified) { 342 final String msg = uploadedModified ? "\n"+tr("Hint: Some changes came from uploading new data to the server.") : ""; 343 final int answer = JOptionPane.showConfirmDialog( 344 parent, tr("There are unsaved changes. Discard the changes and continue?")+msg, 345 tr("Unsaved Changes"), JOptionPane.YES_NO_OPTION); 346 if (answer != JOptionPane.YES_OPTION) 344 final String msg = uploadedModified ? "\n"+tr("Hint: Some changes came from uploading new data to the server.") : ""; 345 int result = new ExtendedDialog(parent, 346 tr("Unsaved Changes"), 347 new javax.swing.JLabel(tr("There are unsaved changes. Discard the changes and continue?")+msg), 348 new String[] {tr("Save and Exit"), tr("Discard and Exit"), tr("Cancel")}, 349 new String[] {"save.png", "exit.png", "cancel.png"}).getValue(); 350 351 // Save before exiting 352 if(result == 1) { 353 for (final Layer l : map.mapView.getAllLayers()) { 354 if (l instanceof OsmDataLayer && ((OsmDataLayer)l).isModified()) { 355 SaveAction save = new SaveAction(l); 356 save.actionPerformed(null); 357 } 358 } 359 return false; 360 } 361 362 // Cancel exiting unless the 2nd button was clicked 363 if(result != 2) 347 364 return true; 348 365 } 349 366 }