Changeset 9266 in josm for trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
- Timestamp:
- 2016-01-02T18:51:06+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r9231 r9266 296 296 } 297 297 298 /** 299 * Determines whether a dialog can be shown for this preset, i.e., at least one tag can/must be set by the user. 300 * 301 * @return {@code true} if a dialog can be shown for this preset 302 */ 298 303 public boolean isShowable() { 299 304 for (TaggingPresetItem i : data) { … … 503 508 } 504 509 505 @Override 510 /** 511 * Determines whether this preset matches the given primitive, i.e., 512 * whether the {@link #typeMatches(Collection) type matches} and the {@link TaggingPresetItem#matches(Map) tags match}. 513 * 514 * @param p the primitive 515 * @return {@code true} if this preset matches the primitive 516 */ 517 @Override 506 518 public boolean evaluate(OsmPrimitive p) { 507 519 return matches(EnumSet.of(TaggingPresetType.forPrimitive(p)), p.getKeys(), false); 508 520 } 509 521 522 /** 523 * Determines whether this preset matches the parameters. 524 * 525 * @param t the preset types to include, see {@link #typeMatches(Collection)} 526 * @param tags the tags to perform matching on, see {@link TaggingPresetItem#matches(Map)} 527 * @param onlyShowable whether the preset must be {@link #isShowable() showable} 528 * @return {@code true} if this preset matches the parameters. 529 */ 510 530 public boolean matches(Collection<TaggingPresetType> t, Map<String, String> tags, boolean onlyShowable) { 511 531 if (onlyShowable && !isShowable()) … … 525 545 } 526 546 527 public static Collection<TaggingPreset> getMatchingPresets(final Collection<TaggingPresetType> t,528 final Map<String, String> tags, final boolean onlyShowable) {529 return Utils.filter(TaggingPresets.getTaggingPresets(), new Predicate<TaggingPreset>() {530 @Override531 public boolean evaluate(TaggingPreset object) {532 return object.matches(t, tags, onlyShowable);533 }534 });535 }536 537 547 /** 538 548 * Action that adds or removes the button on main toolbar
Note:
See TracChangeset
for help on using the changeset viewer.