Changeset 3399 in josm for trunk/src/org


Ignore:
Timestamp:
2010-07-31T21:22:49+02:00 (14 years ago)
Author:
framm
Message:

Modify behaviour regarding the changeset comment. It is now allowed to upload changes
with an empty changeset comment but everything with less than 10 characters prompts
a dialog that explains the importance of changesets and suggests to reconsider.

Also, the last recently used changeset comment is only used as a default if it was used
less than 4 hours ago, to avoid people automatically using the same stuff all the time.

Location:
trunk/src/org/openstreetmap/josm/gui/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java

    r3133 r3399  
    3535public class BasicUploadSettingsPanel extends JPanel {
    3636    public static final String HISTORY_KEY = "upload.comment.history";
     37    public static final String HISTORY_LAST_USED_KEY = "upload.comment.last-used";
    3738
    3839    /** the history combo box for the upload comment */
     
    4849        pnl.add(new JLabel(tr("Provide a brief comment for the changes you are uploading:")), GBC.eol().insets(0, 5, 10, 3));
    4950        hcbUploadComment = new HistoryComboBox();
    50         hcbUploadComment.setToolTipText(tr("Enter an upload comment (min. 3 characters)"));
     51        hcbUploadComment.setToolTipText(tr("Enter an upload comment"));
    5152        List<String> cmtHistory = new LinkedList<String>(Main.pref.getCollection(HISTORY_KEY, new LinkedList<String>()));
    5253        // we have to reverse the history, because ComboBoxHistory will reverse it again
     
    117118        hcbUploadComment.addCurrentItemToHistory();
    118119        Main.pref.putCollection(HISTORY_KEY, hcbUploadComment.getHistory());
     120        Main.pref.putInteger(HISTORY_LAST_USED_KEY, (int) (System.currentTimeMillis() / 1000));
    119121    }
    120122
     
    124126    public void startUserInput() {
    125127        List<String> history = hcbUploadComment.getHistory();
    126         if (history != null && !history.isEmpty()) {
     128        int age = (int) (System.currentTimeMillis()/1000 - Main.pref.getInteger(HISTORY_LAST_USED_KEY, 0));
     129        // only pre-select latest entry if used less than 4 hours ago.
     130        if (age < 4 * 3600 * 1000 && history != null && !history.isEmpty()) {
    127131            hcbUploadComment.setText(history.get(0));
    128132        }
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r3133 r3399  
    3838import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
    3939import org.openstreetmap.josm.gui.help.HelpUtil;
     40import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
    4041import org.openstreetmap.josm.io.OsmApi;
    4142import org.openstreetmap.josm.tools.ImageProvider;
     
    304305
    305306    /**
    306      * Replies the current value for the upload comment
     307     * Returns the current value for the upload comment
    307308     *
    308309     * @return the current value for the upload comment
     
    313314
    314315    /**
    315      * Replies true, if the dialog was canceled
    316      *
    317      * @return true, if the dialog was canceled
     316     * Returns true if the dialog was canceled
     317     *
     318     * @return true if the dialog was canceled
    318319     */
    319320    public boolean isCanceled() {
     
    324325     * Sets whether the dialog was canceled
    325326     *
    326      * @param canceled true, if the dialog is canceled
     327     * @param canceled true if the dialog is canceled
    327328     */
    328329    protected void setCanceled(boolean canceled) {
     
    358359        }
    359360
    360         protected void warnIllegalUploadComment() {
    361             HelpAwareOptionPane.showOptionDialog(
     361        /**
     362         * returns true if the user wants to revisit, false if they
     363         * want to continue
     364         */
     365        protected boolean warnUploadComment() {
     366
     367            ButtonSpec[] options = new ButtonSpec[] {
     368                    new ButtonSpec(
     369                            tr("Yes, revise"),
     370                            ImageProvider.get("ok"),
     371                            tr("Go back to the changeset comment and enter a better description"),
     372                            null
     373                    ),
     374                    new ButtonSpec(
     375                            tr("No, continue as is"),
     376                            ImageProvider.get("cancel"),
     377                            tr("Continue without improving the changeset comment"),
     378                            null
     379                    )
     380            };
     381
     382            return 0 == HelpAwareOptionPane.showOptionDialog(
    362383                    UploadDialog.this,
    363                     tr("Please enter a comment for this upload changeset (min. 3 characters)"),
    364                     tr("Illegal upload comment"),
    365                     JOptionPane.ERROR_MESSAGE,
    366                     ht("/Dialog/UploadDialog#IllegalUploadComment")
     384                    "<html>" +
     385                    tr("Your upload comment is empty, or very short.<br /><br />" +
     386                       "This is technically allowed, but please consider that many users who are<br />" +
     387                       "watching changes in their area depend on meaningful changeset comments<br />" +
     388                       "to understand what is going on!<br /><br />" +
     389                       "If you spend a minute now to explain your change, you will make life<br />" +
     390                       "easier for many other mappers.") +
     391                    "</html>",
     392                    tr("Please revise upload comment"),
     393                    JOptionPane.WARNING_MESSAGE,
     394                    null,
     395                    options,
     396                    options[0],
     397                    ht("/Dialog/UploadDialog#ReviseUploadComment")
    367398            );
    368399        }
     
    379410
    380411        public void actionPerformed(ActionEvent e) {
    381             if (getUploadComment().trim().length() < 3) {
    382                 warnIllegalUploadComment();
    383                 tpConfigPanels.setSelectedIndex(0);
    384                 pnlBasicUploadSettings.initEditingOfUploadComment();
    385                 return;
     412            if (getUploadComment().trim().length() < 10) {
     413                if (warnUploadComment())
     414                {
     415                    tpConfigPanels.setSelectedIndex(0);
     416                    pnlBasicUploadSettings.initEditingOfUploadComment();
     417                    return;
     418                }
    386419            }
    387420            UploadStrategySpecification strategy = getUploadStrategySpecification();
Note: See TracChangeset for help on using the changeset viewer.