Changeset 5964 in josm
- Timestamp:
- 2013-05-17T01:58:59+02:00 (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/data/defaultpresets.xml
r5950 r5964 48 48 text: fixed label to display 49 49 values: comma separated list of values 50 values_from: to use instead of "values" if the list of values has to be obtained with a Java method 51 of this form: public static String[] getValues(); 52 The value must be: "full.package.name.ClassName#methodName" 50 53 display_values: comma separated list of values to be displayed instead of the 51 54 database values, order and number must be equal to values … … 67 70 will also be used to separate selected values in the tag. 68 71 values: delimiter-separated list of values (delimiter can be escaped with backslash) 72 values_from: to use instead of "values" if the list of values has to be obtained with a Java method 73 of this form: public static String[] getValues(); 74 The value must be: "full.package.name.ClassName#methodName" 69 75 rows: specify the number of rows to display (default -1) 70 76 display_values: delimiter-separated list of values to be displayed instead of the … … 6052 6058 <text key="addr:city" text="City name" use_last_as_default="force" match="key" /> 6053 6059 <text key="addr:postcode" text="Post code" use_last_as_default="force" match="key" /> 6054 <combo key="addr:country" text="Country code" values ="AT,CH,DE,FR,GB,IT,RS,US" use_last_as_default="force" match="key" />6060 <combo key="addr:country" text="Country code" values_from="java.util.Locale#getISOCountries" use_last_as_default="force" match="key" /> 6055 6061 </optional> 6056 6062 </item> -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
r5931 r5964 20 20 import java.io.Reader; 21 21 import java.io.UnsupportedEncodingException; 22 import java.lang.reflect.Method; 23 import java.lang.reflect.Modifier; 22 24 import java.text.NumberFormat; 23 25 import java.text.ParseException; … … 666 668 public String locale_text; 667 669 public String values; 670 public String values_from; 668 671 public String values_context; 669 672 public String display_values; … … 760 763 char delChar = getDelChar(); 761 764 762 String[] value_array = splitEscaped(delChar, values); 765 String[] value_array = null; 766 767 if (values_from != null) { 768 String[] class_method = values_from.split("#"); 769 if (class_method != null && class_method.length == 2) { 770 try { 771 Method method = Class.forName(class_method[0]).getMethod(class_method[1]); 772 // Check method is public static String[] methodName(); 773 int mod = method.getModifiers(); 774 if (Modifier.isPublic(mod) && Modifier.isStatic(mod) 775 && method.getReturnType().equals(String[].class) && method.getParameterTypes().length == 0) { 776 value_array = (String[]) method.invoke(null); 777 } else { 778 System.err.println(tr("Broken tagging preset \"{0}-{1}\" - Java method given in ''values_from'' is not \"{2}\"", key, text, 779 "public static String[] methodName()")); 780 } 781 } catch (Exception e) { 782 System.err.println(tr("Broken tagging preset \"{0}-{1}\" - Java method given in ''values_from'' threw {2} ({3})", key, text, 783 e.getClass().getName(), e.getMessage())); 784 } 785 } 786 } 787 788 if (value_array == null) { 789 value_array = splitEscaped(delChar, values); 790 } 763 791 764 792 final String displ = Utils.firstNonNull(locale_display_values, display_values);
Note:
See TracChangeset
for help on using the changeset viewer.