Ignore:
Timestamp:
2008-04-26T01:23:21+02:00 (16 years ago)
Author:
framm
Message:
  • fix changing of keys when multiple objects selected, patch by Michael Bergbauer <michael@…>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r611 r621  
    4747import org.openstreetmap.josm.Main;
    4848import org.openstreetmap.josm.command.ChangePropertyCommand;
     49import org.openstreetmap.josm.command.Command;
    4950import org.openstreetmap.josm.command.SequenceCommand;
    5051import org.openstreetmap.josm.data.SelectionChangedListener;
     
    203204
    204205                String value = values.getEditor().getItem().toString();
    205                 if (value.equals(tr("<different>")))
    206                         return;
    207206                if (value.equals(""))
    208207                        value = null; // delete the key
     
    215214                        Main.main.undoRedo.add(new ChangePropertyCommand(sel, newkey, value));
    216215                else {
    217                         Main.main.undoRedo.add(new SequenceCommand(trn("Change properties of {0} object", "Change properties of {0} objects", sel.size(), sel.size()),
    218                                         new ChangePropertyCommand(sel, key, null),
    219                                         new ChangePropertyCommand(sel, newkey, value)));
     216                        Collection<Command> commands=new Vector<Command>();
     217                        commands.add(new ChangePropertyCommand(sel, key, null));
     218                        if (value.equals(tr("<different>"))) {
     219                                HashMap<String, Vector<OsmPrimitive>> map=new HashMap<String, Vector<OsmPrimitive>>();
     220                                for (OsmPrimitive osm: sel) {
     221                                        String val=osm.keys.get(key);
     222                                        if (map.containsKey(val)) {
     223                                                map.get(val).add(osm);
     224                                        } else {
     225                                                Vector<OsmPrimitive> v = new Vector<OsmPrimitive>();
     226                                                v.add(osm);
     227                                                map.put(val, v);
     228                                        }
     229                                }
     230                                for (Entry<String, Vector<OsmPrimitive>> e: map.entrySet()) {
     231                                        commands.add(new ChangePropertyCommand(e.getValue(), newkey, e.getKey()));
     232                                }
     233                        } else {
     234                                commands.add(new ChangePropertyCommand(sel, newkey, value));
     235                        }
     236                        Main.main.undoRedo.add(new SequenceCommand(trn("Change properties of {0} objects", "Change properties of {0} objects", sel.size(), sel.size()), commands));
    220237                }
    221238
     
    555572                        int count=0;
    556573                        for (Entry<String, Integer> e1: e.getValue().entrySet()) {
    557 //                              System.out.println(e.getKey()+" Entry "+e1.getKey()+" value "+e1.getValue());
    558574                                count+=e1.getValue();
    559575                        }
Note: See TracChangeset for help on using the changeset viewer.