Changeset 9266 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-01-02T18:51:06+01:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PresetListPanel.java
r9243 r9266 17 17 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetLabel; 18 18 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 19 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 19 20 import org.openstreetmap.josm.tools.GBC; 20 21 … … 47 48 } 48 49 49 for (final TaggingPreset t : TaggingPreset .getMatchingPresets(types, tags, true)) {50 for (final TaggingPreset t : TaggingPresets.getMatchingPresets(types, tags, true)) { 50 51 final JLabel lbl = new TaggingPresetLabel(t); 51 52 lbl.addMouseListener(new MouseAdapter() { -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
r9263 r9266 74 74 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager; 75 75 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 76 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 76 77 import org.openstreetmap.josm.gui.util.GuiHelper; 77 78 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; … … 739 740 Map<String, String> map = new HashMap<>(); 740 741 map.put(t.getKey(), t.getValue()); 741 for (TaggingPreset tp : TaggingPreset .getMatchingPresets(null, map, false)) {742 for (TaggingPreset tp : TaggingPresets.getMatchingPresets(null, map, false)) { 742 743 icon = tp.getIcon(); 743 744 if (icon != null) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r9078 r9266 86 86 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 87 87 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 88 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 88 89 import org.openstreetmap.josm.io.OnlineResource; 89 90 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 763 764 CheckParameterUtil.ensureParameterNotNull(orig, "orig"); 764 765 try { 765 final Collection<TaggingPreset> presets = TaggingPreset .getMatchingPresets(766 final Collection<TaggingPreset> presets = TaggingPresets.getMatchingPresets( 766 767 EnumSet.of(TaggingPresetType.RELATION), orig.getKeys(), false); 767 768 Relation relation = new Relation(orig); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r9246 r9266 42 42 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 43 43 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType; 44 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 44 45 import org.openstreetmap.josm.gui.util.GuiHelper; 45 46 import org.openstreetmap.josm.gui.widgets.OsmPrimitivesTableModel; … … 422 423 423 424 private void addMembersAtIndex(List<? extends OsmPrimitive> primitives, int index) { 424 final Collection<TaggingPreset> presets = TaggingPreset .getMatchingPresets(EnumSet.of(TaggingPresetType.RELATION),425 final Collection<TaggingPreset> presets = TaggingPresets.getMatchingPresets(EnumSet.of(TaggingPresetType.RELATION), 425 426 presetHandler.getSelection().iterator().next().getKeys(), false); 426 427 if (primitives == null) -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionManager.java
r8863 r9266 30 30 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 31 31 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 32 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets; 32 33 import org.openstreetmap.josm.gui.tagging.presets.items.CheckGroup; 33 34 import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem; … … 335 336 public void populateWithMemberRoles(AutoCompletionList list, Relation r) { 336 337 CheckParameterUtil.ensureParameterNotNull(list, "list"); 337 Collection<TaggingPreset> presets = r != null ? TaggingPreset .getMatchingPresets(null, r.getKeys(), false) : null;338 Collection<TaggingPreset> presets = r != null ? TaggingPresets.getMatchingPresets(null, r.getKeys(), false) : null; 338 339 if (r != null && presets != null && !presets.isEmpty()) { 339 340 for (TaggingPreset tp : presets) { -
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 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java
r9265 r9266 96 96 } 97 97 98 /** 99 * Replies a new collection of all presets matching the parameters. 100 * 101 * @param t the preset types to include 102 * @param tags the tags to perform matching on, see {@link TaggingPresetItem#matches(Map)} 103 * @param onlyShowable whether only {@link TaggingPreset#isShowable() showable} presets should be returned 104 * @return a new collection of all presets matching the parameters. 105 * @see TaggingPreset#matches(Collection, Map, boolean) 106 * @since 9266 107 */ 108 public static Collection<TaggingPreset> getMatchingPresets(final Collection<TaggingPresetType> t, 109 final Map<String, String> tags, final boolean onlyShowable) { 110 return Utils.filter(getTaggingPresets(), new Predicate<TaggingPreset>() { 111 @Override 112 public boolean evaluate(TaggingPreset object) { 113 return object.matches(t, tags, onlyShowable); 114 } 115 }); 116 } 117 118 /** 119 * Replies a new collection of all presets matching the given preset. 120 * 121 * @param primitive the primitive 122 * @return a new collection of all presets matching the given preset. 123 * @see TaggingPreset#evaluate(OsmPrimitive) 124 * @since 9265 125 */ 98 126 public static Collection<TaggingPreset> getMatchingPresets(final OsmPrimitive primitive) { 99 127 return Utils.filter(getTaggingPresets(), new Predicate<TaggingPreset>() {
Note:
See TracChangeset
for help on using the changeset viewer.