Changeset 301 in josm
- Timestamp:
- 2007-08-08T14:56:38+02:00 (17 years ago)
- Files:
-
- 1 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
.settings/org.eclipse.jdt.ui.prefs
r86 r301 1 # Fri Apr 21 12:51:47 CEST 20061 #Wed Aug 08 13:31:47 GMT+01:00 2007 2 2 eclipse.preferences.version=1 3 3 formatter_profile=_josm 4 4 formatter_settings_version=10 5 org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">// License\: GPL. Copyright 2007 by Immanuel Scholz and others\n</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">// License\: GPL. Copyright 2007 by Immanuel Scholz and others\n${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> -
src/org/openstreetmap/josm/Main.java
r298 r301 40 40 import org.openstreetmap.josm.data.Bounds; 41 41 import org.openstreetmap.josm.data.Preferences; 42 import org.openstreetmap.josm.data.UndoRedoHandler; 42 43 import org.openstreetmap.josm.data.osm.DataSet; 43 44 import org.openstreetmap.josm.data.projection.Epsg4326; … … 47 48 import org.openstreetmap.josm.gui.MapFrame; 48 49 import org.openstreetmap.josm.gui.PleaseWaitDialog; 49 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;50 50 import org.openstreetmap.josm.gui.download.BoundingBoxSelection; 51 51 import org.openstreetmap.josm.gui.download.DownloadDialog.DownloadTask; … … 111 111 112 112 113 public UndoRedoHandler undoRedo = new UndoRedoHandler(); 114 113 115 /** 114 116 * The main menu bar at top of screen. 115 117 */ 116 118 public final MainMenu menu; 119 120 117 121 118 122 … … 125 129 panel.setVisible(false); 126 130 panel.removeAll(); 127 if (map != null) {131 if (map != null) 128 132 map.fillPanel(panel); 129 map.mapView.addLayerChangeListener(new LayerChangeListener(){ 130 public void activeLayerChange(final Layer oldLayer, final Layer newLayer) { 131 setLayerMenu(newLayer.getMenuEntries()); 132 } 133 public void layerAdded(final Layer newLayer) { 134 if (newLayer instanceof OsmDataLayer) 135 Main.main.editLayer().listenerCommands.add(redoUndoListener); 136 } 137 public void layerRemoved(final Layer oldLayer) { 138 if (oldLayer instanceof OsmDataLayer) 139 Main.main.editLayer().listenerCommands.add(redoUndoListener); 140 if (map.mapView.getAllLayers().isEmpty()) 141 setLayerMenu(null); 142 } 143 }); 144 if (map.mapView.editLayer != null) 145 map.mapView.editLayer.listenerCommands.add(redoUndoListener); 146 } else { 133 else { 147 134 old.destroy(); 148 135 panel.add(new GettingStarted(), BorderLayout.CENTER); … … 187 174 menu = new MainMenu(); 188 175 176 undoRedo.listenerCommands.add(redoUndoListener); 177 189 178 // creating toolbar 190 179 contentPane.add(toolbar.control, BorderLayout.NORTH); … … 305 294 } 306 295 }; 307 308 296 /** 309 297 * Should be called before the main constructor to setup some parameter stuff -
src/org/openstreetmap/josm/actions/AlignInCircleAction.java
r298 r301 68 68 } 69 69 70 Main.main. editLayer().add(new SequenceCommand(tr("Align Nodes in Circle"), cmds));70 Main.main.undoRedo.add(new SequenceCommand(tr("Align Nodes in Circle"), cmds)); 71 71 Main.map.repaint(); 72 72 } -
src/org/openstreetmap/josm/actions/AlignInLineAction.java
r298 r301 110 110 111 111 // Do it! 112 Main.main. editLayer().add(new SequenceCommand(tr("Align Nodes in Line"), cmds));112 Main.main.undoRedo.add(new SequenceCommand(tr("Align Nodes in Line"), cmds)); 113 113 Main.map.repaint(); 114 114 } -
src/org/openstreetmap/josm/actions/CombineWayAction.java
r298 r301 99 99 cmds.add(new DeleteCommand(selectedWays)); 100 100 cmds.add(new ChangeCommand(oldWay, newWay)); 101 Main.main. editLayer().add(new SequenceCommand(tr("Combine {0} ways", selectedWays.size()), cmds));101 Main.main.undoRedo.add(new SequenceCommand(tr("Combine {0} ways", selectedWays.size()), cmds)); 102 102 Main.ds.setSelected(oldWay); 103 103 } -
src/org/openstreetmap/josm/actions/RedoAction.java
r298 r301 30 30 return; 31 31 Main.map.repaint(); 32 Main.main. editLayer().redo();32 Main.main.undoRedo.redo(); 33 33 } 34 34 } -
src/org/openstreetmap/josm/actions/ReorderAction.java
r298 r301 59 59 60 60 if( c != null ) 61 Main.main. editLayer().add( c);61 Main.main.undoRedo.add(c); 62 62 } 63 63 } -
src/org/openstreetmap/josm/actions/ReverseSegmentAction.java
r298 r301 54 54 c.add(new ChangeCommand(s, snew)); 55 55 } 56 Main.main. editLayer().add(new SequenceCommand(tr("Reverse Segments"), c));56 Main.main.undoRedo.add(new SequenceCommand(tr("Reverse Segments"), c)); 57 57 Main.map.repaint(); 58 58 } -
src/org/openstreetmap/josm/actions/SplitWayAction.java
r298 r301 455 455 NameVisitor v = new NameVisitor(); 456 456 v.visit(selectedWay); 457 Main.main. editLayer().add(new SequenceCommand(tr("Split way {0} into {1} parts",v.name, segmentSets.size()), commandList));457 Main.main.undoRedo.add(new SequenceCommand(tr("Split way {0} into {1} parts",v.name, segmentSets.size()), commandList)); 458 458 Main.ds.setSelected(newSelection); 459 459 } -
src/org/openstreetmap/josm/actions/UndoAction.java
r298 r301 30 30 return; 31 31 Main.map.repaint(); 32 Main.main. editLayer().undo();32 Main.main.undoRedo.undo(); 33 33 } 34 34 } -
src/org/openstreetmap/josm/actions/mapmode/AddNodeAction.java
r298 r301 170 170 } 171 171 172 Main.main. editLayer().add(c);172 Main.main.undoRedo.add(c); 173 173 Main.ds.setSelected(n); 174 174 Main.map.mapView.repaint(); -
src/org/openstreetmap/josm/actions/mapmode/AddSegmentAction.java
r298 r301 146 146 147 147 Segment ls = new Segment(start, end); 148 Main.main. editLayer().add(new AddCommand(ls));148 Main.main.undoRedo.add(new AddCommand(ls)); 149 149 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 150 150 sel.add(ls); -
src/org/openstreetmap/josm/actions/mapmode/AddWayAction.java
r298 r301 107 107 copy.segments.remove(s); 108 108 if (copy.segments.isEmpty()) { 109 Main.main. editLayer().add(new DeleteCommand(Arrays.asList(new OsmPrimitive[]{way})));109 Main.main.undoRedo.add(new DeleteCommand(Arrays.asList(new OsmPrimitive[]{way}))); 110 110 way = null; 111 111 } else 112 Main.main. editLayer().add(new ChangeCommand(way, copy));112 Main.main.undoRedo.add(new ChangeCommand(way, copy)); 113 113 } else { 114 114 if (way == null) { 115 115 way = new Way(); 116 116 way.segments.add(s); 117 Main.main. editLayer().add(new AddCommand(way));117 Main.main.undoRedo.add(new AddCommand(way)); 118 118 } else { 119 119 Way copy = new Way(way); … … 123 123 break; 124 124 copy.segments.add(i, s); 125 Main.main. editLayer().add(new ChangeCommand(way, copy));125 Main.main.undoRedo.add(new ChangeCommand(way, copy)); 126 126 } 127 127 } … … 198 198 w.segments.clear(); 199 199 w.segments.addAll(sortedSegments); 200 Main.main. editLayer().add(new ChangeCommand(wayToAdd, w));200 Main.main.undoRedo.add(new ChangeCommand(wayToAdd, w)); 201 201 return wayToAdd; 202 202 } … … 207 207 Way w = new Way(); 208 208 w.segments.addAll(sortedSegments); 209 Main.main. editLayer().add(new AddCommand(w));209 Main.main.undoRedo.add(new AddCommand(w)); 210 210 return w; 211 211 } -
src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r298 r301 126 126 v.data.addAll(selection); 127 127 if (!v.data.isEmpty()) 128 Main.main. editLayer().add(new DeleteCommand(v.data));128 Main.main.undoRedo.add(new DeleteCommand(v.data)); 129 129 } 130 130 … … 164 164 } 165 165 if (!del.isEmpty()) 166 Main.main. editLayer().add(new DeleteCommand(del));166 Main.main.undoRedo.add(new DeleteCommand(del)); 167 167 } 168 168 … … 213 213 cmds.add(new ChangeCommand(seg1, s)); 214 214 cmds.add(new DeleteCommand(Arrays.asList(new OsmPrimitive[]{n, seg2}))); 215 Main.main. editLayer().add(new SequenceCommand(tr("Delete Node"), cmds));215 Main.main.undoRedo.add(new SequenceCommand(tr("Delete Node"), cmds)); 216 216 return null; 217 217 } -
src/org/openstreetmap/josm/actions/mapmode/MoveAction.java
r298 r301 106 106 } 107 107 108 Command c = !Main.main. editLayer().commands.isEmpty() ? Main.main.editLayer().commands.getLast() : null;108 Command c = !Main.main.undoRedo.commands.isEmpty() ? Main.main.undoRedo.commands.getLast() : null; 109 109 if (c instanceof MoveCommand && affectedNodes.equals(((MoveCommand)c).objects)) 110 110 ((MoveCommand)c).moveAgain(dx,dy); 111 111 else 112 Main.main. editLayer().add(new MoveCommand(selection, dx, dy));112 Main.main.undoRedo.add(new MoveCommand(selection, dx, dy)); 113 113 114 114 Main.map.mapView.repaint(); -
src/org/openstreetmap/josm/command/AddCommand.java
r298 r301 11 11 12 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.data.osm.DataSet; 13 14 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 15 import org.openstreetmap.josm.data.osm.visitor.AddVisitor; … … 28 29 */ 29 30 private final OsmPrimitive osm; 31 32 private DataSet ds; 30 33 31 34 /** … … 34 37 public AddCommand(OsmPrimitive osm) { 35 38 this.osm = osm; 39 this.ds = Main.ds; 36 40 } 37 41 38 42 @Override public void executeCommand() { 39 osm.visit(new AddVisitor( Main.ds));43 osm.visit(new AddVisitor(ds)); 40 44 } 41 45 42 46 @Override public void undoCommand() { 43 osm.visit(new DeleteVisitor( Main.ds));47 osm.visit(new DeleteVisitor(ds)); 44 48 } 45 49 -
src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r298 r301 19 19 import org.openstreetmap.josm.command.Command; 20 20 import org.openstreetmap.josm.gui.MapFrame; 21 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;22 import org.openstreetmap.josm.gui.layer.Layer;23 import org.openstreetmap.josm.gui.layer.OsmDataLayer;24 21 import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener; 25 22 … … 31 28 public CommandStackDialog(final MapFrame mapFrame) { 32 29 super(tr("Command Stack"), "commandstack", tr("Open a list of all commands (undo buffer)."), KeyEvent.VK_O, 100); 33 mapFrame.mapView.addLayerChangeListener(new LayerChangeListener(){ 34 public void activeLayerChange(Layer oldLayer, Layer newLayer) {} 35 public void layerAdded(Layer newLayer) { 36 if (newLayer instanceof OsmDataLayer) 37 Main.main.editLayer().listenerCommands.add(CommandStackDialog.this); 38 } 39 public void layerRemoved(Layer oldLayer) { 40 if (oldLayer instanceof OsmDataLayer) 41 Main.main.editLayer().listenerCommands.remove(CommandStackDialog.this); 42 } 43 }); 44 if (mapFrame.mapView.editLayer != null) 45 mapFrame.mapView.editLayer.listenerCommands.add(this); 30 Main.main.undoRedo.listenerCommands.add(this); 46 31 47 32 tree.setRootVisible(false); … … 75 60 if (Main.map == null || Main.map.mapView == null || Main.map.mapView.editLayer == null) 76 61 return; 77 Collection<Command> commands = Main.main. editLayer().commands;62 Collection<Command> commands = Main.main.undoRedo.commands; 78 63 DefaultMutableTreeNode root = new DefaultMutableTreeNode(); 79 64 for (Command c : commands) -
src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r298 r301 120 120 if (answer != JOptionPane.OK_OPTION) 121 121 return; 122 Main.main. editLayer().add(new ConflictResolveCommand(resolver.conflicts, sel));122 Main.main.undoRedo.add(new ConflictResolveCommand(resolver.conflicts, sel)); 123 123 Main.map.mapView.repaint(); 124 124 } -
src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r298 r301 157 157 } 158 158 if (key.equals(newkey) || value == null) 159 Main.main. editLayer().add(new ChangePropertyCommand(sel, newkey, value));159 Main.main.undoRedo.add(new ChangePropertyCommand(sel, newkey, value)); 160 160 else { 161 Main.main. editLayer().add(new SequenceCommand(trn("Change properties of {0} object", "Change properties of {0} objects", sel.size(), sel.size()),161 Main.main.undoRedo.add(new SequenceCommand(trn("Change properties of {0} object", "Change properties of {0} objects", sel.size(), sel.size()), 162 162 new ChangePropertyCommand(sel, key, null), 163 163 new ChangePropertyCommand(sel, newkey, value))); … … 239 239 if (value.equals("")) 240 240 return; 241 Main.main. editLayer().add(new ChangePropertyCommand(sel, key, value));241 Main.main.undoRedo.add(new ChangePropertyCommand(sel, key, value)); 242 242 selectionChanged(sel); // update table 243 243 Main.parent.repaint(); // repaint all - drawing could have been changed … … 251 251 String key = data.getValueAt(row, 0).toString(); 252 252 Collection<OsmPrimitive> sel = Main.ds.getSelected(); 253 Main.main. editLayer().add(new ChangePropertyCommand(sel, key, null));253 Main.main.undoRedo.add(new ChangePropertyCommand(sel, key, null)); 254 254 selectionChanged(sel); // update table 255 255 } -
src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r298 r301 17 17 import java.util.LinkedList; 18 18 import java.util.Set; 19 import java.util.Stack;20 19 21 20 import javax.swing.Icon; … … 31 30 import org.openstreetmap.josm.actions.SaveAction; 32 31 import org.openstreetmap.josm.actions.SaveAsAction; 33 import org.openstreetmap.josm.command.Command;34 32 import org.openstreetmap.josm.data.coor.EastNorth; 35 33 import org.openstreetmap.josm.data.osm.DataSet; … … 107 105 */ 108 106 private boolean fromDisk = false; 109 /**110 * All commands that were made on the dataset. Don't write from outside!111 */112 public final LinkedList<Command> commands = new LinkedList<Command>();113 /**114 * The stack for redoing commands115 */116 private final Stack<Command> redoCommands = new Stack<Command>();117 107 118 108 public final LinkedList<ModifiedChangedListener> listenerModified = new LinkedList<ModifiedChangedListener>(); 119 public final LinkedList<CommandQueueListener> listenerCommands = new LinkedList<CommandQueueListener>();120 109 121 110 private SimplePaintVisitor mapPainter = new SimplePaintVisitor(); … … 209 198 210 199 /** 211 * Execute the command and add it to the intern command queue. Also mark all212 * primitives in the command as modified.213 */214 public void add(final Command c) {215 c.executeCommand();216 commands.add(c);217 redoCommands.clear();218 setModified(true);219 fireCommandsChanged();220 }221 222 /**223 * Undoes the last added command.224 * TODO: This has to be moved to a central place in order to support multiple layers.225 */226 public void undo() {227 if (commands.isEmpty())228 return;229 final Command c = commands.removeLast();230 c.undoCommand();231 redoCommands.push(c);232 setModified(uploadedModified || !commands.isEmpty());233 Main.ds.setSelected();234 fireCommandsChanged();235 }236 /**237 * Redoes the last undoed command.238 * TODO: This has to be moved to a central place in order to support multiple layers.239 */240 public void redo() {241 if (redoCommands.isEmpty())242 return;243 final Command c = redoCommands.pop();244 c.executeCommand();245 commands.add(c);246 setModified(true);247 fireCommandsChanged();248 }249 250 /**251 200 * Clean out the data behind the layer. This means clearing the redo/undo lists, 252 201 * really deleting all deleted objects and reset the modified flags. This is done … … 264 213 return; 265 214 266 redoCommands.clear(); 267 commands.clear(); 215 Main.main.undoRedo.clean(); 268 216 269 217 // if uploaded, clean the modified flags as well … … 285 233 uploadedModified = fromDisk && processed != null && dataAdded; 286 234 setModified(uploadedModified); 287 fireCommandsChanged();288 }289 290 public void fireCommandsChanged() {291 for (final CommandQueueListener l : listenerCommands)292 l.commandChanged(commands.size(), redoCommands.size());293 235 } 294 236 -
src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r298 r301 285 285 Command cmd = createCommand(Main.ds.getSelected()); 286 286 if (cmd != null) 287 Main.main. editLayer().add(cmd);287 Main.main.undoRedo.add(cmd); 288 288 } 289 289 Main.ds.setSelected(Main.ds.getSelected()); // force update -
src/org/openstreetmap/josm/io/IncompleteDownloader.java
r298 r301 77 77 } 78 78 if (cmds.size() > 0) 79 Main.main. editLayer().add(new SequenceCommand(tr("Fix data errors"), cmds));79 Main.main.undoRedo.add(new SequenceCommand(tr("Fix data errors"), cmds)); 80 80 } 81 81
Note:
See TracChangeset
for help on using the changeset viewer.