Changeset 1575 in josm for trunk


Ignore:
Timestamp:
2009-05-05T16:49:28+02:00 (16 years ago)
Author:
stoecker
Message:

close #2443 - patch by Henrik Niehaus - History for commit dialog

Location:
trunk/src/org/openstreetmap/josm
Files:
8 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r1546 r1575  
    99import java.util.Collection;
    1010import java.util.LinkedList;
     11import java.util.List;
    1112
    1213import javax.swing.JLabel;
     
    1516import javax.swing.JPanel;
    1617import javax.swing.JScrollPane;
    17 import javax.swing.JTextField;
    1818
    1919import org.openstreetmap.josm.Main;
     
    2222import org.openstreetmap.josm.gui.OsmPrimitivRenderer;
    2323import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     24import org.openstreetmap.josm.gui.historycombobox.StringUtils;
     25import org.openstreetmap.josm.gui.historycombobox.SuggestingJHistoryComboBox;
    2426import org.openstreetmap.josm.io.OsmServerWriter;
    2527import org.openstreetmap.josm.tools.GBC;
     28import org.openstreetmap.josm.tools.Shortcut;
    2629import org.xml.sax.SAXException;
    27 import org.openstreetmap.josm.tools.Shortcut;
    2830
    2931/**
     
    3638 */
    3739public class UploadAction extends JosmAction {
     40   
     41    public static final String HISTORY_KEY = "upload.comment.history";
    3842
    39     /**
    40      * Last commit message used for uploading changes.
    41      * FIXME save this in preferences, or even offer list of 10 last recently used comments?
    42      * FIXME ugly hack; value is filled here and retrieved in the OsmApi class; find better way
    43      */
    44     public static String lastCommitComment;
    45    
    4643    /** Upload Hook */
    4744    public interface UploadHook {
     
    108105               
    109106                p.add(new JLabel(tr("Provide a brief comment for the changes you are uploading:")), GBC.eol().insets(0, 5, 10, 3));
    110                 final JTextField cmt = new JTextField(lastCommitComment);
     107                SuggestingJHistoryComboBox cmt = new SuggestingJHistoryComboBox();
     108                List<String> cmtHistory = StringUtils.stringToList(Main.pref.get(HISTORY_KEY), SuggestingJHistoryComboBox.DELIM);
     109                cmt.setHistory(cmtHistory);
     110                //final JTextField cmt = new JTextField(lastCommitComment);
    111111                p.add(cmt, GBC.eol().fill(GBC.HORIZONTAL));
    112112
     
    124124                    if (cmt.getText().trim().length() < 3) continue;
    125125                   
    126                     lastCommitComment = cmt.getText().trim();
     126                    // store the history of comments
     127                    cmt.addCurrentItemToHistory();
     128                    Main.pref.put(HISTORY_KEY, StringUtils.listToString(cmt.getHistory(), SuggestingJHistoryComboBox.DELIM));
     129                   
    127130                    break;
    128131                }
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r1559 r1575  
    66import java.util.Collection;
    77import java.util.LinkedList;
     8import java.util.List;
    89
    910import javax.swing.JOptionPane;
     
    1314import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1415import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
     16import org.openstreetmap.josm.gui.historycombobox.JHistoryComboBox;
     17import org.openstreetmap.josm.gui.historycombobox.StringUtils;
    1518
    1619/**
     
    7881        // create changeset if required
    7982        try {
    80             if (useChangesets) api.createChangeset(UploadAction.lastCommitComment);
     83            if (useChangesets) {
     84                // add the last entered comment to the changeset
     85                String cmt = "";
     86                List<String> history = StringUtils.stringToList(Main.pref.get(UploadAction.HISTORY_KEY), JHistoryComboBox.DELIM);
     87                if(history.size() > 0) {
     88                    cmt = history.get(0);
     89                }
     90                api.createChangeset(cmt);
     91            }
    8192        } catch (OsmTransferException ex) {
    8293            dealWithTransferException(ex);
Note: See TracChangeset for help on using the changeset viewer.