Ticket #6742: josm_try_3.diff
File josm_try_3.diff, 8.8 KB (added by , 13 years ago) |
---|
-
src/org/openstreetmap/josm/actions/UploadAction.java
7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.KeyEvent; 9 9 import java.util.LinkedList; 10 import java.util.logging.Logger; 10 11 11 12 import javax.swing.JOptionPane; 12 13 … … 35 36 * @author imi 36 37 */ 37 38 public class UploadAction extends JosmAction{ 39 private static Logger logger = Logger.getLogger(UploadAction.class.getName()); 40 38 41 /** 39 42 * The list of upload hooks. These hooks will be called one after the other 40 43 * when the user wants to upload data. Plugins can insert their own hooks here … … 160 163 return; 161 164 162 165 final UploadDialog dialog = UploadDialog.getUploadDialog(); 166 dialog.setDefaultChangesetTags(layer.data.getChangeSetTags()); 163 167 dialog.setUploadedPrimitives(apiData); 164 168 dialog.setVisible(true); 165 169 if (dialog.isCanceled()) -
src/org/openstreetmap/josm/tools/PlatformHookOsx.java
30 30 // Here we register callbacks for the menu entries in the system menu 31 31 try { 32 32 Class Ccom_apple_eawt_Application = Class.forName("com.apple.eawt.Application"); 33 @SuppressWarnings("unchecked") 33 34 Object Ocom_apple_eawt_Application = Ccom_apple_eawt_Application.getConstructor((Class[])null).newInstance((Object[])null); 34 35 Class Ccom_apple_eawt_ApplicationListener = Class.forName("com.apple.eawt.ApplicationListener"); 36 @SuppressWarnings("unchecked") 35 37 Method MaddApplicationListener = Ccom_apple_eawt_Application.getDeclaredMethod("addApplicationListener", new Class[] { Ccom_apple_eawt_ApplicationListener }); 36 38 Object Oproxy = Proxy.newProxyInstance(PlatformHookOsx.class.getClassLoader(), new Class[] { Ccom_apple_eawt_ApplicationListener }, ivhandler); 37 39 MaddApplicationListener.invoke(Ocom_apple_eawt_Application, new Object[] { Oproxy }); 40 @SuppressWarnings("unchecked") 38 41 Method MsetEnabledPreferencesMenu = Ccom_apple_eawt_Application.getDeclaredMethod("setEnabledPreferencesMenu", new Class[] { boolean.class }); 39 42 MsetEnabledPreferencesMenu.invoke(Ocom_apple_eawt_Application, new Object[] { Boolean.TRUE }); 40 43 } catch (Exception ex) { -
src/org/openstreetmap/josm/gui/io/UploadDialog.java
17 17 import java.util.Collections; 18 18 import java.util.List; 19 19 import java.util.Map; 20 import java.util.logging.Logger; 20 21 21 22 import javax.swing.AbstractAction; 22 23 import javax.swing.BorderFactory; … … 52 53 * 53 54 */ 54 55 public class UploadDialog extends JDialog implements PropertyChangeListener, PreferenceChangedListener{ 56 private static Logger logger = Logger.getLogger(UploadDialog.class.getName()); 57 55 58 /** the unique instance of the upload dialog */ 56 59 static private UploadDialog uploadDialog; 57 60 … … 300 303 301 304 public void setDefaultChangesetTags(Map<String, String> tags) { 302 305 pnlTagSettings.setDefaultTags(tags); 306 307 // The following code does not seem to actually work. JOSM ignores the comment given. 308 for (String key: tags.keySet()) { 309 if( key.equals("comment")) { 310 logger.info("TODO: bug, this tag is not working. comment=" +tags.get(key)); 311 pnlTagSettings.setUploadComment(tags.get(key)); 312 } 313 } 303 314 } 304 315 305 316 /** -
src/org/openstreetmap/josm/io/OsmImporter.java
8 8 import java.io.FileNotFoundException; 9 9 import java.io.IOException; 10 10 import java.io.InputStream; 11 import java.util.logging.Logger; 11 12 12 13 import javax.swing.SwingUtilities; 13 14 … … 19 20 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 20 21 21 22 public class OsmImporter extends FileImporter { 23 private static Logger logger = Logger.getLogger(OsmImporter.class.getName()); 22 24 23 25 public OsmImporter() { 24 26 super(new ExtensionFileFilter("osm,xml", "osm", tr("OSM Server Files") + " (*.osm *.xml)")); … … 41 43 protected void importData(InputStream in, File associatedFile) throws IllegalDataException { 42 44 DataSet dataSet = OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE); 43 45 final OsmDataLayer layer = new OsmDataLayer(dataSet, associatedFile.getName(), associatedFile); 46 44 47 // FIXME: remove UI stuff from IO subsystem 45 48 // 46 49 Runnable uiStuff = new Runnable() { -
src/org/openstreetmap/josm/io/OsmReader.java
112 112 /** 113 113 * The current osm primitive to be read. 114 114 */ 115 private OsmPrimitive currentPrimitive ;115 private OsmPrimitive currentPrimitive = null; 116 116 private long currentExternalId; 117 117 private String generator; 118 118 … … 134 134 generator = atts.getValue("generator"); 135 135 ds.setVersion(v); 136 136 137 // JOSM specific extension to the file format. This is for scripts or bots that build 138 // a .osm file for human review. Here the script or bot can pre-set values for 139 // later upload in the changeset. 140 } else if (qName.equals("changeset")) { 141 currentPrimitive = null; // flag for tag parser below 142 137 143 } else if (qName.equals("bounds")) { 138 144 // new style bounds. 139 145 String minlon = atts.getValue("minlon"); … … 259 265 list.add(emd); 260 266 } 261 267 262 // ---- PARSING TAGS (applicable to all objects) ---- 263 268 // ---- PARSING TAGS (applicable to all objects & changesets) ---- 264 269 } else if (qName.equals("tag")) { 265 270 String key = atts.getValue("k"); 266 271 String value = atts.getValue("v"); 267 272 if (key == null || value == null) { 268 273 throwException(tr("Missing key or value attribute in tag.")); 269 274 } 270 currentPrimitive.put(key.intern(), value.intern()); 275 if( currentPrimitive == null) { 276 ds.addChangeSetTag(key.intern(), value.intern() ); // changeset 277 } else { 278 currentPrimitive.put(key.intern(), value.intern()); // node/way/relation 279 } 271 280 272 281 } else { 273 282 System.out.println(tr("Undefined element ''{0}'' found in input stream. Skipping.", qName)); … … 452 461 } 453 462 w.setNodes(wayNodes); 454 463 if (w.hasIncompleteNodes()) { 455 456 464 System.out.println(tr("Way {0} with {1} nodes has incomplete nodes because at least one node was missing in the loaded data.", 465 externalWayId, w.getNodesCount())); 457 466 } 458 467 ds.addPrimitive(w); 459 468 } -
src/org/openstreetmap/josm/data/osm/DataSet.java
206 206 this.version = version; 207 207 } 208 208 209 /* 210 * Holding bin for changeset tag information, to be applied when or if this is ever uploaded. 211 */ 212 //private HashMap changeSetTags = new HashMap(); 213 private Map<String, String> changeSetTags = new HashMap<String, String>(); 214 public Map<String, String> getChangeSetTags() { 215 return changeSetTags; 216 } 217 public void addChangeSetTag(String k, String v) { 218 this.changeSetTags.put(k,v); 219 } 220 209 221 /** 210 222 * All nodes goes here, even when included in other data (ways etc). This enables the instant 211 223 * conversion of the whole DataSet by iterating over this data structure.