Changeset 17684 in josm
- Timestamp:
- 2021-03-28T20:43:23+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/history
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java
r15145 r17684 7 7 import java.awt.GridBagLayout; 8 8 import java.awt.Insets; 9 import java.awt.event.ActionEvent; 9 10 import java.awt.event.MouseAdapter; 10 11 import java.awt.event.MouseEvent; 11 12 13 import javax.swing.AbstractAction; 12 14 import javax.swing.BorderFactory; 13 15 import javax.swing.JLabel; 14 16 import javax.swing.JPanel; 17 import javax.swing.JPopupMenu; 15 18 import javax.swing.UIManager; 16 19 import javax.swing.event.ChangeEvent; … … 19 22 import org.openstreetmap.gui.jmapviewer.JMapViewer; 20 23 import org.openstreetmap.gui.jmapviewer.MapMarkerDot; 24 import org.openstreetmap.josm.command.MoveCommand; 25 import org.openstreetmap.josm.data.UndoRedoHandler; 21 26 import org.openstreetmap.josm.data.coor.LatLon; 22 27 import org.openstreetmap.josm.data.coor.conversion.DecimalDegreesCoordinateFormat; 28 import org.openstreetmap.josm.data.osm.Node; 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 30 import org.openstreetmap.josm.data.osm.history.HistoryNode; 24 31 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; … … 30 37 import org.openstreetmap.josm.tools.CheckParameterUtil; 31 38 import org.openstreetmap.josm.tools.Destroyable; 39 import org.openstreetmap.josm.tools.ImageProvider; 32 40 import org.openstreetmap.josm.tools.Pair; 33 41 … … 114 122 add(mapViewer, gc); 115 123 mapViewer.setZoomControlsVisible(false); 124 125 JPopupMenu popupMenu = new JPopupMenu(); 126 popupMenu.add(new RestoreCoordinateAction()); 127 setComponentPopupMenu(popupMenu); 128 mapViewer.setComponentPopupMenu(popupMenu); 116 129 } 117 130 … … 424 437 } 425 438 } 439 440 private class RestoreCoordinateAction extends AbstractAction { 441 442 RestoreCoordinateAction() { 443 super(tr("Restore")); 444 new ImageProvider("undo").getResource().attachImageIcon(this, true); 445 } 446 447 @Override 448 public void actionPerformed(ActionEvent e) { 449 OsmPrimitive primitive = getPrimitiveFromDataSet(PointInTimeType.REFERENCE_POINT_IN_TIME); 450 if (!(primitive instanceof Node)) { 451 return; 452 } 453 HistoryOsmPrimitive historyPrimitive = model.getPointInTime(PointInTimeType.REFERENCE_POINT_IN_TIME); 454 if (!(historyPrimitive instanceof HistoryNode) || ((HistoryNode) historyPrimitive).getCoords() == null) { 455 return; 456 } 457 MoveCommand command = new MoveCommand(((Node) primitive), ((HistoryNode) historyPrimitive).getCoords()); 458 UndoRedoHandler.getInstance().add(command); 459 } 460 } 426 461 } -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserPanel.java
r14463 r17684 10 10 11 11 import org.openstreetmap.josm.actions.JosmAction; 12 import org.openstreetmap.josm.data.osm.DataSet; 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 import org.openstreetmap.josm.data.osm.PrimitiveId; 15 import org.openstreetmap.josm.gui.MainApplication; 12 16 import org.openstreetmap.josm.tools.Destroyable; 13 17 … … 64 68 } 65 69 70 protected OsmPrimitive getPrimitiveFromDataSet(PointInTimeType pointInTime) { 71 DataSet dataSet = MainApplication.getLayerManager().getEditDataSet(); 72 PrimitiveId primitiveId = model.getPointInTime(pointInTime); 73 if (dataSet == null || primitiveId == null) { 74 return null; 75 } 76 return dataSet.getPrimitiveById(primitiveId.getUniqueId(), primitiveId.getType()); 77 } 78 66 79 protected final <T extends AbstractAction> T trackJosmAction(T action) { 67 80 if (action instanceof JosmAction) { -
trunk/src/org/openstreetmap/josm/gui/history/TagInfoViewer.java
r16960 r17684 15 15 16 16 import org.openstreetmap.josm.actions.RestorePropertyAction; 17 import org.openstreetmap.josm.data.osm.DataSet;18 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 import org.openstreetmap.josm.data.osm.PrimitiveId;20 18 import org.openstreetmap.josm.data.osm.Tagged; 21 import org.openstreetmap.josm.gui.MainApplication;22 19 import org.openstreetmap.josm.gui.dialogs.properties.CopyAllKeyValueAction; 23 20 import org.openstreetmap.josm.gui.dialogs.properties.CopyKeyValueAction; … … 83 80 }; 84 81 Supplier<Collection<? extends Tagged>> objectSp = () -> Collections.singletonList(model.getPointInTime(pointInTime)); 85 Supplier<OsmPrimitive> primitiveSupplier = () -> { 86 DataSet dataSet = MainApplication.getLayerManager().getEditDataSet(); 87 PrimitiveId primitiveId = model.getPointInTime(pointInTime); 88 if (dataSet == null || primitiveId == null) { 89 return null; 90 } 91 return dataSet.getPrimitiveById(primitiveId.getUniqueId(), primitiveId.getType()); 92 }; 82 Supplier<OsmPrimitive> primitiveSupplier = () -> getPrimitiveFromDataSet(pointInTime); 93 83 94 84 tagMenu.add(trackJosmAction(new CopyValueAction(table, tagKeyFn, objectSp)));
Note:
See TracChangeset
for help on using the changeset viewer.