Changeset 7207 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2014-06-02T14:45:10+02:00 (10 years ago)
Author:
akks
Message:

see #10092: preset filtering did not work correctly for closed ways

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetSelector.java

    r7153 r7207  
    341341            presetClassification.classification = 0;
    342342
    343             if (onlyApplicable && !preset.typeMatches(getTypesInSelection())) {
    344                 final Predicate<Role> memberExpressionMatchesOnePrimitive = new Predicate<Role>() {
    345                     @Override
    346                     public boolean evaluate(Role object) {
    347                         return object.memberExpression != null && Utils.exists(Main.main.getCurrentDataSet().getSelected(), object.memberExpression);
    348                     }
    349                 };
    350                 if (preset.types.contains(TaggingPresetType.RELATION) && preset.roles != null
    351                         && Utils.exists(preset.roles.roles, memberExpressionMatchesOnePrimitive)) {
    352                     // keep to allow the creation of new relations
    353                 } else {
     343            if (onlyApplicable) {
     344                boolean suitable = preset.typeMatches(getTypesInSelection());
     345
     346                if (!suitable && preset.types.contains(TaggingPresetType.RELATION) && preset.roles != null) {
     347                    final Predicate<Role> memberExpressionMatchesOnePrimitive = new Predicate<Role>() {
     348                        final Collection<OsmPrimitive> selected = Main.main.getCurrentDataSet().getSelected();
     349                        @Override public boolean evaluate(Role object) {
     350                            return object.memberExpression != null
     351                                    && Utils.exists(selected, object.memberExpression);
     352                        }
     353                    };
     354                    suitable = Utils.exists(preset.roles.roles, memberExpressionMatchesOnePrimitive);
     355                    // keep the preset to allow the creation of new relations
     356                }
     357                if (!suitable) {
    354358                    continue;
    355359                }
     
    400404                        typesInSelection.add(TaggingPresetType.NODE);
    401405                    } else if (primitive instanceof Way) {
    402                         typesInSelection.add(TaggingPresetType.WAY);
    403406                        if (((Way) primitive).isClosed()) {
    404407                            typesInSelection.add(TaggingPresetType.CLOSEDWAY);
     408                        } else {
     409                            // closedway is not a way for preset checking, the types are mutually exclusive
     410                            typesInSelection.add(TaggingPresetType.WAY);
    405411                        }
    406412                    } else if (primitive instanceof Relation) {
Note: See TracChangeset for help on using the changeset viewer.