Changeset 36319 in osm for applications


Ignore:
Timestamp:
2024-08-21T22:49:24+02:00 (4 months ago)
Author:
taylor.smock
Message:

Fix #23701: Support for revert multiple changesets in Remote Control (patch by TrickyFoxy, modified)

Modifications are as follows:

  • Lint cleanups
  • Add remote control checkbox for reverter to preferences
Location:
applications/editors/josm/plugins/reverter
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/reverter/build.xml

    r36122 r36319  
    44    <property name="commit.message" value="Reverter: fix deleted/redacted relation members"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="18723"/>
     6    <property name="plugin.main.version" value="19044"/>
    77
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/reverter/pom.xml

    r36282 r36319  
    1717    <properties>
    1818        <plugin.src.dir>src</plugin.src.dir>
    19         <plugin.main.version>18723</plugin.main.version>
     19        <plugin.main.version>19044</plugin.main.version>
    2020        <plugin.author>Upliner</plugin.author>
    2121        <plugin.class>reverter.ReverterPlugin</plugin.class>
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetHandler.java

    r33572 r36319  
    77import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
    88import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler;
     9import org.openstreetmap.josm.tools.Logging;
    910
     11import java.util.List;
     12import java.util.ArrayList;
     13
     14/**
     15 * The handler for {@link org.openstreetmap.josm.io.remotecontrol.RemoteControl} revert commands
     16 */
    1017public class RevertChangesetHandler extends RequestHandler {
    11     public static final String command = "revert_changeset";
    12     public static final String permissionKey = "remotecontrol.permission.revert_changeset";
    13     public static final boolean permissionDefault = true;
     18    public static final String COMMAND = "revert_changeset";
     19    private static final String PERMISSION_KEY = "remotecontrol.permission.revert_changeset";
     20    private static final boolean PERMISSION_DEFAULT = true;
    1421
    15     private int changesetId;
     22    private final List<Integer> changesetIds = new ArrayList<>();
    1623
    1724    @Override
    18     protected void handleRequest() throws RequestHandlerErrorException,
    19             RequestHandlerBadRequestException {
     25    protected void handleRequest() throws RequestHandlerErrorException {
    2026        try {
    21             MainApplication.worker.submit(new RevertChangesetTask(changesetId, ChangesetReverter.RevertType.FULL, true));
     27            MainApplication.worker.submit(new RevertChangesetTask(changesetIds, ChangesetReverter.RevertType.FULL, true, false));
    2228        } catch (Exception ex) {
    23             System.out.println("RemoteControl: Error parsing revert_changeset remote control request:");
    24             ex.printStackTrace();
     29            Logging.debug("RemoteControl: Error parsing revert_changeset remote control request:");
     30            Logging.debug(ex);
    2531            throw new RequestHandlerErrorException(ex);
    2632        }
     
    3440    @Override
    3541    public PermissionPrefWithDefault getPermissionPref() {
    36         return null;
     42        return new PermissionPrefWithDefault(PERMISSION_KEY, PERMISSION_DEFAULT, tr("Revert changeset(s)"));
    3743    }
    3844
     
    4450    @Override
    4551    protected void validateRequest() throws RequestHandlerBadRequestException {
    46         try {
    47             changesetId = Integer.parseInt(args.get("id"));
    48         } catch (NumberFormatException e) {
    49             throw new RequestHandlerBadRequestException("NumberFormatException: "+e.getMessage());
     52        if (args.get("id") != null) {
     53            try {
     54                for (String id : args.get("id").split(",", -1)) {
     55                    changesetIds.add(Integer.parseInt(id));
     56                }
     57            } catch (NumberFormatException e) {
     58                throw new RequestHandlerBadRequestException("NumberFormatException: " + e.getMessage());
     59            }
     60        } else {
     61            throw new RequestHandlerBadRequestException("The required id argument must be specified");
    5062        }
    5163    }
  • applications/editors/josm/plugins/reverter/src/reverter/ReverterPlugin.java

    r35868 r36319  
    2828        MainMenu.add(historyMenu, new RevertChangesetAction());
    2929        UploadAction.registerUploadHook(new ReverterUploadHook(info));
    30         new RemoteControl().addRequestHandler(RevertChangesetHandler.command, RevertChangesetHandler.class);
     30        new RemoteControl().addRequestHandler(RevertChangesetHandler.COMMAND, RevertChangesetHandler.class);
    3131    }
    3232}
Note: See TracChangeset for help on using the changeset viewer.