Changeset 23837 in osm for applications/editors


Ignore:
Timestamp:
2010-10-26T01:12:25+02:00 (14 years ago)
Author:
oliverw
Message:

Put changes in undo/redo queue.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/AddressEdit/src/org/openstreetmap/josm/plugins/addressEdit/AddressNode.java

    r23836 r23837  
    1414package org.openstreetmap.josm.plugins.addressEdit;
    1515
     16import org.openstreetmap.josm.Main;
     17import org.openstreetmap.josm.command.ChangeCommand;
     18import org.openstreetmap.josm.data.osm.Node;
    1619import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1720
     
    149152                if (streetName != null && streetName.length() == 0) return;
    150153               
    151                 this.osmObject.put(TagUtils.ADDR_STREET_TAG, streetName);
    152                 this.osmObject.setModified(true);
    153         }
     154                changeAddressValue(TagUtils.ADDR_STREET_TAG, streetName);
     155        }
     156
    154157       
    155158        /**
     
    160163                if (state != null && state.length() == 0) return;
    161164               
    162                 this.osmObject.put(TagUtils.ADDR_STATE_TAG, state);
    163                 this.osmObject.setModified(true);
     165                changeAddressValue(TagUtils.ADDR_STATE_TAG, state);
    164166        }
    165167       
     
    171173                if (country != null && country.length() == 0) return;
    172174               
    173                 this.osmObject.put(TagUtils.ADDR_COUNTRY_TAG, country);
    174                 this.osmObject.setModified(true);
     175                changeAddressValue(TagUtils.ADDR_COUNTRY_TAG, country);
    175176        }
    176177       
     
    182183                if (postCode != null && postCode.length() == 0) return;
    183184               
    184                 this.osmObject.put(TagUtils.ADDR_POSTCODE_TAG, postCode);
    185                 this.osmObject.setModified(true);
    186         }
     185                changeAddressValue(TagUtils.ADDR_POSTCODE_TAG, postCode);
     186        }
     187       
     188        /**
     189         * Internal helper method which changes the given property and
     190         * puts the appropriate command {@link src.org.openstreetmap.josm.command.Command}
     191         * into the undo/redo queue.
     192         * @param tag The tag to change.
     193         * @param newValue The new value for the tag.
     194         */
     195        private void changeAddressValue(String tag, String newValue) {
     196                Node oldNode = (Node)osmObject;
     197                OsmPrimitive newNode = new Node(oldNode);
     198                newNode.put(tag, newValue);
     199                Main.main.undoRedo.add( new ChangeCommand(oldNode, newNode));
     200        }
     201
    187202
    188203        @Override
Note: See TracChangeset for help on using the changeset viewer.