- Timestamp:
- 2009-11-19T13:30:09+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UploadAction.java
r2402 r2480 38 38 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 39 39 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 40 import org.openstreetmap.josm.io.ChangesetClosedException; 40 41 import org.openstreetmap.josm.io.OsmApi; 41 42 import org.openstreetmap.josm.io.OsmApiException; 42 43 import org.openstreetmap.josm.io.OsmApiInitializationException; 43 44 import org.openstreetmap.josm.io.OsmApiPrimitiveGoneException; 44 import org.openstreetmap.josm.io.OsmChangesetCloseException;45 45 import org.openstreetmap.josm.io.OsmServerWriter; 46 46 import org.openstreetmap.josm.io.OsmTransferException; … … 480 480 } 481 481 482 if (e instanceof OsmChangesetCloseException) {483 ExceptionDialogUtil.explainOsmChangesetCloseException((OsmChangesetCloseException)e);484 return;485 }486 482 if (e instanceof OsmApiPrimitiveGoneException) { 487 483 handleGone((OsmApiPrimitiveGoneException)e); … … 674 670 } 675 671 layer.onPostUploadToServer(); 676 UploadDialog.getUploadDialog().setOrUpdateChangeset(changeset); 672 if (lastException != null && lastException instanceof ChangesetClosedException) { 673 UploadDialog.getUploadDialog().removeChangeset(changeset); 674 } else { 675 UploadDialog.getUploadDialog().setOrUpdateChangeset(changeset); 676 } 677 677 } 678 678 -
trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
r2413 r2480 14 14 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.io.ChangesetClosedException; 16 17 import org.openstreetmap.josm.io.OsmApiException; 17 18 import org.openstreetmap.josm.io.OsmApiInitializationException; 18 import org.openstreetmap.josm.io.OsmChangesetCloseException;19 19 import org.openstreetmap.josm.io.OsmTransferException; 20 20 import org.openstreetmap.josm.tools.BugReportExceptionHandler; … … 49 49 50 50 /** 51 * handles a n exception caught during OSM API initialization51 * handles a ChangesetClosedException 52 52 * 53 53 * @param e the exception 54 54 */ 55 public static void explain OsmChangesetCloseException(OsmChangesetCloseException e) {56 HelpAwareOptionPane.showOptionDialog( 57 Main.parent, 58 ExceptionUtil.explain OsmChangesetCloseException(e),55 public static void explainChangesetClosedException(ChangesetClosedException e) { 56 HelpAwareOptionPane.showOptionDialog( 57 Main.parent, 58 ExceptionUtil.explainChangesetClosedException(e), 59 59 tr("Error"), 60 60 JOptionPane.ERROR_MESSAGE, 61 ht("/ErrorMessages# OsmChangesetCloseException")61 ht("/ErrorMessages#ChangesetClosedException") 62 62 ); 63 63 } … … 294 294 return; 295 295 } 296 if (e instanceof OsmChangesetCloseException) { 297 explainOsmChangesetCloseException((OsmChangesetCloseException) e); 296 297 if (e instanceof ChangesetClosedException) { 298 explainChangesetClosedException((ChangesetClosedException)e); 298 299 return; 299 300 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r2447 r2480 334 334 public void setOrUpdateChangeset(Changeset cs) { 335 335 pnlChangesetSelection.setOrUpdateChangeset(cs); 336 } 337 338 /** 339 * Removes <code>cs</code> from the list of open changesets in the upload 340 * dialog 341 * 342 * @param cs the changeset. Ignored if null. 343 */ 344 public void removeChangeset(Changeset cs) { 345 if (cs == null) return; 346 pnlChangesetSelection.removeChangeset(cs); 336 347 } 337 348 … … 842 853 public void setOrUpdateChangeset(Changeset cs) { 843 854 if (cs == null) { 844 tagEditorPanel.getModel().clear(); 845 tagEditorPanel.getModel().add("created_by", getDefaultCreatedBy()); 855 cs = new Changeset(); 856 cs.put("created_by", getDefaultCreatedBy()); 857 tagEditorPanel.getModel().initFromPrimitive(cs); 846 858 tagEditorPanel.getModel().appendNewTag(); 859 prepareDialogForNextUpload(cs); 847 860 } else if (cs.getId() == 0) { 848 861 if (cs.get("created_by") == null) { … … 851 864 tagEditorPanel.getModel().initFromPrimitive(cs); 852 865 tagEditorPanel.getModel().appendNewTag(); 866 prepareDialogForNextUpload(cs); 853 867 } else if (cs.getId() > 0 && cs.isOpen()){ 854 868 if (cs.get("created_by") == null) { … … 859 873 cs = model.getChangesetById(cs.getId()); 860 874 cbOpenChangesets.setSelectedItem(cs); 875 prepareDialogForNextUpload(cs); 861 876 } else if (cs.getId() > 0 && !cs.isOpen()){ 877 removeChangeset(cs); 878 } 879 } 880 881 /** 882 * Remove a changeset from the list of open changeset 883 * 884 * @param cs the changeset to be removed. Ignored if null. 885 */ 886 public void removeChangeset(Changeset cs) { 887 if (cs == null) return; 888 Changeset selected = (Changeset)model.getSelectedItem(); 889 model.removeChangeset(cs); 890 if (model.getSize() == 0 || selected == cs) { 891 // no more changesets or removed changeset is the currently selected 892 // changeset? Switch to using a new changeset. 893 // 894 rbUseNew.setSelected(true); 895 model.setSelectedItem(null); 896 southTabbedPane.setTitleAt(1, tr("Tags of new changeset")); 897 898 cs = new Changeset(); 862 899 if (cs.get("created_by") == null) { 863 900 cs.put("created_by", getDefaultCreatedBy()); 901 cs.put("comment", getUploadComment()); 864 902 } 865 903 tagEditorPanel.getModel().initFromPrimitive(cs); 866 model.removeChangeset(cs);867 if (model.getSize() == 0) {868 rbUseNew.setSelected(true);869 model.setSelectedItem(null);870 southTabbedPane.setTitleAt(1, tr("Tags of new changeset"));871 }872 904 } 873 905 prepareDialogForNextUpload(cs); -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r2478 r2480 338 338 * @throws OsmTransferException if something goes wrong. 339 339 * @throws IllegalArgumentException if changeset is null 340 * @throws IllegalArgumentException if changeset.getId() == 0340 * @throws IllegalArgumentException if changeset.getId() <= 0 341 341 * 342 342 */ … … 359 359 monitor 360 360 ); 361 } catch(OsmApiException e) { 362 if (e.getResponseCode() == HttpURLConnection.HTTP_CONFLICT) 363 throw new ChangesetClosedException(e.getErrorHeader()); 364 throw e; 361 365 } finally { 362 366 monitor.finishTask(); -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r2387 r2480 14 14 import java.text.SimpleDateFormat; 15 15 import java.util.Date; 16 import java.util.Locale; 16 17 import java.util.regex.Matcher; 17 18 import java.util.regex.Pattern; 18 19 19 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.io.ChangesetClosedException; 20 22 import org.openstreetmap.josm.io.OsmApi; 21 23 import org.openstreetmap.josm.io.OsmApiException; 22 24 import org.openstreetmap.josm.io.OsmApiInitializationException; 23 import org.openstreetmap.josm.io.OsmChangesetCloseException;24 25 import org.openstreetmap.josm.io.OsmTransferException; 25 26 … … 39 40 + "Check the server URL in your preferences and your internet connection.</html>", Main.pref.get( 40 41 "osm-server.url", "http://api.openstreetmap.org/api")); 41 return msg;42 }43 44 /**45 * handles an exception caught during OSM API initialization46 *47 * @param e the exception48 */49 public static String explainOsmChangesetCloseException(OsmChangesetCloseException e) {50 e.printStackTrace();51 String changsetId = e.getChangeset() == null ? tr("unknown") : Long.toString(e.getChangeset().getId());52 String msg = tr(53 "<html>Failed to close changeset ''{0}'' on the OSM server ''{1}''.<br>"54 + "The changeset will automatically be closed by the server after a timeout.</html>", changsetId,55 Main.pref.get("osm-server.url", "http://api.openstreetmap.org/api"));56 42 return msg; 57 43 } … … 115 101 if (m.matches()) { 116 102 long changesetId = Long.parseLong(m.group(1)); 117 // Example: Tue Oct 15 10:00:00 UTC 2009 118 DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"); 103 // Example: Tue Oct 15 10:00:00 UTC 2009. Always parsed with english locale, regardless 104 // of the current locale in JOSM 105 DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH); 119 106 Date closeDate = null; 120 107 try { … … 153 140 154 141 /** 142 * Explains an exception thrown during upload because the changeset which data is 143 * uploaded to is already closed. 144 * 145 * @param e the exception 146 */ 147 public static String explainChangesetClosedException(ChangesetClosedException e) { 148 String msg; 149 SimpleDateFormat dateFormat = new SimpleDateFormat(); 150 msg = tr( 151 "<html>Failed to upload to changeset <strong>{0}</strong><br>" 152 +"because it has already been closed on {1}.</html>", 153 e.getChangesetId(), 154 dateFormat.format(e.getClosedOn()) 155 ); 156 e.printStackTrace(); 157 return msg; 158 } 159 160 /** 155 161 * Explains an exception with a generic message dialog 156 162 * … … 338 344 if (e instanceof OsmApiInitializationException) 339 345 return explainOsmApiInitializationException((OsmApiInitializationException) e); 340 if (e instanceof OsmChangesetCloseException) 341 return explainOsmChangesetCloseException((OsmChangesetCloseException) e); 346 347 if (e instanceof ChangesetClosedException) 348 return explainChangesetClosedException((ChangesetClosedException)e); 342 349 343 350 if (e instanceof OsmApiException) {
Note:
See TracChangeset
for help on using the changeset viewer.