Changeset 4645 in josm
- Timestamp:
- 2011-12-10T06:44:44+01:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java
r4386 r4645 57 57 58 58 private boolean canceled; 59 pr ivateCredentialPanel pnlCredentials;59 protected CredentialPanel pnlCredentials; 60 60 String saveUsernameAndPasswordCheckboxText; 61 61 … … 135 135 } 136 136 137 pr ivatestatic class CredentialPanel extends JPanel {137 protected static class CredentialPanel extends JPanel { 138 138 protected JTextField tfUserName; 139 139 protected JPasswordField tfPassword; -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r4310 r4645 31 31 import org.openstreetmap.josm.data.osm.IPrimitive; 32 32 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 33 import org.openstreetmap.josm.gui.layer.ImageryLayer; 33 34 import org.openstreetmap.josm.gui.layer.Layer; 34 import org.openstreetmap.josm.gui.layer.ImageryLayer;35 35 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 36 36 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 107 107 */ 108 108 private boolean initialized = false; 109 110 private StringWriter swriter = new StringWriter();111 private OsmWriter osmWriter = new OsmWriter(new PrintWriter(swriter), true, null);112 109 113 110 /** … … 175 172 serverUrl, 176 173 version)); 177 osmWriter.setVersion(version);178 174 initialized = true; 179 175 180 /* This is an interim solution for openstreetmap.org not currently 176 /* This is an interim solution for openstreetmap.org not currently 181 177 * transmitting their imagery blacklist in the capabilities call. 182 178 * remove this as soon as openstreetmap.org adds blacklists. */ … … 191 187 /* This checks if there are any layers currently displayed that 192 188 * are now on the blacklist, and removes them. This is a rare 193 * situat on - probably only occurs if the user changes the API URL189 * situation - probably only occurs if the user changes the API URL 194 190 * in the preferences menu. Otherwise they would not have been able 195 191 * to load the layers in the first place becuase they would have … … 228 224 */ 229 225 private String toXml(IPrimitive o, boolean addBody) { 226 StringWriter swriter = new StringWriter(); 227 OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(swriter), true, version); 230 228 swriter.getBuffer().setLength(0); 231 229 osmWriter.setWithBody(addBody); … … 234 232 o.visit(osmWriter); 235 233 osmWriter.footer(); 236 osmWriter. out.flush();234 osmWriter.flush(); 237 235 return swriter.toString(); 238 236 } … … 245 243 */ 246 244 private String toXml(Changeset s) { 245 StringWriter swriter = new StringWriter(); 246 OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(swriter), true, version); 247 247 swriter.getBuffer().setLength(0); 248 248 osmWriter.header(); 249 249 osmWriter.visit(s); 250 250 osmWriter.footer(); 251 osmWriter. out.flush();251 osmWriter.flush(); 252 252 return swriter.toString(); 253 253 } -
trunk/src/org/openstreetmap/josm/io/OsmChangeBuilder.java
r4310 r4645 34 34 this.apiVersion = apiVersion == null ? DEFAULT_API_VERSION : apiVersion; 35 35 writer = new PrintWriter(swriter = new StringWriter()); 36 osmwriter = newOsmWriter(writer, false, apiVersion);36 osmwriter = OsmWriterFactory.createOsmWriter(writer, false, apiVersion); 37 37 osmwriter.setChangeset(changeset); 38 38 } -
trunk/src/org/openstreetmap/josm/io/OsmExporter.java
r3461 r4645 67 67 Writer writer = new OutputStreamWriter(out, "UTF-8"); 68 68 69 OsmWriter w = newOsmWriter(new PrintWriter(writer), false, layer.data.getVersion());69 OsmWriter w = OsmWriterFactory.createOsmWriter(new PrintWriter(writer), false, layer.data.getVersion()); 70 70 layer.data.getReadLock().lock(); 71 71 try { -
trunk/src/org/openstreetmap/josm/io/OsmReader.java
r4532 r4645 50 50 protected XMLStreamReader parser; 51 51 52 /** Used by plugins to register themselves as data postprocessors. */ 53 public static ArrayList<OsmServerReadPostprocessor> postprocessors; 54 55 /** register a new postprocessor */ 56 public static void registerPostprocessor(OsmServerReadPostprocessor pp) { 57 if (postprocessors == null) { 58 postprocessors = new ArrayList<OsmServerReadPostprocessor>(); 59 } 60 postprocessors.add(pp); 61 } 62 63 /** deregister a postprocessor previously registered with registerPostprocessor */ 64 public static void deregisterPostprocessor(OsmServerReadPostprocessor pp) { 65 if (postprocessors != null) { 66 postprocessors.remove(pp); 67 } 68 } 69 52 70 /** 53 71 * constructor (for private and subclasses use only) … … 71 89 if (event == XMLStreamConstants.START_ELEMENT) { 72 90 parseRoot(); 73 } else if (event == XMLStreamConstants.END_ELEMENT) {91 } else if (event == XMLStreamConstants.END_ELEMENT) 74 92 return; 75 }76 93 if (parser.hasNext()) { 77 94 event = parser.next(); … … 82 99 parser.close(); 83 100 } 84 101 85 102 protected void parseRoot() throws XMLStreamException { 86 103 if (parser.getLocalName().equals("osm")) { … … 121 138 parseUnknown(); 122 139 } 123 } else if (event == XMLStreamConstants.END_ELEMENT) {140 } else if (event == XMLStreamConstants.END_ELEMENT) 124 141 return; 125 }126 142 } 127 143 } … … 172 188 parseUnknown(); 173 189 } 174 } else if (event == XMLStreamConstants.END_ELEMENT) {190 } else if (event == XMLStreamConstants.END_ELEMENT) 175 191 return n; 176 }177 192 } 178 193 } … … 301 316 parseUnknown(); 302 317 } 303 } else if (event == XMLStreamConstants.END_ELEMENT) {318 } else if (event == XMLStreamConstants.END_ELEMENT) 304 319 return; 305 }306 320 } 307 321 } else { … … 328 342 if (event == XMLStreamConstants.START_ELEMENT) { 329 343 parseUnknown(false); /* no more warning for inner elements */ 330 } else if (event == XMLStreamConstants.END_ELEMENT) {344 } else if (event == XMLStreamConstants.END_ELEMENT) 331 345 return; 332 }333 346 } 334 347 } … … 350 363 if (event == XMLStreamConstants.START_ELEMENT) { 351 364 parseUnknown(printWarning); 352 } else if (event == XMLStreamConstants.END_ELEMENT) {365 } else if (event == XMLStreamConstants.END_ELEMENT) 353 366 return; 354 }355 367 } 356 368 } … … 555 567 prepareDataSet(); 556 568 progressMonitor.worked(1); 569 570 // iterate over registered postprocessors and give them each a chance 571 // to modify the dataset we have just loaded. 572 if (postprocessors != null) { 573 for (OsmServerReadPostprocessor pp : postprocessors) { 574 pp.postprocessDataSet(getDataSet(), progressMonitor); 575 } 576 } 557 577 return getDataSet(); 558 578 } catch(IllegalDataException e) { … … 567 587 msg = m.group(1); 568 588 } 569 if (e.getLocation() != null) {589 if (e.getLocation() != null) 570 590 throw new IllegalDataException(tr("Line {0} column {1}: ", e.getLocation().getLineNumber(), e.getLocation().getColumnNumber()) + msg, e); 571 } else {591 else 572 592 throw new IllegalDataException(msg, e); 573 }574 593 } catch(Exception e) { 575 594 throw new IllegalDataException(e); … … 578 597 } 579 598 } 580 599 581 600 /** 582 601 * Parse the given input source and return the dataset. -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r4191 r4645 36 36 */ 37 37 private Collection<IPrimitive> processed; 38 39 private static ArrayList<OsmServerWritePostprocessor> postprocessors; 40 public static void registerPostprocessor(OsmServerWritePostprocessor pp) { 41 if (postprocessors == null) { 42 postprocessors = new ArrayList<OsmServerWritePostprocessor>(); 43 } 44 postprocessors.add(pp); 45 } 46 public static void unregisterPostprocessor(OsmServerWritePostprocessor pp) { 47 if (postprocessors != null) { 48 postprocessors.remove(pp); 49 } 50 } 38 51 39 52 private OsmApi api = OsmApi.getOsmApi(); … … 205 218 throw e; 206 219 } finally { 220 executePostprocessors(monitor); 207 221 monitor.finishTask(); 208 222 api.setChangeset(null); … … 216 230 api.createPrimitive(osm, progressMonitor); 217 231 } else { 218 api.modifyPrimitive(osm, progressMonitor);232 api.modifyPrimitive(osm, progressMonitor); 219 233 } 220 234 } … … 235 249 return processed; 236 250 } 251 252 /** 253 * Calls all registered upload postprocessors. 254 */ 255 public void executePostprocessors(ProgressMonitor pm) { 256 if (postprocessors != null) { 257 for (OsmServerWritePostprocessor pp : postprocessors) { 258 pp.postprocessUploadedPrimitives(processed, pm); 259 } 260 } 261 } 237 262 } -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r4105 r4645 42 42 private Changeset changeset; 43 43 44 public OsmWriter(PrintWriter out, boolean osmConform, String version) { 44 /** 45 * Do not call this directly. Use OsmWriterFactory instead. 46 */ 47 protected OsmWriter(PrintWriter out, boolean osmConform, String version) { 45 48 super(out); 46 49 this.osmConform = osmConform; … … 68 71 } 69 72 70 pr ivatestatic final Comparator<OsmPrimitive> byIdComparator = new Comparator<OsmPrimitive>() {73 protected static final Comparator<OsmPrimitive> byIdComparator = new Comparator<OsmPrimitive>() { 71 74 @Override public int compare(OsmPrimitive o1, OsmPrimitive o2) { 72 75 return (o1.getUniqueId()<o2.getUniqueId() ? -1 : (o1.getUniqueId()==o2.getUniqueId() ? 0 : 1)); … … 74 77 }; 75 78 76 pr ivateCollection<OsmPrimitive> sortById(Collection<? extends OsmPrimitive> primitives) {79 protected Collection<OsmPrimitive> sortById(Collection<? extends OsmPrimitive> primitives) { 77 80 List<OsmPrimitive> result = new ArrayList<OsmPrimitive>(primitives.size()); 78 81 result.addAll(primitives); … … 99 102 } 100 103 101 pr ivateboolean shouldWrite(OsmPrimitive osm) {104 protected boolean shouldWrite(OsmPrimitive osm) { 102 105 return !osm.isNewOrUndeleted() || !osm.isDeleted(); 103 106 } … … 185 188 } 186 189 187 pr ivatestatic final Comparator<Entry<String, String>> byKeyComparator = new Comparator<Entry<String,String>>() {190 protected static final Comparator<Entry<String, String>> byKeyComparator = new Comparator<Entry<String,String>>() { 188 191 @Override public int compare(Entry<String, String> o1, Entry<String, String> o2) { 189 192 return o1.getKey().compareTo(o2.getKey()); … … 191 194 }; 192 195 193 pr ivatevoid addTags(Tagged osm, String tagname, boolean tagOpen) {196 protected void addTags(Tagged osm, String tagname, boolean tagOpen) { 194 197 if (osm.hasKeys()) { 195 198 if (tagOpen) { … … 216 219 * id, action, user, and visible. 217 220 */ 218 pr ivatevoid addCommon(IPrimitive osm, String tagname) {221 protected void addCommon(IPrimitive osm, String tagname) { 219 222 out.print(" <"+tagname); 220 223 if (osm.getUniqueId() != 0) { … … 261 264 } 262 265 266 @Override 263 267 public void flush() { 264 268 out.flush(); -
trunk/src/org/openstreetmap/josm/io/XmlWriter.java
r1677 r4645 18 18 } 19 19 20 public void flush() { 21 out.flush(); 22 } 23 20 24 /** 21 25 * Encode the given string in XML1.0 format. … … 27 31 String encS = XmlWriter.encoding.get(unencoded.charAt(i)); 28 32 if (encS != null) { 29 if (buffer == null) 33 if (buffer == null) { 30 34 buffer = new StringBuilder(unencoded.substring(0,i)); 35 } 31 36 buffer.append(encS); 32 } else if (buffer != null) 37 } else if (buffer != null) { 33 38 buffer.append(unencoded.charAt(i)); 39 } 34 40 } 35 41 return (buffer == null) ? unencoded : buffer.toString();
Note:
See TracChangeset
for help on using the changeset viewer.