Changeset 32 in josm for src/org/openstreetmap/josm/command


Ignore:
Timestamp:
2005-12-19T22:58:10+01:00 (20 years ago)
Author:
imi
Message:
  • Fixed bugs in reading/writing
  • Added correct extension filter to load/save
  • Delete now moves to deleted. modified flag reintroduced
Location:
src/org/openstreetmap/josm/command
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/command/ChangeKeyValueCommand.java

    r31 r32  
    3838         */
    3939        private List<Map<Key, String>> oldProperties;
     40       
     41        /**
     42         * These are the old modified states of the data.
     43         */
     44        private List<Boolean> oldModified = new LinkedList<Boolean>();
    4045
    4146        public ChangeKeyValueCommand(Collection<OsmPrimitive> objects, Key key, String value) {
     
    4853                // save old
    4954                oldProperties = new LinkedList<Map<Key, String>>();
    50                 for (OsmPrimitive osm : objects)
     55                for (OsmPrimitive osm : objects) {
    5156                        oldProperties.add(osm.keys == null ? null : new HashMap<Key, String>(osm.keys));
     57                        oldModified.add(osm.modified);
     58                }
    5259                       
    5360                if (value == null) {
     
    7077        public void undoCommand() {
    7178                Iterator<Map<Key, String>> it = oldProperties.iterator();
    72                 for (OsmPrimitive osm : objects)
     79                Iterator<Boolean> itMod = oldModified.iterator();
     80                for (OsmPrimitive osm : objects) {
    7381                        osm.keys = it.next();
     82                        osm.modified = itMod.next();
     83                }
    7484        }
    7585
  • src/org/openstreetmap/josm/command/MoveCommand.java

    r31 r32  
    11package org.openstreetmap.josm.command;
    22
    3 import java.awt.geom.Point2D;
    43import java.util.Collection;
    54import java.util.Iterator;
     
    3332
    3433        /**
    35          * x/y List of all old positions of the objects.
     34         * Small helper for holding the interesting part of the old data state of the
     35         * objects.
     36         * @author imi
    3637         */
    37         private List<Point2D.Double> oldPositions = new LinkedList<Point2D.Double>();
     38        class OldState
     39        {
     40                double x,y;
     41                boolean modified;
     42        }
     43        /**
     44         * List of all old states of the objects.
     45         */
     46        private List<OldState> oldState = new LinkedList<OldState>();
    3847
    3948        /**
     
    4453                this.y = y;
    4554                this.objects = getAffectedNodes(objects);
    46                 for (Node n : this.objects)
    47                         oldPositions.add(new Point2D.Double(n.coor.x, n.coor.y));
     55                for (Node n : this.objects) {
     56                        OldState os = new OldState();
     57                        os.x = n.coor.x;
     58                        os.y = n.coor.y;
     59                        os.modified = n.modified;
     60                        oldState.add(os);
     61                }
    4862        }
    4963
     
    8094                        n.coor.x += x;
    8195                        n.coor.y += y;
     96                        n.modified = true;
    8297                }
    8398        }
    8499
    85100        public void undoCommand() {
    86                 Iterator<Point2D.Double> it = oldPositions.iterator();
     101                Iterator<OldState> it = oldState.iterator();
    87102                for (Node n : objects) {
    88                         Point2D.Double p = it.next();
    89                         n.coor.x = p.x;
    90                         n.coor.y = p.y;
     103                        OldState os = it.next();
     104                        n.coor.x = os.x;
     105                        n.coor.y = os.y;
     106                        n.modified = os.modified;
    91107                }
    92108        }
Note: See TracChangeset for help on using the changeset viewer.