Changeset 2289 in josm
- Timestamp:
- 2009-10-15T04:45:06+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java
r2240 r2289 144 144 145 145 /** 146 * Explains a {@see OsmApiException} which was thrown because of a conflict 147 * 148 * @param e the exception 149 */ 150 public static void explainConflict(OsmApiException e) { 151 JOptionPane.showMessageDialog(Main.parent, ExceptionUtil.explainConflict(e), tr("Conflict"), 152 JOptionPane.ERROR_MESSAGE); 153 } 154 155 /** 146 156 * Explains a {@see UnknownHostException} which has caused an {@see OsmTransferException}. 147 157 * This is most likely happening when there is an error in the API URL or when … … 231 241 return; 232 242 } 243 if (oae.getResponseCode() == HttpURLConnection.HTTP_CONFLICT) { 244 explainConflict(oae); 245 return; 246 } 233 247 234 248 } -
trunk/src/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTask.java
r2135 r2289 70 70 new Runnable() { 71 71 public void run() { 72 model. addOrUpdate(changesets);72 model.setChangesets(changesets); 73 73 } 74 74 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r2285 r2289 52 52 import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 53 53 import org.openstreetmap.josm.gui.SideButton; 54 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; 55 import org.openstreetmap.josm.gui.help.HelpBuilder; 54 56 import org.openstreetmap.josm.gui.tagging.TagEditorModel; 55 57 import org.openstreetmap.josm.gui.tagging.TagEditorPanel; … … 64 66 * This is a dialog for entering upload options like the parameters for 65 67 * the upload changeset and the strategy for opening/closing a changeset. 66 * 67 * 68 * 68 69 */ 69 70 public class UploadDialog extends JDialog { 70 71 71 72 72 public static final String HISTORY_KEY = "upload.comment.history"; … … 109 109 110 110 private ChangesetSelectionPanel pnlChangesetSelection; 111 112 111 private boolean canceled = false; 113 112 … … 152 151 southTabbedPane.setComponentAt(0, pnlChangesetSelection = new ChangesetSelectionPanel()); 153 152 southTabbedPane.setTitleAt(0, tr("Settings")); 153 southTabbedPane.setToolTipTextAt(0, tr("Decide how to upload the data and which changeset to use")); 154 154 southTabbedPane.setTitleAt(1, tr("Tags of new changeset")); 155 southTabbedPane.setToolTipTextAt(1, tr("Apply tags to the changeset data is uploaded to")); 155 156 southTabbedPane.addChangeListener(new TabbedPaneChangeLister()); 156 157 JPanel pnl1 = new JPanel(); … … 191 192 JComponent.WHEN_IN_FOCUSED_WINDOW 192 193 ); 194 195 pnl.add(new SideButton(new ContextSensitiveHelpAction("/Help/Dialogs/UploadDialog"))); 196 HelpBuilder.setHelpContext(getRootPane(),"/Help/Dialogs/UploadDialog"); 193 197 return pnl; 194 198 } … … 562 566 563 567 /** 564 * Listens to window closing events and processes them as cancel events 568 * Listens to window closing events and processes them as cancel events. 569 * Listens to window open events and initializes user input 565 570 * 566 571 */ … … 572 577 573 578 @Override 574 public void window Activated(WindowEvent e) {579 public void windowOpened(WindowEvent e) { 575 580 startUserInput(); 576 581 } … … 621 626 pnl.add(new JLabel(tr("Provide a brief comment for the changes you are uploading:")), GBC.eol().insets(0, 5, 10, 3)); 622 627 cmt = new HistoryComboBox(); 628 cmt.setToolTipText(tr("Enter an upload comment (min. 3 characters)")); 623 629 List<String> cmtHistory = new LinkedList<String>(Main.pref.getCollection(HISTORY_KEY, new LinkedList<String>())); 624 630 // we have to reverse the history, because ComboBoxHistory will reverse it again … … 994 1000 } 995 1001 1002 /** 1003 * A combobox model for the list of open changesets 1004 * 1005 */ 996 1006 public class OpenChangesetModel extends DefaultComboBoxModel { 997 1007 private List<Changeset> changesets; … … 1034 1044 } 1035 1045 1036 /** 1037 * Updates the current list of open changesets with the changesets 1038 * in <code>changesets</code> 1039 * 1040 * @param changesets the collection of changesets. If null, removes 1041 * all changesets from the current list of changesets 1042 */ 1043 public void addOrUpdate(Collection<Changeset> changesets) { 1044 if (changesets == null){ 1045 this.changesets.clear(); 1046 setSelectedItem(null); 1047 } 1048 for (Changeset cs: changesets) { 1049 internalAddOrUpdate(cs); 1046 public void setChangesets(Collection<Changeset> changesets) { 1047 this.changesets.clear(); 1048 if (changesets != null) { 1049 for (Changeset cs: changesets) { 1050 internalAddOrUpdate(cs); 1051 } 1050 1052 } 1051 1053 fireContentsChanged(this, 0, getSize()); … … 1055 1057 if (changesets.contains(getSelectedItem())) { 1056 1058 setSelectedItem(getSelectedItem()); 1059 } else if (!this.changesets.isEmpty()){ 1060 setSelectedItem(this.changesets.get(0)); 1057 1061 } else { 1058 setSelectedItem( this.changesets.get(0));1062 setSelectedItem(null); 1059 1063 } 1060 1064 } else { -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r2246 r2289 10 10 import java.net.URL; 11 11 import java.net.UnknownHostException; 12 import java.text.DateFormat; 13 import java.text.ParseException; 14 import java.text.SimpleDateFormat; 15 import java.util.Date; 12 16 import java.util.regex.Matcher; 13 17 import java.util.regex.Pattern; 14 18 15 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 16 21 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 17 22 import org.openstreetmap.josm.io.OsmApi; … … 95 100 + "dataset violates a precondition.<br>" + "The error message is:<br>" + "{0}" + "</html>", e 96 101 .getMessage().replace("&", "&").replace("<", "<").replace(">", ">")); 102 return msg; 103 } 104 105 /** 106 * Explains an error due to a 409 conflict 107 * 108 * @param e the exception 109 */ 110 public static String explainConflict(OsmApiException e) { 111 e.printStackTrace(); 112 String msg = e.getErrorHeader(); 113 if (msg != null) { 114 String pattern = "The changeset (\\d+) was closed at (.*)"; 115 Pattern p = Pattern.compile(pattern); 116 Matcher m = p.matcher(msg); 117 if (m.matches()) { 118 long changesetId = Long.parseLong(m.group(1)); 119 // Example: Tue Oct 15 10:00:00 UTC 2009 120 DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy"); 121 Date closeDate = null; 122 try { 123 closeDate = formatter.parse(m.group(2)); 124 } catch(ParseException ex) { 125 System.err.println(tr("Failed to parse date ''{0}'' replied by server.", m.group(2))); 126 ex.printStackTrace(); 127 } 128 if (closeDate == null) { 129 msg = tr( 130 "<html>Closing of changeset <strong>{0}</strong> failed <br>because it has already been closed.</html>", 131 changesetId 132 ); 133 } else { 134 SimpleDateFormat dateFormat = new SimpleDateFormat(); 135 msg = tr( 136 "<html>Closing of changeset <strong>{0}</strong> failed<br>" 137 +" because it has already been closed on {1}.</html>", 138 changesetId, 139 dateFormat.format(closeDate) 140 ); 141 } 142 return msg; 143 } 144 msg = tr( 145 "<html>The server reported that it has detected a conflict.<br>" + 146 "Error message (untranslated):<br>" + 147 "{0}", 148 msg 149 ); 150 } 151 msg = tr( 152 "<html>The server reported that it has detected a conflict.</html>" 153 ); 97 154 return msg; 98 155 }
Note:
See TracChangeset
for help on using the changeset viewer.