Changeset 1546 in josm for trunk/src/org


Ignore:
Timestamp:
2009-04-22T02:39:47+02:00 (16 years ago)
Author:
framm
Message:
  • streamline uploading by requesting commit message as part of the upload confirmation dialog; allow user to re-use latest commit message
Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r1523 r1546  
    1515import javax.swing.JPanel;
    1616import javax.swing.JScrollPane;
     17import javax.swing.JTextField;
    1718
    1819import org.openstreetmap.josm.Main;
     
    3637public class UploadAction extends JosmAction {
    3738
     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   
    3846    /** Upload Hook */
    3947    public interface UploadHook {
     
    98106                    p.add(new JScrollPane(l), GBC.eol().fill());
    99107                }
     108               
     109                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);
     111                p.add(cmt, GBC.eol().fill(GBC.HORIZONTAL));
    100112
    101                 return new ExtendedDialog(Main.parent,
     113                while(true) {
     114                    int result = new ExtendedDialog(Main.parent,
    102115                        tr("Upload these changes?"),
    103116                        p,
    104117                        new String[] {tr("Upload Changes"), tr("Cancel")},
    105                         new String[] {"upload.png", "cancel.png"}).getValue() == 1; 
     118                        new String[] {"upload.png", "cancel.png"}).getValue();
     119                   
     120                    // cancel pressed
     121                    if (result != 1) return false;
     122                   
     123                    // don't allow empty commit message
     124                    if (cmt.getText().trim().length() < 3) continue;
     125                   
     126                    lastCommitComment = cmt.getText().trim();
     127                    break;
     128                }
     129                return true;
    106130            }
    107131        });
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r1541 r1546  
    66import java.io.BufferedReader;
    77import java.io.BufferedWriter;
    8 import java.io.ByteArrayOutputStream;
    98import java.io.InputStreamReader;
    109import java.io.OutputStream;
     
    2019import java.util.ArrayList;
    2120import java.util.Collection;
     21import java.util.HashMap;
    2222import java.util.Properties;
    23 import java.util.HashMap;
    2423import java.util.StringTokenizer;
    2524
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r1523 r1546  
    77import java.util.LinkedList;
    88
    9 import javax.swing.JOptionPane;
    10 
    119import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.actions.UploadAction;
    1211import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1312import org.openstreetmap.josm.data.osm.visitor.NameVisitor;
     
    3029     */
    3130    public Collection<OsmPrimitive> processed;
     31   
    3232
    3333    private OsmApi api = new OsmApi();
     
    7474            "0.6".equals(api.getVersion()));
    7575
    76         // solicit commit comment from user
    77         String comment = null;
    78         while (useChangesets && comment == null) {
    79             comment = JOptionPane.showInputDialog(Main.parent,
    80                  tr("Provide a brief comment for the changes you are uploading:"),
    81                  tr("Commit comment"), JOptionPane.QUESTION_MESSAGE);
    82             if (comment == null)
    83                 return;
    84             // Don't let people just hit enter
    85             if (comment.trim().length() >= 3)
    86                 break;
    87             comment = null;
    88         }
    89        
    9076        // create changeset if required
    9177        try {
    92             if (useChangesets) api.createChangeset(comment);
     78            if (useChangesets) api.createChangeset(UploadAction.lastCommitComment);
    9379        } catch (OsmTransferException ex) {
    9480            dealWithTransferException(ex);
Note: See TracChangeset for help on using the changeset viewer.