Changeset 2322 in josm for trunk/src/org/openstreetmap/josm/gui
- Timestamp:
- 2009-10-25T23:09:53+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 6 edited
-
PleaseWaitRunnable.java (modified) (2 diffs)
-
download/DownloadDialog.java (modified) (2 diffs)
-
layer/GeoImageLayer.java (modified) (4 diffs)
-
layer/GpxLayer.java (modified) (6 diffs)
-
progress/PleaseWaitProgressMonitor.java (modified) (1 diff)
-
progress/ProgressMonitor.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/PleaseWaitRunnable.java
r2319 r2322 73 73 } 74 74 } 75 } catch (SAXException x) {76 x.printStackTrace();77 progressMonitor.setErrorMessage(tr("Error while parsing")+": "+x.getMessage());78 } catch (FileNotFoundException x) {79 x.printStackTrace();80 progressMonitor.setErrorMessage(tr("File not found")+": "+x.getMessage());81 } catch (IOException x) {82 x.printStackTrace();83 progressMonitor.setErrorMessage(x.getMessage());84 } catch(OsmTransferException x) {85 x.printStackTrace();86 if (x.getCause() != null) {87 progressMonitor.setErrorMessage(x.getCause().getMessage());88 } else {89 progressMonitor.setErrorMessage(x.getMessage());90 }91 75 } finally { 92 76 progressMonitor.finishTask(); … … 96 80 } 97 81 } 98 } catch (final Throwablee) {82 } catch (final Exception e) { 99 83 if (!ignoreException) { 100 84 // Exception has to thrown in EDT to be shown to user 101 85 SwingUtilities.invokeLater(new Runnable() { 102 86 public void run() { 103 throw new RuntimeException(e);87 ExceptionDialogUtil.explainException(e); 104 88 } 105 89 }); -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r2215 r2322 27 27 import org.openstreetmap.josm.actions.downloadtasks.DownloadGpsTask; 28 28 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 29 import org.openstreetmap.josm.actions.downloadtasks.DownloadTask; 29 30 import org.openstreetmap.josm.data.Bounds; 30 31 import org.openstreetmap.josm.gui.MapView; … … 46 47 public class DownloadDialog extends JPanel { 47 48 48 public interface DownloadTask {49 /**50 * Execute the download using the given bounding box. Set silent on progressMonitor51 * if no error messages should be popped up.52 */53 void download(DownloadAction action, double minlat, double minlon,54 double maxlat, double maxlon, ProgressMonitor progressMonitor);55 56 /**57 * Execute the download using the given URL58 * @param newLayer59 * @param url60 */61 void loadUrl(boolean newLayer, String url, ProgressMonitor progressMonitor);62 63 /**64 * @return The checkbox presented to the user65 */66 JCheckBox getCheckBox();67 68 /**69 * @return The name of the preferences suffix to use for storing the70 * selection state.71 */72 String getPreferencesSuffix();73 74 /**75 * Gets the error message of the task once it executed. If there is no error message, an empty76 * string is returned.77 *78 * WARNING: Never call this in the same thread you requested the download() or it will cause a79 * dead lock. See actions/downloadTasks/DownloadOsmTaskList.java for a proper implementation.80 *81 * @return Error message or empty String82 */83 String getErrorMessage();84 }85 86 49 /** 87 50 * The list of download tasks. First entry should be the osm data entry -
trunk/src/org/openstreetmap/josm/gui/layer/GeoImageLayer.java
r2186 r2322 278 278 private final Collection<File> files; 279 279 private final GpxLayer gpxLayer; 280 private LinkedList<TimedPoint> gps; 281 280 282 public Loader(Collection<File> files, GpxLayer gpxLayer) { 281 283 super(tr("Images for {0}", gpxLayer.getName())); … … 286 288 progressMonitor.subTask(tr("Read GPX...")); 287 289 progressMonitor.setTicksCount(10 + files.size()); 288 LinkedList<TimedPoint>gps = new LinkedList<TimedPoint>();290 gps = new LinkedList<TimedPoint>(); 289 291 290 292 // Extract dates and locations from GPX input … … 322 324 323 325 324 if (gps.isEmpty()) { 325 progressMonitor.setErrorMessage(tr("No images with readable timestamps found.")); 326 if (gps.isEmpty()) 326 327 return; 327 }328 328 329 329 // read the image files … … 352 352 } 353 353 @Override protected void finish() { 354 if (gps.isEmpty()) { 355 JOptionPane.showMessageDialog( 356 Main.parent, 357 tr("No images with readable timestamps found."), 358 tr("Warning"), 359 JOptionPane.WARNING_MESSAGE 360 ); 361 return; 362 } 354 363 if (layer != null) { 355 364 Main.main.addLayer(layer); 356 365 } 357 366 } 367 358 368 @Override 359 369 protected void cancel() { -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r2151 r2322 29 29 import java.util.LinkedList; 30 30 import java.util.List; 31 import java.util.concurrent.Future; 31 32 32 33 import javax.swing.AbstractAction; … … 346 347 347 348 if (data.tracks.size() > 0) { 348 info.append("<table><thead align=\"center\"><tr><td colspan=\"5\">"349 + trn("{0} track", "{0} tracks", data.tracks.size(), data.tracks.size())350 + "</td></tr><tr><td>" + tr("Name") + "</td><td>"351 + tr("Description") + "</td><td>" + tr("Timespan")352 + "</td><td>" + tr("Length") + "</td><td>" + tr("URL")353 + "</td></tr></thead>");349 info.append("<table><thead align=\"center\"><tr><td colspan=\"5\">" 350 + trn("{0} track", "{0} tracks", data.tracks.size(), data.tracks.size()) 351 + "</td></tr><tr><td>" + tr("Name") + "</td><td>" 352 + tr("Description") + "</td><td>" + tr("Timespan") 353 + "</td><td>" + tr("Length") + "</td><td>" + tr("URL") 354 + "</td></tr></thead>"); 354 355 355 356 for (GpxTrack trk : data.tracks) { 356 WayPoint earliest = null, latest = null; 357 358 info.append("<tr><td>"); 359 if (trk.attr.containsKey("name")) 360 info.append(trk.attr.get("name")); 361 info.append("</td><td>"); 362 if (trk.attr.containsKey("desc")) 363 info.append(" ").append(trk.attr.get("desc")); 364 info.append("</td><td>"); 357 WayPoint earliest = null, latest = null; 358 359 info.append("<tr><td>"); 360 if (trk.attr.containsKey("name")) { 361 info.append(trk.attr.get("name")); 362 } 363 info.append("</td><td>"); 364 if (trk.attr.containsKey("desc")) { 365 info.append(" ").append(trk.attr.get("desc")); 366 } 367 info.append("</td><td>"); 365 368 366 369 for (Collection<WayPoint> seg : trk.trackSegs) { … … 378 381 } 379 382 380 if (earliest != null && latest != null) { 381 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); 382 info.append(df.format(new Date((long) (earliest.time * 1000))) + " - " 383 + df.format(new Date((long) (latest.time * 1000)))); 384 int diff = (int) (latest.time - earliest.time); 385 info.append(" (" + (diff / 3600) + ":" + ((diff % 3600) / 60) + ")"); 386 } 387 388 info.append("</td><td>"); 389 info.append(new DecimalFormat("#0.00").format(trk.length() / 1000) + "km"); 390 info.append("</td><td>"); 391 if (trk.attr.containsKey("url")) 392 info.append(trk.attr.get("url")); 393 info.append("</td></tr>"); 394 } 395 396 info.append("</table><br><br>"); 383 if (earliest != null && latest != null) { 384 DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); 385 info.append(df.format(new Date((long) (earliest.time * 1000))) + " - " 386 + df.format(new Date((long) (latest.time * 1000)))); 387 int diff = (int) (latest.time - earliest.time); 388 info.append(" (" + (diff / 3600) + ":" + ((diff % 3600) / 60) + ")"); 389 } 390 391 info.append("</td><td>"); 392 info.append(new DecimalFormat("#0.00").format(trk.length() / 1000) + "km"); 393 info.append("</td><td>"); 394 if (trk.attr.containsKey("url")) { 395 info.append(trk.attr.get("url")); 396 } 397 info.append("</td></tr>"); 398 } 399 400 info.append("</table><br><br>"); 397 401 398 402 } … … 401 405 info.append("<br>"); 402 406 403 info.append(trn("{0} route, ", "{0} routes, ", data.routes.size(), data.routes.size())).append(404 trn("{0} waypoint", "{0} waypoints", data.waypoints.size(), data.waypoints.size())).append("<br>");407 info.append(trn("{0} route, ", "{0} routes, ", data.routes.size(), data.routes.size())).append( 408 trn("{0} waypoint", "{0} waypoints", data.waypoints.size(), data.waypoints.size())).append("<br>"); 405 409 406 410 return info.append("</html>").toString(); … … 694 698 } // end for segment 695 699 } // end for trk 696 } // end if large || hdopcircle 700 } // end if large || hdopcircle 697 701 698 702 /**************************************************************** … … 939 943 } 940 944 } 941 new DownloadOsmTaskList().download(false, toDownload, new PleaseWaitProgressMonitor(tr("Download data"))); 945 final PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download data")); 946 final Future<?> future = new DownloadOsmTaskList().download(false, toDownload, monitor); 947 Main.worker.submit( 948 new Runnable() { 949 public void run() { 950 try { 951 future.get(); 952 } catch(Exception e) { 953 e.printStackTrace(); 954 return; 955 } 956 monitor.close(); 957 } 958 } 959 ); 942 960 } 943 961 } -
trunk/src/org/openstreetmap/josm/gui/progress/PleaseWaitProgressMonitor.java
r2319 r2322 16 16 import org.openstreetmap.josm.Main; 17 17 import org.openstreetmap.josm.gui.PleaseWaitDialog; 18 import static org.openstreetmap.josm.tools.I18n.tr; 18 19 19 20 -
trunk/src/org/openstreetmap/josm/gui/progress/ProgressMonitor.java
r2319 r2322 121 121 122 122 void setSilent(boolean value); 123 void setErrorMessage(String message);124 String getErrorMessage();125 123 126 124 /**
Note:
See TracChangeset
for help on using the changeset viewer.
