Ticket #1967: supressErrorMessage.patch

File supressErrorMessage.patch, 6.8 KB (added by xeen, 17 years ago)

Adds low-level boolean silent that supresses all MessageBoxes

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

    diff -u -r orig/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
    old new  
    1919import org.xml.sax.SAXException;
    2020
    2121public class DownloadGpsTask implements DownloadTask {
    22 
     22    private boolean silent=false;
     23 
    2324    private static class Task extends PleaseWaitRunnable {
    2425        private BoundingBoxDownloader reader;
    2526        private GpxData rawData;
    2627        private final boolean newLayer;
    2728
    28         public Task(boolean newLayer, BoundingBoxDownloader reader) {
    29             super(tr("Downloading GPS data"));
     29        public Task(boolean newLayer, BoundingBoxDownloader reader, boolean silent) {
     30            super(tr("Downloading GPS data"), silent);
    3031            this.reader = reader;
    3132            this.newLayer = newLayer;
    3233        }
     
    6970    private JCheckBox checkBox = new JCheckBox(tr("Raw GPS data"));
    7071
    7172    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        Task task = new Task(action.dialog.newLayer.isSelected(), new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon), silent);
    7374        Main.worker.execute(task);
    7475    }
    7576
    7677    public JCheckBox getCheckBox() {
    7778        return checkBox;
    7879    }
     80   
     81    public void setSilent(boolean silent) {
     82        this.silent=silent;
     83    }
    7984
    8085    public String getPreferencesSuffix() {
    8186        return "gps";
  • src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    diff -u -r orig/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
    old new  
    2929public class DownloadOsmTask implements DownloadTask {
    3030
    3131    private static Bounds currentBounds;
     32    private boolean silent=false;
    3233
    3334    private static class Task extends PleaseWaitRunnable {
    3435        private OsmServerReader reader;
    3536        private DataSet dataSet;
    3637        private boolean newLayer;
    3738
    38         public Task(boolean newLayer, OsmServerReader reader) {
    39             super(tr("Downloading data"));
     39        public Task(boolean newLayer, OsmServerReader reader, boolean silent) {
     40            super(tr("Downloading data"), silent);
    4041            this.reader = reader;
    4142            this.newLayer = newLayer;
    4243        }
     
    8081            double t = minlon; minlon = maxlon; maxlon = t;
    8182        }
    8283
    83         Task task = new Task(action != null && (action.dialog == null || action.dialog.newLayer.isSelected()), new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon));
     84        Task task = new Task(action != null && (action.dialog == null || action.dialog.newLayer.isSelected()), new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon), silent);
    8485        currentBounds = new Bounds(new LatLon(minlat, minlon), new LatLon(maxlat, maxlon));
    8586        Main.worker.execute(task);
    8687    }
    8788
    8889    public void loadUrl(boolean new_layer, String url) {
    89         Task task = new Task(new_layer, new OsmServerLocationReader(url));
     90        Task task = new Task(new_layer, new OsmServerLocationReader(url), silent);
    9091        Main.worker.execute(task);
    9192    }
    92 
    93 
    94 
     93   
     94    public void setSilent(boolean silent) {
     95      this.silent=silent;
     96    }
    9597
    9698    public JCheckBox getCheckBox() {
    9799        return checkBox;
  • src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    diff -u -r orig/src/org/openstreetmap/josm/gui/download/DownloadDialog.java trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
    old new  
    4444         */
    4545        void download(DownloadAction action, double minlat, double minlon, double maxlat, double maxlon);
    4646        void loadUrl(boolean newLayer, String url);
     47        void setSilent(boolean silent);
    4748        /**
    4849         * @return The checkbox presented to the user
    4950         */
  • src/org/openstreetmap/josm/gui/layer/GpxLayer.java

    diff -u -r orig/src/org/openstreetmap/josm/gui/layer/GpxLayer.java trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
    old new  
    877877            // downloads left, and "cancel" needs to be honoured. An error along the way
    878878            // should abort the whole process.
    879879            DownloadTask osmTask = new DownloadOsmTask();
     880            osmTask.setSilent(true);
    880881            for (Rectangle2D td : toDownload) {
    881882               osmTask.download(null, td.getMinY(), td.getMinX(), td.getMaxY(), td.getMaxX());
    882883            }
  • src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java

    diff -u -r orig/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
    old new  
    2929
    3030    private boolean closeDialogCalled = false;
    3131    private boolean cancelled = false;
     32    private boolean silent = false;
    3233
    3334    private final String title;
    3435
    3536    /**
    3637     * Create the runnable object with a given message for the user.
    3738     */
    38     public PleaseWaitRunnable(String title) {
     39    public PleaseWaitRunnable(String title, boolean silent) {
    3940        this.title = title;
     41        this.silent = silent;
    4042        Main.pleaseWaitDlg.cancel.addActionListener(new ActionListener(){
    4143            public void actionPerformed(ActionEvent e) {
    4244                if (!cancelled) {
     
    130132                        Main.pleaseWaitDlg.setVisible(false);
    131133                        Main.pleaseWaitDlg.dispose();
    132134                    }
    133                     if (errorMessage != null)
    134                         JOptionPane.showMessageDialog(Main.parent, errorMessage);
     135                    if (errorMessage != null) {
     136                        if(silent)
     137                            System.out.println(errorMessage);
     138                        else
     139                            JOptionPane.showMessageDialog(Main.parent, errorMessage);
     140                    }
    135141                }
    136142            };