Ignore:
Timestamp:
2011-11-19T20:56:55+01:00 (13 years ago)
Author:
upliner
Message:

'reverter: add support for remotecontrol for curl-scripted reverts'

Location:
applications/editors/josm/plugins/reverter
Files:
3 edited

Legend:

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

    r26990 r27091  
    3030<project name="reverter" default="dist" basedir=".">
    3131    <!-- enter the SVN commit message -->
    32     <property name="commit.message" value="recompile after change in OsmPrimitive in JOSM 4099"/>
     32    <property name="commit.message" value="reverter: add support for remotecontrol for curl-scripted reverts"/>
    3333    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    3434    <property name="plugin.main.version" value="4549"/>
  • applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetAction.java

    r26509 r27091  
    55import java.awt.event.ActionEvent;
    66import java.awt.event.KeyEvent;
    7 import java.util.List;
    8 
    9 import javax.swing.JOptionPane;
    107
    118import org.openstreetmap.josm.Main;
    129import org.openstreetmap.josm.actions.JosmAction;
    13 import org.openstreetmap.josm.command.Command;
    14 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    15 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
    16 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    17 import org.openstreetmap.josm.io.OsmTransferException;
    1810import org.openstreetmap.josm.tools.Shortcut;
    1911
     
    4840        if (revertType == null) return;
    4941
    50         Main.worker.submit(new PleaseWaitRunnable(tr("Reverting...")) {
    51             private ChangesetReverter rev;
    52             private boolean downloadConfirmed = false;
    53 
    54             private boolean checkAndDownloadMissing() throws OsmTransferException {
    55                 if (!rev.hasMissingObjects()) return true;
    56                 if (!downloadConfirmed) {
    57                     downloadConfirmed = JOptionPane.showConfirmDialog(Main.parent,
    58                             tr("This changeset has objects that are not present in current dataset.\n" +
    59                                     "It is needed to download them before reverting. Do you want to continue?"),
    60                             tr("Confirm"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
    61                     if (!downloadConfirmed) return false;
    62                 }
    63                 final PleaseWaitProgressMonitor monitor =
    64                     new PleaseWaitProgressMonitor(tr("Fetching missing primitives"));
    65                 try {
    66                     rev.downloadMissingPrimitives(monitor);
    67                 } finally {
    68                     monitor.close();
    69                 }
    70                 return !monitor.isCanceled();
    71             }
    72 
    73             @Override
    74             protected void realRun() throws OsmTransferException {
    75                 progressMonitor.indeterminateSubTask(tr("Downloading changeset"));
    76                 rev = new ChangesetReverter(changesetId, revertType,
    77                         progressMonitor.createSubTaskMonitor(0, true));
    78                 if (progressMonitor.isCanceled()) return;
    79 
    80                 // Check missing objects
    81                 rev.checkMissingCreated();
    82                 rev.checkMissingUpdated();
    83                 if (rev.hasMissingObjects()) {
    84                     // If missing created or updated objects, ask user
    85                     rev.checkMissingDeleted();
    86                     if (!checkAndDownloadMissing()) return;
    87                 } else {
    88                     // Don't ask user to download primitives going to be undeleted
    89                     rev.checkMissingDeleted();
    90                     rev.downloadMissingPrimitives(progressMonitor.createSubTaskMonitor(0, false));
    91                 }
    92 
    93                 if (progressMonitor.isCanceled()) return;
    94                 rev.downloadObjectsHistory(progressMonitor.createSubTaskMonitor(ProgressMonitor.ALL_TICKS, false));
    95                 if (progressMonitor.isCanceled()) return;
    96                 if (!checkAndDownloadMissing()) return;
    97                 List<Command> cmds = rev.getCommands();
    98                 Command cmd = new RevertChangesetCommand(tr(revertType == RevertType.FULL ? "Revert changeset #{0}" :
    99                         "Partially revert changeset #{0}",changesetId),cmds);
    100                 Main.main.undoRedo.add(cmd);
    101             }
    102 
    103             @Override
    104             protected void cancel() {
    105             }
    106 
    107             @Override
    108             protected void finish() {
    109             }
    110         });
     42        Main.worker.submit(new RevertChangesetTask(changesetId, revertType));
    11143    }
    11244}
  • applications/editors/josm/plugins/reverter/src/reverter/ReverterPlugin.java

    r25578 r27091  
    1111import org.openstreetmap.josm.actions.UploadAction;
    1212import org.openstreetmap.josm.gui.MainMenu;
     13import org.openstreetmap.josm.io.remotecontrol.RemoteControl;
    1314import org.openstreetmap.josm.plugins.Plugin;
    1415import org.openstreetmap.josm.plugins.PluginInformation;
     
    2324        MainMenu.add(historyMenu, new RevertChangesetAction());
    2425        UploadAction.registerUploadHook(new ReverterUploadHook(this));
     26        new RemoteControl().addRequestHandler(RevertChangesetHandler.command, RevertChangesetHandler.class);
    2527    }
    2628}
Note: See TracChangeset for help on using the changeset viewer.