Ticket #21408: 21408-3.patch
| File 21408-3.patch, 9.8 KB (added by , 4 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/tagging/ac/AutoCompTextField.java
37 37 /** true if the combobox should autocomplete */ 38 38 private boolean autocompleteEnabled = true; 39 39 /** a filter to enforce max. text length */ 40 private MaxLengthDocumentFilter docFilter;40 private transient MaxLengthDocumentFilter docFilter; 41 41 /** the model */ 42 42 protected AutoCompComboBoxModel<E> model; 43 43 /** Whether to autocomplete numbers */ … … 202 202 * 203 203 * @param l the autoComp listener to be removed 204 204 */ 205 public synchronized void removeActionListener(AutoCompListener l) { 206 if ((l != null) && (getAction() == l)) { 207 setAction(null); 208 } else { 209 listenerList.remove(AutoCompListener.class, l); 210 } 205 public synchronized void removeAutoCompListener(AutoCompListener l) { 206 listenerList.remove(AutoCompListener.class, l); 211 207 } 212 208 213 209 /** … … 244 240 case AutoCompEvent.AUTOCOMP_BEFORE: 245 241 ((AutoCompListener) listeners[i + 1]).autoCompBefore(e); 246 242 break; 243 default: 244 break; 247 245 } 248 246 } 249 247 } … … 260 258 */ 261 259 @Override 262 260 public void keyTyped(KeyEvent e) { 263 if (autocompleteEnabled) { 264 // if selection is at the end 265 if (getSelectionEnd() == getText().length()) { 266 final String oldText = getText().substring(0, getSelectionStart()); 267 // We got the event before the editor component could see it. Let the editor do its job first. 268 SwingUtilities.invokeLater(() -> autocomplete(oldText)); 269 } 261 // if selection is at the end 262 if (autocompleteEnabled && getSelectionEnd() == getText().length()) { 263 final String oldText = getText().substring(0, getSelectionStart()); 264 // We got the event before the editor component could see it. Let the editor do its job first. 265 SwingUtilities.invokeLater(() -> autocomplete(oldText)); 270 266 } 271 267 } 272 268 273 269 @Override 274 270 public void keyPressed(KeyEvent e) { 271 // not interested 275 272 } 276 273 277 274 @Override 278 275 public void keyReleased(KeyEvent e) { 276 // not interested 279 277 } 280 278 281 279 /* ------------------------------------------------------------------------------------ */ -
src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java
42 42 /** 43 43 * Display OSM keys as {@linkplain org.openstreetmap.josm.gui.widgets.OsmIdTextField#setHint hint} 44 44 */ 45 protected static BooleanProperty DISPLAY_KEYS_AS_HINT = new BooleanProperty("taggingpreset.display-keys-as-hint", true);45 protected static final BooleanProperty DISPLAY_KEYS_AS_HINT = new BooleanProperty("taggingpreset.display-keys-as-hint", true); 46 46 47 47 protected void initAutoCompletionField(AutoCompletingTextField field, String... key) { 48 48 initAutoCompletionField(field, Arrays.asList(key)); … … 96 96 * @return {@code true} if matches (positive), {@code null} if neutral, {@code false} if mismatches (negative). 97 97 */ 98 98 public Boolean matches(Map<String, String> tags) { 99 return null; 99 return null; // NOSONAR 100 100 } 101 101 102 102 protected static Set<TaggingPresetType> getType(String types) throws SAXException { -
src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java
52 52 /** 53 53 * Sort presets menu alphabetically 54 54 */ 55 public static BooleanProperty SORT_MENU = new BooleanProperty("taggingpreset.sortvalues", true);55 public static final BooleanProperty SORT_MENU = new BooleanProperty("taggingpreset.sortvalues", true); 56 56 /** 57 57 * Custom icon sources 58 58 */ -
src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java
259 259 */ 260 260 private List<String> checkListsSameLength(List<String> a, List<String> b, String name) { 261 261 if (a != null && a.size() != b.size()) { 262 Logging.error(tr("Broken tagging preset \"{0}-{1}\" - number of items in ''{2} List'' must be the same as in ''values''",262 Logging.error(tr("Broken tagging preset \"{0}-{1}\" - number of items in ''{2}'' must be the same as in ''values''", 263 263 key, text, name)); 264 264 Logging.error(tr("Detailed information: {0} <> {1}", a, b)); 265 265 return null; // NOSONAR … … 291 291 List<String> localeShortDescriptionsList = splitEscaped(delimiter, locale_short_descriptions); 292 292 List<String> shortDescriptionsList = splitEscaped(delimiter, short_descriptions); 293 293 294 displayList = checkListsSameLength(displayList, valueList, "display ");295 localeDisplayList = checkListsSameLength(localeDisplayList, valueList, "locale Display");296 shortDescriptionsList = checkListsSameLength(shortDescriptionsList, valueList, "short Descriptions");297 localeShortDescriptionsList = checkListsSameLength(localeShortDescriptionsList, valueList, "locale ShortDescriptions");294 displayList = checkListsSameLength(displayList, valueList, "display_values"); 295 localeDisplayList = checkListsSameLength(localeDisplayList, valueList, "locale_display_values"); 296 shortDescriptionsList = checkListsSameLength(shortDescriptionsList, valueList, "short_descriptions"); 297 localeShortDescriptionsList = checkListsSameLength(localeShortDescriptionsList, valueList, "locale_short_descriptions"); 298 298 299 299 for (int i = 0; i < valueList.size(); i++) { 300 300 final PresetListEntry e = new PresetListEntry(valueList.get(i), this); -
src/org/openstreetmap/josm/gui/widgets/OrientationAction.java
34 34 */ 35 35 public class OrientationAction extends AbstractAction implements PropertyChangeListener { 36 36 /** Default for {@link #RTL_LANGUAGES} */ 37 p ublic static final List<String> DEFAULT_RTL_LANGUAGES = Arrays.asList("ar", "he", "fa", "iw", "ur", "lld");37 private static final List<String> DEFAULT_RTL_LANGUAGES = Arrays.asList("ar", "he", "fa", "iw", "ur"); 38 38 39 39 /** Default for {@link #LOCALIZED_KEYS} */ 40 p ublicstatic final List<String> DEFAULT_LOCALIZED_KEYS = Arrays.asList(40 private static final List<String> DEFAULT_LOCALIZED_KEYS = Arrays.asList( 41 41 "(\\p{Alnum}+_)?name", "addr", "description", "fixme", "note", "source", "strapline", "operator"); 42 42 43 43 /** … … 56 56 public static final ListProperty LOCALIZED_KEYS = new ListProperty("properties.localized-keys", DEFAULT_LOCALIZED_KEYS); 57 57 58 58 private static final Pattern LANG_PATTERN = Pattern.compile(":([a-z]{2,3})$"); 59 private static final String NEW_STATE = "newState"; 59 60 60 61 private Component component; 61 62 private ImageIcon iconRTL; 62 63 private ImageIcon iconLTR; 63 protected static Set<String> RTLLanguages = new HashSet<>(RTL_LANGUAGES.get());64 protected static Pattern localizedKeys = compile_localized_keys();64 protected static final Set<String> RTLLanguages = new HashSet<>(RTL_LANGUAGES.get()); 65 protected static final Pattern localizedKeys = compileLocalizedKeys(); 65 66 66 67 /** 67 68 * Constructs a new {@code OrientationAction}. … … 83 84 84 85 @Override 85 86 public void actionPerformed(ActionEvent e) { 86 firePropertyChange("orientationAction", null, getValue( "newState"));87 firePropertyChange("orientationAction", null, getValue(NEW_STATE)); 87 88 } 88 89 89 90 /** … … 94 95 putValue(Action.NAME, tr("Right to Left")); 95 96 putValue(Action.SMALL_ICON, iconRTL); 96 97 putValue(Action.SHORT_DESCRIPTION, tr("Switch the text orientation to Right-to-Left.")); 97 putValue( "newState", ComponentOrientation.RIGHT_TO_LEFT);98 putValue(NEW_STATE, ComponentOrientation.RIGHT_TO_LEFT); 98 99 } else { 99 100 putValue(Action.NAME, tr("Left to Right")); 100 101 putValue(Action.SMALL_ICON, iconLTR); 101 102 putValue(Action.SHORT_DESCRIPTION, tr("Switch the text orientation to Left-to-Right.")); 102 putValue( "newState", ComponentOrientation.LEFT_TO_RIGHT);103 putValue(NEW_STATE, ComponentOrientation.LEFT_TO_RIGHT); 103 104 } 104 105 } 105 106 … … 205 206 return ComponentOrientation.LEFT_TO_RIGHT; 206 207 } 207 208 208 private static Pattern compile _localized_keys() {209 private static Pattern compileLocalizedKeys() { 209 210 return Pattern.compile("^(" + String.join("|", LOCALIZED_KEYS.get()) + ")$"); 210 211 } 211 212 }
