Ignore:
Timestamp:
2011-12-10T06:44:44+01:00 (12 years ago)
Author:
framm
Message:

Added three new hooks for plugins, allowing plugins to mess with JOSM's server I/O. Plugins can now add postprocessors to server reading (so they may change what JOSM receives from the OSM server), and they can add postprocessors to server writing (so they can react to an upload action *after* it happened and after IDs for new objects have been assigned - this is in addition to the existing UploadHook which is a server writing preprocessor). Thirdly, plugins can now substitute their own version of OsmWriter. Taken together, these changes make it possible for a plugin to introduce extra information from a non-OSM source into the JOSM editing process, and upon upload split away that extra information and send it to another destination. - Also made minor changes to CredentialDialog to allow plugins to subclass the dialog in case they need their own authentication.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/OsmApi.java

    r4310 r4645  
    3131import org.openstreetmap.josm.data.osm.IPrimitive;
    3232import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     33import org.openstreetmap.josm.gui.layer.ImageryLayer;
    3334import org.openstreetmap.josm.gui.layer.Layer;
    34 import org.openstreetmap.josm.gui.layer.ImageryLayer;
    3535import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3636import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    107107     */
    108108    private boolean initialized = false;
    109 
    110     private StringWriter swriter = new StringWriter();
    111     private OsmWriter osmWriter = new OsmWriter(new PrintWriter(swriter), true, null);
    112109
    113110    /**
     
    175172                    serverUrl,
    176173                    version));
    177             osmWriter.setVersion(version);
    178174            initialized = true;
    179175
    180             /* This is an interim solution for openstreetmap.org not currently 
     176            /* This is an interim solution for openstreetmap.org not currently
    181177             * transmitting their imagery blacklist in the capabilities call.
    182178             * remove this as soon as openstreetmap.org adds blacklists. */
     
    191187            /* This checks if there are any layers currently displayed that
    192188             * are now on the blacklist, and removes them. This is a rare
    193              * situaton - probably only occurs if the user changes the API URL
     189             * situation - probably only occurs if the user changes the API URL
    194190             * in the preferences menu. Otherwise they would not have been able
    195191             * to load the layers in the first place becuase they would have
     
    228224     */
    229225    private String toXml(IPrimitive o, boolean addBody) {
     226        StringWriter swriter = new StringWriter();
     227        OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(swriter), true, version);
    230228        swriter.getBuffer().setLength(0);
    231229        osmWriter.setWithBody(addBody);
     
    234232        o.visit(osmWriter);
    235233        osmWriter.footer();
    236         osmWriter.out.flush();
     234        osmWriter.flush();
    237235        return swriter.toString();
    238236    }
     
    245243     */
    246244    private String toXml(Changeset s) {
     245        StringWriter swriter = new StringWriter();
     246        OsmWriter osmWriter = OsmWriterFactory.createOsmWriter(new PrintWriter(swriter), true, version);
    247247        swriter.getBuffer().setLength(0);
    248248        osmWriter.header();
    249249        osmWriter.visit(s);
    250250        osmWriter.footer();
    251         osmWriter.out.flush();
     251        osmWriter.flush();
    252252        return swriter.toString();
    253253    }
Note: See TracChangeset for help on using the changeset viewer.