Changeset 29296 in osm for applications/editors/josm/plugins/reverter/src
- Timestamp:
- 2013-03-01T20:09:10+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/reverter/src/reverter
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/reverter/src/reverter/ChangesetIdQuery.java
r23192 r29296 9 9 10 10 import javax.swing.ButtonGroup; 11 import javax.swing.JCheckBox; 11 12 import javax.swing.JFormattedTextField; 12 13 import javax.swing.JLabel; … … 21 22 @SuppressWarnings("serial") 22 23 public class ChangesetIdQuery extends ExtendedDialog { 23 private JFormattedTextField tcid = new JFormattedTextField(NumberFormat.getInstance());24 private ButtonGroup bgRevertType = new ButtonGroup();25 private JRadioButton rbFull = new JRadioButton(tr("Revert changeset fully"));26 private JRadioButton rbSelection = new JRadioButton(tr("Revert selection only"));27 private JRadioButton rbSelectionUndelete =28 new JRadioButton(tr("Revert selection and restore deleted objects"));24 private final JFormattedTextField tcid = new JFormattedTextField(NumberFormat.getInstance()); 25 private final ButtonGroup bgRevertType = new ButtonGroup(); 26 private final JRadioButton rbFull = new JRadioButton(tr("Revert changeset fully")); 27 private final JRadioButton rbSelection = new JRadioButton(tr("Revert selection only")); 28 private final JRadioButton rbSelectionUndelete = new JRadioButton(tr("Revert selection and restore deleted objects")); 29 private final JCheckBox cbNewLayer = new JCheckBox(tr("Download as new layer")); 29 30 30 31 public int getChangesetId() { 31 32 try { 32 return NumberFormat.getInstance().parse(tcid.getText()).intValue();33 return NumberFormat.getInstance().parse(tcid.getText()).intValue(); 33 34 } catch (ParseException e) { 34 return 0;35 return 0; 35 36 } 37 } 38 39 /** 40 * Replies true if the user requires to download into a new layer 41 * 42 * @return true if the user requires to download into a new layer 43 */ 44 public boolean isNewLayerRequired() { 45 return cbNewLayer.isSelected(); 36 46 } 37 47 … … 60 70 panel.add(rbSelectionUndelete, GBC.eol().fill(GBC.HORIZONTAL)); 61 71 72 cbNewLayer.setToolTipText(tr("<html>Select to download data into a new data layer.<br>" 73 +"Unselect to download into the currently active data layer.</html>")); 74 panel.add(cbNewLayer, GBC.eol().fill(GBC.HORIZONTAL)); 75 62 76 setContent(panel); 63 77 setupDialog(); -
applications/editors/josm/plugins/reverter/src/reverter/ChangesetReverter.java
r28535 r29296 119 119 * @throws OsmTransferException 120 120 */ 121 public ChangesetReverter(int changesetId, RevertType revertType, ProgressMonitor monitor)121 public ChangesetReverter(int changesetId, RevertType revertType, boolean newLayer, ProgressMonitor monitor) 122 122 throws OsmTransferException { 123 123 this.changesetId = changesetId; 124 this.layer = Main.main.getEditLayer(); 125 this.ds = layer.data; 124 if (newLayer) { 125 this.ds = new DataSet(); 126 this.layer = new OsmDataLayer(this.ds, tr("Reverted changeset") + tr(" [id: {0}]", changesetId), null); 127 } else { 128 this.layer = Main.main.getEditLayer(); 129 this.ds = layer.data; 130 } 126 131 this.revertType = revertType; 127 132 … … 133 138 } finally { 134 139 monitor.finishTask(); 140 if (newLayer) { 141 Main.main.addLayer(layer); 142 } 135 143 } 136 144 … … 186 194 switch (p.getType()) { 187 195 case NODE: ds.addPrimitive(new Node(p.getUniqueId())); break; 196 case CLOSEDWAY: 188 197 case WAY: ds.addPrimitive(new Way(p.getUniqueId())); break; 198 case MULTIPOLYGON: 189 199 case RELATION: ds.addPrimitive(new Relation(p.getUniqueId())); break; 200 default: throw new AssertionError(); 190 201 } 191 202 } … … 205 216 rdr.append(new Node(id.getUniqueId())); 206 217 break; 218 case CLOSEDWAY: 207 219 case WAY: 208 220 rdr.append(new Way(id.getUniqueId())); 209 221 break; 222 case MULTIPOLYGON: 210 223 case RELATION: 211 224 rdr.append(new Relation(id.getUniqueId())); … … 229 242 case NODE: 230 243 return new Conflict<Node>((Node)p,new Node((Node)p), isMyDeleted); 244 case CLOSEDWAY: 231 245 case WAY: 232 246 return new Conflict<Way>((Way)p,new Way((Way)p), isMyDeleted); 247 case MULTIPOLYGON: 233 248 case RELATION: 234 249 return new Conflict<Relation>((Relation)p,new Relation((Relation)p), isMyDeleted); … … 244 259 LatLon historyCoor = ((HistoryNode)history).getCoords(); 245 260 return currentCoor == historyCoor || (currentCoor != null && historyCoor != null && currentCoor.equals(historyCoor)); 261 case CLOSEDWAY: 246 262 case WAY: 247 263 List<Node> currentNodes = ((Way)current).getNodes(); … … 252 268 } 253 269 return true; 270 case MULTIPOLYGON: 254 271 case RELATION: 255 272 List<org.openstreetmap.josm.data.osm.RelationMember> currentMembers = … … 367 384 return cmds; 368 385 } 386 369 387 public boolean hasMissingObjects() { 370 388 return !missing.isEmpty(); -
applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetAction.java
r27852 r29296 39 39 if (revertType == null) return; 40 40 41 Main.worker.submit(new RevertChangesetTask(changesetId, revertType)); 41 boolean newLayer = dlg.isNewLayerRequired(); 42 Main.worker.submit(new RevertChangesetTask(changesetId, revertType, newLayer, newLayer)); 42 43 } 43 44 } -
applications/editors/josm/plugins/reverter/src/reverter/RevertChangesetTask.java
r27245 r29296 19 19 private final int changesetId; 20 20 private final RevertType revertType; 21 private final boolean newLayer; 21 22 22 23 private ChangesetReverter rev; 23 private boolean downloadConfirmed = false;24 private boolean downloadConfirmed; 24 25 25 public RevertChangesetTask(int changesetId, RevertType revertType) 26 { 26 public RevertChangesetTask(int changesetId, RevertType revertType) { 27 this(changesetId, revertType, false); 28 } 29 30 public RevertChangesetTask(int changesetId, RevertType revertType, boolean autoConfirmDownload) { 31 this(changesetId, revertType, autoConfirmDownload, false); 32 } 33 34 public RevertChangesetTask(int changesetId, RevertType revertType, boolean autoConfirmDownload, boolean newLayer) { 27 35 super(tr("Reverting...")); 28 36 this.changesetId = changesetId; 29 37 this.revertType = revertType; 30 } 31 public RevertChangesetTask(int changesetId, RevertType revertType, boolean autoConfirmDownload) 32 { 33 this(changesetId, revertType); 34 downloadConfirmed = autoConfirmDownload; 38 this.downloadConfirmed = autoConfirmDownload; 39 this.newLayer = newLayer; 35 40 } 36 41 … … 57 62 protected void realRun() throws OsmTransferException { 58 63 progressMonitor.indeterminateSubTask(tr("Downloading changeset")); 59 rev = new ChangesetReverter(changesetId, revertType, 64 rev = new ChangesetReverter(changesetId, revertType, newLayer, 60 65 progressMonitor.createSubTaskMonitor(0, true)); 61 66 if (progressMonitor.isCanceled()) return;
Note:
See TracChangeset
for help on using the changeset viewer.