Changeset 14134 in josm
- Timestamp:
- 2018-08-11T23:33:58+02:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 61 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/I18nSimilarStrings.java
r14119 r14134 5 5 import org.openstreetmap.josm.Main; 6 6 import org.openstreetmap.josm.data.Preferences; 7 import org.openstreetmap.josm.data.UndoRedoHandler;8 7 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 9 8 import org.openstreetmap.josm.data.preferences.JosmUrls; 10 9 import org.openstreetmap.josm.data.validation.tests.SimilarNamedWays; 11 import org.openstreetmap.josm.gui.MainApplication;12 10 import org.openstreetmap.josm.gui.MainApplicationTest; 13 11 import org.openstreetmap.josm.plugins.PluginHandlerTestIT; … … 34 32 Config.setPreferencesInstance(pref); 35 33 pref.init(false); 36 MainApplication.undoRedo = new UndoRedoHandler();37 34 MainApplicationTest.initContentPane(); 38 35 MainApplicationTest.initToolbar(); -
trunk/src/org/openstreetmap/josm/Main.java
r14133 r14134 71 71 /** 72 72 * The commands undo/redo handler. 73 */ 74 public final UndoRedoHandler undoRedo = new UndoRedoHandler(); 73 * @deprecated Use {@link UndoRedoHandler#getInstance} 74 */ 75 @Deprecated 76 public final UndoRedoHandler undoRedo = UndoRedoHandler.getInstance(); 75 77 76 78 /** -
trunk/src/org/openstreetmap/josm/actions/AddNodeAction.java
r12726 r14134 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.command.AddCommand; 13 import org.openstreetmap.josm.data.UndoRedoHandler; 13 14 import org.openstreetmap.josm.data.coor.LatLon; 14 15 import org.openstreetmap.josm.data.osm.DataSet; … … 68 69 // add the node 69 70 DataSet ds = getLayerManager().getEditDataSet(); 70 MainApplication.undoRedo.add(new AddCommand(ds, nnew));71 UndoRedoHandler.getInstance().add(new AddCommand(ds, nnew)); 71 72 ds.setSelected(nnew); 72 73 MapView mapView = MainApplication.getMap().mapView; -
trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r13434 r14134 20 20 import org.openstreetmap.josm.command.MoveCommand; 21 21 import org.openstreetmap.josm.command.SequenceCommand; 22 import org.openstreetmap.josm.data.UndoRedoHandler; 22 23 import org.openstreetmap.josm.data.coor.EastNorth; 23 24 import org.openstreetmap.josm.data.coor.PolarCoor; … … 26 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 28 import org.openstreetmap.josm.data.osm.Way; 28 import org.openstreetmap.josm.gui.MainApplication;29 29 import org.openstreetmap.josm.gui.Notification; 30 30 import org.openstreetmap.josm.tools.Geometry; … … 243 243 } 244 244 245 MainApplication.undoRedo.add(new SequenceCommand(tr("Align Nodes in Circle"), cmds));245 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Align Nodes in Circle"), cmds)); 246 246 } 247 247 -
trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java
r13434 r14134 20 20 import org.openstreetmap.josm.command.MoveCommand; 21 21 import org.openstreetmap.josm.command.SequenceCommand; 22 import org.openstreetmap.josm.data.UndoRedoHandler; 22 23 import org.openstreetmap.josm.data.coor.EastNorth; 23 24 import org.openstreetmap.josm.data.coor.PolarCoor; … … 26 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 27 28 import org.openstreetmap.josm.data.osm.Way; 28 import org.openstreetmap.josm.gui.MainApplication;29 29 import org.openstreetmap.josm.gui.Notification; 30 30 import org.openstreetmap.josm.tools.Logging; … … 175 175 Command cmd = buildCommand(getLayerManager().getEditDataSet()); 176 176 if (cmd != null) { 177 MainApplication.undoRedo.add(cmd);177 UndoRedoHandler.getInstance().add(cmd); 178 178 } 179 179 } catch (InvalidSelection except) { -
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r13611 r14134 25 25 import org.openstreetmap.josm.command.SequenceCommand; 26 26 import org.openstreetmap.josm.corrector.ReverseWayTagCorrector; 27 import org.openstreetmap.josm.data.UndoRedoHandler; 27 28 import org.openstreetmap.josm.data.osm.DataSet; 28 29 import org.openstreetmap.josm.data.osm.Node; … … 34 35 import org.openstreetmap.josm.data.preferences.BooleanProperty; 35 36 import org.openstreetmap.josm.gui.ExtendedDialog; 36 import org.openstreetmap.josm.gui.MainApplication;37 37 import org.openstreetmap.josm.gui.Notification; 38 38 import org.openstreetmap.josm.gui.conflict.tags.CombinePrimitiveResolverDialog; … … 176 176 if (!reverseWayTagCommands.isEmpty()) { 177 177 // commands need to be executed for CombinePrimitiveResolverDialog 178 MainApplication.undoRedo.add(new SequenceCommand(tr("Reverse Ways"), reverseWayTagCommands));178 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Reverse Ways"), reverseWayTagCommands)); 179 179 } 180 180 wayTags = TagCollection.unionOfAllPrimitives(reversedTagWays); … … 195 195 if (!reverseWayTagCommands.isEmpty()) { 196 196 // undo reverseWayTagCorrector and merge into SequenceCommand below 197 MainApplication.undoRedo.undo();197 UndoRedoHandler.getInstance().undo(); 198 198 } 199 199 } … … 239 239 return; 240 240 final Way selectedWay = combineResult.a; 241 MainApplication.undoRedo.add(combineResult.b);241 UndoRedoHandler.getInstance().add(combineResult.b); 242 242 if (selectedWay != null) { 243 243 GuiHelper.runInEDT(() -> ds.setSelected(selectedWay)); -
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r14120 r14134 22 22 import org.openstreetmap.josm.command.Command; 23 23 import org.openstreetmap.josm.command.SequenceCommand; 24 import org.openstreetmap.josm.data.UndoRedoHandler; 24 25 import org.openstreetmap.josm.data.coor.EastNorth; 25 26 import org.openstreetmap.josm.data.coor.LatLon; … … 30 31 import org.openstreetmap.josm.data.osm.Way; 31 32 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 32 import org.openstreetmap.josm.gui.MainApplication;33 33 import org.openstreetmap.josm.gui.Notification; 34 34 import org.openstreetmap.josm.tools.Geometry; … … 244 244 } 245 245 246 MainApplication.undoRedo.add(new SequenceCommand(tr("Create Circle"), cmds));246 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Create Circle"), cmds)); 247 247 } 248 248 -
trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
r13957 r14134 27 27 import org.openstreetmap.josm.command.Command; 28 28 import org.openstreetmap.josm.command.SequenceCommand; 29 import org.openstreetmap.josm.data.UndoRedoHandler; 29 30 import org.openstreetmap.josm.data.osm.DataSet; 30 31 import org.openstreetmap.josm.data.osm.MultipolygonBuilder; … … 108 109 // to avoid EDT violations 109 110 SwingUtilities.invokeLater(() -> { 110 MainApplication.undoRedo.add(command);111 UndoRedoHandler.getInstance().add(command); 111 112 112 113 // Use 'SwingUtilities.invokeLater' to make sure the relationListDialog -
trunk/src/org/openstreetmap/josm/actions/DistributeAction.java
r13434 r14134 19 19 import org.openstreetmap.josm.command.MoveCommand; 20 20 import org.openstreetmap.josm.command.SequenceCommand; 21 import org.openstreetmap.josm.data.UndoRedoHandler; 21 22 import org.openstreetmap.josm.data.osm.Node; 22 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; 23 24 import org.openstreetmap.josm.data.osm.Way; 24 import org.openstreetmap.josm.gui.MainApplication;25 25 import org.openstreetmap.josm.gui.Notification; 26 26 import org.openstreetmap.josm.tools.Logging; … … 98 98 99 99 // Do it! 100 MainApplication.undoRedo.add(new SequenceCommand(tr("Distribute Nodes"), cmds));100 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Distribute Nodes"), cmds)); 101 101 } 102 102 -
trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java
r13434 r14134 15 15 import org.openstreetmap.josm.command.SelectCommand; 16 16 import org.openstreetmap.josm.command.SequenceCommand; 17 import org.openstreetmap.josm.data.UndoRedoHandler; 17 18 import org.openstreetmap.josm.data.osm.DataSet; 18 19 import org.openstreetmap.josm.data.osm.Node; … … 114 115 newFollower.addNode(newPoint); 115 116 } 116 MainApplication.undoRedo.add(new SequenceCommand(tr("Follow line"),117 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Follow line"), 117 118 new ChangeCommand(ds, follower, newFollower), 118 119 new SelectCommand(ds, newFollower.isClosed() // see #10028 - unselect last node when closing a way -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r13736 r14134 570 570 makeCommitsOneAction(tr("Reverting changes")); 571 571 if (addUndoRedo) { 572 MainApplication.undoRedo.undo();573 MainApplication.undoRedo.redoCommands.clear();572 UndoRedoHandler.getInstance().undo(); 573 UndoRedoHandler.getInstance().redoCommands.clear(); 574 574 } 575 575 } … … 835 835 private void commitCommand(Command c) { 836 836 if (Main.main != null && addUndoRedo) { 837 MainApplication.undoRedo.add(c);837 UndoRedoHandler.getInstance().add(c); 838 838 } else { 839 839 c.executeCommand(); -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r14120 r14134 23 23 import org.openstreetmap.josm.command.MoveCommand; 24 24 import org.openstreetmap.josm.command.SequenceCommand; 25 import org.openstreetmap.josm.data.UndoRedoHandler; 25 26 import org.openstreetmap.josm.data.coor.EastNorth; 26 27 import org.openstreetmap.josm.data.osm.DataSet; … … 162 163 163 164 if (cmds.isEmpty()) return; 164 MainApplication.undoRedo.add(new SequenceCommand(getValue(NAME).toString(), cmds));165 UndoRedoHandler.getInstance().add(new SequenceCommand(getValue(NAME).toString(), cmds)); 165 166 } 166 167 -
trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java
r13842 r14134 26 26 import org.openstreetmap.josm.command.DeleteCommand; 27 27 import org.openstreetmap.josm.command.SequenceCommand; 28 import org.openstreetmap.josm.data.UndoRedoHandler; 28 29 import org.openstreetmap.josm.data.coor.EastNorth; 29 30 import org.openstreetmap.josm.data.coor.LatLon; … … 98 99 Command cmd = mergeNodes(selectedNodes, targetNode, targetLocationNode); 99 100 if (cmd != null) { 100 MainApplication.undoRedo.add(cmd);101 UndoRedoHandler.getInstance().add(cmd); 101 102 getLayerManager().getEditLayer().data.setSelected(targetNode); 102 103 } … … 277 278 Command cmd = mergeNodes(nodes, target, targetLocationNode); 278 279 if (cmd != null) { 279 MainApplication.undoRedo.add(cmd);280 UndoRedoHandler.getInstance().add(cmd); 280 281 layer.data.setSelected(target); 281 282 } -
trunk/src/org/openstreetmap/josm/actions/MirrorAction.java
r13434 r14134 17 17 import org.openstreetmap.josm.command.MoveCommand; 18 18 import org.openstreetmap.josm.command.SequenceCommand; 19 import org.openstreetmap.josm.data.UndoRedoHandler; 19 20 import org.openstreetmap.josm.data.osm.Node; 20 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; 21 22 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.gui.MainApplication;23 23 import org.openstreetmap.josm.gui.Notification; 24 24 import org.openstreetmap.josm.tools.Shortcut; … … 80 80 } 81 81 82 MainApplication.undoRedo.add(new SequenceCommand(tr("Mirror"), cmds));82 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Mirror"), cmds)); 83 83 } 84 84 -
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r13434 r14134 14 14 import org.openstreetmap.josm.command.Command; 15 15 import org.openstreetmap.josm.command.MoveCommand; 16 import org.openstreetmap.josm.data.UndoRedoHandler; 16 17 import org.openstreetmap.josm.data.coor.EastNorth; 17 18 import org.openstreetmap.josm.data.osm.DataSet; … … 136 137 Collection<Node> affectedNodes = AllNodesVisitor.getAllNodes(selection); 137 138 138 Command c = MainApplication.undoRedo.getLastCommand();139 Command c = UndoRedoHandler.getInstance().getLastCommand(); 139 140 140 141 ds.beginUpdate(); … … 145 146 } else { 146 147 c = new MoveCommand(ds, selection, distx, disty); 147 MainApplication.undoRedo.add(c);148 UndoRedoHandler.getInstance().add(c); 148 149 } 149 150 } finally { -
trunk/src/org/openstreetmap/josm/actions/MoveNodeAction.java
r13611 r14134 10 10 import org.openstreetmap.josm.Main; 11 11 import org.openstreetmap.josm.command.MoveCommand; 12 import org.openstreetmap.josm.data.UndoRedoHandler; 12 13 import org.openstreetmap.josm.data.coor.LatLon; 13 14 import org.openstreetmap.josm.data.osm.Node; … … 51 52 52 53 // move the node 53 MainApplication.undoRedo.add(new MoveCommand(n, coordinates));54 UndoRedoHandler.getInstance().add(new MoveCommand(n, coordinates)); 54 55 MainApplication.getMap().mapView.repaint(); 55 56 } -
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r13927 r14134 35 35 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 36 36 import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmUrlTask; 37 import org.openstreetmap.josm.actions.downloadtasks.DownloadParams; 37 38 import org.openstreetmap.josm.actions.downloadtasks.DownloadSessionTask; 38 import org.openstreetmap.josm.actions.downloadtasks.DownloadParams;39 39 import org.openstreetmap.josm.actions.downloadtasks.DownloadTask; 40 40 import org.openstreetmap.josm.actions.downloadtasks.PostDownloadHandler; -
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r14120 r14134 25 25 import org.openstreetmap.josm.command.MoveCommand; 26 26 import org.openstreetmap.josm.command.SequenceCommand; 27 import org.openstreetmap.josm.data.UndoRedoHandler; 27 28 import org.openstreetmap.josm.data.coor.EastNorth; 28 29 import org.openstreetmap.josm.data.coor.PolarCoor; … … 32 33 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 33 34 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 34 import org.openstreetmap.josm.gui.MainApplication;35 35 import org.openstreetmap.josm.gui.Notification; 36 36 import org.openstreetmap.josm.tools.Geometry; … … 120 120 } 121 121 if (!commands.isEmpty()) { 122 MainApplication.undoRedo.add(new SequenceCommand(tr("Orthogonalize / Undo"), commands));122 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Orthogonalize / Undo"), commands)); 123 123 } else { 124 124 throw new InvalidUserInputException("Commands are empty"); … … 168 168 169 169 try { 170 MainApplication.undoRedo.add(orthogonalize(sel));170 UndoRedoHandler.getInstance().add(orthogonalize(sel)); 171 171 } catch (InvalidUserInputException ex) { 172 172 Logging.debug(ex); -
trunk/src/org/openstreetmap/josm/actions/PreferenceToggleAction.java
r12885 r14134 7 7 8 8 import org.openstreetmap.josm.Main; 9 import org.openstreetmap.josm.data.preferences.BooleanProperty; 9 10 import org.openstreetmap.josm.spi.preferences.PreferenceChangeEvent; 10 11 import org.openstreetmap.josm.spi.preferences.PreferenceChangedListener; 11 import org.openstreetmap.josm.data.preferences.BooleanProperty;12 12 13 13 /** -
trunk/src/org/openstreetmap/josm/actions/PurgeAction.java
r13564 r14134 29 29 import org.openstreetmap.josm.Main; 30 30 import org.openstreetmap.josm.command.PurgeCommand; 31 import org.openstreetmap.josm.data.UndoRedoHandler; 31 32 import org.openstreetmap.josm.data.osm.DataSet; 32 33 import org.openstreetmap.josm.data.osm.IPrimitive; 33 34 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 35 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 35 import org.openstreetmap.josm.gui.MainApplication;36 36 import org.openstreetmap.josm.gui.PrimitiveRenderer; 37 37 import org.openstreetmap.josm.gui.help.HelpUtil; … … 104 104 } 105 105 106 MainApplication.undoRedo.add(cmd);106 UndoRedoHandler.getInstance().add(cmd); 107 107 if (clearUndoRedo) { 108 MainApplication.undoRedo.clean();108 UndoRedoHandler.getInstance().clean(); 109 109 getLayerManager().getEditDataSet().clearSelectionHistory(); 110 110 } -
trunk/src/org/openstreetmap/josm/actions/RedoAction.java
r12718 r14134 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.UndoRedoHandler; 11 12 import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener; 12 13 import org.openstreetmap.josm.gui.MainApplication; … … 37 38 return; 38 39 map.repaint(); 39 MainApplication.undoRedo.redo();40 UndoRedoHandler.getInstance().redo(); 40 41 } 41 42 42 43 @Override 43 44 protected void updateEnabledState() { 44 setEnabled(Main.main != null && ! MainApplication.undoRedo.redoCommands.isEmpty());45 setEnabled(Main.main != null && !UndoRedoHandler.getInstance().redoCommands.isEmpty()); 45 46 } 46 47 47 48 @Override 48 49 public void commandChanged(int queueSize, int redoSize) { 49 if ( MainApplication.undoRedo.redoCommands.isEmpty()) {50 if (UndoRedoHandler.getInstance().redoCommands.isEmpty()) { 50 51 putValue(NAME, tr("Redo")); 51 52 setTooltip(tr("Redo the last undone action.")); … … 53 54 putValue(NAME, tr("Redo ...")); 54 55 setTooltip(tr("Redo {0}", 55 MainApplication.undoRedo.redoCommands.getFirst().getDescriptionText()));56 UndoRedoHandler.getInstance().redoCommands.getFirst().getDescriptionText())); 56 57 } 57 58 } -
trunk/src/org/openstreetmap/josm/actions/ReverseWayAction.java
r13761 r14134 21 21 import org.openstreetmap.josm.corrector.ReverseWayNoTagCorrector; 22 22 import org.openstreetmap.josm.corrector.ReverseWayTagCorrector; 23 import org.openstreetmap.josm.data.UndoRedoHandler; 23 24 import org.openstreetmap.josm.data.osm.DataSet; 24 25 import org.openstreetmap.josm.data.osm.Node; 25 26 import org.openstreetmap.josm.data.osm.OsmPrimitive; 26 27 import org.openstreetmap.josm.data.osm.Way; 27 import org.openstreetmap.josm.gui.MainApplication;28 28 import org.openstreetmap.josm.gui.Notification; 29 29 import org.openstreetmap.josm.spi.preferences.Config; … … 138 138 c.addAll(revResult.getCommands()); 139 139 } 140 MainApplication.undoRedo.add(new SequenceCommand(tr("Reverse Ways"), c));140 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Reverse Ways"), c)); 141 141 } 142 142 -
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r13842 r14134 25 25 import org.openstreetmap.josm.command.DeleteCommand; 26 26 import org.openstreetmap.josm.command.SequenceCommand; 27 import org.openstreetmap.josm.data.UndoRedoHandler; 27 28 import org.openstreetmap.josm.data.osm.DataSet; 28 29 import org.openstreetmap.josm.data.osm.Node; … … 32 33 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 33 34 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 34 import org.openstreetmap.josm.gui.MainApplication;35 35 import org.openstreetmap.josm.gui.Notification; 36 36 import org.openstreetmap.josm.spi.preferences.Config; … … 120 120 allCommands 121 121 ); 122 MainApplication.undoRedo.add(rootCommand);122 UndoRedoHandler.getInstance().add(rootCommand); 123 123 } finally { 124 124 ds.endUpdate(); -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r13611 r14134 26 26 import org.openstreetmap.josm.Main; 27 27 import org.openstreetmap.josm.command.SplitWayCommand; 28 import org.openstreetmap.josm.data.UndoRedoHandler; 28 29 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 29 30 import org.openstreetmap.josm.data.osm.Node; … … 281 282 final boolean isMapModeDraw = map != null && map.mapMode == map.mapModeDraw; 282 283 final SplitWayCommand result = SplitWayCommand.doSplitWay(way, wayToKeep, newWays, !isMapModeDraw ? newSelection : null); 283 MainApplication.undoRedo.add(result);284 UndoRedoHandler.getInstance().add(result); 284 285 List<? extends PrimitiveId> newSel = result.getNewSelection(); 285 286 if (newSel != null && !newSel.isEmpty()) { -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r13761 r14134 32 32 import org.openstreetmap.josm.command.Command; 33 33 import org.openstreetmap.josm.command.SequenceCommand; 34 import org.openstreetmap.josm.data.UndoRedoHandler; 34 35 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 35 36 import org.openstreetmap.josm.data.osm.Node; … … 314 315 } 315 316 316 MainApplication.undoRedo.add(new SequenceCommand(tr("Unglued Node"), cmds));317 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Unglued Node"), cmds)); 317 318 getLayerManager().getEditDataSet().setSelected(n); 318 319 mv.repaint(); … … 553 554 */ 554 555 private void execCommands(List<Command> cmds, List<Node> newNodes) { 555 MainApplication.undoRedo.add(new SequenceCommand(/* for correct i18n of plural forms - see #9110 */556 UndoRedoHandler.getInstance().add(new SequenceCommand(/* for correct i18n of plural forms - see #9110 */ 556 557 trn("Dupe into {0} node", "Dupe into {0} nodes", newNodes.size() + 1L, newNodes.size() + 1L), cmds)); 557 558 // select one of the new nodes … … 641 642 notifyWayPartOfRelation(Collections.singleton(selectedWay)); 642 643 643 MainApplication.undoRedo.add(new SequenceCommand(644 UndoRedoHandler.getInstance().add(new SequenceCommand( 644 645 trn("Dupe {0} node into {1} nodes", "Dupe {0} nodes into {1} nodes", 645 646 selectedNodes.size(), selectedNodes.size(), selectedNodes.size()+allNewNodes.size()), cmds)); -
trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java
r13434 r14134 16 16 17 17 import org.openstreetmap.josm.command.RemoveNodesCommand; 18 import org.openstreetmap.josm.data.UndoRedoHandler; 18 19 import org.openstreetmap.josm.data.osm.Node; 19 20 import org.openstreetmap.josm.data.osm.OsmPrimitive; 20 21 import org.openstreetmap.josm.data.osm.Way; 21 import org.openstreetmap.josm.gui.MainApplication;22 22 import org.openstreetmap.josm.gui.Notification; 23 23 import org.openstreetmap.josm.tools.Shortcut; … … 89 89 90 90 // I'm sure there's a better way to handle this 91 MainApplication.undoRedo.add(new RemoveNodesCommand(selectedWay, selectedNodes));91 UndoRedoHandler.getInstance().add(new RemoveNodesCommand(selectedWay, selectedNodes)); 92 92 } 93 93 -
trunk/src/org/openstreetmap/josm/actions/UndoAction.java
r12718 r14134 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.data.UndoRedoHandler; 11 12 import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener; 12 13 import org.openstreetmap.josm.gui.MainApplication; … … 37 38 return; 38 39 map.repaint(); 39 MainApplication.undoRedo.undo();40 UndoRedoHandler.getInstance().undo(); 40 41 } 41 42 42 43 @Override 43 44 protected void updateEnabledState() { 44 setEnabled(Main.main != null && ! MainApplication.undoRedo.commands.isEmpty());45 setEnabled(Main.main != null && !UndoRedoHandler.getInstance().commands.isEmpty()); 45 46 } 46 47 47 48 @Override 48 49 public void commandChanged(int queueSize, int redoSize) { 49 if ( MainApplication.undoRedo.commands.isEmpty()) {50 if (UndoRedoHandler.getInstance().commands.isEmpty()) { 50 51 putValue(NAME, tr("Undo")); 51 52 setTooltip(tr("Undo the last action.")); … … 53 54 putValue(NAME, tr("Undo ...")); 54 55 setTooltip(tr("Undo {0}", 55 MainApplication.undoRedo.commands.getLast().getDescriptionText()));56 UndoRedoHandler.getInstance().commands.getLast().getDescriptionText())); 56 57 } 57 58 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r13434 r14134 15 15 import org.openstreetmap.josm.command.Command; 16 16 import org.openstreetmap.josm.command.DeleteCommand; 17 import org.openstreetmap.josm.data.UndoRedoHandler; 17 18 import org.openstreetmap.josm.data.osm.DataSet; 18 19 import org.openstreetmap.josm.data.osm.Node; … … 157 158 // if c is null, an error occurred or the user aborted. Don't do anything in that case. 158 159 if (c != null) { 159 MainApplication.undoRedo.add(c);160 UndoRedoHandler.getInstance().add(c); 160 161 //FIXME: This should not be required, DeleteCommand should update the selection, otherwise undo/redo won't work. 161 162 lm.getEditDataSet().setSelected(); … … 304 305 Command c = buildDeleteCommands(e, e.getModifiersEx(), false); 305 306 if (c != null) { 306 MainApplication.undoRedo.add(c);307 UndoRedoHandler.getInstance().add(c); 307 308 } 308 309 … … 355 356 if (cmd != null) { 356 357 // cmd can be null if the user cancels dialogs DialogCommand displays 357 MainApplication.undoRedo.add(cmd);358 UndoRedoHandler.getInstance().add(cmd); 358 359 for (Relation relation : toDelete) { 359 360 if (layer.data.getSelectedRelations().contains(relation)) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r14011 r14134 39 39 import org.openstreetmap.josm.command.SequenceCommand; 40 40 import org.openstreetmap.josm.data.Bounds; 41 import org.openstreetmap.josm.data.UndoRedoHandler; 41 42 import org.openstreetmap.josm.data.coor.EastNorth; 42 43 import org.openstreetmap.josm.data.osm.DataSelectionListener; … … 667 668 Command c = new SequenceCommand(title, cmds); 668 669 669 MainApplication.undoRedo.add(c);670 UndoRedoHandler.getInstance().add(c); 670 671 if (!wayIsFinished) { 671 672 lastUsedNode = n; … … 1382 1383 @Override 1383 1384 public void actionPerformed(ActionEvent e) { 1384 MainApplication.undoRedo.undo();1385 Command lastCmd = MainApplication.undoRedo.getLastCommand();1385 UndoRedoHandler.getInstance().undo(); 1386 Command lastCmd = UndoRedoHandler.getInstance().getLastCommand(); 1386 1387 if (lastCmd == null) return; 1387 1388 Node n = null; -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r14120 r14134 37 37 import org.openstreetmap.josm.command.SequenceCommand; 38 38 import org.openstreetmap.josm.data.Bounds; 39 import org.openstreetmap.josm.data.UndoRedoHandler; 39 40 import org.openstreetmap.josm.data.coor.EastNorth; 40 41 import org.openstreetmap.josm.data.osm.DataIntegrityProblemException; … … 497 498 moveCommand2 = new MoveCommand(movingNodeList.get(1), movement2.getX(), movement2.getY()); 498 499 Command c = new SequenceCommand(tr("Extrude Way"), moveCommand, moveCommand2); 499 MainApplication.undoRedo.add(c);500 UndoRedoHandler.getInstance().add(c); 500 501 } else { 501 502 // reuse existing move commands … … 512 513 //make a new move command 513 514 moveCommand = new MoveCommand(new ArrayList<OsmPrimitive>(movingNodeList), bestMovement); 514 MainApplication.undoRedo.add(moveCommand);515 UndoRedoHandler.getInstance().add(moveCommand); 515 516 } else { 516 517 //reuse existing move command … … 594 595 wnew.addNode(ws.lowerIndex+1, n); 595 596 DataSet ds = ws.way.getDataSet(); 596 MainApplication.undoRedo.add(new SequenceCommand(tr("Add a new node to an existing way"),597 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Add a new node to an existing way"), 597 598 new AddCommand(ds, n), new ChangeCommand(ds, ws.way, wnew))); 598 599 } … … 626 627 cmds.add(new AddCommand(ds, wnew)); 627 628 Command c = new SequenceCommand(tr("Extrude Way"), cmds); 628 MainApplication.undoRedo.add(c);629 UndoRedoHandler.getInstance().add(c); 629 630 ds.setSelected(wnew); 630 631 } … … 715 716 } 716 717 Command c = new SequenceCommand(tr("Extrude Way"), cmds); 717 MainApplication.undoRedo.add(c);718 UndoRedoHandler.getInstance().add(c); 718 719 joinNodesIfCollapsed(changedNodes); 719 720 } … … 727 728 Command mergeCmd = MergeNodesAction.mergeNodes(changedNodes, targetNode, locNode); 728 729 if (mergeCmd != null) { 729 MainApplication.undoRedo.add(mergeCmd);730 UndoRedoHandler.getInstance().add(mergeCmd); 730 731 } else { 731 732 // undo extruding command itself 732 MainApplication.undoRedo.undo();733 UndoRedoHandler.getInstance().undo(); 733 734 } 734 735 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyAction.java
r13964 r14134 29 29 import org.openstreetmap.josm.command.SequenceCommand; 30 30 import org.openstreetmap.josm.data.Bounds; 31 import org.openstreetmap.josm.data.UndoRedoHandler; 31 32 import org.openstreetmap.josm.data.coor.EastNorth; 32 33 import org.openstreetmap.josm.data.osm.DataSelectionListener; … … 478 479 virtualSegments.size(), virtualSegments.size()); 479 480 480 MainApplication.undoRedo.add(new SequenceCommand(text, virtualCmds));481 UndoRedoHandler.getInstance().add(new SequenceCommand(text, virtualCmds)); 481 482 482 483 } else if (alt && !ctrl && candidateNode != null) { … … 495 496 final Command deleteCmd = DeleteCommand.delete(Collections.singleton(targetWay), true); 496 497 if (deleteCmd != null) { 497 MainApplication.undoRedo.add(deleteCmd);498 UndoRedoHandler.getInstance().add(deleteCmd); 498 499 } 499 500 } else { 500 MainApplication.undoRedo.add(new ChangeCommand(targetWay, newWay));501 UndoRedoHandler.getInstance().add(new ChangeCommand(targetWay, newWay)); 501 502 } 502 503 } else if (candidateNode.isTagged()) { … … 507 508 final Command deleteCmd = DeleteCommand.delete(Collections.singleton(candidateNode), true); 508 509 if (deleteCmd != null) { 509 MainApplication.undoRedo.add(deleteCmd);510 UndoRedoHandler.getInstance().add(deleteCmd); 510 511 } 511 512 } … … 517 518 EastNorth cursorEN = mv.getEastNorth(mousePos.x, mousePos.y); 518 519 519 MainApplication.undoRedo.add(new MoveCommand(candidateNode, cursorEN.east() - nodeEN.east(), cursorEN.north() - nodeEN.north()));520 UndoRedoHandler.getInstance().add(new MoveCommand(candidateNode, cursorEN.east() - nodeEN.east(), cursorEN.north() - nodeEN.north())); 520 521 } 521 522 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWays.java
r12969 r14134 15 15 import org.openstreetmap.josm.command.Command; 16 16 import org.openstreetmap.josm.command.SequenceCommand; 17 import org.openstreetmap.josm.data.UndoRedoHandler; 17 18 import org.openstreetmap.josm.data.coor.EastNorth; 18 19 import org.openstreetmap.josm.data.osm.DataSet; … … 20 21 import org.openstreetmap.josm.data.osm.NodeGraph; 21 22 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.gui.MainApplication;23 23 import org.openstreetmap.josm.tools.Geometry; 24 24 … … 186 186 */ 187 187 public void commit() { 188 MainApplication.undoRedo.add(new SequenceCommand("Make parallel way(s)", makeAddWayAndNodesCommandList()));188 UndoRedoHandler.getInstance().add(new SequenceCommand("Make parallel way(s)", makeAddWayAndNodesCommandList())); 189 189 } 190 190 -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r13926 r14134 31 31 import org.openstreetmap.josm.command.ScaleCommand; 32 32 import org.openstreetmap.josm.command.SequenceCommand; 33 import org.openstreetmap.josm.data.UndoRedoHandler; 33 34 import org.openstreetmap.josm.data.coor.EastNorth; 34 35 import org.openstreetmap.josm.data.coor.LatLon; … … 718 719 } else if (!selection.isEmpty()) { 719 720 c = new MoveCommand(selection, startEN, currentEN); 720 MainApplication.undoRedo.add(c);721 UndoRedoHandler.getInstance().add(c); 721 722 } 722 723 for (Node n : affectedNodes) { … … 753 754 ((RotateCommand) c).handleEvent(currentEN); 754 755 } else { 755 MainApplication.undoRedo.add(new RotateCommand(selection, currentEN));756 UndoRedoHandler.getInstance().add(new RotateCommand(selection, currentEN)); 756 757 } 757 758 } else if (mode == Mode.SCALE) { … … 759 760 ((ScaleCommand) c).handleEvent(currentEN); 760 761 } else { 761 MainApplication.undoRedo.add(new ScaleCommand(selection, currentEN));762 UndoRedoHandler.getInstance().add(new ScaleCommand(selection, currentEN)); 762 763 } 763 764 } … … 808 809 */ 809 810 private static Command getLastCommandInDataset(DataSet ds) { 810 Command lastCommand = MainApplication.undoRedo.getLastCommand();811 Command lastCommand = UndoRedoHandler.getInstance().getLastCommand(); 811 812 if (lastCommand instanceof SequenceCommand) { 812 813 lastCommand = ((SequenceCommand) lastCommand).getLastCommand(); … … 834 835 ed.showDialog(); 835 836 if (ed.getValue() != 1) { 836 MainApplication.undoRedo.undo();837 UndoRedoHandler.getInstance().undo(); 837 838 } 838 839 } … … 860 861 861 862 if (ed.getValue() != 1) { 862 MainApplication.undoRedo.undo();863 UndoRedoHandler.getInstance().undo(); 863 864 } 864 865 } else { … … 1260 1261 "Add and move a virtual new node to {0} ways", virtualWays.size(), 1261 1262 virtualWays.size()); 1262 MainApplication.undoRedo.add(new SequenceCommand(text, virtualCmds));1263 UndoRedoHandler.getInstance().add(new SequenceCommand(text, virtualCmds)); 1263 1264 ds.setSelected(Collections.singleton((OsmPrimitive) virtualNode)); 1264 1265 clear(); -
trunk/src/org/openstreetmap/josm/actions/relation/AddSelectionToRelations.java
r13957 r14134 13 13 import org.openstreetmap.josm.command.Command; 14 14 import org.openstreetmap.josm.command.SequenceCommand; 15 import org.openstreetmap.josm.data.UndoRedoHandler; 15 16 import org.openstreetmap.josm.data.osm.DataSelectionListener; 16 17 import org.openstreetmap.josm.data.osm.IPrimitive; … … 48 49 } 49 50 if (!cmds.isEmpty()) { 50 MainApplication.undoRedo.add(new SequenceCommand(tr("Add selection to relation"), cmds));51 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Add selection to relation"), cmds)); 51 52 new Notification( 52 53 "<html>"+ -
trunk/src/org/openstreetmap/josm/actions/relation/RecentRelationsAction.java
r13278 r14134 19 19 20 20 import org.openstreetmap.josm.actions.JosmAction; 21 import org.openstreetmap.josm.data.UndoRedoHandler; 21 22 import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener; 22 23 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; … … 49 50 arrow = editButton.createArrow(this); 50 51 arrow.setToolTipText(tr("List of recent relations")); 51 MainApplication.undoRedo.addCommandQueueListener(this);52 UndoRedoHandler.getInstance().addCommandQueueListener(this); 52 53 enableArrow(); 53 54 shortcut = Shortcut.registerShortcut("relationeditor:editrecentrelation", -
trunk/src/org/openstreetmap/josm/actions/upload/DiscardTagsHook.java
r13809 r14134 13 13 import org.openstreetmap.josm.command.SequenceCommand; 14 14 import org.openstreetmap.josm.data.APIDataSet; 15 import org.openstreetmap.josm.data.UndoRedoHandler; 15 16 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 16 17 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 import org.openstreetmap.josm.gui.MainApplication;18 18 19 19 /** … … 45 45 SequenceCommand removeKeys = new SequenceCommand(tr("Removed obsolete tags"), 46 46 new ChangePropertyCommand(objectsToUpload, map)); 47 MainApplication.undoRedo.add(removeKeys);47 UndoRedoHandler.getInstance().add(removeKeys); 48 48 } 49 49 return true; -
trunk/src/org/openstreetmap/josm/actions/upload/FixDataHook.java
r13597 r14134 16 16 import org.openstreetmap.josm.command.SequenceCommand; 17 17 import org.openstreetmap.josm.data.APIDataSet; 18 import org.openstreetmap.josm.data.UndoRedoHandler; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 20 import org.openstreetmap.josm.data.osm.Relation; 20 import org.openstreetmap.josm.gui.MainApplication;21 21 import org.openstreetmap.josm.spi.preferences.Config; 22 22 import org.openstreetmap.josm.tools.Utils; … … 205 205 206 206 if (!cmds.isEmpty()) { 207 MainApplication.undoRedo.add(new SequenceCommand(tr("Fix deprecated tags"), cmds));207 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Fix deprecated tags"), cmds)); 208 208 } 209 209 } -
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r13764 r14134 18 18 * If you want to change a data set, you can use {@link #add(Command)} to execute a command on it and make that command undoable. 19 19 */ 20 public class UndoRedoHandler {20 public final class UndoRedoHandler { 21 21 22 22 /** … … 34 34 private final LinkedList<CommandQueuePreciseListener> preciseListenerCommands = new LinkedList<>(); 35 35 36 private static class InstanceHolder { 37 static final UndoRedoHandler INSTANCE = new UndoRedoHandler(); 38 } 39 40 /** 41 * Returns the unique instance. 42 * @return the unique instance 43 * @since 14134 44 */ 45 public static UndoRedoHandler getInstance() { 46 return InstanceHolder.INSTANCE; 47 } 48 36 49 /** 37 50 * Constructs a new {@code UndoRedoHandler}. 38 51 */ 39 p ublicUndoRedoHandler() {40 // Do nothing52 private UndoRedoHandler() { 53 // Hide constructor 41 54 } 42 55 -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r14128 r14134 241 241 * The commands undo/redo handler. 242 242 * @since 12641 243 */ 244 public static volatile UndoRedoHandler undoRedo; 243 * @deprecated Use {@link UndoRedoHandler#getInstance} 244 */ 245 @Deprecated 246 public static final UndoRedoHandler undoRedo = UndoRedoHandler.getInstance(); 245 247 246 248 private static final LayerChangeListener undoRedoCleaner = new LayerChangeListener() { … … 360 362 public MainApplication(MainFrame mainFrame) { 361 363 this.mainFrame = mainFrame; 362 undoRedo = super.undoRedo;363 364 getLayerManager().addLayerChangeListener(undoRedoCleaner); 364 365 ProjectionRegistry.setboundsProvider(mainBoundsProvider); -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r13891 r14134 115 115 import org.openstreetmap.josm.actions.audio.AudioSlowerAction; 116 116 import org.openstreetmap.josm.actions.search.SearchAction; 117 import org.openstreetmap.josm.data.UndoRedoHandler; 117 118 import org.openstreetmap.josm.gui.dialogs.MenuItemSearchDialog; 118 119 import org.openstreetmap.josm.gui.io.RecentlyOpenedFilesMenu; … … 687 688 688 689 add(editMenu, undo); 689 MainApplication.undoRedo.addCommandQueueListener(undo);690 UndoRedoHandler.getInstance().addCommandQueueListener(undo); 690 691 add(editMenu, redo); 691 MainApplication.undoRedo.addCommandQueueListener(redo);692 UndoRedoHandler.getInstance().addCommandQueueListener(redo); 692 693 editMenu.addSeparator(); 693 694 add(editMenu, copy); -
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/AbstractTagPaster.java
r12920 r14134 18 18 import org.openstreetmap.josm.command.Command; 19 19 import org.openstreetmap.josm.command.SequenceCommand; 20 import org.openstreetmap.josm.data.UndoRedoHandler; 20 21 import org.openstreetmap.josm.data.coor.EastNorth; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 import org.openstreetmap.josm.gui.MainApplication;23 23 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 24 24 import org.openstreetmap.josm.tools.I18n; … … 66 66 @I18n.QuirkyPluralString 67 67 final String title = title1 + ' ' + title2; 68 MainApplication.undoRedo.add(new SequenceCommand(title, commands));68 UndoRedoHandler.getInstance().add(new SequenceCommand(title, commands)); 69 69 } 70 70 } -
trunk/src/org/openstreetmap/josm/gui/datatransfer/importers/PrimitiveDataPaster.java
r14120 r14134 16 16 import org.openstreetmap.josm.Main; 17 17 import org.openstreetmap.josm.command.AddPrimitivesCommand; 18 import org.openstreetmap.josm.data.UndoRedoHandler; 18 19 import org.openstreetmap.josm.data.coor.EastNorth; 19 20 import org.openstreetmap.josm.data.osm.NodeData; … … 25 26 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 26 27 import org.openstreetmap.josm.gui.ExtendedDialog; 27 import org.openstreetmap.josm.gui.MainApplication;28 28 import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData; 29 29 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 59 59 60 60 /* Now execute the commands to add the duplicated contents of the paste buffer to the map */ 61 MainApplication.undoRedo.add(command);61 UndoRedoHandler.getInstance().add(command); 62 62 return true; 63 63 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r13943 r14134 40 40 import org.openstreetmap.josm.command.Command; 41 41 import org.openstreetmap.josm.command.PseudoCommand; 42 import org.openstreetmap.josm.data.UndoRedoHandler; 42 43 import org.openstreetmap.josm.data.UndoRedoHandler.CommandAddedEvent; 43 44 import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueCleanedEvent; … … 237 238 listener.updateEnabledState(); 238 239 } 239 MainApplication.undoRedo.addCommandQueuePreciseListener(this);240 UndoRedoHandler.getInstance().addCommandQueuePreciseListener(this); 240 241 } 241 242 … … 255 256 undoTreeModel.setRoot(undoRoot); 256 257 redoTreeModel.setRoot(redoRoot); 257 MainApplication.undoRedo.removeCommandQueuePreciseListener(this);258 UndoRedoHandler.getInstance().removeCommandQueuePreciseListener(this); 258 259 } 259 260 … … 270 271 271 272 private void buildUndoTree() { 272 List<Command> undoCommands = MainApplication.undoRedo.commands;273 List<Command> undoCommands = UndoRedoHandler.getInstance().commands; 273 274 undoRoot = new DefaultMutableTreeNode(); 274 275 for (int i = 0; i < undoCommands.size(); ++i) { … … 279 280 280 281 private void buildRedoTree() { 281 List<Command> redoCommands = MainApplication.undoRedo.redoCommands;282 List<Command> redoCommands = UndoRedoHandler.getInstance().redoCommands; 282 283 redoRoot = new DefaultMutableTreeNode(); 283 284 for (int i = 0; i < redoCommands.size(); ++i) { … … 288 289 289 290 private void ensureTreesConsistency() { 290 List<Command> undoCommands = MainApplication.undoRedo.commands;291 List<Command> redoCommands = MainApplication.undoRedo.redoCommands;291 List<Command> undoCommands = UndoRedoHandler.getInstance().commands; 292 List<Command> redoCommands = UndoRedoHandler.getInstance().redoCommands; 292 293 if (redoTreeModel.getChildCount(redoRoot) > 0) { 293 294 redoTree.scrollRowToVisible(0); … … 505 506 case UNDO: 506 507 int numUndo = ((DefaultMutableTreeNode) undoTreeModel.getRoot()).getChildCount() - idx; 507 MainApplication.undoRedo.undo(numUndo);508 UndoRedoHandler.getInstance().undo(numUndo); 508 509 break; 509 510 case REDO: 510 511 int numRedo = idx+1; 511 MainApplication.undoRedo.redo(numRedo);512 UndoRedoHandler.getInstance().redo(numRedo); 512 513 break; 513 514 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r13842 r14134 41 41 import org.openstreetmap.josm.command.Command; 42 42 import org.openstreetmap.josm.command.SequenceCommand; 43 import org.openstreetmap.josm.data.UndoRedoHandler; 43 44 import org.openstreetmap.josm.data.conflict.Conflict; 44 45 import org.openstreetmap.josm.data.conflict.ConflictCollection; … … 523 524 } 524 525 } 525 MainApplication.undoRedo.add(new SequenceCommand(name, commands));526 UndoRedoHandler.getInstance().add(new SequenceCommand(name, commands)); 526 527 refreshView(); 527 528 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
r12663 r14134 18 18 19 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.data.UndoRedoHandler; 20 21 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; 21 22 import org.openstreetmap.josm.data.osm.OsmPrimitive; 22 23 import org.openstreetmap.josm.gui.ExtendedDialog; 23 import org.openstreetmap.josm.gui.MainApplication;24 24 import org.openstreetmap.josm.gui.conflict.pair.ConflictResolver; 25 25 import org.openstreetmap.josm.gui.help.HelpBrowser; … … 204 204 } 205 205 } 206 MainApplication.undoRedo.add(resolver.buildResolveCommand());206 UndoRedoHandler.getInstance().add(resolver.buildResolveCommand()); 207 207 buttonAction(1, evt); 208 208 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
r13940 r14134 35 35 import org.openstreetmap.josm.actions.relation.EditRelationAction; 36 36 import org.openstreetmap.josm.command.Command; 37 import org.openstreetmap.josm.data.UndoRedoHandler; 37 38 import org.openstreetmap.josm.data.osm.DataSelectionListener; 38 39 import org.openstreetmap.josm.data.osm.DataSet; … … 560 561 final Command fixCommand = error.getFix(); 561 562 if (fixCommand != null) { 562 SwingUtilities.invokeAndWait(() -> MainApplication.undoRedo.addNoRedraw(fixCommand));563 SwingUtilities.invokeAndWait(() -> UndoRedoHandler.getInstance().addNoRedraw(fixCommand)); 563 564 } 564 565 // It is wanted to ignore an error if it said fixable, even if fixCommand was null … … 591 592 monitor.subTask(tr("Updating map ...")); 592 593 SwingUtilities.invokeAndWait(() -> { 593 MainApplication.undoRedo.afterAdd(null);594 UndoRedoHandler.getInstance().afterAdd(null); 594 595 invalidateValidatorLayers(); 595 596 tree.resetErrors(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r14102 r14134 59 59 import org.openstreetmap.josm.command.ChangePropertyCommand; 60 60 import org.openstreetmap.josm.command.Command; 61 import org.openstreetmap.josm.data.UndoRedoHandler; 61 62 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 62 63 import org.openstreetmap.josm.data.osm.DataSelectionListener; … … 844 845 Command command = TaggingPreset.createCommand(getSelection(), tags); 845 846 if (command != null) { 846 MainApplication.undoRedo.add(command);847 UndoRedoHandler.getInstance().add(command); 847 848 } 848 849 } … … 1011 1012 1012 1013 Collection<OsmPrimitive> sel = Main.main.getInProgressSelection(); 1013 MainApplication.undoRedo.add(new ChangePropertyCommand(sel, tags));1014 UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, tags)); 1014 1015 1015 1016 membershipTable.clearSelection(); … … 1042 1043 rel.removeMembersFor(primitive); 1043 1044 } 1044 MainApplication.undoRedo.add(new ChangeCommand(cur, rel));1045 UndoRedoHandler.getInstance().add(new ChangeCommand(cur, rel)); 1045 1046 1046 1047 tagTable.clearSelection(); … … 1164 1165 if (sel.isEmpty() || clipboard == null || sel.iterator().next().getDataSet().isLocked()) 1165 1166 return; 1166 MainApplication.undoRedo.add(new ChangePropertyCommand(sel, key, Utils.strip(clipboard)));1167 UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, key, Utils.strip(clipboard))); 1167 1168 } 1168 1169 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r13597 r14134 68 68 import org.openstreetmap.josm.command.Command; 69 69 import org.openstreetmap.josm.command.SequenceCommand; 70 import org.openstreetmap.josm.data.UndoRedoHandler; 70 71 import org.openstreetmap.josm.data.osm.OsmPrimitive; 71 72 import org.openstreetmap.josm.data.osm.Tag; … … 81 82 import org.openstreetmap.josm.gui.ExtendedDialog; 82 83 import org.openstreetmap.josm.gui.IExtendedDialog; 83 import org.openstreetmap.josm.gui.MainApplication;84 84 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 85 85 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; … … 508 508 return; 509 509 if (key.equals(newkey) || value == null) { 510 MainApplication.undoRedo.add(new ChangePropertyCommand(sel, newkey, value));510 UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, newkey, value)); 511 511 AutoCompletionManager.rememberUserInput(newkey, value, true); 512 512 } else { … … 542 542 AutoCompletionManager.rememberUserInput(newkey, value, false); 543 543 } 544 MainApplication.undoRedo.add(new SequenceCommand(544 UndoRedoHandler.getInstance().add(new SequenceCommand( 545 545 trn("Change properties of up to {0} object", 546 546 "Change properties of up to {0} objects", sel.size(), sel.size()), … … 1077 1077 AutoCompletionManager.rememberUserInput(key, value, false); 1078 1078 commandCount++; 1079 MainApplication.undoRedo.add(new ChangePropertyCommand(sel, key, value));1079 UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, key, value)); 1080 1080 changedKey = key; 1081 1081 clearEntries(); … … 1088 1088 1089 1089 public void undoAllTagsAdding() { 1090 MainApplication.undoRedo.undo(commandCount);1090 UndoRedoHandler.getInstance().undo(commandCount); 1091 1091 } 1092 1092 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/RefreshAction.java
r14030 r14134 12 12 13 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.data.UndoRedoHandler; 14 15 import org.openstreetmap.josm.data.UndoRedoHandler.CommandQueueListener; 15 16 import org.openstreetmap.josm.data.osm.Relation; 16 17 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 17 18 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 18 import org.openstreetmap.josm.gui.MainApplication;19 19 import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor; 20 20 import org.openstreetmap.josm.tools.ImageProvider; … … 46 46 rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sc.getKeyStroke(), "refresh"); 47 47 } 48 MainApplication.undoRedo.addCommandQueueListener(this);48 UndoRedoHandler.getInstance().addCommandQueueListener(this); 49 49 updateEnabledState(); 50 50 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SavingAction.java
r14029 r14134 15 15 import org.openstreetmap.josm.command.ChangeCommand; 16 16 import org.openstreetmap.josm.command.conflict.ConflictAddCommand; 17 import org.openstreetmap.josm.data.UndoRedoHandler; 17 18 import org.openstreetmap.josm.data.conflict.Conflict; 18 19 import org.openstreetmap.josm.data.osm.DefaultNameFormatter; … … 67 68 if (newRelation.getMembersCount() == 0 && !newRelation.hasKeys()) 68 69 return; 69 MainApplication.undoRedo.add(new AddCommand(getLayer().getDataSet(), newRelation));70 UndoRedoHandler.getInstance().add(new AddCommand(getLayer().getDataSet(), newRelation)); 70 71 71 72 // make sure everybody is notified about the changes … … 89 90 editorAccess.getMemberTableModel().applyToRelation(editedRelation); 90 91 Conflict<Relation> conflict = new Conflict<>(editorAccess.getEditor().getRelation(), editedRelation); 91 MainApplication.undoRedo.add(new ConflictAddCommand(getLayer().getDataSet(), conflict));92 UndoRedoHandler.getInstance().add(new ConflictAddCommand(getLayer().getDataSet(), conflict)); 92 93 } 93 94 … … 102 103 getMemberTableModel().applyToRelation(editedRelation); 103 104 if (!editedRelation.hasEqualSemanticAttributes(originRelation, false)) { 104 MainApplication.undoRedo.add(new ChangeCommand(originRelation, editedRelation));105 UndoRedoHandler.getInstance().add(new ChangeCommand(originRelation, editedRelation)); 105 106 } 106 107 } -
trunk/src/org/openstreetmap/josm/gui/io/AsynchronousUploadPrimitivesTask.java
r14052 r14134 9 9 10 10 import org.openstreetmap.josm.data.APIDataSet; 11 import org.openstreetmap.josm.data.UndoRedoHandler; 11 12 import org.openstreetmap.josm.data.osm.Changeset; 12 13 import org.openstreetmap.josm.gui.MainApplication; … … 120 121 GuiHelper.runInEDTAndWait(() -> { 121 122 // Remove the commands from the undo stack 122 MainApplication.undoRedo.clean(uploadDataLayer.getDataSet());123 UndoRedoHandler.getInstance().clean(uploadDataLayer.getDataSet()); 123 124 MainApplication.getLayerManager().prepareLayerForUpload(uploadDataLayer); 124 125 -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r14129 r14134 39 39 import org.openstreetmap.josm.gui.io.importexport.GpxImporter; 40 40 import org.openstreetmap.josm.gui.layer.gpx.ChooseTrackVisibilityAction; 41 import org.openstreetmap.josm.gui.layer.gpx.ConvertFromGpxLayerAction; 41 42 import org.openstreetmap.josm.gui.layer.gpx.CustomizeDrawingAction; 42 43 import org.openstreetmap.josm.gui.layer.gpx.DownloadAlongTrackAction; 43 44 import org.openstreetmap.josm.gui.layer.gpx.DownloadWmsAlongTrackAction; 44 import org.openstreetmap.josm.gui.layer.gpx.ConvertFromGpxLayerAction;45 45 import org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper; 46 46 import org.openstreetmap.josm.gui.layer.gpx.ImportAudioAction; -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r14075 r14134 52 52 import org.openstreetmap.josm.data.DataSource; 53 53 import org.openstreetmap.josm.data.ProjectionBounds; 54 import org.openstreetmap.josm.data.UndoRedoHandler; 54 55 import org.openstreetmap.josm.data.conflict.Conflict; 55 56 import org.openstreetmap.josm.data.conflict.ConflictCollection; … … 618 619 return; 619 620 620 MainApplication.undoRedo.clean(data);621 UndoRedoHandler.getInstance().clean(data); 621 622 622 623 // if uploaded, clean the modified flags as well -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r13926 r14134 37 37 import org.openstreetmap.josm.command.Command; 38 38 import org.openstreetmap.josm.command.SequenceCommand; 39 import org.openstreetmap.josm.data.UndoRedoHandler; 39 40 import org.openstreetmap.josm.data.osm.DataSet; 40 41 import org.openstreetmap.josm.data.osm.IPrimitive; … … 402 403 Command cmd = createCommand(sel, getChangedTags()); 403 404 if (cmd != null) { 404 MainApplication.undoRedo.add(cmd);405 UndoRedoHandler.getInstance().add(cmd); 405 406 } 406 407 } else if (answer == DIALOG_ANSWER_NEW_RELATION) { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r13259 r14134 31 31 import org.openstreetmap.josm.Main; 32 32 import org.openstreetmap.josm.command.ChangePropertyCommand; 33 import org.openstreetmap.josm.data.UndoRedoHandler; 33 34 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 35 import org.openstreetmap.josm.gui.ExtendedDialog; … … 259 260 String key = (String) tm.getValueAt(i, 1); 260 261 Object value = tm.getValueAt(i, 2); 261 MainApplication.undoRedo.add(new ChangePropertyCommand(sel,262 UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, 262 263 key, value instanceof String ? (String) value : "")); 263 264 } … … 313 314 if (MainApplication.getLayerManager().getEditDataSet() != null) { 314 315 for (String[] row : keyValue) { 315 MainApplication.undoRedo.add(new ChangePropertyCommand(primitives, row[0], row[1]));316 UndoRedoHandler.getInstance().add(new ChangePropertyCommand(primitives, row[0], row[1])); 316 317 } 317 318 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandler.java
r12846 r14134 10 10 import org.openstreetmap.josm.actions.AutoScaleAction; 11 11 import org.openstreetmap.josm.command.AddCommand; 12 import org.openstreetmap.josm.data.UndoRedoHandler; 12 13 import org.openstreetmap.josm.data.coor.LatLon; 13 14 import org.openstreetmap.josm.data.osm.DataSet; … … 101 102 node = new Node(ll); 102 103 // Now execute the commands to add this node. 103 MainApplication.undoRedo.add(new AddCommand(ds, node));104 UndoRedoHandler.getInstance().add(new AddCommand(ds, node)); 104 105 } 105 106 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
r13827 r14134 18 18 import org.openstreetmap.josm.command.Command; 19 19 import org.openstreetmap.josm.command.SequenceCommand; 20 import org.openstreetmap.josm.data.UndoRedoHandler; 20 21 import org.openstreetmap.josm.data.coor.LatLon; 21 22 import org.openstreetmap.josm.data.osm.DataSet; … … 170 171 DataSet ds = MainApplication.getLayerManager().getEditDataSet(); 171 172 commands.add(new AddCommand(ds, way)); 172 MainApplication.undoRedo.add(new SequenceCommand(tr("Add way"), commands));173 UndoRedoHandler.getInstance().add(new SequenceCommand(tr("Add way"), commands)); 173 174 ds.setSelected(way); 174 175 if (PermissionPrefWithDefault.CHANGE_VIEWPORT.isAllowed()) { -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/DrawActionTest.java
r14005 r14134 16 16 import org.junit.Rule; 17 17 import org.junit.Test; 18 import org.openstreetmap.josm.data.UndoRedoHandler; 18 19 import org.openstreetmap.josm.data.coor.EastNorth; 19 20 import org.openstreetmap.josm.data.osm.DataSet; … … 91 92 assertNotNull(renderer.getListCellRendererComponent(lstPrimitives, n3, 0, false, false)); 92 93 93 MainApplication.undoRedo.undo();94 UndoRedoHandler.getInstance().undo(); 94 95 95 96 assertEquals(2, w.getNodesCount()); -
trunk/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java
r12729 r14134 15 15 import org.openstreetmap.josm.command.SequenceCommand; 16 16 import org.openstreetmap.josm.data.APIDataSet; 17 import org.openstreetmap.josm.data.UndoRedoHandler; 17 18 import org.openstreetmap.josm.data.osm.DataSet; 18 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 20 import org.openstreetmap.josm.data.osm.Relation; 20 21 import org.openstreetmap.josm.data.osm.Way; 21 import org.openstreetmap.josm.gui.MainApplication;22 22 import org.openstreetmap.josm.testutils.JOSMTestRules; 23 23 … … 42 42 public void testCheckUpload() { 43 43 // Empty data set 44 MainApplication.undoRedo.commands.clear();44 UndoRedoHandler.getInstance().commands.clear(); 45 45 new FixDataHook().checkUpload(new APIDataSet()); 46 assertTrue( MainApplication.undoRedo.commands.isEmpty());46 assertTrue(UndoRedoHandler.getInstance().commands.isEmpty()); 47 47 48 48 // Complete data set (except empty node which cannot be tested anymore) … … 76 76 ads.init(new DataSet(emptyWay, emptyRelation, w1, w2, w3, w4, w5, w6, w7, r1, r2)); 77 77 78 MainApplication.undoRedo.commands.clear();78 UndoRedoHandler.getInstance().commands.clear(); 79 79 new FixDataHook().checkUpload(ads); 80 assertEquals(1, MainApplication.undoRedo.commands.size());80 assertEquals(1, UndoRedoHandler.getInstance().commands.size()); 81 81 82 SequenceCommand seq = (SequenceCommand) MainApplication.undoRedo.commands.iterator().next();82 SequenceCommand seq = (SequenceCommand) UndoRedoHandler.getInstance().commands.iterator().next(); 83 83 Collection<? extends OsmPrimitive> prims = seq.getParticipatingPrimitives(); 84 84 assertNotNull(prims); -
trunk/test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java
r12828 r14134 13 13 import org.junit.Test; 14 14 import org.openstreetmap.josm.command.SplitWayCommand.Strategy; 15 import org.openstreetmap.josm.data.UndoRedoHandler; 15 16 import org.openstreetmap.josm.data.coor.LatLon; 16 17 import org.openstreetmap.josm.data.osm.DataSet; … … 20 21 import org.openstreetmap.josm.data.osm.RelationMember; 21 22 import org.openstreetmap.josm.data.osm.Way; 22 import org.openstreetmap.josm.gui.MainApplication;23 23 import org.openstreetmap.josm.testutils.JOSMTestRules; 24 24 … … 121 121 final SplitWayCommand result = SplitWayCommand.splitWay( 122 122 w2, SplitWayCommand.buildSplitChunks(w2, Arrays.asList(n3, n4, n5)), new ArrayList<OsmPrimitive>(), strategy); 123 MainApplication.undoRedo.add(result);123 UndoRedoHandler.getInstance().add(result); 124 124 125 125 assertEquals(6, route.getMembersCount()); -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java
r12726 r14134 9 9 import org.openstreetmap.josm.TestUtils; 10 10 import org.openstreetmap.josm.command.Command; 11 import org.openstreetmap.josm.data.UndoRedoHandler; 11 12 import org.openstreetmap.josm.data.osm.DataSet; 12 13 import org.openstreetmap.josm.gui.MainApplication; … … 52 53 Command cmd1 = TestUtils.newCommand(ds); 53 54 Command cmd2 = TestUtils.newCommand(ds); 54 MainApplication.undoRedo.add(cmd1);55 MainApplication.undoRedo.add(cmd2);56 MainApplication.undoRedo.undo(1);55 UndoRedoHandler.getInstance().add(cmd1); 56 UndoRedoHandler.getInstance().add(cmd2); 57 UndoRedoHandler.getInstance().undo(1); 57 58 58 assertFalse( MainApplication.undoRedo.commands.isEmpty());59 assertFalse( MainApplication.undoRedo.redoCommands.isEmpty());59 assertFalse(UndoRedoHandler.getInstance().commands.isEmpty()); 60 assertFalse(UndoRedoHandler.getInstance().redoCommands.isEmpty()); 60 61 61 62 MapFrame map = MainApplication.getMap(); … … 68 69 assertFalse(dlg.isVisible()); 69 70 } finally { 70 MainApplication.undoRedo.clean();71 UndoRedoHandler.getInstance().clean(); 71 72 MainApplication.getLayerManager().removeLayer(layer); 72 73 }
Note:
See TracChangeset
for help on using the changeset viewer.