Changeset 35310 in osm for applications/editors/josm
- Timestamp:
- 2020-01-27T08:05:05+01:00 (5 years ago)
- Location:
- applications/editors/josm/plugins/reverter/src/reverter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java
r35226 r35310 74 74 private final DataSet ds; // DataSet associated with reverter 75 75 private final ChangesetDataSet cds; // Current changeset data 76 /** original DataSet, used if a new layer is requested */ 77 private final DataSet ods; 76 78 private DataSet nds; // Dataset that contains new objects downloaded by reverter 77 79 … … 118 120 return true; 119 121 } 120 OsmPrimitive p = ds.getPrimitiveById(entry.getPrimitive().getPrimitiveId()); 122 if (ods == null) 123 return false; // should not happen 124 OsmPrimitive p = ods.getPrimitiveById(entry.getPrimitive().getPrimitiveId()); 121 125 if (p == null) return false; 122 126 return p.isSelected(); … … 128 132 * @param revertType type of revert 129 133 * @param newLayer set to true if a new layer should be created 134 * @param ods original dataset to search for selected primitives, can be null 130 135 * @param monitor progress monitor 131 136 * @throws OsmTransferException if data transfer errors occur 132 137 * @throws RevertRedactedChangesetException if a redacted changeset is requested 133 138 */ 134 public ChangesetReverter(int changesetId, RevertType revertType, boolean newLayer, ProgressMonitor monitor)139 public ChangesetReverter(int changesetId, RevertType revertType, boolean newLayer, DataSet ods, ProgressMonitor monitor) 135 140 throws OsmTransferException, RevertRedactedChangesetException { 136 141 this.changesetId = changesetId; 142 OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 137 143 if (newLayer) { 138 144 this.ds = new DataSet(); 139 145 this.layer = new OsmDataLayer(this.ds, tr("Reverted changeset") + tr(" [id: {0}]", String.valueOf(changesetId)), null); 146 this.ods = ods; 140 147 } else { 141 this.layer = MainApplication.getLayerManager().getEditLayer(); 142 this.ds = layer.data; 148 this.layer = editLayer; 149 this.ds = editLayer.data; 150 this.ods = ods; 143 151 } 144 152 this.revertType = revertType; 153 if ((revertType == RevertType.SELECTION || revertType == RevertType.SELECTION_WITH_UNDELETE) 154 && (ods == null || ods.getAllSelected().isEmpty())) { 155 throw new IllegalArgumentException("No selected elements with revert type " + revertType); 156 } 145 157 146 158 OsmServerChangesetReader csr = new OsmServerChangesetReader(true); -
applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetTask.java
r34953 r35310 18 18 import org.openstreetmap.josm.command.conflict.ConflictAddCommand; 19 19 import org.openstreetmap.josm.data.UndoRedoHandler; 20 import org.openstreetmap.josm.data.osm.DataSet; 20 21 import org.openstreetmap.josm.gui.MainApplication; 21 22 import org.openstreetmap.josm.gui.Notification; 22 23 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 24 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 23 25 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 24 26 import org.openstreetmap.josm.gui.util.GuiHelper; … … 33 35 private final RevertType revertType; 34 36 private boolean newLayer; 37 private final DataSet oldDataSet; 35 38 36 39 private ChangesetReverter rev; … … 56 59 this.downloadConfirmed = autoConfirmDownload; 57 60 this.newLayer = newLayer; 61 OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer(); 62 this.oldDataSet = editLayer == null ? null : editLayer.data; 58 63 } 59 64 … … 116 121 progressMonitor.indeterminateSubTask(tr("Reverting changeset {0}", Long.toString(changesetId))); 117 122 try { 118 rev = new ChangesetReverter(changesetId, revertType, newLayer, progressMonitor.createSubTaskMonitor(0, true));123 rev = new ChangesetReverter(changesetId, revertType, newLayer, oldDataSet, progressMonitor.createSubTaskMonitor(0, true)); 119 124 } catch (final RevertRedactedChangesetException e) { 120 125 GuiHelper.runInEDT(() -> new Notification(
Note:
See TracChangeset
for help on using the changeset viewer.