Changeset 34974 in osm for applications/editors/josm/plugins
- Timestamp:
- 2019-04-12T08:02:04+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/reverter/src/reverter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/src/reverter/ReverterPlugin.java
r34917 r34974 25 25 JMenu historyMenu = MainApplication.getMenu().dataMenu; 26 26 MainMenu.add(historyMenu, new RevertChangesetAction()); 27 UploadAction.registerUploadHook(new ReverterUploadHook( this));27 UploadAction.registerUploadHook(new ReverterUploadHook(info)); 28 28 new RemoteControl().addRequestHandler(RevertChangesetHandler.command, RevertChangesetHandler.class); 29 29 } -
applications/editors/josm/plugins/reverter/src/reverter/ReverterUploadHook.java
r34552 r34974 4 4 import org.openstreetmap.josm.actions.upload.UploadHook; 5 5 import org.openstreetmap.josm.command.Command; 6 import org.openstreetmap.josm.command.SequenceCommand; 6 7 import org.openstreetmap.josm.data.APIDataSet; 7 8 import org.openstreetmap.josm.data.UndoRedoHandler; 8 9 import org.openstreetmap.josm.gui.MainApplication; 10 import org.openstreetmap.josm.plugins.PluginInformation; 9 11 12 /** 13 * Upload hook to add tag to new changeset. 14 * 15 */ 10 16 public class ReverterUploadHook implements UploadHook { 11 String pluginString; 12 public ReverterUploadHook(ReverterPlugin plugin) { 13 pluginString = "reverter_plugin/" + plugin.getPluginInformation().version; 17 final String pluginString; 18 19 /** 20 * Create new {@link ReverterUploadHook} 21 * @param info plugin information 22 */ 23 public ReverterUploadHook(PluginInformation info) { 24 pluginString = "reverter_plugin/" + info.version; 14 25 } 15 26 16 27 @Override 17 28 public boolean checkUpload(APIDataSet apiDataSet) { 18 if ( !ReverterPlugin.reverterUsed) return true;19 boolean hasRevertions = false;20 for (Command cmd : UndoRedoHandler.getInstance().commands) {21 if (cmd instanceof RevertChangesetCommand) {22 hasRevertions = true;23 break;29 if (ReverterPlugin.reverterUsed) { 30 for (Command cmd : UndoRedoHandler.getInstance().commands) { 31 if (isReverterCmd(cmd)) { 32 MainApplication.getLayerManager().getEditDataSet().addChangeSetTag("created_by", pluginString); 33 break; 34 } 24 35 } 25 }26 27 if (hasRevertions) {28 MainApplication.getLayerManager().getEditDataSet().addChangeSetTag("created_by", "reverter");29 36 } 30 37 return true; 31 38 } 32 39 40 private static boolean isReverterCmd(Command cmd) { 41 if (cmd instanceof RevertChangesetCommand) 42 return true; 43 if (cmd instanceof SequenceCommand) { 44 return ((SequenceCommand) cmd).getLastCommand() instanceof RevertChangesetCommand; 45 } 46 return false; 47 } 33 48 }
Note:
See TracChangeset
for help on using the changeset viewer.