Changeset 15158 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2019-06-03T22:39:22+02:00 (5 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r15059 r15158 11 11 import java.util.Collections; 12 12 import java.util.EnumMap; 13 import java.util.HashMap; 13 14 import java.util.List; 14 15 import java.util.Locale; … … 700 701 } 701 702 703 private static final Map<String, String> localizedCountriesCache = new HashMap<>(); 704 static { 705 localizedCountriesCache.put("", tr("Worldwide")); 706 } 707 708 /** 709 * Returns a localized name for the given country code, or "Worldwide" if empty. 710 * This function falls back on the English name, and uses the ISO code as a last-resortvalue. 711 * 712 * @param countryCode An ISO 3166 alpha-2 country code or a UN M.49 numeric-3 area code 713 * @return The name of the country appropriate to the current locale. 714 * @see Locale#getDisplayCountry 715 * @since 15158 716 */ 717 public static String getLocalizedCountry(String countryCode) { 718 return localizedCountriesCache.computeIfAbsent(countryCode, code -> new Locale("en", code).getDisplayCountry()); 719 } 720 702 721 @Override 703 722 public String toString() { 704 return "ImageryInfo{" + 705 "name='" + name + '\'' + 706 ", countryCode='" + countryCode + '\'' + 707 ", url='" + url + '\'' + 708 ", imageryType=" + imageryType + 709 '}'; 723 // Used in imagery preferences filtering, so must be efficient 724 return new StringBuilder("ImageryInfo{") 725 .append("name='").append(name).append('\'') 726 .append(", countryCode='").append(countryCode).append('\'') 727 // appending the localized country in toString() allows us to filter imagery preferences table with it! 728 .append(", localizedCountry='").append(getLocalizedCountry(countryCode)).append('\'') 729 .append(", url='").append(url).append('\'') 730 .append(", imageryType=").append(imageryType) 731 .append('}').toString(); 710 732 } 711 733 -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryProvidersPanel.java
r15153 r15158 20 20 import java.util.HashSet; 21 21 import java.util.List; 22 import java.util.Locale;23 22 import java.util.Map; 24 23 import java.util.Optional; … … 189 188 private static class ImageryCountryTableCellRenderer extends ImageryProvidersPanel.ImageryTableCellRenderer<String> { 190 189 ImageryCountryTableCellRenderer() { 191 super(code -> code, code -> code.isEmpty() ? tr("Worldwide") : new Locale("en", code).getDisplayCountry(), null);190 super(code -> code, ImageryInfo::getLocalizedCountry, null); 192 191 } 193 192 } … … 686 685 687 686 @Override 687 public Class<?> getColumnClass(int columnIndex) { 688 switch (columnIndex) { 689 case 0: 690 return ImageryCategory.class; 691 case 1: 692 return String.class; 693 case 2: 694 return ImageryInfo.class; 695 case 3: 696 return String.class; 697 default: 698 return super.getColumnClass(columnIndex); 699 } 700 } 701 702 @Override 688 703 public Object getValueAt(int row, int column) { 689 704 ImageryInfo info = layerInfo.getAllDefaultLayers().get(row);
Note:
See TracChangeset
for help on using the changeset viewer.