Ignore:
Timestamp:
2012-09-03T18:56:02+02:00 (12 years ago)
Author:
bastiK
Message:

applied #7915 - Automatically discard some TIGER tags on upload (based on patch by ToeBee)

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r5266 r5497  
    1414import org.openstreetmap.josm.Main;
    1515import org.openstreetmap.josm.actions.upload.ApiPreconditionCheckerHook;
     16import org.openstreetmap.josm.actions.upload.DiscardTagsHook;
    1617import org.openstreetmap.josm.actions.upload.RelationUploadOrderHook;
    1718import org.openstreetmap.josm.actions.upload.UploadHook;
     
    5051     */
    5152    private static final LinkedList<UploadHook> uploadHooks = new LinkedList<UploadHook>();
     53    private static final LinkedList<UploadHook> lateUploadHooks = new LinkedList<UploadHook>();
    5254    static {
    5355        uploadHooks.add(new ValidateUploadHook());
     
    6163         */
    6264        uploadHooks.add(new RelationUploadOrderHook());
     65
     66        /**
     67         * Removes discardable tags like created_by on modified objects
     68         */
     69        lateUploadHooks.add(new DiscardTagsHook());
    6370    }
    6471
     
    6976     */
    7077    public static void registerUploadHook(UploadHook hook) {
     78        registerUploadHook(hook, false);
     79    }
     80
     81    /**
     82     * Registers an upload hook. Adds the hook at the first position of the upload hooks.
     83     *
     84     * @param hook the upload hook. Ignored if null.
     85     * @param late true, if the hook should be executed after the upload dialog
     86     * has been confirmed. Late upload hooks should in general succeed and not
     87     * abort the upload.
     88     */
     89    public static void registerUploadHook(UploadHook hook, boolean late) {
    7190        if(hook == null) return;
    72         if (!uploadHooks.contains(hook)) {
    73             uploadHooks.add(0,hook);
     91        if (late) {
     92            if (!lateUploadHooks.contains(hook)) {
     93                lateUploadHooks.add(0, hook);
     94            }
     95        } else {
     96            if (!uploadHooks.contains(hook)) {
     97                uploadHooks.add(0, hook);
     98            }
    7499        }
    75100    }
     
    84109        if (uploadHooks.contains(hook)) {
    85110            uploadHooks.remove(hook);
     111        }
     112        if (lateUploadHooks.contains(hook)) {
     113            lateUploadHooks.remove(hook);
    86114        }
    87115    }
     
    122150     * want to continue
    123151     */
    124     public static final boolean warnUploadDiscouraged(OsmDataLayer layer) {
     152    public static boolean warnUploadDiscouraged(OsmDataLayer layer) {
    125153        return GuiHelper.warnUser(tr("Upload discouraged"),
    126154                "<html>" +
     
    200228        dialog.rememberUserInput();
    201229
     230        for (UploadHook hook : lateUploadHooks) {
     231            if (!hook.checkUpload(apiData))
     232                return;
     233        }
     234
    202235        Main.worker.execute(
    203236                new UploadPrimitivesTask(
Note: See TracChangeset for help on using the changeset viewer.