Changeset 23190 in osm for applications/editors/josm/plugins/DirectUpload/src
- Timestamp:
- 2010-09-15T18:54:18+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload
- Files:
-
- 2 edited
-
UploadDataGui.java (modified) (3 diffs)
-
UploadDataGuiPlugin.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified applications/editors/josm/plugins/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGui.java ¶
r22017 r23190 82 82 83 83 @Override 84 public String toString() {84 public String toString() { 85 85 return this.name().toLowerCase(); 86 86 } … … 134 134 */ 135 135 private JPanel initComponents() { 136 JLabel visibilityLabel = new JLabel(tr("Visibility"));136 JLabel visibilityLabel = new JLabel(tr("Visibility")); 137 137 visibilityLabel.setToolTipText(tr("Defines the visibility of your trace for other OSM users.")); 138 138 for(visibility v : visibility.values()) { 139 visibilityCombo.addItem(v.description);139 visibilityCombo.addItem(v.description); 140 140 } 141 141 UrlLabel visiUrl = new UrlLabel(tr("http://wiki.openstreetmap.org/wiki/Visibility_of_GPS_traces"), tr("(What does that mean?)")); … … 205 205 */ 206 206 private void upload(String description, String tags, String visi, GpxData gpxData, ProgressMonitor progressMonitor) throws IOException { 207 progressMonitor.beginTask(null);208 try {209 if(checkForErrors(username, password, description, gpxData))210 return;211 212 // Clean description/tags from disallowed chars213 description = description.replaceAll("[&?/\\\\]"," ");214 tags = tags.replaceAll("[&?/\\\\.;]"," ");215 216 // Set progress dialog to indeterminate while connecting217 progressMonitor.indeterminateSubTask(tr("Connecting..."));218 219 try {220 // Generate data for upload221 ByteArrayOutputStream baos = new ByteArrayOutputStream();222 writeGpxFile(baos, "file", gpxData);223 writeField(baos, "description", description);224 writeField(baos, "tags", (tags != null && tags.length() > 0) ? tags : "");225 writeField(baos, "visibility", visi);226 writeString(baos, "--" + BOUNDARY + "--" + LINE_END);227 228 ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());229 HttpURLConnection conn = setupConnection(baos.size());230 231 progressMonitor.setTicksCount(baos.size());232 progressMonitor.subTask(null);233 234 try {235 flushToServer(bais, conn.getOutputStream(), progressMonitor);236 } catch(Exception e) {}237 238 if(cancelled) {239 conn.disconnect();240 OutputDisplay.setText(tr("Upload cancelled"));241 buttons.get(0).setEnabled(true);242 cancelled = false;243 } else {244 boolean success = finishUpConnection(conn);245 buttons.get(0).setEnabled(!success);246 if(success)247 buttons.get(1).setText(tr("Close"));248 }249 } catch(Exception e) {250 OutputDisplay.setText(tr("Error while uploading"));251 e.printStackTrace();252 }253 } finally {254 progressMonitor.finishTask();255 }207 progressMonitor.beginTask(null); 208 try { 209 if(checkForErrors(username, password, description, gpxData)) 210 return; 211 212 // Clean description/tags from disallowed chars 213 description = description.replaceAll("[&?/\\\\]"," "); 214 tags = tags.replaceAll("[&?/\\\\.;]"," "); 215 216 // Set progress dialog to indeterminate while connecting 217 progressMonitor.indeterminateSubTask(tr("Connecting...")); 218 219 try { 220 // Generate data for upload 221 ByteArrayOutputStream baos = new ByteArrayOutputStream(); 222 writeGpxFile(baos, "file", gpxData); 223 writeField(baos, "description", description); 224 writeField(baos, "tags", (tags != null && tags.length() > 0) ? tags : ""); 225 writeField(baos, "visibility", visi); 226 writeString(baos, "--" + BOUNDARY + "--" + LINE_END); 227 228 ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); 229 HttpURLConnection conn = setupConnection(baos.size()); 230 231 progressMonitor.setTicksCount(baos.size()); 232 progressMonitor.subTask(null); 233 234 try { 235 flushToServer(bais, conn.getOutputStream(), progressMonitor); 236 } catch(Exception e) {} 237 238 if(cancelled) { 239 conn.disconnect(); 240 OutputDisplay.setText(tr("Upload cancelled")); 241 buttons.get(0).setEnabled(true); 242 cancelled = false; 243 } else { 244 boolean success = finishUpConnection(conn); 245 buttons.get(0).setEnabled(!success); 246 if(success) 247 buttons.get(1).setText(tr("Close")); 248 } 249 } catch(Exception e) { 250 OutputDisplay.setText(tr("Error while uploading")); 251 e.printStackTrace(); 252 } 253 } finally { 254 progressMonitor.finishTask(); 255 } 256 256 } 257 257 -
TabularUnified applications/editors/josm/plugins/DirectUpload/src/org/openstreetmap/josm/plugins/DirectUpload/UploadDataGuiPlugin.java ¶
r20880 r23190 27 27 28 28 public UploadDataGuiPlugin(PluginInformation info) { 29 super(info);29 super(info); 30 30 openaction = new UploadAction(); 31 31 Main.main.menu.toolsMenu.add(openaction); … … 44 44 45 45 @Override 46 protected void updateEnabledState() {47 // enable button if there is "one active GpxLayer" or "exactly one GpxLayer in the list of all layers available"48 if(Main.map == null46 protected void updateEnabledState() { 47 // enable button if there is "one active GpxLayer" or "exactly one GpxLayer in the list of all layers available" 48 if(Main.map == null 49 49 || Main.map.mapView == null 50 50 || Main.map.mapView.getActiveLayer() == null 51 || !(Main.map.mapView.getActiveLayer() instanceof GpxLayer)) { 51 || !(Main.map.mapView.getActiveLayer() instanceof GpxLayer)) { 52 52 setEnabled(false); 53 53 } else { 54 setEnabled(true);54 setEnabled(true); 55 55 } 56 56 … … 61 61 } 62 62 63 } 63 } 64 64 } 65 65 }
Note:
See TracChangeset
for help on using the changeset viewer.
