Changeset 3435 in josm for trunk/src/org


Ignore:
Timestamp:
2010-08-14T07:39:38+02:00 (14 years ago)
Author:
jttt
Message:

Fix #5320 autosave restore: josm loads data before affirmation

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

Legend:

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

    r3381 r3435  
    244244    }
    245245
    246     public List<OsmDataLayer> getUnsavedLayers() {
    247         List<OsmDataLayer> result = new ArrayList<OsmDataLayer>();
    248 
     246    public List<File> getUnsavedLayersFiles() {
     247        List<File> result = new ArrayList<File>();
    249248        File[] files = autosaveDir.listFiles();
    250249        if (files == null)
    251250            return result;
    252         for (File f: autosaveDir.listFiles()) {
    253             if (f.isDirectory()) {
    254                 continue;
    255             }
     251        for (File file: files) {
     252            if (file.isFile()) {
     253                result.add(file);
     254            }
     255        }
     256        return result;
     257    }
     258
     259    public List<OsmDataLayer> getUnsavedLayers() {
     260        List<OsmDataLayer> result = new ArrayList<OsmDataLayer>();
     261
     262        for (File f: getUnsavedLayersFiles()) {
    256263            try {
    257264                DataSet ds = OsmReader.parseDataSet(new FileInputStream(f), NullProgressMonitor.INSTANCE);
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r3431 r3435  
    1010import java.awt.event.WindowAdapter;
    1111import java.awt.event.WindowEvent;
     12import java.io.File;
    1213import java.net.Authenticator;
    1314import java.net.ProxySelector;
     
    247248
    248249        AutosaveTask autosaveTask = new AutosaveTask();
    249         List<OsmDataLayer> unsavedLayers = autosaveTask.getUnsavedLayers();
    250         if (!unsavedLayers.isEmpty()) {
     250        List<File> unsavedLayerFiles = autosaveTask.getUnsavedLayersFiles();
     251        if (!unsavedLayerFiles.isEmpty()) {
    251252            ExtendedDialog dialog = new ExtendedDialog(
    252253                    Main.parent,
     
    255256            );
    256257            dialog.setContent(tr("JOSM found {0} unsaved osm data layers. It looks like JOSM crashed last time. Do you want to restore data?",
    257                     unsavedLayers.size()));
    258             dialog.setIcon(JOptionPane.INFORMATION_MESSAGE);
     258                    unsavedLayerFiles.size()));
    259259            dialog.setButtonIcons(new String[] {"ok.png", "cancel.png"});
    260260            dialog.showDialog();
    261261            if (dialog.getValue() == 1) {
    262                 for (OsmDataLayer layer: unsavedLayers) {
     262                for (OsmDataLayer layer: autosaveTask.getUnsavedLayers()) {
    263263                    Main.main.addLayer(layer);
    264264                }
     
    305305            if (version.startsWith("1.5") || version.startsWith("5")) {
    306306                JLabel ho = new JLabel("<html>"+
    307                     tr("<h2>JOSM requires Java version 6.</h2>"+
    308                         "Detected Java version: {0}.<br>"+
    309                         "You can <ul><li>update your Java (JRE) or</li>"+
    310                         "<li>use an earlier (Java 5 compatible) version of JOSM.</li></ul>"+
    311                         "More Info:", version)+"</html>");
     307                        tr("<h2>JOSM requires Java version 6.</h2>"+
     308                                "Detected Java version: {0}.<br>"+
     309                                "You can <ul><li>update your Java (JRE) or</li>"+
     310                                "<li>use an earlier (Java 5 compatible) version of JOSM.</li></ul>"+
     311                                "More Info:", version)+"</html>");
    312312                JTextArea link = new JTextArea("http://josm.openstreetmap.de/wiki/Help/SystemRequirements");
    313313                link.setEditable(false);
Note: See TracChangeset for help on using the changeset viewer.