- Timestamp:
- 2014-05-23T08:02:13+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
r7128 r7171 799 799 public String value_on = OsmUtils.trueval; 800 800 public String value_off = OsmUtils.falseval; 801 public boolean disable_off = false; 801 802 public boolean default_ = false; // only used for tagless objects 802 803 … … 808 809 809 810 // find out if our key is already used in the selection. 810 Usage usage = determineBooleanUsage(sel, key); 811 final Usage usage = determineBooleanUsage(sel, key); 812 final String oneValue = usage.values.isEmpty() ? null : usage.values.last(); 811 813 def = default_; 812 814 … … 819 821 } 820 822 821 String oneValue = null;822 for (String s : usage.values) {823 oneValue = s;824 }825 823 if (usage.values.size() < 2 && (oneValue == null || value_on.equals(oneValue) || value_off.equals(oneValue))) { 826 824 if (def && !PROP_FILL_DEFAULT.get()) { … … 834 832 // all selected objects share the same value which is either true or false or unset, 835 833 // we can display a standard check box. 836 initialState = value_on.equals(oneValue) ? 837 QuadStateCheckBox.State.SELECTED : 838 value_off.equals(oneValue) ? 839 QuadStateCheckBox.State.NOT_SELECTED : 840 def ? QuadStateCheckBox.State.SELECTED 841 : QuadStateCheckBox.State.UNSET; 842 check = new QuadStateCheckBox(locale_text, initialState, 843 new QuadStateCheckBox.State[] { 844 QuadStateCheckBox.State.SELECTED, 845 QuadStateCheckBox.State.NOT_SELECTED, 846 QuadStateCheckBox.State.UNSET }); 834 initialState = value_on.equals(oneValue) 835 ? QuadStateCheckBox.State.SELECTED 836 : value_off.equals(oneValue) 837 ? QuadStateCheckBox.State.NOT_SELECTED 838 : def 839 ? QuadStateCheckBox.State.SELECTED 840 : QuadStateCheckBox.State.UNSET; 847 841 } else { 848 842 def = false; … … 851 845 // in "partial" state. 852 846 initialState = QuadStateCheckBox.State.PARTIAL; 853 check = new QuadStateCheckBox(locale_text, QuadStateCheckBox.State.PARTIAL, 854 new QuadStateCheckBox.State[] { 855 QuadStateCheckBox.State.PARTIAL, 856 QuadStateCheckBox.State.SELECTED, 857 QuadStateCheckBox.State.NOT_SELECTED, 858 QuadStateCheckBox.State.UNSET }); 859 } 847 } 848 849 final List<QuadStateCheckBox.State> allowedStates = new ArrayList<>(4); 850 if (QuadStateCheckBox.State.PARTIAL.equals(initialState)) 851 allowedStates.add(QuadStateCheckBox.State.PARTIAL); 852 allowedStates.add(QuadStateCheckBox.State.SELECTED); 853 if (!disable_off || value_off.equals(oneValue)) 854 allowedStates.add(QuadStateCheckBox.State.NOT_SELECTED); 855 allowedStates.add(QuadStateCheckBox.State.UNSET); 856 check = new QuadStateCheckBox(locale_text, initialState, 857 allowedStates.toArray(new QuadStateCheckBox.State[allowedStates.size()])); 858 860 859 p.add(check, GBC.eol().fill(GBC.HORIZONTAL)); 861 860 return true; … … 881 880 @Override 882 881 public Collection<String> getValues() { 883 return Arrays.asList(value_on, value_off);882 return disable_off ? Arrays.asList(value_on) : Arrays.asList(value_on, value_off); 884 883 } 885 884
Note:
See TracChangeset
for help on using the changeset viewer.