Changeset 3640 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
- Timestamp:
- 2010-10-24T15:07:01+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r3561 r3640 54 54 import org.openstreetmap.josm.Main; 55 55 import org.openstreetmap.josm.actions.CopyAction; 56 import org.openstreetmap.josm.actions.PasteTagsAction.TagPaster; 56 57 import org.openstreetmap.josm.command.AddCommand; 57 58 import org.openstreetmap.josm.command.ChangeCommand; … … 132 133 @Override 133 134 public void updateTags(List<Tag> tags) { 134 Map<String, TagModel> modelTags = new HashMap<String, TagModel>(); 135 for (int i=0; i<tagEditorPanel.getModel().getRowCount(); i++) { 136 TagModel tagModel = tagEditorPanel.getModel().get(i); 137 modelTags.put(tagModel.getName(), tagModel); 138 } 139 for (Tag tag: tags) { 140 TagModel existing = modelTags.get(tag.getKey()); 141 142 if (tag.getValue().isEmpty()) { 143 if (existing != null) { 144 tagEditorPanel.getModel().delete(tag.getKey()); 145 } 146 } else { 147 if (existing != null) { 148 tagEditorPanel.getModel().updateTagValue(existing, tag.getValue()); 149 } else { 150 tagEditorPanel.getModel().add(tag.getKey(), tag.getValue()); 151 } 152 } 153 154 } 135 GenericRelationEditor.this.updateTags(tags); 155 136 } 156 137 … … 429 410 new PasteMembersAction(); 430 411 new CopyMembersAction(); 412 new PasteTagsAction(); 431 413 432 414 return pnl3; … … 650 632 } 651 633 634 protected void updateTags(List<Tag> tags) { 635 636 if (tags.isEmpty()) 637 return; 638 639 Map<String, TagModel> modelTags = new HashMap<String, TagModel>(); 640 for (int i=0; i<tagEditorPanel.getModel().getRowCount(); i++) { 641 TagModel tagModel = tagEditorPanel.getModel().get(i); 642 modelTags.put(tagModel.getName(), tagModel); 643 } 644 for (Tag tag: tags) { 645 TagModel existing = modelTags.get(tag.getKey()); 646 647 if (tag.getValue().isEmpty()) { 648 if (existing != null) { 649 tagEditorPanel.getModel().delete(tag.getKey()); 650 } 651 } else { 652 if (existing != null) { 653 tagEditorPanel.getModel().updateTagValue(existing, tag.getValue()); 654 } else { 655 tagEditorPanel.getModel().add(tag.getKey(), tag.getValue()); 656 } 657 } 658 659 } 660 } 661 652 662 static class AddAbortException extends Exception { 653 663 } … … 1565 1575 } 1566 1576 1577 class PasteTagsAction extends AbstractAction { 1578 1579 public PasteTagsAction() { 1580 registerCopyPasteAction(this, "PASTE_TAGS", Shortcut.registerShortcut("system:pastestyle", tr("Edit: {0}", tr("Paste Tags")), KeyEvent.VK_V, Shortcut.GROUP_MENU, Shortcut.SHIFT_DEFAULT).getKeyStroke()); 1581 } 1582 1583 @Override 1584 public void actionPerformed(ActionEvent e) { 1585 Relation relation = new Relation(); 1586 tagEditorPanel.getModel().applyToPrimitive(relation); 1587 TagPaster tagPaster = new TagPaster(Main.pasteBuffer.getDirectlyAdded(), Collections.<OsmPrimitive>singletonList(relation)); 1588 updateTags(tagPaster.execute()); 1589 } 1590 1591 } 1592 1567 1593 class MemberTableDblClickAdapter extends MouseAdapter { 1568 1594 @Override
Note:
See TracChangeset
for help on using the changeset viewer.