Changeset 2289 in josm


Ignore:
Timestamp:
Oct 15, 2009 4:45:06 AM (4 years ago)
Author:
Gubaer
Message:

fixed #3719: Upload dialog still lists closed changesets after JOSM knows they've been closed
fixed #3668: Upload dialog: comment textbox buggy
Added context sensitive help to upload dialog
Improved error handling for errors due to closing already closed changesets

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  
    144144 
    145145    /** 
     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    /** 
    146156     * Explains a {@see UnknownHostException} which has caused an {@see OsmTransferException}. 
    147157     * This is most likely happening when there is an error in the API URL or when 
     
    231241                return; 
    232242            } 
     243            if (oae.getResponseCode() == HttpURLConnection.HTTP_CONFLICT) { 
     244                explainConflict(oae); 
     245                return; 
     246            } 
    233247 
    234248        } 
  • trunk/src/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTask.java

    r2135 r2289  
    7070                new Runnable() { 
    7171                    public void run() { 
    72                         model.addOrUpdate(changesets); 
     72                        model.setChangesets(changesets); 
    7373                    } 
    7474                } 
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r2285 r2289  
    5252import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 
    5353import org.openstreetmap.josm.gui.SideButton; 
     54import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; 
     55import org.openstreetmap.josm.gui.help.HelpBuilder; 
    5456import org.openstreetmap.josm.gui.tagging.TagEditorModel; 
    5557import org.openstreetmap.josm.gui.tagging.TagEditorPanel; 
     
    6466 * This is a dialog for entering upload options like the parameters for 
    6567 * the upload changeset and the strategy for opening/closing a changeset. 
    66  *  
    67  *  
     68 * 
    6869 */ 
    6970public class UploadDialog extends JDialog { 
    70  
    7171 
    7272    public static final String HISTORY_KEY = "upload.comment.history"; 
     
    109109 
    110110    private ChangesetSelectionPanel pnlChangesetSelection; 
    111  
    112111    private boolean canceled = false; 
    113112 
     
    152151        southTabbedPane.setComponentAt(0, pnlChangesetSelection = new ChangesetSelectionPanel()); 
    153152        southTabbedPane.setTitleAt(0, tr("Settings")); 
     153        southTabbedPane.setToolTipTextAt(0, tr("Decide how to upload the data and which changeset to use")); 
    154154        southTabbedPane.setTitleAt(1, tr("Tags of new changeset")); 
     155        southTabbedPane.setToolTipTextAt(1, tr("Apply tags to the changeset data is uploaded to")); 
    155156        southTabbedPane.addChangeListener(new TabbedPaneChangeLister()); 
    156157        JPanel pnl1 = new JPanel(); 
     
    191192                JComponent.WHEN_IN_FOCUSED_WINDOW 
    192193        ); 
     194 
     195        pnl.add(new SideButton(new ContextSensitiveHelpAction("/Help/Dialogs/UploadDialog"))); 
     196        HelpBuilder.setHelpContext(getRootPane(),"/Help/Dialogs/UploadDialog"); 
    193197        return pnl; 
    194198    } 
     
    562566 
    563567    /** 
    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 
    565570     * 
    566571     */ 
     
    572577 
    573578        @Override 
    574         public void windowActivated(WindowEvent e) { 
     579        public void windowOpened(WindowEvent e) { 
    575580            startUserInput(); 
    576581        } 
     
    621626            pnl.add(new JLabel(tr("Provide a brief comment for the changes you are uploading:")), GBC.eol().insets(0, 5, 10, 3)); 
    622627            cmt = new HistoryComboBox(); 
     628            cmt.setToolTipText(tr("Enter an upload comment (min. 3 characters)")); 
    623629            List<String> cmtHistory = new LinkedList<String>(Main.pref.getCollection(HISTORY_KEY, new LinkedList<String>())); 
    624630            // we have to reverse the history, because ComboBoxHistory will reverse it again 
     
    9941000    } 
    9951001 
     1002    /** 
     1003     * A combobox model for the list of open changesets 
     1004     * 
     1005     */ 
    9961006    public class OpenChangesetModel extends DefaultComboBoxModel { 
    9971007        private List<Changeset> changesets; 
     
    10341044        } 
    10351045 
    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                } 
    10501052            } 
    10511053            fireContentsChanged(this, 0, getSize()); 
     
    10551057                if (changesets.contains(getSelectedItem())) { 
    10561058                    setSelectedItem(getSelectedItem()); 
     1059                } else if (!this.changesets.isEmpty()){ 
     1060                    setSelectedItem(this.changesets.get(0)); 
    10571061                } else { 
    1058                     setSelectedItem(this.changesets.get(0)); 
     1062                    setSelectedItem(null); 
    10591063                } 
    10601064            } else { 
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r2246 r2289  
    1010import java.net.URL; 
    1111import java.net.UnknownHostException; 
     12import java.text.DateFormat; 
     13import java.text.ParseException; 
     14import java.text.SimpleDateFormat; 
     15import java.util.Date; 
    1216import java.util.regex.Matcher; 
    1317import java.util.regex.Pattern; 
    1418 
    1519import org.openstreetmap.josm.Main; 
     20import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; 
    1621import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 
    1722import org.openstreetmap.josm.io.OsmApi; 
     
    95100                + "dataset violates a precondition.<br>" + "The error message is:<br>" + "{0}" + "</html>", e 
    96101                .getMessage().replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")); 
     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        ); 
    97154        return msg; 
    98155    } 
Note: See TracChangeset for help on using the changeset viewer.