Ticket #17540: 17540.patch
File 17540.patch, 2.1 KB (added by , 6 years ago) |
---|
-
src/reverter/ReverterUploadHook.java
3 3 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; 9 10 11 /** 12 * Upload hook to add tag to new changeset. 13 * 14 */ 10 15 public class ReverterUploadHook implements UploadHook { 11 String pluginString;16 final String pluginString; 12 17 public ReverterUploadHook(ReverterPlugin plugin) { 13 18 pluginString = "reverter_plugin/" + plugin.getPluginInformation().version; 14 19 } … … 15 20 16 21 @Override 17 22 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;23 if (ReverterPlugin.reverterUsed) { 24 for (Command cmd : UndoRedoHandler.getInstance().commands) { 25 if (isReverterCmd(cmd)) { 26 MainApplication.getLayerManager().getEditDataSet().addChangeSetTag("created_by", pluginString); 27 break; 28 } 24 29 } 25 30 } 31 return true; 32 } 26 33 27 if (hasRevertions) { 28 MainApplication.getLayerManager().getEditDataSet().addChangeSetTag("created_by", "reverter"); 34 private static boolean isReverterCmd(Command cmd) { 35 if (cmd instanceof RevertChangesetCommand) 36 return true; 37 if (cmd instanceof SequenceCommand) { 38 return ((SequenceCommand) cmd).getLastCommand() instanceof RevertChangesetCommand; 29 39 } 30 return true;40 return false; 31 41 } 32 33 42 }