Ticket #1967: NoErrorMstg.2.patch
File NoErrorMstg.2.patch, 31.0 KB (added by , 16 years ago) |
---|
-
src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 6 import java.io.IOException; 7 import java.util.concurrent.Future; 7 8 8 9 import javax.swing.JCheckBox; 9 10 10 11 import org.openstreetmap.josm.Main; 11 12 import org.openstreetmap.josm.actions.DownloadAction; 13 import org.openstreetmap.josm.data.gpx.GpxData; 12 14 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 13 15 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask; 16 import org.openstreetmap.josm.gui.layer.GpxLayer; 14 17 import org.openstreetmap.josm.gui.layer.Layer; 15 import org.openstreetmap.josm.gui.layer.GpxLayer;16 import org.openstreetmap.josm.data.gpx.GpxData;17 18 import org.openstreetmap.josm.io.BoundingBoxDownloader; 18 19 import org.xml.sax.SAXException; 19 20 20 21 public class DownloadGpsTask implements DownloadTask { 22 private Future<Task> task = null; 21 23 22 24 private static class Task extends PleaseWaitRunnable { 23 25 private BoundingBoxDownloader reader; 24 26 private GpxData rawData; 25 27 private final boolean newLayer; 28 private String msg = ""; 26 29 27 public Task(boolean newLayer, BoundingBoxDownloader reader ) {30 public Task(boolean newLayer, BoundingBoxDownloader reader, boolean silent, String msg) { 28 31 super(tr("Downloading GPS data")); 32 this.msg = msg; 29 33 this.reader = reader; 30 34 this.newLayer = newLayer; 35 this.silent = silent; 31 36 } 32 37 33 38 @Override public void realRun() throws IOException, SAXException { 39 Main.pleaseWaitDlg.setCustomText(msg); 34 40 rawData = reader.parseRawGps(); 35 41 } 36 42 … … 45 51 Main.main.addLayer(layer); 46 52 else 47 53 x.mergeFrom(layer); 54 55 Main.pleaseWaitDlg.setCustomText(""); 48 56 } 49 57 50 58 private Layer findMergeLayer() { … … 63 71 @Override protected void cancel() { 64 72 if (reader != null) 65 73 reader.cancel(); 74 Main.pleaseWaitDlg.cancel.setEnabled(false); 66 75 } 67 76 } 68 77 69 78 private JCheckBox checkBox = new JCheckBox(tr("Raw GPS data")); 70 79 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, ""); 74 83 } 75 84 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 76 96 public JCheckBox getCheckBox() { 77 97 return checkBox; 78 98 } … … 84 104 public void loadUrl(boolean a,java.lang.String b) { 85 105 // FIXME this is not currently used 86 106 } 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 } 87 125 } -
src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 6 import java.io.IOException; 7 import java.util.concurrent.Future; 7 8 8 9 import javax.swing.JCheckBox; 9 10 10 11 import org.openstreetmap.josm.Main; 11 12 import org.openstreetmap.josm.actions.DownloadAction; 13 import org.openstreetmap.josm.data.Bounds; 14 import org.openstreetmap.josm.data.coor.LatLon; 12 15 import org.openstreetmap.josm.data.osm.DataSet; 13 16 import org.openstreetmap.josm.data.osm.DataSource; 14 17 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 15 18 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask; 19 import org.openstreetmap.josm.gui.layer.Layer; 16 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 21 import org.openstreetmap.josm.io.BoundingBoxDownloader; 18 22 import org.openstreetmap.josm.io.OsmServerLocationReader; 19 23 import org.openstreetmap.josm.io.OsmServerReader; 20 import org.openstreetmap.josm.data.Bounds;21 import org.openstreetmap.josm.data.coor.LatLon;22 24 import org.xml.sax.SAXException; 23 25 24 26 … … 27 29 * Run in the worker thread. 28 30 */ 29 31 public class DownloadOsmTask implements DownloadTask { 30 31 32 private static Bounds currentBounds; 33 private Future<Task> task = null; 32 34 33 35 private static class Task extends PleaseWaitRunnable { 34 36 private OsmServerReader reader; 35 37 private DataSet dataSet; 36 38 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) { 39 44 super(tr("Downloading data")); 45 this.msg = msg; 40 46 this.reader = reader; 41 47 this.newLayer = newLayer; 48 this.silent = silent; 42 49 } 43 50 44 51 @Override public void realRun() throws IOException, SAXException { 52 Main.pleaseWaitDlg.setCustomText(msg); 45 53 dataSet = reader.parseOsm(); 46 54 } 47 55 48 56 @Override protected void finish() { 49 57 if (dataSet == null) 50 return; // user cancel led download or error occoured58 return; // user canceled download or error occurred 51 59 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."); 53 63 // need to synthesize a download bounds lest the visual indication of downloaded 54 64 // area doesn't work 55 65 dataSet.dataSources.add(new DataSource(currentBounds, "OpenStreetMap server")); 56 66 } 57 58 OsmDataLayer layer = new OsmDataLayer(dataSet, tr("Data Layer "), null);67 68 OsmDataLayer layer = new OsmDataLayer(dataSet, tr("Data Layer {0}", num), null); 59 69 if (newLayer) 60 70 Main.main.addLayer(layer); 61 71 else 62 72 Main.main.editLayer().mergeFrom(layer); 73 74 Main.pleaseWaitDlg.setCustomText(""); 63 75 } 64 76 65 77 @Override protected void cancel() { 66 78 if (reader != null) 67 79 reader.cancel(); 80 Main.pleaseWaitDlg.cancel.setEnabled(false); 68 81 } 69 82 } 70 83 private JCheckBox checkBox = new JCheckBox(tr("OpenStreetMap data"), true); 71 84 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) { 73 87 // Swap min and max if user has specified them the wrong way round 74 88 // (easy to do if you are crossing 0, for example) 75 89 // FIXME should perhaps be done in download dialog? … … 79 93 if (minlon > maxlon) { 80 94 double t = minlon; minlon = maxlon; maxlon = t; 81 95 } 96 97 boolean newLayer = action != null 98 && (action.dialog == null || action.dialog.newLayer.isSelected()); 82 99 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); 84 105 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); 86 109 } 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 } 87 115 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 */ 88 121 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); 91 128 } 92 129 93 94 95 96 130 public JCheckBox getCheckBox() { 97 131 return checkBox; 98 132 } … … 100 134 public String getPreferencesSuffix() { 101 135 return "osm"; 102 136 } 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 } 103 169 } -
src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java
1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.actions.downloadtasks; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.awt.geom.Area; 7 import java.awt.geom.Rectangle2D; 8 import java.util.Collection; 9 import java.util.LinkedList; 10 import java.util.List; 11 12 import javax.swing.JOptionPane; 13 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.data.osm.DataSet; 16 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask; 17 import org.openstreetmap.josm.gui.layer.Layer; 18 import 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 */ 27 public 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
6 6 import java.awt.event.ActionEvent; 7 7 import java.awt.event.KeyEvent; 8 8 import java.awt.geom.Area; 9 import java.awt.geom.Rectangle2D;10 9 import java.util.ArrayList; 11 10 import java.util.List; 12 11 13 12 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask ;13 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTaskList; 15 14 import org.openstreetmap.josm.data.osm.DataSource; 16 15 import org.openstreetmap.josm.gui.ExtendedDialog; 17 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;18 16 import org.openstreetmap.josm.tools.Shortcut; 19 17 20 18 public class UpdateDataAction extends JosmAction { … … 76 74 if(result != 1) 77 75 return; 78 76 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); 84 78 } 85 79 86 80 } -
src/org/openstreetmap/josm/gui/download/DownloadDialog.java
50 50 51 51 public interface DownloadTask { 52 52 /** 53 * Execute the download .53 * Execute the download using the given bounding box 54 54 */ 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 */ 56 71 void loadUrl(boolean newLayer, String url); 72 57 73 /** 58 74 * @return The checkbox presented to the user 59 75 */ 60 76 JCheckBox getCheckBox(); 77 61 78 /** 62 79 * @return The name of the preferences suffix to use for storing the 63 80 * selection state. 64 81 */ 65 82 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(); 66 94 } 67 95 68 96 /** -
src/org/openstreetmap/josm/gui/layer/GpxLayer.java
15 15 import java.awt.event.ActionListener; 16 16 import java.awt.geom.Area; 17 17 import java.awt.geom.Rectangle2D; 18 import java.io.BufferedReader;19 18 import 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; 19 import java.text.DateFormat; 20 import java.text.DecimalFormat; 26 21 import java.util.ArrayList; 27 22 import java.util.Collection; 28 23 import java.util.Collections; 29 24 import java.util.Comparator; 30 import java.util.LinkedList;31 25 import java.util.Date; 26 import java.util.LinkedList; 32 27 import java.util.List; 33 import java.text.DateFormat;34 import java.text.DecimalFormat;35 28 36 29 import javax.swing.AbstractAction; 37 30 import javax.swing.Box; 38 31 import javax.swing.ButtonGroup; 39 32 import javax.swing.Icon; 40 import javax.swing.JCheckBox;41 33 import javax.swing.JColorChooser; 42 34 import javax.swing.JFileChooser; 43 35 import javax.swing.JLabel; … … 47 39 import javax.swing.JPanel; 48 40 import javax.swing.JRadioButton; 49 41 import javax.swing.JSeparator; 50 import javax.swing.JTextField;51 42 import javax.swing.filechooser.FileFilter; 52 43 53 44 import org.openstreetmap.josm.Main; 54 45 import org.openstreetmap.josm.actions.RenameLayerAction; 55 46 import org.openstreetmap.josm.actions.SaveAction; 56 47 import org.openstreetmap.josm.actions.SaveAsAction; 57 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask ;48 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTaskList; 58 49 import org.openstreetmap.josm.data.coor.EastNorth; 59 50 import org.openstreetmap.josm.data.coor.LatLon; 60 51 import org.openstreetmap.josm.data.gpx.GpxData; … … 68 59 import org.openstreetmap.josm.gui.MapView; 69 60 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 70 61 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 71 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask;72 62 import org.openstreetmap.josm.gui.layer.markerlayer.AudioMarker; 73 63 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 74 import org.openstreetmap.josm.io.GpxWriter;75 import org.openstreetmap.josm.io.MultiPartFormOutputStream;76 64 import org.openstreetmap.josm.tools.DontShowAgainInfo; 77 65 import org.openstreetmap.josm.tools.GBC; 78 66 import org.openstreetmap.josm.tools.ImageProvider; … … 367 355 {-ll0,+sl4,-sl4,+ll0}, 368 356 {-ll0,-sl9,-ll0,+sl9} 369 357 }; 370 358 371 359 // the different color modes 372 360 enum colorModes { none, velocity, dilution } 373 361 374 362 @Override public void paint(Graphics g, MapView mv) { 375 363 376 364 /**************************************************************** … … 379 367 // Long startTime = System.currentTimeMillis(); 380 368 Color neutralColor = getColor(name); 381 369 // 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"); 383 371 // draw direction arrows on the lines 384 boolean direction = Main.pref.getBoolean("draw.rawgps.direction"); 372 boolean direction = Main.pref.getBoolean("draw.rawgps.direction"); 385 373 // 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); 387 375 // draw line between points, global setting 388 boolean lines = Main.pref.getBoolean("draw.rawgps.lines"); 376 boolean lines = Main.pref.getBoolean("draw.rawgps.lines"); 389 377 String linesKey = "draw.rawgps.lines.layer "+name; 390 378 // draw lines, per-layer setting 391 379 if (Main.pref.hasKey(linesKey)) 392 lines = Main.pref.getBoolean(linesKey); 380 lines = Main.pref.getBoolean(linesKey); 393 381 // paint large dots for points 394 382 boolean large = Main.pref.getBoolean("draw.rawgps.large"); 395 383 // color the lines 396 384 colorModes colored = colorModes.none; 397 385 try { 398 colored = colorModes.values()[Main.pref.getInteger("draw.rawgps.colors", 0)]; 386 colored = colorModes.values()[Main.pref.getInteger("draw.rawgps.colors", 0)]; 399 387 } catch(Exception e) { } 400 388 // 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"); 402 390 // 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); 404 392 // 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); 406 394 /**************************************************************** 407 395 ********** STEP 2a - CHECK CACHE VALIDITY ********************** 408 396 ****************************************************************/ … … 447 435 else 448 436 trkPnt.customColoring = colors[(int) (velColor)]; 449 437 break; 450 438 451 439 case dilution: 452 440 if(trkPnt.attr.get("hdop") != null) { 453 441 float hdop = ((Float)trkPnt.attr.get("hdop")).floatValue(); … … 457 445 int hdopcolor = 255 - (hdoplvl > 255 ? 255 : hdoplvl); 458 446 trkPnt.customColoring = colors[hdopcolor]; 459 447 } 460 break; 448 break; 461 449 } 462 450 463 451 if (maxLineLength == -1 || dist <= maxLineLength) { … … 793 781 return; 794 782 } 795 783 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); 803 785 } 804 786 } 805 787 -
src/org/openstreetmap/josm/gui/PleaseWaitDialog.java
25 25 private final JProgressBar progressBar = new JProgressBar(); 26 26 27 27 public final JLabel currentAction = new JLabel(I18n.tr("Contacting the OSM server...")); 28 private final JLabel customText = new JLabel(""); 28 29 public final BoundedRangeModel progress = progressBar.getModel(); 29 30 public final JButton cancel = new JButton(I18n.tr("Cancel")); 30 31 … … 34 35 JPanel pane = new JPanel(new GridBagLayout()); 35 36 pane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); 36 37 pane.add(currentAction, GBC.eol().fill(GBC.HORIZONTAL)); 38 pane.add(customText, GBC.eol().fill(GBC.HORIZONTAL)); 37 39 pane.add(progressBar, GBC.eop().fill(GBC.HORIZONTAL)); 38 40 pane.add(cancel, GBC.eol().anchor(GBC.CENTER)); 39 41 setContentPane(pane); 40 setSize(Main.pref.getInteger("progressdialog.size",600),100); 42 //setSize(Main.pref.getInteger("progressdialog.size",600),100); 43 setCustomText(""); 41 44 setLocationRelativeTo(Main.parent); 42 45 addComponentListener(new ComponentListener() { 43 46 public void componentHidden(ComponentEvent e) {} … … 55 58 UIManager.put("ProgressBar.cycleTime", UIManager.getInt("ProgressBar.repaintInterval") * 100); 56 59 progressBar.setIndeterminate(newValue); 57 60 } 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 } 58 77 } -
src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
24 24 * @author Imi 25 25 */ 26 26 public abstract class PleaseWaitRunnable implements Runnable { 27 27 public boolean silent = false; 28 28 public String errorMessage; 29 29 30 30 private boolean closeDialogCalled = false; … … 65 65 66 66 // reset dialog state 67 67 Main.pleaseWaitDlg.setTitle(title); 68 Main.pleaseWaitDlg.cancel.setEnabled(true); 69 Main.pleaseWaitDlg.setCustomText(""); 68 70 errorMessage = null; 69 71 closeDialogCalled = false; 70 72 … … 130 132 Main.pleaseWaitDlg.setVisible(false); 131 133 Main.pleaseWaitDlg.dispose(); 132 134 } 133 if (errorMessage != null )135 if (errorMessage != null && !silent) 134 136 JOptionPane.showMessageDialog(Main.parent, errorMessage); 135 137 } 136 138 }; -
src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
92 92 try { 93 93 Main.pleaseWaitDlg.progress.setValue(0); 94 94 Main.pleaseWaitDlg.currentAction.setText(tr("Contacting OSM Server...")); 95 Main.pleaseWaitDlg.setIndeterminate(true); 95 Main.pleaseWaitDlg.setIndeterminate(true); 96 96 final InputStream in = getInputStream("map?bbox="+lon1+","+lat1+","+lon2+","+lat2, Main.pleaseWaitDlg); 97 Main.pleaseWaitDlg.setIndeterminate(false); 97 Main.pleaseWaitDlg.setIndeterminate(false); 98 98 if (in == null) 99 99 return null; 100 100 Main.pleaseWaitDlg.currentAction.setText(tr("Downloading OSM data...")); -
src/org/openstreetmap/josm/Main.java
15 15 import java.util.Locale; 16 16 import java.util.Map; 17 17 import java.util.StringTokenizer; 18 import java.util.concurrent.Executor ;18 import java.util.concurrent.ExecutorService; 19 19 import java.util.concurrent.Executors; 20 20 import java.util.regex.Matcher; 21 21 import java.util.regex.Pattern; … … 26 26 import javax.swing.JPanel; 27 27 import javax.swing.UIManager; 28 28 29 import org.openstreetmap.josm.actions.SaveAction; 29 30 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask; 30 31 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 31 32 import org.openstreetmap.josm.actions.mapmode.MapMode; 32 import org.openstreetmap.josm.actions.SaveAction;33 33 import org.openstreetmap.josm.actions.search.SearchAction; 34 34 import org.openstreetmap.josm.data.Bounds; 35 35 import org.openstreetmap.josm.data.Preferences; … … 54 54 import org.openstreetmap.josm.tools.ImageProvider; 55 55 import org.openstreetmap.josm.tools.OsmUrlToBounds; 56 56 import org.openstreetmap.josm.tools.PlatformHook; 57 import org.openstreetmap.josm.tools.PlatformHookOsx; 57 58 import org.openstreetmap.josm.tools.PlatformHookUnixoid; 58 59 import org.openstreetmap.josm.tools.PlatformHookWindows; 59 import org.openstreetmap.josm.tools.PlatformHookOsx;60 60 import org.openstreetmap.josm.tools.Shortcut; 61 61 62 62 abstract public class Main { … … 73 73 * calculations. The executed runnables are guaranteed to be executed separately 74 74 * and sequential. 75 75 */ 76 public final static Executor worker = Executors.newSingleThreadExecutor();76 public final static ExecutorService worker = Executors.newSingleThreadExecutor(); 77 77 /** 78 78 * Global application preferences 79 79 */