Changeset 1373 in josm for trunk


Ignore:
Timestamp:
2009-02-07T22:03:47+01:00 (16 years ago)
Author:
stoecker
Message:

fixed #1425. modified patch by xeen

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/Main.java

    r1356 r1373  
    3030import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
    3131import org.openstreetmap.josm.actions.mapmode.MapMode;
     32import org.openstreetmap.josm.actions.SaveAction;
    3233import org.openstreetmap.josm.actions.search.SearchAction;
    3334import org.openstreetmap.josm.data.Bounds;
     
    3738import org.openstreetmap.josm.data.projection.Epsg4326;
    3839import org.openstreetmap.josm.data.projection.Projection;
     40import org.openstreetmap.josm.gui.ExtendedDialog;
    3941import org.openstreetmap.josm.gui.GettingStarted;
    4042import org.openstreetmap.josm.gui.MainMenu;
     
    340342            }
    341343            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"
     345                +tr("Hint: Some changes came from uploading new data to the server.") : "";
     346                int result = new ExtendedDialog(parent, 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                    Boolean savefailed = false;
     354                    for (final Layer l : map.mapView.getAllLayers()) {
     355                        if (l instanceof OsmDataLayer && ((OsmDataLayer)l).isModified()) {
     356                            SaveAction save = new SaveAction(l);
     357                            if(!save.doSave())
     358                                savefailed = true;
     359                        }
     360                    }
     361                    return savefailed;
     362                }
     363                else if(result != 2) // Cancel exiting unless the 2nd button was clicked
    347364                    return true;
    348365            }
  • trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java

    r1180 r1373  
    3434
    3535    public void actionPerformed(ActionEvent e) {
     36        doSave();
     37    }
     38
     39    public Boolean doSave() {
    3640        Layer layer = this.layer;
    3741        if (layer == null && Main.map != null && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
     
    4246
    4347        if (!checkSaveConditions(layer))
    44             return;
     48            return false;
    4549
    4650
    4751        File file = getFile(layer);
    4852        if (file == null)
    49             return;
     53            return false;
    5054
    5155        save(file, layer);
     
    5458        layer.associatedFile = file;
    5559        Main.parent.repaint();
     60        return true;
    5661    }
    5762
Note: See TracChangeset for help on using the changeset viewer.