Changeset 18918 in josm
- Timestamp:
- 2023-12-19T17:09:19+01:00 (17 months ago)
- Location:
- trunk
- Files:
-
- 3 added
- 30 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/resources/data/defaultpresets.xml
r18897 r18918 1466 1466 <list_entry value="no" /> 1467 1467 </combo> 1468 <combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" /> 1468 <combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" regions="GB" /> 1469 1469 <combo key="kerb" text="Kerb" values="flush,lowered,no,raised,rolled,yes" values_context="kerb" /> 1470 1470 <combo key="supervised" text="Crossing attendant" delimiter="|" values="yes|no|06:00-20:00|Mo-Fr 09:00-18:00,Sa 08:00-14:00|May-Sep 09:30-12:30,14:15-19:30" values_i18n="false" values_sort="false" /> … … 1517 1517 </combo> 1518 1518 <reference ref="crossing_markings" /> 1519 <combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" values_searchable="true" /> 1519 <combo key="crossing_ref" text="Crossing type name (UK)" values="zebra,pelican,toucan,puffin,pegasus,tiger" values_searchable="true" regions="GB" /> 1520 1520 <combo key="kerb" text="Kerb" values="flush,lowered,no,raised,rolled,yes" values_context="kerb" /> 1521 1521 <combo key="supervised" text="Crossing attendant" delimiter="|" values="yes|no|06:00-20:00|Mo-Fr 09:00-18:00,Sa 08:00-14:00|May-Sep 09:30-12:30,14:15-19:30" values_i18n="false" values_sort="false" /> … … 7309 7309 <list_entry value="sculpture" short_description="A non figurative sculpture which does not match any of the other categories." /> 7310 7310 <list_entry value="cross" short_description="A cross-shaped memorial." /> 7311 <list_entry value="blue_plaque" short_description="A blue plaque commemorating a historical link to that location. (UK)" /> 7311 <list_entry value="blue_plaque" short_description="A blue plaque commemorating a historical link to that location. (UK)" regions="GB" /> 7312 7312 <list_entry value="obelisk" short_description="An obelisk." /> 7313 7313 <list_entry value="ghost_bike" short_description="A bicycle painted white permanently placed as memorial for a victim of a road accident (usually cyclists)." /> 7314 <list_entry value="stolperstein" short_description="10cm × 10cm brass plaque commemorating victims of Nazi persecution. (EU,RU)" /> 7314 <list_entry value="stolperstein" short_description="10cm × 10cm brass plaque commemorating victims of Nazi persecution. (EU,RU)" regions="EU,RU" /> 7315 7315 <list_entry value="bench" short_description="A bench placed in memory of someone or something; usually has a plaque, and sometimes a statue sitting on (part of) it." /> 7316 7316 </combo> … … 8262 8262 <check key="payment:laser" text="Laser" match="keyvalue" /> 8263 8263 <check key="payment:maestro" text="Maestro" match="keyvalue" /> 8264 <check key="payment:postfinance_card" text="PostFinance Card (ch)" match="keyvalue" /> 8264 <check key="payment:postfinance_card" text="PostFinance Card (ch)" match="keyvalue" region="CH" /> 8265 8265 <check key="payment:visa_debit" text="Visa Debit" match="keyvalue" /> 8266 8266 <check key="payment:visa_electron" text="Visa Electron" match="keyvalue" /> … … 8281 8281 <combo key="payment:electronic_purses" text="Electronic purses and Charge cards" values="yes,no" match="keyvalue" /> 8282 8282 <checkgroup columns="4"> 8283 <check key="payment:ep_avant" text="Avant (fi)" match="keyvalue" /> 8284 <check key="payment:ep_geldkarte" text="Geldkarte (de)" match="keyvalue" /> 8285 <check key="payment:ep_mep" text="Mep (pt)" match="keyvalue" /> 8286 <check key="payment:ep_minicash" text="Minicash (lu)" match="keyvalue" /> 8287 <check key="payment:ep_minipay" text="Minipay (it)" match="keyvalue" /> 8288 <check key="payment:ep_monedero4b" text="Mondero 4b (es)" match="keyvalue" /> 8283 <check key="payment:ep_avant" text="Avant (fi)" match="keyvalue" regions="FI" /> 8284 <check key="payment:ep_geldkarte" text="Geldkarte (de)" match="keyvalue" regions="DE" /> 8285 <check key="payment:ep_mep" text="Mep (pt)" match="keyvalue" regions="PT" /> 8286 <check key="payment:ep_minicash" text="Minicash (lu)" match="keyvalue" regions="LU" /> 8287 <check key="payment:ep_minipay" text="Minipay (it)" match="keyvalue" regions="IT" /> 8288 <check key="payment:ep_monedero4b" text="Mondero 4b (es)" match="keyvalue" regions="ES" /> 8289 8289 </checkgroup> 8290 8290 <space /> … … 9969 9969 <text key="destination" text="Name of river/lake/sea/ocean it runs into" /> 9970 9970 <text key="ref" text="Reference" /> 9971 <text key="ref:sandre" text="Reference Sandre (FR)" /> 9972 <text key="ref:fgkz" text="Reference FGKZ (DE)" /> 9973 <text key="ref:regine" text="Reference REGINE (NO)" /> 9974 <text key="ref:gnis" text="Reference GNIS (USA)" /> 9975 <text key="ref:gnbc" text="Reference GNBC (CA)" /> 9971 <text key="ref:sandre" text="Reference Sandre (FR)" regions="FR" /> 9972 <text key="ref:fgkz" text="Reference FGKZ (DE)" regions="DE" /> 9973 <text key="ref:regine" text="Reference REGINE (NO)" regions="NO" /> 9974 <text key="ref:gnis" text="Reference GNIS (USA)" regions="US" /> 9975 <text key="ref:gnbc" text="Reference GNBC (CA)" regions="CA" /> 9976 9976 <reference ref="wikipedia_wikidata" /> 9977 9977 </optional> -
trunk/resources/data/tagging-preset.xsd
r18812 r18918 107 107 <extension base="tns:group-parent"> 108 108 <attributeGroup ref="tns:attributes.name" /> 109 <attributeGroup ref="tns:attributes.regions"/> 109 110 </extension> 110 111 </complexContent> … … 122 123 <annotation> 123 124 <documentation> 124 Every item is one annotation set to select from. name is required, type and preset_name_label are recommended , icon and name_templateare optional attributes.125 Every item is one annotation set to select from. name is required, type and preset_name_label are recommended and icon, name_template, regions and exclude_regions are optional attributes. 125 126 </documentation> 126 127 </annotation> … … 135 136 <attributeGroup ref="tns:attributes.name" /> 136 137 <attributeGroup ref="tns:attributes.icon" /> 138 <attributeGroup ref="tns:attributes.regions"/> 137 139 <attribute name="type" type="string"> 138 140 <annotation> … … 365 367 <annotation> 366 368 <documentation><![CDATA[ 367 Used in <combo/> and <multiselect/>. More information see short_descriptions below. The attributes are value, display_value, short_description, icon andicon_size.369 Used in <combo/> and <multiselect/>. More information see short_descriptions below. The attributes are value, display_value, short_description, icon, icon_size, regions, and exclude_regions. 368 370 ]]></documentation> 369 371 </annotation> … … 379 381 </attribute> 380 382 <attributeGroup ref="tns:attributes.icon" /> 383 <attributeGroup ref="tns:attributes.regions"/> 381 384 <anyAttribute processContents="skip" /> 382 385 </complexType> … … 490 493 <attribute name="match" type="tns:match" /> 491 494 <attributeGroup ref="tns:attributes.icon" /> 495 <attributeGroup ref="tns:attributes.regions"/> 492 496 493 497 <attribute name="name" use="prohibited" /> … … 559 563 <annotation> 560 564 <documentation> 561 To specify possible roles of members in relations. The key attribute is required, text, requisite, count, type andmember_expression are optional.565 To specify possible roles of members in relations. The key attribute is required, text, requisite, count, type, member_expression, regions, and exclude_regions are optional. 562 566 </documentation> 563 567 </annotation> … … 575 579 <attribute name="member_expression" type="string" /> 576 580 <attribute name="regexp" type="boolean" /> 581 <attributeGroup ref="tns:attributes.regions"/> 577 582 <anyAttribute processContents="skip" /> 578 583 </complexType> … … 730 735 </attributeGroup> 731 736 737 <attributeGroup name="attributes.regions"> 738 <attribute name="regions" type="string"> 739 <annotation> 740 <documentation> 741 Comma separated list of countries this preset group or item is applicable for. If not specified, the preset is applicable for all countries. 742 </documentation> 743 </annotation> 744 </attribute> 745 <attribute name="exclude_regions" type="boolean"> 746 <annotation> 747 <documentation> 748 If true, invert the meaning of regions. 749 </documentation> 750 </annotation> 751 </attribute> 752 </attributeGroup> 753 732 754 </schema> -
trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java
r18801 r18918 36 36 /** 37 37 * Discouraged synonym for {@link #TRUE_VALUE} 38 * @deprecated since xxx, use {@link #TRUE_VALUE} instead.38 * @deprecated since 18801, use {@link #TRUE_VALUE} instead. 39 39 */ 40 40 @Deprecated … … 42 42 /** 43 43 * Discouraged synonym for {@link #FALSE_VALUE} 44 * @deprecated since xxx, use {@link #FALSE_VALUE} instead.44 * @deprecated since 18801, use {@link #FALSE_VALUE} instead. 45 45 */ 46 46 @Deprecated … … 48 48 /** 49 49 * Discouraged synonym for {@link #REVERSE_VALUE} 50 * @deprecated since xxx, use {@link #REVERSE_VALUE} instead.50 * @deprecated since 18801, use {@link #REVERSE_VALUE} instead. 51 51 */ 52 52 @Deprecated -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r18900 r18918 25 25 import java.util.Map; 26 26 import java.util.Map.Entry; 27 import java.util.Objects; 27 28 import java.util.OptionalInt; 28 29 import java.util.Set; … … 38 39 import org.openstreetmap.josm.command.Command; 39 40 import org.openstreetmap.josm.command.SequenceCommand; 41 import org.openstreetmap.josm.data.coor.LatLon; 40 42 import org.openstreetmap.josm.data.osm.AbstractPrimitive; 41 43 import org.openstreetmap.josm.data.osm.DataSet; 44 import org.openstreetmap.josm.data.osm.Node; 42 45 import org.openstreetmap.josm.data.osm.OsmPrimitive; 43 46 import org.openstreetmap.josm.data.osm.OsmUtils; … … 63 66 import org.openstreetmap.josm.gui.tagging.presets.items.Check; 64 67 import org.openstreetmap.josm.gui.tagging.presets.items.CheckGroup; 68 import org.openstreetmap.josm.gui.tagging.presets.items.ComboMultiSelect; 69 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 65 70 import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem; 71 import org.openstreetmap.josm.gui.tagging.presets.items.PresetListEntry; 72 import org.openstreetmap.josm.gui.tagging.presets.items.RegionSpecific; 66 73 import org.openstreetmap.josm.gui.widgets.EditableList; 67 74 import org.openstreetmap.josm.io.CachedFile; 68 75 import org.openstreetmap.josm.spi.preferences.Config; 69 76 import org.openstreetmap.josm.tools.GBC; 77 import org.openstreetmap.josm.tools.JosmRuntimeException; 70 78 import org.openstreetmap.josm.tools.Logging; 71 79 import org.openstreetmap.josm.tools.MultiMap; 80 import org.openstreetmap.josm.tools.Territories; 72 81 import org.openstreetmap.josm.tools.Utils; 73 82 … … 132 141 */ 133 142 public static final String PREF_CHECK_PRESETS_TYPES = PREFIX + ".checkPresetsTypes"; 143 public static final String PREF_CHECK_REGIONS = PREFIX + ".checkPresetsRegions"; 134 144 135 145 /** … … 160 170 */ 161 171 public static final String PREF_CHECK_PRESETS_TYPES_BEFORE_UPLOAD = PREF_CHECK_PRESETS_TYPES + BEFORE_UPLOAD; 172 public static final String PREF_CHECK_REGIONS_BEFORE_UPLOAD = PREF_CHECK_REGIONS + BEFORE_UPLOAD; 162 173 163 174 /** … … 176 187 protected boolean checkFixmes; 177 188 protected boolean checkPresetsTypes; 189 protected boolean checkRegions; 178 190 179 191 protected JCheckBox prefCheckKeys; … … 182 194 protected JCheckBox prefCheckFixmes; 183 195 protected JCheckBox prefCheckPresetsTypes; 196 protected JCheckBox prefCheckRegions; 184 197 185 198 protected JCheckBox prefCheckKeysBeforeUpload; … … 188 201 protected JCheckBox prefCheckFixmesBeforeUpload; 189 202 protected JCheckBox prefCheckPresetsTypesBeforeUpload; 203 protected JCheckBox prefCheckRegionsBeforeUpload; 190 204 191 205 // CHECKSTYLE.OFF: SingleSpaceSeparator … … 211 225 protected static final int MULTIPOLYGON_MAYBE_NO_AREA = 1220; 212 226 protected static final int MULTIPOLYGON_SAME_TAG_ON_OUTER = 1221; 227 protected static final int INVALID_REGION = 1222; 213 228 // CHECKSTYLE.ON: SingleSpaceSeparator 214 229 … … 560 575 * @return {@code true} if the given key is in internal presets 561 576 * @since 9023 562 * @deprecated Use {@link TaggingPresets#isKeyInPresets(String)} instead577 * @deprecated since 18281 -- use {@link TaggingPresets#isKeyInPresets(String)} instead 563 578 */ 564 579 @Deprecated … … 653 668 654 669 if (p instanceof Relation && p.hasTag("type", "multipolygon")) { 655 checkMultipolygonTags(p); 656 } 657 658 if (checkPresetsTypes) { 659 TagMap tags = p.getKeys(); 660 TaggingPresetType presetType = TaggingPresetType.forPrimitive(p); 661 EnumSet<TaggingPresetType> presetTypes = EnumSet.of(presetType); 662 663 Collection<TaggingPreset> matchingPresets = presetIndex.entrySet().stream() 670 checkMultipolygonTags(p); 671 } 672 673 final Collection<TaggingPreset> matchingPresets; 674 TagMap tags; 675 if (checkPresetsTypes || checkRegions) { 676 tags = p.getKeys(); 677 matchingPresets = presetIndex.entrySet().stream() 664 678 .filter(e -> TaggingPresetItem.matches(e.getValue(), tags)) 665 679 .map(Entry::getKey) 666 680 .collect(Collectors.toCollection(LinkedHashSet::new)); 667 Collection<TaggingPreset> matchingPresetsOK = matchingPresets.stream().filter( 668 tp -> tp.typeMatches(presetTypes)).collect(Collectors.toList()); 669 Collection<TaggingPreset> matchingPresetsKO = matchingPresets.stream().filter( 670 tp -> !tp.typeMatches(presetTypes)).collect(Collectors.toList()); 671 672 for (TaggingPreset tp : matchingPresetsKO) { 673 // Potential error, unless matching tags are all known by a supported preset 674 Map<String, String> matchingTags = tp.data.stream() 681 } else { 682 matchingPresets = null; 683 tags = null; 684 } 685 686 if (checkPresetsTypes) { 687 checkPresetsTypes(p, matchingPresets, tags); 688 } 689 690 if (checkRegions) { 691 checkRegions(p, matchingPresets); 692 } 693 } 694 695 /** 696 * Check that the primitive matches the preset types for the preset 697 * @param p The primitive to check 698 * @param matchingPresets The presets to go through 699 * @param tags Tags from the primitive to check 700 */ 701 private void checkPresetsTypes(OsmPrimitive p, Collection<TaggingPreset> matchingPresets, Map<String, String> tags) { 702 TaggingPresetType presetType = TaggingPresetType.forPrimitive(p); 703 EnumSet<TaggingPresetType> presetTypes = EnumSet.of(presetType); 704 705 Collection<TaggingPreset> matchingPresetsOK = matchingPresets.stream().filter( 706 tp -> tp.typeMatches(presetTypes)).collect(Collectors.toList()); 707 Collection<TaggingPreset> matchingPresetsKO = matchingPresets.stream().filter( 708 tp -> !tp.typeMatches(presetTypes)).collect(Collectors.toList()); 709 710 for (TaggingPreset tp : matchingPresetsKO) { 711 // Potential error, unless matching tags are all known by a supported preset 712 Map<String, String> matchingTags = tp.data.stream() 675 713 .filter(i -> Boolean.TRUE.equals(i.matches(tags))) 676 714 .filter(i -> i instanceof KeyedItem).map(i -> ((KeyedItem) i).key) 677 715 .collect(Collectors.toMap(k -> k, tags::get)); 678 if (matchingPresetsOK.stream().noneMatch( 679 tp2 -> matchingTags.entrySet().stream().allMatch( 680 e -> tp2.data.stream().anyMatch( 681 i -> i instanceof KeyedItem && ((KeyedItem) i).key.equals(e.getKey()))))) { 682 errors.add(TestError.builder(this, Severity.OTHER, INVALID_PRESETS_TYPE) 683 .message(tr("Object type not in preset"), 684 marktr("Object type {0} is not supported by tagging preset: {1}"), 685 tr(presetType.getName()), tp.getLocaleName()) 716 if (matchingPresetsOK.stream().noneMatch( 717 tp2 -> matchingTags.entrySet().stream().allMatch( 718 e -> tp2.data.stream().anyMatch( 719 i -> i instanceof KeyedItem && ((KeyedItem) i).key.equals(e.getKey()))))) { 720 errors.add(TestError.builder(this, Severity.OTHER, INVALID_PRESETS_TYPE) 721 .message(tr("Object type not in preset"), 722 marktr("Object type {0} is not supported by tagging preset: {1}"), 723 tr(presetType.getName()), tp.getLocaleName()) 724 .primitives(p) 725 .build()); 726 } 727 } 728 } 729 730 /** 731 * Check that the preset is valid for the region the primitive is in 732 * @param p The primitive to check 733 * @param matchingPresets The presets to check against 734 */ 735 private void checkRegions(OsmPrimitive p, Collection<TaggingPreset> matchingPresets) { 736 LatLon center; 737 if (p instanceof Node) { 738 center = ((Node) p).getCoor(); 739 } else { 740 center = p.getBBox().getCenter(); 741 } 742 for (TaggingPreset preset : matchingPresets) { 743 if (preset.regions() != null) { 744 boolean isInRegion = false; //true if the object is in an applicable region 745 for (String region : preset.regions()) { 746 if (Territories.isIso3166Code(region, center)) { //check if center of the object is in a region 747 isInRegion = true; 748 } 749 } 750 if (isInRegion == preset.exclude_regions()) { 751 errors.add(TestError.builder(this, Severity.WARNING, INVALID_REGION) 752 .message(tr("Invalid region for this preset"), 753 marktr("Preset {0} should not be applied in this region"), 754 preset.getLocaleName()) 686 755 .primitives(p) 687 756 .build()); 688 757 } 689 758 } 690 } 759 // Check the tags 760 tagCheck(preset, p, center, preset.data); 761 } 762 } 763 764 /** 765 * Perform the checks against a given preset value 766 * @param preset The originating preset (used for error creation) 767 * @param p The originating primitive (used for error creation) 768 * @param center The center of the primitive or other location of the primitive to check 769 * @param tagInformation The sub items for the preset 770 */ 771 private void tagCheck(TaggingPreset preset, OsmPrimitive p, LatLon center, List<? extends TaggingPresetItem> tagInformation) { 772 for (TaggingPresetItem item : tagInformation) { 773 if (item instanceof CheckGroup) { 774 tagCheckReal(preset, p, center, ((CheckGroup) item).checks); 775 } else if (item instanceof ComboMultiSelect) { 776 tagCheckReal(preset, p, center, ((ComboMultiSelect) item).presetListEntries()); 777 } 778 if (item instanceof RegionSpecific && ((RegionSpecific) item).regions() != null) { 779 tagCheckReal(preset, p, center, (RegionSpecific) item); 780 } 781 } 782 } 783 784 /** 785 * Perform the checks against a given preset value 786 * @param preset The originating preset (used for error creation) 787 * @param p The originating primitive (used for error creation) 788 * @param center The center of the primitive or other location of the primitive to check 789 * @param data The data for the region specific information 790 */ 791 private void tagCheckReal(TaggingPreset preset, OsmPrimitive p, LatLon center, List<? extends RegionSpecific> data) { 792 for (RegionSpecific regionSpecific : data) { 793 if (regionSpecific.regions() != null) { 794 tagCheckReal(preset, p, center, regionSpecific); 795 } 796 } 797 } 798 799 /** 800 * Perform the checks against a given preset value 801 * @param preset The originating preset (used for error creation) 802 * @param p The originating primitive (used for error creation) 803 * @param center The center of the primitive or other location of the primitive to check 804 * @param data The data for the region specific information 805 */ 806 private void tagCheckReal(TaggingPreset preset, OsmPrimitive p, LatLon center, RegionSpecific data) { 807 // First, check if we aren't in the region for the tag 808 if (latLonInRegions(center, data.regions()) == data.exclude_regions()) { 809 final String key; 810 final String value; 811 if (data instanceof PresetListEntry) { 812 key = ((PresetListEntry) data).cms.key; 813 value = ((PresetListEntry) data).value; 814 } else if (data instanceof KeyedItem) { 815 key = ((KeyedItem) data).key; 816 if (data instanceof Key) { 817 value = ((Key) data).value; 818 } else { 819 value = null; 820 } 821 } else { 822 throw new JosmRuntimeException("Unknown implementor for RegionSpecific"); 823 } 824 if (p.hasTag(key) && (value == null || value.equals(p.get(key)))) { 825 final TestError.Builder builder = TestError.builder(this, Severity.WARNING, INVALID_REGION) 826 .primitives(p); 827 if (value == null) { 828 builder.message(tr("Invalid region for this preset"), 829 marktr("Preset {0} should not have the key {1}"), 830 preset.getLocaleName(), key); 831 } else { 832 builder.message(tr("Invalid region for this preset"), 833 marktr("Preset {0} should not have the tag {1}={2}"), 834 preset.getLocaleName(), key, value); 835 } 836 errors.add(builder.build()); 837 } 838 } 839 } 840 841 /** 842 * Check if the specified latlon is inside any of the specified regions 843 * @param latLon The {@link LatLon} to check 844 * @param regions The regions to see if the {@link LatLon} is in 845 * @return {@code true} if the coordinate is inside any of the regions 846 */ 847 private static boolean latLonInRegions(LatLon latLon, Collection<String> regions) { 848 if (regions != null) { 849 for (String region : regions) { 850 if (Territories.isIso3166Code(region, latLon)) { 851 return true; 852 } 853 } 854 } 855 return false; 691 856 } 692 857 … … 916 1081 } 917 1082 918 if (!Utils.isEmpty(fixedKey) && !fixedKey .equals(key)) {1083 if (!Utils.isEmpty(fixedKey) && !Objects.equals(fixedKey, key)) { 919 1084 final String proposedKey = fixedKey; 920 1085 // misspelled preset key … … 1101 1266 checkPresetsTypes = checkPresetsTypes && Config.getPref().getBoolean(PREF_CHECK_PRESETS_TYPES_BEFORE_UPLOAD, true); 1102 1267 } 1268 1269 checkRegions = includeOtherSeverity && Config.getPref().getBoolean(PREF_CHECK_REGIONS, true); 1270 if (isBeforeUpload) { 1271 checkRegions = checkRegions && Config.getPref().getBoolean(PREF_CHECK_REGIONS_BEFORE_UPLOAD, true); 1272 } 1103 1273 deprecatedChecker = OsmValidator.getTest(MapCSSTagChecker.class); 1104 1274 ignoreForOuterMPSameTagCheck.addAll(Config.getPref().getList(PREF_KEYS_IGNORE_OUTER_MP_SAME_TAG, Collections.emptyList())); … … 1113 1283 @Override 1114 1284 public void visit(Collection<OsmPrimitive> selection) { 1115 if (checkKeys || checkValues || checkComplex || checkFixmes || checkPresetsTypes) { 1285 if (checkKeys || checkValues || checkComplex || checkFixmes || checkPresetsTypes || checkRegions) { 1116 1286 super.visit(selection); 1117 1287 } … … 1178 1348 prefCheckPresetsTypesBeforeUpload.setSelected(Config.getPref().getBoolean(PREF_CHECK_PRESETS_TYPES_BEFORE_UPLOAD, true)); 1179 1349 testPanel.add(prefCheckPresetsTypesBeforeUpload, a); 1350 1351 prefCheckRegions = new JCheckBox(tr("Check for regions."), Config.getPref().getBoolean(PREF_CHECK_REGIONS, true)); 1352 prefCheckRegions.setToolTipText(tr("Validate that objects are in the correct region.")); 1353 testPanel.add(prefCheckRegions, GBC.std().insets(20, 0, 0, 0)); 1354 1355 prefCheckRegionsBeforeUpload = new JCheckBox(); 1356 prefCheckRegionsBeforeUpload.setSelected(Config.getPref().getBoolean(PREF_CHECK_REGIONS_BEFORE_UPLOAD, true)); 1357 testPanel.add(prefCheckRegionsBeforeUpload, a); 1180 1358 } 1181 1359 … … 1200 1378 Config.getPref().putBoolean(PREF_CHECK_FIXMES, prefCheckFixmes.isSelected()); 1201 1379 Config.getPref().putBoolean(PREF_CHECK_PRESETS_TYPES, prefCheckPresetsTypes.isSelected()); 1380 Config.getPref().putBoolean(PREF_CHECK_REGIONS, prefCheckRegions.isSelected()); 1202 1381 Config.getPref().putBoolean(PREF_CHECK_VALUES_BEFORE_UPLOAD, prefCheckValuesBeforeUpload.isSelected()); 1203 1382 Config.getPref().putBoolean(PREF_CHECK_COMPLEX_BEFORE_UPLOAD, prefCheckComplexBeforeUpload.isSelected()); … … 1205 1384 Config.getPref().putBoolean(PREF_CHECK_FIXMES_BEFORE_UPLOAD, prefCheckFixmesBeforeUpload.isSelected()); 1206 1385 Config.getPref().putBoolean(PREF_CHECK_PRESETS_TYPES_BEFORE_UPLOAD, prefCheckPresetsTypesBeforeUpload.isSelected()); 1386 Config.getPref().putBoolean(PREF_CHECK_REGIONS_BEFORE_UPLOAD, prefCheckRegionsBeforeUpload.isSelected()); 1207 1387 return Config.getPref().putList(PREF_SOURCES, sourcesList.getItems()); 1208 1388 } -
trunk/src/org/openstreetmap/josm/gui/NoteInputDialog.java
r18839 r18918 53 53 * @param icon Icon to display in the action button 54 54 * @param text Default text of the note's comment 55 * @since xxx55 * @since 18839 56 56 */ 57 57 public void showNoteDialog(String message, Icon icon, String text) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/Environment.java
r18757 r18918 285 285 * @param selector The selector to use 286 286 * @return A clone of this environment, with the specified selector 287 * @since xxx287 * @since 18757 288 288 */ 289 289 public Environment withSelector(Selector selector) { … … 335 335 * Get the selector for this environment 336 336 * @return The selector. May be {@code null}. 337 * @since xxx337 * @since 18757 338 338 */ 339 339 public Selector selector() { -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/PlaceholderExpression.java
r18758 r18918 15 15 /** 16 16 * Used for expressions that contain placeholders 17 * @since xxx17 * @since 18758 18 18 */ 19 19 public final class PlaceholderExpression implements Expression { -
trunk/src/org/openstreetmap/josm/gui/oauth/TestAccessTokenTask.java
r18764 r18918 80 80 * @param parameters the OAuth parameters. Must not be null. 81 81 * @param accessToken the Access Token. Must not be null. 82 * @since xxx82 * @since 18764 83 83 */ 84 84 public TestAccessTokenTask(Component parent, String apiUrl, IOAuthParameters parameters, IOAuthToken accessToken) { -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPreset.java
r18866 r18918 68 68 import org.openstreetmap.josm.gui.tagging.presets.items.Roles; 69 69 import org.openstreetmap.josm.gui.tagging.presets.items.Space; 70 import org.openstreetmap.josm.gui.tagging.presets.items.RegionSpecific; 70 71 import org.openstreetmap.josm.gui.util.GuiHelper; 71 72 import org.openstreetmap.josm.tools.GBC; … … 89 90 * @since 294 90 91 */ 91 public class TaggingPreset extends AbstractAction implements ActiveLayerChangeListener, AdaptableAction, Predicate<IPrimitive> { 92 public class TaggingPreset extends AbstractAction implements ActiveLayerChangeListener, AdaptableAction, Predicate<IPrimitive>, 93 RegionSpecific { 92 94 93 95 /** The user pressed the "Apply" button */ … … 142 144 */ 143 145 public transient Set<TaggingPresetType> types; 146 /** 147 * List of regions the preset is applicable for. 148 */ 149 private Collection<String> regions; 150 /** 151 * If true, invert the meaning of regions. 152 */ 153 private boolean excludeRegions; 144 154 /** 145 155 * The list of preset items … … 350 360 } 351 361 362 @Override 363 public final Collection<String> regions() { 364 return this.regions != null || this.group == null ? this.regions : this.group.regions(); 365 } 366 367 @Override 368 public final void realSetRegions(Collection<String> regions) { 369 this.regions = regions; 370 } 371 372 @Override 373 public final boolean exclude_regions() { 374 return this.excludeRegions; 375 } 376 377 @Override 378 public final void setExclude_regions(boolean excludeRegions) { 379 this.excludeRegions = excludeRegions; 380 } 381 352 382 private static class PresetPanel extends JPanel { 353 383 private boolean hasElements; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetValidation.java
r18001 r18918 25 25 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 26 26 import org.openstreetmap.josm.data.validation.tests.OpeningHourTest; 27 import org.openstreetmap.josm.data.validation.tests.TagChecker; 27 28 import org.openstreetmap.josm.gui.MainApplication; 29 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 28 30 import org.openstreetmap.josm.gui.util.GuiHelper; 29 31 import org.openstreetmap.josm.tools.Logging; … … 56 58 MapCSSTagChecker mapCSSTagChecker = OsmValidator.getTest(MapCSSTagChecker.class); 57 59 OpeningHourTest openingHourTest = OsmValidator.getTest(OpeningHourTest.class); 58 OsmValidator.initializeTests(Arrays.asList(mapCSSTagChecker, openingHourTest)); 60 TagChecker tagChecker = OsmValidator.getTest(TagChecker.class); 61 tagChecker.startTest(NullProgressMonitor.INSTANCE); //since initializeTest works if test is enabled 62 OsmValidator.initializeTests(Arrays.asList(mapCSSTagChecker, openingHourTest, tagChecker)); 63 59 64 60 65 List<TestError> errors = new ArrayList<>(); 61 66 openingHourTest.addErrorsForPrimitive(primitive, errors); 62 67 errors.addAll(mapCSSTagChecker.getErrorsForPrimitive(primitive, ValidatorPrefHelper.PREF_OTHER.get())); 68 tagChecker.check(primitive); 69 errors.addAll(tagChecker.getErrors()); 63 70 64 71 boolean visible = !errors.isEmpty(); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
r18801 r18918 11 11 import java.util.Arrays; 12 12 import java.util.Collection; 13 import java.util.Collections; 13 14 import java.util.List; 14 15 import java.util.Map; … … 310 311 } 311 312 312 if (values_sort && TaggingPresets.SORT_MENU.get()) { 313 if (values_sort && Boolean.TRUE.equals(TaggingPresets.SORT_MENU.get())) { 313 314 presetListEntries.sort((a, b) -> AlphanumComparator.getInstance().compare(a.getDisplayValue(), b.getDisplayValue())); 314 315 } … … 341 342 initialValue = DIFFERENT; 342 343 originalValue = initialValue; 343 } else if (!usage.hadKeys() || isForceUseLastAsDefault() || PROP_FILL_DEFAULT.get()) { 344 } else if (!usage.hadKeys() || isForceUseLastAsDefault() || Boolean.TRUE.equals(PROP_FILL_DEFAULT.get())) { 344 345 // at this point no primitive had any value for this key 345 346 if (!support.isPresetInitiallyMatches() && isUseLastAsDefault() && LAST_VALUES.containsKey(key)) { … … 404 405 405 406 /** 407 * Get the entries for this {@link ComboMultiSelect} object 408 * @return The {@link PresetListEntry} values for this object 409 */ 410 public List<PresetListEntry> presetListEntries() { 411 return Collections.unmodifiableList(this.presetListEntries); 412 } 413 414 /** 406 415 * Adds a preset list entry. 407 416 * @param e list entry to add -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java
r18871 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 8 9 import java.util.HashMap; 9 10 import java.util.Map; 11 import java.util.NoSuchElementException; 10 12 import java.util.SortedMap; 11 import java.util.NoSuchElementException;12 13 import java.util.TreeMap; 13 14 … … 25 26 * Preset item associated to an OSM key. 26 27 */ 27 public abstract class KeyedItem extends TextItem { 28 public abstract class KeyedItem extends TextItem implements RegionSpecific { 28 29 29 30 /** The constant value {@code "<different>"}. */ 30 protected static final String DIFFERENT = "<different>"; 31 protected static final String DIFFERENT = marktr("<different>"); 31 32 /** Translation of {@code "<different>"}. */ 32 public static final String DIFFERENT_I18N = tr( "<different>");33 public static final String DIFFERENT_I18N = tr(DIFFERENT); 33 34 34 35 /** True if the default value should also be set on primitives that already have tags. */ … … 52 53 */ 53 54 public String match = getDefaultMatch().getValue(); // NOSONAR 55 56 /** 57 * List of regions the preset is applicable for. 58 */ 59 private Collection<String> regions; 60 /** 61 * If true, invert the meaning of regions. 62 */ 63 private boolean excludeRegions; 54 64 55 65 /** … … 262 272 263 273 @Override 274 public final Collection<String> regions() { 275 return this.regions; 276 } 277 278 @Override 279 public final void realSetRegions(Collection<String> regions) { 280 this.regions = regions; 281 } 282 283 @Override 284 public final boolean exclude_regions() { 285 return this.excludeRegions; 286 } 287 288 @Override 289 public final void setExclude_regions(boolean excludeRegions) { 290 this.excludeRegions = excludeRegions; 291 } 292 293 @Override 264 294 public String toString() { 265 295 return "KeyedItem [key=" + key + ", text=" + text -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/PresetListEntry.java
r18801 r18918 6 6 import static org.openstreetmap.josm.tools.I18n.trc; 7 7 8 import java.util.Collection; 8 9 import java.util.Objects; 9 10 … … 21 22 * {@link MultiSelect}. 22 23 */ 23 public class PresetListEntry implements Comparable<PresetListEntry> { 24 public class PresetListEntry implements Comparable<PresetListEntry>, RegionSpecific { 24 25 /** Used to display an entry matching several different values. */ 25 26 protected static final PresetListEntry ENTRY_DIFFERENT = new PresetListEntry(KeyedItem.DIFFERENT, null); … … 48 49 public String locale_short_description; // NOSONAR 49 50 51 /** 52 * List of regions the entry is applicable for. 53 */ 54 private Collection<String> regions; 55 56 /** 57 * If true, invert the meaning of regions. 58 */ 59 private boolean excludeRegions; 60 50 61 private String cachedDisplayValue; 51 62 private String cachedShortDescription; … … 54 65 /** 55 66 * Constructs a new {@code PresetListEntry}, uninitialized. 56 * 67 * <p> 57 68 * Public default constructor is needed by {@link org.openstreetmap.josm.tools.XmlObjectParser.Parser#startElement} 58 69 */ … … 74 85 /** 75 86 * Returns the contents displayed in the dropdown list. 76 * 87 * <p> 77 88 * This is the contents that would be displayed in the current view plus a short description to 78 89 * aid the user. The whole content is wrapped to {@code width}. … … 164 175 } 165 176 177 @Override 178 public Collection<String> regions() { 179 return this.regions; 180 } 181 182 @Override 183 public void realSetRegions(Collection<String> regions) { 184 this.regions = regions; 185 } 186 187 @Override 188 public boolean exclude_regions() { 189 return this.excludeRegions; 190 } 191 192 @Override 193 public void setExclude_regions(boolean excludeRegions) { 194 this.excludeRegions = excludeRegions; 195 } 196 166 197 // toString is mainly used to initialize the Editor 167 198 @Override -
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r18871 r18918 165 165 * @throws WMSGetCapabilitiesException when there are errors when parsing get capabilities document 166 166 * @throws InvalidPathException if a Path object cannot be constructed for the capabilities cached file 167 * @since xxx167 * @since 18780 168 168 */ 169 169 public WMSImagery(String url, Map<String, String> headers, ProgressMonitor monitor) -
trunk/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
r18870 r18918 225 225 assertEquals("Value 'Residential' for key 'highway' is unknown, maybe 'residential' is meant?", 226 226 errors.get(0).getDescription()); 227 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 228 assertFalse(errors.get(0).isFixable()); 229 } 230 231 @Test 232 void testRegionKey() throws IOException { 233 final List<TestError> errors = test(OsmUtils.createPrimitive("node highway=crossing crossing_ref=zebra")); 234 assertEquals(1, errors.size()); 235 assertEquals("Invalid region for this preset", errors.get(0).getMessage()); 236 assertEquals("Preset Pedestrian Crossing should not have the key crossing_ref", errors.get(0).getDescription()); 237 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 238 assertFalse(errors.get(0).isFixable()); 239 240 } 241 242 @Test 243 void testRegionTag() throws IOException { 244 final List<TestError> errors = test(OsmUtils.createPrimitive("relation type=waterway ref:gnis=123456")); 245 assertEquals(1, errors.size()); 246 assertEquals("Invalid region for this preset", errors.get(0).getMessage()); 247 assertEquals("Preset Waterway should not have the key ref:gnis", errors.get(0).getDescription()); 227 248 assertEquals(Severity.WARNING, errors.get(0).getSeverity()); 228 249 assertFalse(errors.get(0).isFixable()); -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckGroupTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 5 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 6 13 7 /** 14 8 * Unit tests of {@link CheckGroup} class. 15 9 */ 16 class CheckGroupTest { 17 /** 18 * Unit test for {@link CheckGroup#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 CheckGroup cg = new CheckGroup(); 23 JPanel p = new JPanel(); 24 assertEquals(0, p.getComponentCount()); 25 assertFalse(cg.addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 26 assertTrue(p.getComponentCount() > 0); 10 class CheckGroupTest implements TaggingPresetItemTest { 11 @Override 12 public TaggingPresetItem getInstance() { 13 return new CheckGroup(); 27 14 } 28 15 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckTest.java
r18870 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 import org.openstreetmap.josm.testutils.annotations.Main; 12 13 … … 15 16 */ 16 17 @Main 17 class CheckTest { 18 class CheckTest implements RegionSpecificTest, TaggingPresetItemTest { 19 @Override 20 public Check getInstance() { 21 final Check check = new Check(); 22 check.key = "crossing:island"; 23 return check; 24 } 25 18 26 /** 19 27 * Unit test for {@link Check#addToPanel}. 20 28 */ 29 @Override 21 30 @Test 22 void testAddToPanel() { 31 public void testAddToPanel() { 23 32 JPanel p = new JPanel(); 24 33 assertEquals(0, p.getComponentCount()); 25 assertTrue( new Check().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));34 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 26 35 assertTrue(p.getComponentCount() > 0); 27 36 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java
r18870 r18918 13 13 import org.openstreetmap.josm.data.osm.OsmUtils; 14 14 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 15 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 15 16 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 16 17 import org.openstreetmap.josm.testutils.annotations.I18n; … … 23 24 @I18n("de") 24 25 @Main 25 class ComboTest { 26 class ComboTest implements TaggingPresetItemTest { 27 @Override 28 public Combo getInstance() { 29 return new Combo(); 30 } 31 26 32 /** 27 * Unit test for {@link C ombo#addToPanel}.33 * Unit test for {@link Check#addToPanel}. 28 34 */ 35 @Override 29 36 @Test 30 void testAddToPanel() { 37 public void testAddToPanel() { 31 38 JPanel p = new JPanel(); 32 39 assertEquals(0, p.getComponentCount()); 33 assertTrue( new Combo().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));40 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 34 41 assertTrue(p.getComponentCount() > 0); 35 42 } … … 40 47 @Test 41 48 void testUseLastAsDefault() { 42 Combo combo = new Combo();49 final Combo combo = getInstance(); 43 50 combo.key = "addr:country"; 44 51 combo.values_from = "java.util.Locale#getISOCountries"; … … 119 126 @Test 120 127 void testColor() { 121 Combo combo = new Combo();128 final Combo combo = getInstance(); 122 129 combo.key = "colour"; 123 130 combo.values = "red;green;blue;black"; -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ItemSeparatorTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 5 13 6 /** 14 7 * Unit tests of {@link ItemSeparator} class. 15 8 */ 16 class ItemSeparatorTest { 17 /** 18 * Unit test for {@link ItemSeparator#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 JPanel p = new JPanel(); 23 assertEquals(0, p.getComponentCount()); 24 assertFalse(new ItemSeparator().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 25 assertTrue(p.getComponentCount() > 0); 9 class ItemSeparatorTest implements TaggingPresetItemTest { 10 @Override 11 public ItemSeparator getInstance() { 12 return new ItemSeparator(); 26 13 } 27 14 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/KeyTest.java
r18853 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 12 13 /** 13 14 * Unit tests of {@link Key} class. 14 15 */ 15 class KeyTest { 16 class KeyTest implements RegionSpecificTest, TaggingPresetItemTest { 17 @Override 18 public Key getInstance() { 19 final Key key = new Key(); 20 key.key = "highway"; 21 key.value = "residential"; 22 return key; 23 } 24 16 25 /** 17 26 * Unit test for {@link Key#addToPanel}. 18 27 */ 19 28 @Test 20 void testAddToPanel() { 29 @Override 30 public void testAddToPanel() { 21 31 JPanel p = new JPanel(); 22 32 assertEquals(0, p.getComponentCount()); -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/LabelTest.java
r18853 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 12 13 /** 13 14 * Unit tests of {@link Label} class. 14 15 */ 15 class LabelTest { 16 class LabelTest implements TaggingPresetItemTest { 17 @Override 18 public Label getInstance() { 19 return new Label(); 20 } 21 16 22 /** 17 * Unit test for {@link Label#addToPanel}.23 * Unit test for {@link Check#addToPanel}. 18 24 */ 25 @Override 19 26 @Test 20 void testAddToPanel() { 27 public void testAddToPanel() { 21 28 JPanel p = new JPanel(); 22 29 assertEquals(0, p.getComponentCount()); 23 assertTrue( new Label().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));30 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 24 31 assertTrue(p.getComponentCount() > 0); 25 32 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/LinkTest.java
r18853 r18918 10 10 import org.junit.jupiter.api.Test; 11 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 12 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 13 import org.openstreetmap.josm.spi.preferences.Config; 13 14 … … 15 16 * Unit tests of {@link Link} class. 16 17 */ 17 class LinkTest { 18 class LinkTest implements TaggingPresetItemTest { 19 @Override 20 public Link getInstance() { 21 return new Link(); 22 } 23 18 24 /** 19 25 * Unit test for {@link Link#addToPanel}. 20 26 */ 27 @Override 21 28 @Test 22 void testAddToPanel() { 23 Link l = new Link();29 public void testAddToPanel() { 30 Link l = getInstance(); 24 31 JPanel p = new JPanel(); 25 32 assertEquals(0, p.getComponentCount()); -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/MultiSelectTest.java
r18870 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 import org.openstreetmap.josm.testutils.annotations.Main; 12 13 … … 15 16 */ 16 17 @Main 17 class MultiSelectTest { 18 class MultiSelectTest implements TaggingPresetItemTest { 19 @Override 20 public MultiSelect getInstance() { 21 return new MultiSelect(); 22 } 23 18 24 /** 19 * Unit test for {@link MultiSelect#addToPanel}.25 * Unit test for {@link Check#addToPanel}. 20 26 */ 27 @Override 21 28 @Test 22 void testAddToPanel() { 29 public void testAddToPanel() { 23 30 JPanel p = new JPanel(); 24 31 assertEquals(0, p.getComponentCount()); 25 assertTrue( new MultiSelect().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));32 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 26 33 assertTrue(p.getComponentCount() > 0); 27 34 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/OptionalTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 5 13 6 /** 14 7 * Unit tests of {@link Optional} class. 15 8 */ 16 class OptionalTest { 17 /** 18 * Unit test for {@link Optional#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 JPanel p = new JPanel(); 23 assertEquals(0, p.getComponentCount()); 24 assertFalse(new Optional().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 25 assertTrue(p.getComponentCount() > 0); 9 class OptionalTest implements TaggingPresetItemTest { 10 @Override 11 public Optional getInstance() { 12 return new Optional(); 26 13 } 27 14 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/PresetLinkTest.java
r18870 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 5 import org.openstreetmap.josm.testutils.annotations.TaggingPresets; 13 6 … … 16 9 */ 17 10 @TaggingPresets 18 class PresetLinkTest { 19 /** 20 * Unit test for {@link PresetLink#addToPanel}. 21 */ 22 @Test 23 void testAddToPanel() { 24 PresetLink l = new PresetLink(); 25 l.preset_name = "River"; 26 JPanel p = new JPanel(); 27 assertEquals(0, p.getComponentCount()); 28 assertFalse(l.addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 29 assertTrue(p.getComponentCount() > 0); 11 class PresetLinkTest implements TaggingPresetItemTest { 12 @Override 13 public PresetLink getInstance() { 14 PresetLink presetLink = new PresetLink(); 15 presetLink.preset_name = "River"; 16 return presetLink; 30 17 } 31 18 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/RolesTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem; 5 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 6 13 7 /** 14 8 * Unit tests of {@link Roles} class. 15 9 */ 16 class RolesTest { 17 /** 18 * Unit test for {@link Roles#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 JPanel p = new JPanel(); 23 assertEquals(0, p.getComponentCount()); 24 assertFalse(new Roles().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 25 assertTrue(p.getComponentCount() > 0); 10 class RolesTest implements TaggingPresetItemTest { 11 @Override 12 public TaggingPresetItem getInstance() { 13 return new Roles(); 26 14 } 27 15 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/SpaceTest.java
r18853 r18918 2 2 package org.openstreetmap.josm.gui.tagging.presets.items; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 8 import javax.swing.JPanel; 9 10 import org.junit.jupiter.api.Test; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 4 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 12 5 13 6 /** 14 7 * Unit tests of {@link Space} class. 15 8 */ 16 class SpaceTest { 17 /** 18 * Unit test for {@link Space#addToPanel}. 19 */ 20 @Test 21 void testAddToPanel() { 22 JPanel p = new JPanel(); 23 assertEquals(0, p.getComponentCount()); 24 assertFalse(new Space().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 25 assertTrue(p.getComponentCount() > 0); 9 class SpaceTest implements TaggingPresetItemTest { 10 @Override 11 public Space getInstance() { 12 return new Space(); 26 13 } 27 14 } -
trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/TextTest.java
r18870 r18918 9 9 import org.junit.jupiter.api.Test; 10 10 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport; 11 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemTest; 11 12 import org.openstreetmap.josm.testutils.annotations.Main; 12 13 … … 15 16 */ 16 17 @Main 17 class TextTest { 18 class TextTest implements TaggingPresetItemTest { 19 @Override 20 public Text getInstance() { 21 return new Text(); 22 } 23 18 24 /** 19 * Unit test for {@link Text#addToPanel}.25 * Unit test for {@link Check#addToPanel}. 20 26 */ 27 @Override 21 28 @Test 22 void testAddToPanel() { 29 public void testAddToPanel() { 23 30 JPanel p = new JPanel(); 24 31 assertEquals(0, p.getComponentCount()); 25 assertTrue( new Text().addToPanel(p, TaggingPresetItemGuiSupport.create(false)));32 assertTrue(getInstance().addToPanel(p, TaggingPresetItemGuiSupport.create(false))); 26 33 assertTrue(p.getComponentCount() > 0); 27 34 } -
trunk/test/unit/org/openstreetmap/josm/testutils/annotations/TaggingPresets.java
r18867 r18918 9 9 import java.util.Collection; 10 10 11 import org.junit.jupiter.api.extension.BeforeAllCallback; 11 12 import org.junit.jupiter.api.extension.BeforeEachCallback; 12 13 import org.junit.jupiter.api.extension.ExtendWith; … … 25 26 @Target({ ElementType.METHOD, ElementType.TYPE }) 26 27 @BasicPreferences 28 @Territories 27 29 @ExtendWith(TaggingPresets.TaggingPresetsExtension.class) 28 30 public @interface TaggingPresets { 29 31 30 class TaggingPresetsExtension implements BeforeEachCallback { 32 class TaggingPresetsExtension implements BeforeEachCallback, BeforeAllCallback { 31 33 private static int expectedHashcode = 0; 34 35 @Override 36 public void beforeAll(ExtensionContext extensionContext) throws Exception { 37 setup(); 38 } 32 39 33 40 @Override … … 37 44 38 45 /** 39 * Setup the tagging presets 46 * Set up the tagging presets 40 47 */ 41 48 public static synchronized void setup() { -
trunk/tools/pmd/josm-ruleset.xml
r18629 r18918 93 93 <rule ref="category/java/codestyle.xml/MethodNamingConventions"> 94 94 <properties> 95 <property name="violationSuppressXPath" value="//MethodDeclaration/../../..[@SimpleName='Functions' or @SimpleName='PseudoClasses' or @SimpleName='Role' or @SimpleName='TaggingPreset']"/> 95 <property name="violationSuppressXPath" value="//MethodDeclaration/../../..[@SimpleName='Functions' or @SimpleName='PseudoClasses' or @SimpleName='Role' or @SimpleName='TaggingPreset' or @SimpleName='RegionSpecific']"/> 96 96 </properties> 97 97 </rule>
Note:
See TracChangeset
for help on using the changeset viewer.