Ticket #1967: NoErrorMstg.2.patch

File NoErrorMstg.2.patch, 31.0 KB (added by xeen, 16 years ago)

Forgot removing fixed FIXME comment

  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java

     
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    66import java.io.IOException;
     7import java.util.concurrent.Future;
    78
    89import javax.swing.JCheckBox;
    910
    1011import org.openstreetmap.josm.Main;
    1112import org.openstreetmap.josm.actions.DownloadAction;
     13import org.openstreetmap.josm.data.gpx.GpxData;
    1214import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    1315import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;
     16import org.openstreetmap.josm.gui.layer.GpxLayer;
    1417import org.openstreetmap.josm.gui.layer.Layer;
    15 import org.openstreetmap.josm.gui.layer.GpxLayer;
    16 import org.openstreetmap.josm.data.gpx.GpxData;
    1718import org.openstreetmap.josm.io.BoundingBoxDownloader;
    1819import org.xml.sax.SAXException;
    1920
    2021public class DownloadGpsTask implements DownloadTask {
     22    private Future<Task> task = null;
    2123
    2224    private static class Task extends PleaseWaitRunnable {
    2325        private BoundingBoxDownloader reader;
    2426        private GpxData rawData;
    2527        private final boolean newLayer;
     28        private String msg = "";
    2629
    27         public Task(boolean newLayer, BoundingBoxDownloader reader) {
     30        public Task(boolean newLayer, BoundingBoxDownloader reader, boolean silent, String msg) {
    2831            super(tr("Downloading GPS data"));
     32            this.msg = msg;
    2933            this.reader = reader;
    3034            this.newLayer = newLayer;
     35            this.silent = silent;
    3136        }
    3237
    3338        @Override public void realRun() throws IOException, SAXException {
     39            Main.pleaseWaitDlg.setCustomText(msg);
    3440            rawData = reader.parseRawGps();
    3541        }
    3642
     
    4551                Main.main.addLayer(layer);
    4652            else
    4753                x.mergeFrom(layer);
     54
     55            Main.pleaseWaitDlg.setCustomText("");
    4856        }
    4957
    5058        private Layer findMergeLayer() {
     
    6371        @Override protected void cancel() {
    6472            if (reader != null)
    6573                reader.cancel();
     74            Main.pleaseWaitDlg.cancel.setEnabled(false);
    6675        }
    6776    }
    6877
    6978    private JCheckBox checkBox = new JCheckBox(tr("Raw GPS data"));
    7079
    71     public void download(DownloadAction action, double minlat, double minlon, double maxlat, double maxlon) {
    72         Task task = new Task(action.dialog.newLayer.isSelected(), new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon));
    73         Main.worker.execute(task);
     80    public void download(DownloadAction action, double minlat, double minlon,
     81            double maxlat, double maxlon) {
     82        download(action, minlat, minlon, maxlat, maxlon, false, "");
    7483    }
    7584
     85    public void download(DownloadAction action, double minlat, double minlon,
     86            double maxlat, double maxlon, boolean silent, String message) {
     87        Task t = new Task(action.dialog.newLayer.isSelected(),
     88                new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon),
     89                silent,
     90                message);
     91        // We need submit instead of execute so we can wait for it to finish and get the error
     92        // message if necessary. If no one calls getErrorMessage() it just behaves like execute.
     93        task = Main.worker.submit(t, t);
     94    }
     95
    7696    public JCheckBox getCheckBox() {
    7797        return checkBox;
    7898    }
     
    84104    public void loadUrl(boolean a,java.lang.String b) {
    85105        // FIXME this is not currently used
    86106    }
     107
     108    /*
     109     * (non-Javadoc)
     110     * @see org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask#getErrorMessage()
     111     */
     112    public String getErrorMessage() {
     113        if(task == null)
     114            return "";
     115
     116        try {
     117            Task t = task.get();
     118            return t.errorMessage == null
     119                ? ""
     120                : t.errorMessage;
     121        } catch (Exception e) {
     122            return "";
     123        }
     124    }
    87125}
  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

     
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    66import java.io.IOException;
     7import java.util.concurrent.Future;
    78
    89import javax.swing.JCheckBox;
    910
    1011import org.openstreetmap.josm.Main;
    1112import org.openstreetmap.josm.actions.DownloadAction;
     13import org.openstreetmap.josm.data.Bounds;
     14import org.openstreetmap.josm.data.coor.LatLon;
    1215import org.openstreetmap.josm.data.osm.DataSet;
    1316import org.openstreetmap.josm.data.osm.DataSource;
    1417import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    1518import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;
     19import org.openstreetmap.josm.gui.layer.Layer;
    1620import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1721import org.openstreetmap.josm.io.BoundingBoxDownloader;
    1822import org.openstreetmap.josm.io.OsmServerLocationReader;
    1923import org.openstreetmap.josm.io.OsmServerReader;
    20 import org.openstreetmap.josm.data.Bounds;
    21 import org.openstreetmap.josm.data.coor.LatLon;
    2224import org.xml.sax.SAXException;
    2325
    2426
     
    2729 * Run in the worker thread.
    2830 */
    2931public class DownloadOsmTask implements DownloadTask {
    30 
    3132    private static Bounds currentBounds;
     33    private Future<Task> task = null;
    3234
    3335    private static class Task extends PleaseWaitRunnable {
    3436        private OsmServerReader reader;
    3537        private DataSet dataSet;
    3638        private boolean newLayer;
    37 
    38         public Task(boolean newLayer, OsmServerReader reader) {
     39        private int num = 1;
     40        private String msg = "";
     41       
     42        public Task(boolean newLayer, OsmServerReader reader, boolean silent,
     43                int numLayers, String msg) {
    3944            super(tr("Downloading data"));
     45            this.msg = msg;
    4046            this.reader = reader;
    4147            this.newLayer = newLayer;
     48            this.silent = silent;
    4249        }
    4350
    4451        @Override public void realRun() throws IOException, SAXException {
     52            Main.pleaseWaitDlg.setCustomText(msg);
    4553            dataSet = reader.parseOsm();
    4654        }
    4755
    4856        @Override protected void finish() {
    4957            if (dataSet == null)
    50                 return; // user cancelled download or error occoured
     58                return; // user canceled download or error occurred
    5159            if (dataSet.allPrimitives().isEmpty()) {
    52                 errorMessage = tr("No data imported.");
     60                // If silent is set to true, we don't want to see information messages
     61                if(!silent)
     62                    errorMessage = tr("No data imported.");
    5363                // need to synthesize a download bounds lest the visual indication of downloaded
    5464                // area doesn't work
    5565                dataSet.dataSources.add(new DataSource(currentBounds, "OpenStreetMap server"));
    5666            }
    57 
    58             OsmDataLayer layer = new OsmDataLayer(dataSet, tr("Data Layer"), null);
     67           
     68            OsmDataLayer layer = new OsmDataLayer(dataSet, tr("Data Layer {0}", num), null);
    5969            if (newLayer)
    6070                Main.main.addLayer(layer);
    6171            else
    6272                Main.main.editLayer().mergeFrom(layer);
     73           
     74            Main.pleaseWaitDlg.setCustomText("");
    6375        }
    6476
    6577        @Override protected void cancel() {
    6678            if (reader != null)
    6779                reader.cancel();
     80            Main.pleaseWaitDlg.cancel.setEnabled(false);
    6881        }
    6982    }
    7083    private JCheckBox checkBox = new JCheckBox(tr("OpenStreetMap data"), true);
    7184
    72     public void download(DownloadAction action, double minlat, double minlon, double maxlat, double maxlon) {
     85    public void download(DownloadAction action, double minlat, double minlon,
     86            double maxlat, double maxlon, boolean silent, String message) {
    7387        // Swap min and max if user has specified them the wrong way round
    7488        // (easy to do if you are crossing 0, for example)
    7589        // FIXME should perhaps be done in download dialog?
     
    7993        if (minlon > maxlon) {
    8094            double t = minlon; minlon = maxlon; maxlon = t;
    8195        }
     96       
     97        boolean newLayer = action != null
     98                                && (action.dialog == null || action.dialog.newLayer.isSelected());
    8299
    83         Task task = new Task(action != null && (action.dialog == null || action.dialog.newLayer.isSelected()), new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon));
     100        Task t = new Task(newLayer,
     101                new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon),
     102                silent,
     103                getDataLayersCount(),
     104                message);
    84105        currentBounds = new Bounds(new LatLon(minlat, minlon), new LatLon(maxlat, maxlon));
    85         Main.worker.execute(task);
     106        // We need submit instead of execute so we can wait for it to finish and get the error
     107        // message if necessary. If no one calls getErrorMessage() it just behaves like execute.
     108        task = Main.worker.submit(t, t);       
    86109    }
     110   
     111    public void download(DownloadAction action, double minlat, double minlon,
     112            double maxlat, double maxlon) {
     113        download(action, minlat, minlon, maxlat, maxlon, false, "");
     114    }
    87115
     116    /**
     117     * Loads a given URL from the OSM Server
     118     * @param True if the data should be saved to a new layer
     119     * @param The URL as String
     120     */
    88121    public void loadUrl(boolean new_layer, String url) {
    89         Task task = new Task(new_layer, new OsmServerLocationReader(url));
    90         Main.worker.execute(task);
     122        Task t = new Task(new_layer,
     123                new OsmServerLocationReader(url),
     124                false,
     125                getDataLayersCount(),
     126                "");
     127        task = Main.worker.submit(t, t);
    91128    }
    92129
    93 
    94 
    95 
    96130    public JCheckBox getCheckBox() {
    97131        return checkBox;
    98132    }
     
    100134    public String getPreferencesSuffix() {
    101135        return "osm";
    102136    }
     137   
     138    /**
     139     * Finds the number of data layers currently opened
     140     * @return Number of data layers
     141     */
     142    private int getDataLayersCount() {
     143        if(Main.map == null || Main.map.mapView == null)
     144            return 0;
     145        int num = 0;
     146        for(Layer l : Main.map.mapView.getAllLayers())
     147            if(l instanceof OsmDataLayer)
     148                num++;
     149        return num;
     150    }
     151   
     152   /*
     153    * (non-Javadoc)
     154    * @see org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask#getErrorMessage()
     155    */
     156    public String getErrorMessage() {
     157        if(task == null)
     158            return "";       
     159
     160        try {
     161            Task t = task.get();
     162            return t.errorMessage == null
     163                ? ""
     164                : t.errorMessage;
     165        } catch (Exception e) {
     166            return "";
     167        }
     168    }
    103169}
  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.actions.downloadtasks;
     3
     4import static org.openstreetmap.josm.tools.I18n.tr;
     5
     6import java.awt.geom.Area;
     7import java.awt.geom.Rectangle2D;
     8import java.util.Collection;
     9import java.util.LinkedList;
     10import java.util.List;
     11
     12import javax.swing.JOptionPane;
     13
     14import org.openstreetmap.josm.Main;
     15import org.openstreetmap.josm.data.osm.DataSet;
     16import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;
     17import org.openstreetmap.josm.gui.layer.Layer;
     18import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     19
     20/**
     21 * This class encapsulates the downloading of several bounding boxes that would otherwise be too
     22 * large to download in one go. Error messages will be collected for all downloads and displayed
     23 * as a list in the end.
     24 * @author xeen
     25 *
     26 */
     27public class DownloadOsmTaskList implements Runnable {
     28    private List<DownloadTask> osmTasks = new LinkedList<DownloadTask>();
     29
     30    /**
     31     * Downloads a list of areas from the OSM Server
     32     * @param newLayer Set to true if all areas should be put into a single new layer
     33     * @param The List of Rectangle2D to download
     34     */
     35    public void download(boolean newLayer, List<Rectangle2D> rects) {
     36        if(newLayer) {
     37            Layer l = new OsmDataLayer(new DataSet(), tr("Data Layer"), null);
     38            Main.main.addLayer(l);
     39            Main.map.mapView.setActiveLayer(l);
     40        }
     41
     42        int i = 0;
     43        for(Rectangle2D td : rects) {
     44            i++;
     45            DownloadTask dt = new DownloadOsmTask();
     46            dt.download(null, td.getMinY(), td.getMinX(), td.getMaxY(), td.getMaxX(), true,
     47                    tr("Download {0} of {1} ({2} left)", i, rects.size(), rects.size()-i));
     48            osmTasks.add(dt);
     49        }
     50
     51        // If we try to get the error message now the download task will never have been started
     52        // and we'd be stuck in a classical dead lock. Instead attach this to the worker and once
     53        // run() gets called all downloadTasks have finished and we can grab the error messages.
     54        Main.worker.execute(this);
     55    }
     56
     57    /**
     58     * Downloads a list of areas from the OSM Server
     59     * @param newLayer Set to true if all areas should be put into a single new layer
     60     * @param The Collection of Areas to download
     61     */
     62    public void download(boolean newLayer, Collection<Area> areas) {
     63        List<Rectangle2D> rects = new LinkedList<Rectangle2D>();
     64        for(Area a : areas)
     65            rects.add(a.getBounds2D());
     66
     67        download(newLayer, rects);
     68    }
     69
     70    /**
     71     * Grabs and displays the error messages after all download threads have finished.
     72     */
     73    public void run() {
     74        String errors = "";
     75
     76        for(DownloadTask dt : osmTasks) {
     77            String err = dt.getErrorMessage();
     78            if(err.equals(""))
     79                continue;
     80            errors += "* " + err + "\r\n";
     81        }
     82
     83        osmTasks.clear();
     84        if(errors.equals(""))
     85            return;
     86
     87        JOptionPane.showMessageDialog(Main.parent,
     88                tr("The following errors occured during mass download:") + "\r\n" + errors,
     89                tr("Errors during Download"),
     90                JOptionPane.ERROR_MESSAGE);
     91    }
     92}
  • src/org/openstreetmap/josm/actions/UpdateDataAction.java

     
    66import java.awt.event.ActionEvent;
    77import java.awt.event.KeyEvent;
    88import java.awt.geom.Area;
    9 import java.awt.geom.Rectangle2D;
    109import java.util.ArrayList;
    1110import java.util.List;
    1211
    1312import org.openstreetmap.josm.Main;
    14 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
     13import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTaskList;
    1514import org.openstreetmap.josm.data.osm.DataSource;
    1615import org.openstreetmap.josm.gui.ExtendedDialog;
    17 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;
    1816import org.openstreetmap.josm.tools.Shortcut;
    1917
    2018public class UpdateDataAction extends JosmAction {
     
    7674        if(result != 1)
    7775            return;
    7876
    79         DownloadTask osmTask = new DownloadOsmTask();
    80         for(Area a : areas) {
    81             Rectangle2D td = a.getBounds2D();
    82             osmTask.download(null, td.getMinY(), td.getMinX(), td.getMaxY(), td.getMaxX());
    83         }
     77        new DownloadOsmTaskList().download(false, areas);
    8478    }
    8579
    8680}
  • src/org/openstreetmap/josm/gui/download/DownloadDialog.java

     
    5050
    5151    public interface DownloadTask {
    5252        /**
    53          * Execute the download.
     53         * Execute the download using the given bounding box
    5454         */
    55         void download(DownloadAction action, double minlat, double minlon, double maxlat, double maxlon);
     55        void download(DownloadAction action, double minlat, double minlon,
     56                double maxlat, double maxlon);
     57
     58        /**
     59         * Execute the download using the given bounding box. Set silent to true if no error
     60         * messages should be popped up. Message can be used to display an additional text below
     61         * the default description.
     62         */
     63        void download(DownloadAction action, double minlat, double minlon,
     64                double maxlat, double maxlon, boolean silent, String message);
     65
     66        /**
     67         * Execute the download using the given URL
     68         * @param newLayer
     69         * @param url
     70         */
    5671        void loadUrl(boolean newLayer, String url);
     72
    5773        /**
    5874         * @return The checkbox presented to the user
    5975         */
    6076        JCheckBox getCheckBox();
     77
    6178        /**
    6279         * @return The name of the preferences suffix to use for storing the
    6380         * selection state.
    6481         */
    6582        String getPreferencesSuffix();
     83
     84        /**
     85         * Gets the error message of the task once it executed. If there is no error message, an empty
     86         * string is returned.
     87         *
     88         * WARNING: Never call this in the same thread you requested the download() or it will cause a
     89         * dead lock. See actions/downloadTasks/DownloadOsmTaskList.java for a proper implementation.
     90         *
     91         * @return Error message or empty String
     92         */
     93        String getErrorMessage();
    6694    }
    6795
    6896    /**
  • src/org/openstreetmap/josm/gui/layer/GpxLayer.java

     
    1515import java.awt.event.ActionListener;
    1616import java.awt.geom.Area;
    1717import java.awt.geom.Rectangle2D;
    18 import java.io.BufferedReader;
    1918import java.io.File;
    20 import java.io.FileInputStream;
    21 import java.io.FileOutputStream;
    22 import java.io.InputStreamReader;
    23 import java.net.URL;
    24 import java.net.URLConnection;
    25 import java.net.UnknownHostException;
     19import java.text.DateFormat;
     20import java.text.DecimalFormat;
    2621import java.util.ArrayList;
    2722import java.util.Collection;
    2823import java.util.Collections;
    2924import java.util.Comparator;
    30 import java.util.LinkedList;
    3125import java.util.Date;
     26import java.util.LinkedList;
    3227import java.util.List;
    33 import java.text.DateFormat;
    34 import java.text.DecimalFormat;
    3528
    3629import javax.swing.AbstractAction;
    3730import javax.swing.Box;
    3831import javax.swing.ButtonGroup;
    3932import javax.swing.Icon;
    40 import javax.swing.JCheckBox;
    4133import javax.swing.JColorChooser;
    4234import javax.swing.JFileChooser;
    4335import javax.swing.JLabel;
     
    4739import javax.swing.JPanel;
    4840import javax.swing.JRadioButton;
    4941import javax.swing.JSeparator;
    50 import javax.swing.JTextField;
    5142import javax.swing.filechooser.FileFilter;
    5243
    5344import org.openstreetmap.josm.Main;
    5445import org.openstreetmap.josm.actions.RenameLayerAction;
    5546import org.openstreetmap.josm.actions.SaveAction;
    5647import org.openstreetmap.josm.actions.SaveAsAction;
    57 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
     48import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTaskList;
    5849import org.openstreetmap.josm.data.coor.EastNorth;
    5950import org.openstreetmap.josm.data.coor.LatLon;
    6051import org.openstreetmap.josm.data.gpx.GpxData;
     
    6859import org.openstreetmap.josm.gui.MapView;
    6960import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    7061import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
    71 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;
    7262import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker;
    7363import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    74 import org.openstreetmap.josm.io.GpxWriter;
    75 import org.openstreetmap.josm.io.MultiPartFormOutputStream;
    7664import org.openstreetmap.josm.tools.DontShowAgainInfo;
    7765import org.openstreetmap.josm.tools.GBC;
    7866import org.openstreetmap.josm.tools.ImageProvider;
     
    367355        {-ll0,+sl4,-sl4,+ll0},
    368356        {-ll0,-sl9,-ll0,+sl9}
    369357    };
    370    
     358
    371359    // the different color modes
    372360    enum colorModes { none, velocity, dilution }
    373    
     361
    374362    @Override public void paint(Graphics g, MapView mv) {
    375363
    376364        /****************************************************************
     
    379367        // Long startTime = System.currentTimeMillis();
    380368        Color neutralColor = getColor(name);
    381369        // also draw lines between points belonging to different segments
    382         boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force");   
     370        boolean forceLines = Main.pref.getBoolean("draw.rawgps.lines.force");
    383371        // draw direction arrows on the lines
    384         boolean direction = Main.pref.getBoolean("draw.rawgps.direction");   
     372        boolean direction = Main.pref.getBoolean("draw.rawgps.direction");
    385373        // don't draw lines if longer than x meters
    386         int maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", -1);       
     374        int maxLineLength = Main.pref.getInteger("draw.rawgps.max-line-length", -1);
    387375        // draw line between points, global setting
    388         boolean lines = Main.pref.getBoolean("draw.rawgps.lines");                               
     376        boolean lines = Main.pref.getBoolean("draw.rawgps.lines");
    389377        String linesKey = "draw.rawgps.lines.layer "+name;
    390378        // draw lines, per-layer setting
    391379        if (Main.pref.hasKey(linesKey))
    392             lines = Main.pref.getBoolean(linesKey);   
     380            lines = Main.pref.getBoolean(linesKey);
    393381        // paint large dots for points
    394382        boolean large = Main.pref.getBoolean("draw.rawgps.large");
    395383        // color the lines
    396384        colorModes colored = colorModes.none;
    397385        try {
    398             colored = colorModes.values()[Main.pref.getInteger("draw.rawgps.colors", 0)]; 
     386            colored = colorModes.values()[Main.pref.getInteger("draw.rawgps.colors", 0)];
    399387        } catch(Exception e) { }
    400388        // paint direction arrow with alternate math. may be faster
    401         boolean alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection");   
     389        boolean alternatedirection = Main.pref.getBoolean("draw.rawgps.alternatedirection");
    402390        // don't draw arrows nearer to each other than this
    403         int delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", 0);       
     391        int delta = Main.pref.getInteger("draw.rawgps.min-arrow-distance", 0);
    404392        // allows to tweak line coloring for different speed levels.
    405         int colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45); 
     393        int colorTracksTune = Main.pref.getInteger("draw.rawgps.colorTracksTune", 45);
    406394        /****************************************************************
    407395         ********** STEP 2a - CHECK CACHE VALIDITY **********************
    408396         ****************************************************************/
     
    447435                                    else
    448436                                        trkPnt.customColoring = colors[(int) (velColor)];
    449437                                    break;
    450                                
     438
    451439                                case dilution:
    452440                                    if(trkPnt.attr.get("hdop") != null) {
    453441                                        float hdop = ((Float)trkPnt.attr.get("hdop")).floatValue();
     
    457445                                        int hdopcolor = 255 - (hdoplvl > 255 ? 255 : hdoplvl);
    458446                                        trkPnt.customColoring = colors[hdopcolor];
    459447                                    }
    460                                     break;                               
     448                                    break;
    461449                            }
    462450
    463451                            if (maxLineLength == -1 || dist <= maxLineLength) {
     
    793781                return;
    794782            }
    795783
    796             // FIXME: DownloadTask's "please wait" dialog should display the number of
    797             // downloads left, and "cancel" needs to be honoured. An error along the way
    798             // should abort the whole process.
    799             DownloadTask osmTask = new DownloadOsmTask();
    800             for (Rectangle2D td : toDownload) {
    801                osmTask.download(null, td.getMinY(), td.getMinX(), td.getMaxY(), td.getMaxX());
    802             }
     784            new DownloadOsmTaskList().download(false, toDownload);
    803785        }
    804786    }
    805787
  • src/org/openstreetmap/josm/gui/PleaseWaitDialog.java

     
    2525    private final JProgressBar progressBar = new JProgressBar();
    2626
    2727    public final JLabel currentAction = new JLabel(I18n.tr("Contacting the OSM server..."));
     28    private final JLabel customText = new JLabel("");
    2829    public final BoundedRangeModel progress = progressBar.getModel();
    2930    public final JButton cancel = new JButton(I18n.tr("Cancel"));
    3031
     
    3435        JPanel pane = new JPanel(new GridBagLayout());
    3536        pane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
    3637        pane.add(currentAction, GBC.eol().fill(GBC.HORIZONTAL));
     38        pane.add(customText, GBC.eol().fill(GBC.HORIZONTAL));
    3739        pane.add(progressBar, GBC.eop().fill(GBC.HORIZONTAL));
    3840        pane.add(cancel, GBC.eol().anchor(GBC.CENTER));
    3941        setContentPane(pane);
    40         setSize(Main.pref.getInteger("progressdialog.size",600),100);
     42        //setSize(Main.pref.getInteger("progressdialog.size",600),100);
     43        setCustomText("");
    4144        setLocationRelativeTo(Main.parent);
    4245        addComponentListener(new ComponentListener() {
    4346            public void componentHidden(ComponentEvent e) {}
     
    5558        UIManager.put("ProgressBar.cycleTime", UIManager.getInt("ProgressBar.repaintInterval") * 100);
    5659        progressBar.setIndeterminate(newValue);
    5760    }
     61   
     62    /**
     63     * Sets a custom text line below currentAction. Can be used to display additional information
     64     * @param text
     65     */
     66    public void setCustomText(String text) {
     67        if(text.length() == 0) {
     68            customText.setVisible(false);
     69            setSize(Main.pref.getInteger("progressdialog.size", 600), 100);
     70            return;
     71        }
     72       
     73        customText.setVisible(true);
     74        customText.setText(text);
     75        setSize(Main.pref.getInteger("progressdialog.size", 600), 120);
     76    }
    5877}
  • src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java

     
    2424 * @author Imi
    2525 */
    2626public abstract class PleaseWaitRunnable implements Runnable {
    27 
     27    public boolean silent = false;
    2828    public String errorMessage;
    2929
    3030    private boolean closeDialogCalled = false;
     
    6565
    6666            // reset dialog state
    6767            Main.pleaseWaitDlg.setTitle(title);
     68            Main.pleaseWaitDlg.cancel.setEnabled(true);
     69            Main.pleaseWaitDlg.setCustomText("");
    6870            errorMessage = null;
    6971            closeDialogCalled = false;
    7072
     
    130132                        Main.pleaseWaitDlg.setVisible(false);
    131133                        Main.pleaseWaitDlg.dispose();
    132134                    }
    133                     if (errorMessage != null)
     135                    if (errorMessage != null && !silent)
    134136                        JOptionPane.showMessageDialog(Main.parent, errorMessage);
    135137                }
    136138            };
  • src/org/openstreetmap/josm/io/BoundingBoxDownloader.java

     
    9292        try {
    9393            Main.pleaseWaitDlg.progress.setValue(0);
    9494            Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server..."));
    95             Main.pleaseWaitDlg.setIndeterminate(true); 
     95            Main.pleaseWaitDlg.setIndeterminate(true);
    9696            final InputStream in = getInputStream("map?bbox="+lon1+","+lat1+","+lon2+","+lat2, Main.pleaseWaitDlg);
    97             Main.pleaseWaitDlg.setIndeterminate(false); 
     97            Main.pleaseWaitDlg.setIndeterminate(false);
    9898            if (in == null)
    9999                return null;
    100100            Main.pleaseWaitDlg.currentAction.setText(tr("Downloading OSM data..."));
  • src/org/openstreetmap/josm/Main.java

     
    1515import java.util.Locale;
    1616import java.util.Map;
    1717import java.util.StringTokenizer;
    18 import java.util.concurrent.Executor;
     18import java.util.concurrent.ExecutorService;
    1919import java.util.concurrent.Executors;
    2020import java.util.regex.Matcher;
    2121import java.util.regex.Pattern;
     
    2626import javax.swing.JPanel;
    2727import javax.swing.UIManager;
    2828
     29import org.openstreetmap.josm.actions.SaveAction;
    2930import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask;
    3031import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask;
    3132import org.openstreetmap.josm.actions.mapmode.MapMode;
    32 import org.openstreetmap.josm.actions.SaveAction;
    3333import org.openstreetmap.josm.actions.search.SearchAction;
    3434import org.openstreetmap.josm.data.Bounds;
    3535import org.openstreetmap.josm.data.Preferences;
     
    5454import org.openstreetmap.josm.tools.ImageProvider;
    5555import org.openstreetmap.josm.tools.OsmUrlToBounds;
    5656import org.openstreetmap.josm.tools.PlatformHook;
     57import org.openstreetmap.josm.tools.PlatformHookOsx;
    5758import org.openstreetmap.josm.tools.PlatformHookUnixoid;
    5859import org.openstreetmap.josm.tools.PlatformHookWindows;
    59 import org.openstreetmap.josm.tools.PlatformHookOsx;
    6060import org.openstreetmap.josm.tools.Shortcut;
    6161
    6262abstract public class Main {
     
    7373     * calculations. The executed runnables are guaranteed to be executed separately
    7474     * and sequential.
    7575     */
    76     public final static Executor worker = Executors.newSingleThreadExecutor();
     76    public final static ExecutorService worker = Executors.newSingleThreadExecutor();
    7777    /**
    7878     * Global application preferences
    7979     */