Changeset 10137 in josm for trunk/src/org/openstreetmap/josm/gui/tagging/ac
- Timestamp:
- 2016-04-10T23:53:54+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/tagging/ac
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionItemPriority.java
r9231 r10137 7 7 * 8 8 * Instances of this class are not modifiable. 9 * @since 1762 9 10 */ 10 11 public class AutoCompletionItemPriority implements Comparable<AutoCompletionItemPriority> { … … 44 45 private final boolean selected; 45 46 46 47 47 /** 48 * C reate new AutoCompletionItemPriority object.48 * Constructs a new {@code AutoCompletionItemPriority}. 49 49 * 50 50 * @param inDataSet true, if the item is found in the currently active data layer 51 * @param inStandard true, if the item is a standard tag, e.g. from the presets .51 * @param inStandard true, if the item is a standard tag, e.g. from the presets 52 52 * @param selected true, if it is found on an object that is currently selected 53 53 * @param userInput null, if the user hasn't entered this tag so far. A number when … … 62 62 } 63 63 64 /** 65 * Constructs a new {@code AutoCompletionItemPriority}. 66 * 67 * @param inDataSet true, if the item is found in the currently active data layer 68 * @param inStandard true, if the item is a standard tag, e.g. from the presets 69 * @param selected true, if it is found on an object that is currently selected 70 */ 64 71 public AutoCompletionItemPriority(boolean inDataSet, boolean inStandard, boolean selected) { 65 72 this(inDataSet, inStandard, selected, NO_USER_INPUT); 66 73 } 67 74 75 /** 76 * Determines if the item is found in the currently active data layer. 77 * @return {@code true} if the item is found in the currently active data layer 78 */ 68 79 public boolean isInDataSet() { 69 80 return inDataSet; 70 81 } 71 82 83 /** 84 * Determines if the item is a standard tag, e.g. from the presets. 85 * @return {@code true} if the item is a standard tag, e.g. from the presets 86 */ 72 87 public boolean isInStandard() { 73 88 return inStandard; 74 89 } 75 90 91 /** 92 * Determines if it is found on an object that is currently selected. 93 * @return {@code true} if it is found on an object that is currently selected 94 */ 76 95 public boolean isSelected() { 77 96 return selected; 78 97 } 79 98 99 /** 100 * Returns a number when the tag key / value has been entered by the user before. 101 * A lower number means this happened more recently and beats a higher number in priority. 102 * @return a number when the tag key / value has been entered by the user before. 103 * {@code null}, if the user hasn't entered this tag so far. 104 */ 80 105 public Integer getUserInput() { 81 106 return userInput == NO_USER_INPUT ? null : userInput; … … 89 114 public int compareTo(AutoCompletionItemPriority other) { 90 115 int ui = Integer.compare(other.userInput, userInput); 91 if (ui != 0) return ui; 116 if (ui != 0) 117 return ui; 92 118 93 119 int sel = Boolean.valueOf(selected).compareTo(other.selected); 94 if (sel != 0) return sel; 120 if (sel != 0) 121 return sel; 95 122 96 123 int ds = Boolean.valueOf(inDataSet).compareTo(other.inDataSet); 97 if (ds != 0) return ds; 124 if (ds != 0) 125 return ds; 98 126 99 127 int std = Boolean.valueOf(inStandard).compareTo(other.inStandard); 100 if (std != 0) return std; 128 if (std != 0) 129 return std; 101 130 102 131 return 0; -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionList.java
r9078 r10137 28 28 * AutoCompletionList is an {@link AbstractTableModel} which serves the list of filtered 29 29 * items to a {@link JTable}. 30 * 30 * @since 1762 31 31 */ 32 32 public class AutoCompletionList extends AbstractTableModel { … … 67 67 /** 68 68 * clears the current filter 69 *70 69 */ 71 70 public void clearFilter() { … … 135 134 */ 136 135 public void add(Collection<String> values, AutoCompletionItemPriority priority) { 137 if (values == null) return; 138 for (String value: values) { 136 if (values == null) 137 return; 138 for (String value : values) { 139 139 if (value == null) { 140 140 continue; … … 148 148 } 149 149 150 /** 151 * Adds values that have been entered by the user. 152 * @param values values that have been entered by the user 153 */ 150 154 public void addUserInput(Collection<String> values) { 151 if (values == null) return; 155 if (values == null) 156 return; 152 157 int i = 0; 153 for (String value: values) { 154 if (value == null) { 155 continue; 156 } 157 AutoCompletionListItem item = new AutoCompletionListItem(value, new AutoCompletionItemPriority(false, false, false, i)); 158 appendOrUpdatePriority(item); 159 i++; 158 for (String value : values) { 159 if (value != null) { 160 appendOrUpdatePriority( 161 new AutoCompletionListItem(value, new AutoCompletionItemPriority(false, false, false, i++))); 162 } 160 163 } 161 164 sort();
Note:
See TracChangeset
for help on using the changeset viewer.