Changeset 402 in josm for trunk/src/org
- Timestamp:
- 2007-10-19T01:04:24+02:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r390 r402 54 54 private Point mousePos; 55 55 private SelectionManager selectionManager; 56 57 /** 58 * Create a new MoveAction 59 * @param mapFrame The MapFrame, this action belongs to. 56 57 /** 58 * The time which needs to pass between click and release before something 59 * counts as a move 60 */ 61 private int initialMoveDelay = 100; 62 63 /** 64 * Create a new SelectAction 65 * @param mapFrame The MapFrame this action belongs to. 60 66 */ 61 67 public SelectAction(MapFrame mapFrame) { … … 64 70 getCursor("normal", "selection", Cursor.DEFAULT_CURSOR)); 65 71 putValue("help", "Action/Move/Move"); 66 selectionManager = new SelectionManager(this, false, mapFrame.mapView); 72 selectionManager = new SelectionManager(this, false, mapFrame.mapView); 73 try { initialMoveDelay = Integer.parseInt(Main.pref.get("edit.initial-move-delay","100")); } catch (NumberFormatException x) {}; 74 75 67 76 } 68 77 … … 114 123 115 124 // do not count anything as a move if it lasts less than 100 milliseconds. 116 if ((mode == Mode.move) && (System.currentTimeMillis() - mouseDownTime < 100)) return;125 if ((mode == Mode.move) && (System.currentTimeMillis() - mouseDownTime < initialMoveDelay)) return; 117 126 118 127 if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == 0) -
trunk/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
r343 r402 5 5 import static org.openstreetmap.josm.tools.I18n.trn; 6 6 7 import java.awt.CheckboxGroup; 7 8 import java.awt.Color; 8 9 import java.awt.Component; … … 12 13 import java.awt.event.ActionEvent; 13 14 import java.awt.event.ActionListener; 15 import java.io.BufferedReader; 16 import java.io.ByteArrayOutputStream; 14 17 import java.io.File; 18 import java.io.FileInputStream; 19 import java.io.InputStreamReader; 20 import java.io.OutputStream; 21 import java.net.HttpURLConnection; 22 import java.net.URL; 23 import java.net.URLConnection; 24 import java.net.UnknownHostException; 15 25 import java.util.Collection; 16 26 import java.util.LinkedList; … … 20 30 import javax.swing.ButtonGroup; 21 31 import javax.swing.Icon; 32 import javax.swing.JCheckBox; 22 33 import javax.swing.JColorChooser; 23 34 import javax.swing.JFileChooser; … … 28 39 import javax.swing.JRadioButton; 29 40 import javax.swing.JSeparator; 41 import javax.swing.JTextField; 30 42 import javax.swing.filechooser.FileFilter; 31 43 … … 43 55 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 44 56 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 57 import org.openstreetmap.josm.io.MultiPartFormOutputStream; 58 import org.openstreetmap.josm.io.OsmWriter; 45 59 import org.openstreetmap.josm.tools.ColorHelper; 46 60 import org.openstreetmap.josm.tools.DontShowAgainInfo; … … 79 93 Main.main.addLayer(new OsmDataLayer(ds, tr("Converted from: {0}", RawGpsLayer.this.name), null)); 80 94 Main.main.removeLayer(RawGpsLayer.this); 95 } 96 } 97 98 public class UploadTraceAction extends AbstractAction { 99 public UploadTraceAction() { 100 super(tr("Upload this trace..."), ImageProvider.get("uploadtrace")); 101 } 102 public void actionPerformed(ActionEvent e) { 103 JPanel msg = new JPanel(new GridBagLayout()); 104 msg.add(new JLabel(tr("<html>This functionality has been added only recently. Please<br>"+ 105 "use with care and check if it works as expected.</html>")), GBC.eop()); 106 ButtonGroup bg = new ButtonGroup(); 107 JRadioButton c1 = null; 108 JRadioButton c2 = null; 109 110 if (associatedFile != null) { 111 c1 = new JRadioButton(tr("Upload track filtered by JOSM"), false); 112 c2 = new JRadioButton(tr("Upload raw file: {0}", associatedFile.getName()), true); 113 } 114 else 115 { 116 c1 = new JRadioButton(tr("Upload track filtered by JOSM"), true); 117 c2 = new JRadioButton(tr("Upload raw file: "), false); 118 c2.setEnabled(false); 119 } 120 c1.setEnabled(false); 121 bg.add(c1); 122 bg.add(c2); 123 124 msg.add(c1, GBC.eol()); 125 msg.add(c2, GBC.eop()); 126 127 128 JTextField description = new JTextField(); 129 JTextField tags = new JTextField(); 130 msg.add(new JLabel(tr("Description:")), GBC.std()); 131 msg.add(description, GBC.eol().fill(GBC.HORIZONTAL)); 132 msg.add(new JLabel(tr("Tags:")), GBC.std()); 133 msg.add(tags, GBC.eol().fill(GBC.HORIZONTAL)); 134 JCheckBox c3 = new JCheckBox("public"); 135 msg.add(c3, GBC.eop()); 136 msg.add(new JLabel("Please ensure that you don't upload your traces twice."), GBC.eop()); 137 138 int answer = JOptionPane.showConfirmDialog(Main.parent, msg, tr("GPX-Upload"), JOptionPane.OK_CANCEL_OPTION); 139 if (answer == JOptionPane.OK_OPTION) 140 { 141 try { 142 String version = Main.pref.get("osm-server.version", "0.5"); 143 URL url = new URL(Main.pref.get("osm-server.url") + 144 "/" + version + "/gpx/create"); 145 146 // create a boundary string 147 String boundary = MultiPartFormOutputStream.createBoundary(); 148 URLConnection urlConn = MultiPartFormOutputStream.createConnection(url); 149 urlConn.setRequestProperty("Accept", "*/*"); 150 urlConn.setRequestProperty("Content-Type", 151 MultiPartFormOutputStream.getContentType(boundary)); 152 // set some other request headers... 153 urlConn.setRequestProperty("Connection", "Keep-Alive"); 154 urlConn.setRequestProperty("Cache-Control", "no-cache"); 155 // no need to connect cuz getOutputStream() does it 156 MultiPartFormOutputStream out = 157 new MultiPartFormOutputStream(urlConn.getOutputStream(), boundary); 158 out.writeField("description", description.getText()); 159 out.writeField("tags", tags.getText()); 160 out.writeField("public", (c3.getSelectedObjects() != null) ? "1" : "0"); 161 // upload a file 162 out.writeFile("gpx_file", "text/xml", associatedFile); 163 // can also write bytes directly 164 // out.writeFile("myFile", "text/plain", "C:\\test.txt", 165 // "This is some file text.".getBytes("ASCII")); 166 out.close(); 167 // read response from server 168 BufferedReader in = new BufferedReader( 169 new InputStreamReader(urlConn.getInputStream())); 170 String line = ""; 171 while((line = in.readLine()) != null) { 172 System.out.println(line); 173 } 174 in.close(); 175 176 /* 177 int retCode = activeConnection.getResponseCode(); 178 System.out.println("got return: "+retCode); 179 String retMsg = activeConnection.getResponseMessage(); 180 activeConnection.disconnect(); 181 if (retCode != 200) { 182 // Look for a detailed error message from the server 183 if (activeConnection.getHeaderField("Error") != null) 184 retMsg += "\n" + activeConnection.getHeaderField("Error"); 185 186 // Report our error 187 ByteArrayOutputStream o = new ByteArrayOutputStream(); 188 System.out.println(new String(o.toByteArray(), "UTF-8").toString()); 189 throw new RuntimeException(retCode+" "+retMsg); 190 } 191 */ 192 } catch (UnknownHostException ex) { 193 throw new RuntimeException(tr("Unknown host")+": "+ex.getMessage(), ex); 194 } catch (Exception ex) { 195 //if (cancel) 196 // return; // assume cancel 197 if (ex instanceof RuntimeException) 198 throw (RuntimeException)ex; 199 throw new RuntimeException(ex.getMessage(), ex); 200 } 201 } 81 202 } 82 203 } … … 278 399 line, 279 400 new JMenuItem(new ConvertToDataLayerAction()), 401 //new JMenuItem(new UploadTraceAction()), 280 402 new JSeparator(), 281 403 new JMenuItem(new RenameLayerAction(associatedFile, this)), … … 291 413 tagimage, 292 414 new JMenuItem(new ConvertToDataLayerAction()), 415 //new JMenuItem(new UploadTraceAction()), 293 416 new JSeparator(), 294 417 new JMenuItem(new RenameLayerAction(associatedFile, this)),
Note:
See TracChangeset
for help on using the changeset viewer.