Ignore:
Timestamp:
2009-09-12T16:39:20+02:00 (15 years ago)
Author:
Gubaer
Message:

added auto completion to combine way dialog
fixed #3461: Value selection in new "combine ways" gets hidden when not selected (now using a JComboBox as renderer)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r2095 r2099  
    104104    }
    105105
    106     protected void completeTagCollectionWithMissingTags(TagCollection tc, Collection<Way> combinedWays) {
     106    protected static void completeTagCollectionWithMissingTags(TagCollection tc, Collection<? extends OsmPrimitive> merged) {
     107        for (String key: tc.getKeys()) {
     108            // make sure the empty value is in the tag set if a tag is not present
     109            // on all merged nodes
     110            //
     111            for (OsmPrimitive p: merged) {
     112                if (p.get(key) == null) {
     113                    tc.add(new Tag(key)); // add a tag with key and empty value
     114                }
     115            }
     116        }
     117        // remove irrelevant tags
     118        //
     119        tc.removeByKey("created_by");
     120    }
     121
     122    protected static void completeTagCollectionForEditing(TagCollection tc) {
    107123        for (String key: tc.getKeys()) {
    108124            // make sure the empty value is in the tag set such that we can delete the tag
     
    110126            //
    111127            tc.add(new Tag(key,""));
    112             for (Way w: combinedWays) {
    113                 if (w.get(key) == null) {
    114                     tc.add(new Tag(key)); // add a tag with key and empty value
    115                 }
    116             }
    117         }
    118         // remove irrelevant tags
    119         //
    120         tc.removeByKey("created_by");
     128        }
    121129    }
    122130
     
    165173        TagCollection completeWayTags = new TagCollection(wayTags);
    166174        completeTagCollectionWithMissingTags(completeWayTags, ways);
     175        TagCollection tagsToEdit = new TagCollection(completeWayTags);
     176        completeTagCollectionForEditing(tagsToEdit);
    167177
    168178        CombinePrimitiveResolverDialog dialog = CombinePrimitiveResolverDialog.getInstance();
    169         dialog.getTagConflictResolverModel().populate(completeWayTags);
     179        dialog.getTagConflictResolverModel().populate(tagsToEdit);
    170180        dialog.setTargetPrimitive(targetWay);
    171181        dialog.getRelationMemberConflictResolverModel().populate(
     
    177187        // resolve tag conflicts if necessary
    178188        //
    179         if (!wayTags.isApplicableToPrimitive() || !referringRelations.getRelations().isEmpty()) {
     189        if (!completeWayTags.isApplicableToPrimitive() || !referringRelations.getRelations().isEmpty()) {
    180190            dialog.setVisible(true);
    181191            if (dialog.isCancelled())
    182192                return;
    183193        }
    184 
    185 
    186194
    187195        LinkedList<Command> cmds = new LinkedList<Command>();
Note: See TracChangeset for help on using the changeset viewer.