Changeset 34917 in osm for applications/editors/josm/plugins
- Timestamp:
- 2019-03-11T16:00:20+01:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/reverter/src/reverter
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java
r33865 r34917 24 24 import org.openstreetmap.josm.data.osm.PrimitiveId; 25 25 import org.openstreetmap.josm.data.osm.Relation; 26 import org.openstreetmap.josm.data.osm.RelationMember; 26 27 import org.openstreetmap.josm.data.osm.RelationMemberData; 27 28 import org.openstreetmap.josm.data.osm.SimplePrimitiveId; … … 39 40 import org.openstreetmap.josm.io.OsmTransferException; 40 41 import org.openstreetmap.josm.tools.Logging; 42 import org.openstreetmap.josm.tools.Utils; 41 43 42 44 import reverter.corehacks.ChangesetDataSet; … … 110 112 111 113 /** 112 * Checks if {@ seeChangesetDataSetEntry} conforms to current RevertType114 * Checks if {@link ChangesetDataSetEntry} conforms to current RevertType 113 115 * @param entry entry to be checked 114 * @return <code>true</code> if {@ seeChangesetDataSetEntry} conforms to current RevertType116 * @return <code>true</code> if {@link ChangesetDataSetEntry} conforms to current RevertType 115 117 */ 116 118 private boolean checkOsmChangeEntry(ChangesetDataSetEntry entry) { … … 128 130 * creates a reverter for specific changeset and fetches initial data 129 131 * @param changesetId changeset id 132 * @param revertType type of revert 133 * @param newLayer set to true if a new layer should be created 130 134 * @param monitor progress monitor 131 135 * @throws OsmTransferException if data transfer errors occur … … 185 189 } 186 190 187 private void readObjectVersion(OsmServerMultiObjectReader rdr, PrimitiveId id, int version, ProgressMonitor progressMonitor)191 private static void readObjectVersion(OsmServerMultiObjectReader rdr, PrimitiveId id, int version, ProgressMonitor progressMonitor) 188 192 throws OsmTransferException { 189 193 boolean readOK = false; … … 214 218 * @throws OsmTransferException if data transfer errors occur 215 219 */ 216 @SuppressWarnings("unchecked")217 220 public void downloadObjectsHistory(ProgressMonitor progressMonitor) throws OsmTransferException { 218 221 final OsmServerMultiObjectReader rdr = new OsmServerMultiObjectReader(); … … 220 223 progressMonitor.beginTask(tr("Downloading objects history"), updated.size()+deleted.size()+1); 221 224 try { 222 for (HashSet<HistoryOsmPrimitive> collection : Arrays.asList( new HashSet[]{updated, deleted})) {225 for (HashSet<HistoryOsmPrimitive> collection : Arrays.asList(updated, deleted)) { 223 226 for (HistoryOsmPrimitive entry : collection) { 224 227 PrimitiveId id = entry.getPrimitiveId(); … … 279 282 } 280 283 281 private static Conflict<? extends OsmPrimitive> CreateConflict(OsmPrimitive p, boolean isMyDeleted) {284 private static Conflict<? extends OsmPrimitive> createConflict(OsmPrimitive p, boolean isMyDeleted) { 282 285 switch (p.getType()) { 283 286 case NODE: … … 337 340 /** 338 341 * Builds a list of commands that will revert the changeset 342 * @return list of commands 339 343 * 340 344 */ … … 390 394 /* Don't create conflict if the object has to be deleted but has already been deleted */ 391 395 && !(toDelete.contains(dp) && dp.isDeleted())) { 392 cmds.add(new ConflictAddCommand(layer.data, CreateConflict(dp,396 cmds.add(new ConflictAddCommand(layer.data, createConflict(dp, 393 397 entry.getModificationType() == ChangesetModificationType.CREATED))); 394 398 conflicted.add(dp); … … 412 416 */ 413 417 if (!conflicted.contains(p)) { 414 cmds.add(new ConflictAddCommand(layer.data, CreateConflict(p, true)));418 cmds.add(new ConflictAddCommand(layer.data, createConflict(p, true))); 415 419 conflicted.add(p); 416 420 } … … 421 425 422 426 // Create a Command to delete all marked objects 423 List<? extends OsmPrimitive> list;424 list = OsmPrimitive.getFilteredList(toDelete, Relation.class);425 if (! list.isEmpty()) cmds.add(new DeleteCommand(list));426 list = OsmPrimitive.getFilteredList(toDelete, Way.class);427 if (! list.isEmpty()) cmds.add(new DeleteCommand(list));428 list = OsmPrimitive.getFilteredList(toDelete, Node.class);429 if (! list.isEmpty()) cmds.add(new DeleteCommand(list));427 Collection<? extends OsmPrimitive> collection; 428 collection = Utils.filteredCollection(toDelete, Relation.class); 429 if (!collection.isEmpty()) cmds.add(new DeleteCommand(collection)); 430 collection = Utils.filteredCollection(toDelete, Way.class); 431 if (!collection.isEmpty()) cmds.add(new DeleteCommand(collection)); 432 collection = Utils.filteredCollection(toDelete, Node.class); 433 if (!collection.isEmpty()) cmds.add(new DeleteCommand(collection)); 430 434 return cmds; 431 435 } -
applications/editors/josm/plugins/reverter/src/reverter/DataSetCommandMerger.java
r33572 r34917 23 23 24 24 /** 25 * Modified {@ seeorg.openstreetmap.josm.data.osm.DataSetMerger} that25 * Modified {@link org.openstreetmap.josm.data.osm.DataSetMerger} that 26 26 * produces list of commands instead of directly merging layers. 27 27 * … … 40 40 /** 41 41 * constructor 42 * @param sourceDataSet the source Dataset for the merge 43 * @param targetDataSet the target Dataset for the merge 42 44 */ 43 45 DataSetCommandMerger(DataSet sourceDataSet, DataSet targetDataSet) { … … 65 67 } 66 68 67 private void mergePrimitive(OsmPrimitive source, OsmPrimitive target, OsmPrimitive newTarget) {69 private static void mergePrimitive(OsmPrimitive source, OsmPrimitive target, OsmPrimitive newTarget) { 68 70 newTarget.mergeFrom(source); 69 71 newTarget.setOsmId(target.getId(), target.getVersion()); -
applications/editors/josm/plugins/reverter/src/reverter/MultiOsmReader.java
r32905 r34917 14 14 15 15 /** 16 * Subclass of {@ seeorg.openstreetmap.josm.io.OsmReader} that can handle multiple XML streams.16 * Subclass of {@link org.openstreetmap.josm.io.OsmReader} that can handle multiple XML streams. 17 17 * 18 18 */ -
applications/editors/josm/plugins/reverter/src/reverter/OsmServerMultiObjectReader.java
r32905 r34917 14 14 import org.openstreetmap.josm.io.OsmServerReader; 15 15 import org.openstreetmap.josm.io.OsmTransferException; 16 import org.xml.sax.SAXException;17 16 18 17 public class OsmServerMultiObjectReader extends OsmServerReader { … … 24 23 25 24 public void readObject(long id, int version, OsmPrimitiveType type, ProgressMonitor progressMonitor) throws OsmTransferException { 26 StringBu ffer sb = new StringBuffer();25 StringBuilder sb = new StringBuilder(); 27 26 sb.append(type.getAPIName()); 28 27 sb.append("/"); … … 43 42 * Method to parse downloaded objects 44 43 * @return the data requested 45 * @throws SAXException in case of SAX error 46 * @throws IOException in case of I/O error 44 * @throws OsmTransferException in case of error 47 45 */ 48 46 @Override -
applications/editors/josm/plugins/reverter/src/reverter/ReverterPlugin.java
r33572 r34917 11 11 import org.openstreetmap.josm.plugins.PluginInformation; 12 12 13 /** 14 * The reverter plugin 15 */ 13 16 public class ReverterPlugin extends Plugin { 14 static boolean reverterUsed = false; 17 static boolean reverterUsed; 18 19 /** 20 * Constructs a new {@code ReverterPlugin}. 21 * @param info plugin information 22 */ 15 23 public ReverterPlugin(PluginInformation info) { 16 24 super(info); 17 25 JMenu historyMenu = MainApplication.getMenu().dataMenu; 18 //MainMenu.add(historyMenu, new ObjectsHistoryAction());19 26 MainMenu.add(historyMenu, new RevertChangesetAction()); 20 27 UploadAction.registerUploadHook(new ReverterUploadHook(this)); -
applications/editors/josm/plugins/reverter/src/reverter/corehacks/ChangesetDataSet.java
r32905 r34917 166 166 167 167 /** 168 * Replies the {@ seeHistoryOsmPrimitive} with id <code>id</code> from this168 * Replies the {@link HistoryOsmPrimitive} with id <code>id</code> from this 169 169 * dataset. null, if there is no such primitive in the data set. 170 170 * 171 171 * @param id the id 172 * @return the {@ seeHistoryOsmPrimitive} with id <code>id</code> from this172 * @return the {@link HistoryOsmPrimitive} with id <code>id</code> from this 173 173 * dataset 174 174 */ -
applications/editors/josm/plugins/reverter/src/reverter/corehacks/OsmServerChangesetReader.java
r34271 r34917 54 54 * @param query the query specification. Must not be null. 55 55 * @param monitor a progress monitor. Set to {@link NullProgressMonitor#INSTANCE} if null 56 * @return the list of changesets read from the server 56 * @return the list of changesets read from the server or {@code null} 57 57 * @throws IllegalArgumentException thrown if query is null 58 58 * @throws OsmTransferException thrown if something goes wrong w … … 65 65 try { 66 66 monitor.beginTask(tr("Reading changesets...")); 67 StringBu ffer sb = new StringBuffer();67 StringBuilder sb = new StringBuilder(); 68 68 sb.append("changesets?").append(query.getQueryString()); 69 69 InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true)); … … 98 98 try { 99 99 monitor.beginTask(tr("Reading changeset {0} ...", id)); 100 StringBu ffer sb = new StringBuffer();100 StringBuilder sb = new StringBuilder(); 101 101 sb.append("changeset/").append(id); 102 102 InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true)); … … 120 120 * Reads the changeset with id <code>id</code> from the server 121 121 * 122 * @param ids the listof ids. Ignored if null. Only load changesets for ids > 0.122 * @param ids the collection of ids. Ignored if null. Only load changesets for ids > 0. 123 123 * @param monitor the progress monitor. Set to {@link NullProgressMonitor#INSTANCE} if null 124 * @return the changeset read124 * @return the list of changesets read or an empty list or null in case of errors 125 125 * @throws OsmTransferException thrown if something goes wrong 126 126 * @throws IllegalArgumentException if id <= 0 … … 143 143 } 144 144 i++; 145 StringBu ffer sb = new StringBuffer();145 StringBuilder sb = new StringBuilder(); 146 146 sb.append("changeset/").append(id); 147 147 InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true)); … … 175 175 * @throws OsmTransferException thrown if something went wrong 176 176 */ 177 public ChangesetDataSet downloadChangeset(int id, ProgressMonitor monitor) throws IllegalArgumentException,OsmTransferException {177 public ChangesetDataSet downloadChangeset(int id, ProgressMonitor monitor) throws OsmTransferException { 178 178 if (id <= 0) 179 179 throw new IllegalArgumentException( … … 184 184 try { 185 185 monitor.beginTask(tr("Downloading changeset content")); 186 StringBu ffer sb = new StringBuffer();186 StringBuilder sb = new StringBuilder(); 187 187 sb.append("changeset/").append(id).append("/download"); 188 188 InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true)); … … 191 191 monitor.setCustomText(tr("Downloading content for changeset {0} ...", id)); 192 192 OsmChangesetContentParser parser = new OsmChangesetContentParser(in); 193 ChangesetDataSet ds = parser.parse(monitor.createSubTaskMonitor(1, true)); 194 return ds; 195 } catch (UnsupportedEncodingException e) { 196 throw new OsmTransferException(e); 197 } catch (XmlParsingException e) { 193 return parser.parse(monitor.createSubTaskMonitor(1, true)); 194 } catch (UnsupportedEncodingException | XmlParsingException e) { 198 195 throw new OsmTransferException(e); 199 196 } finally {
Note:
See TracChangeset
for help on using the changeset viewer.