diff --git a/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompTextField.java b/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompTextField.java index 3c70dc5d36e..3728e1249c8 100644 --- a/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompTextField.java +++ b/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompTextField.java @@ -37,7 +37,7 @@ public class AutoCompTextField extends JosmTextField implements TableCellEdit /** true if the combobox should autocomplete */ private boolean autocompleteEnabled = true; /** a filter to enforce max. text length */ - private MaxLengthDocumentFilter docFilter; + private transient MaxLengthDocumentFilter docFilter; /** the model */ protected AutoCompComboBoxModel model; /** Whether to autocomplete numbers */ @@ -202,12 +202,8 @@ public synchronized void addAutoCompListener(AutoCompListener l) { * * @param l the autoComp listener to be removed */ - public synchronized void removeActionListener(AutoCompListener l) { - if ((l != null) && (getAction() == l)) { - setAction(null); - } else { - listenerList.remove(AutoCompListener.class, l); - } + public synchronized void removeAutoCompListener(AutoCompListener l) { + listenerList.remove(AutoCompListener.class, l); } /** @@ -244,6 +240,8 @@ protected void fireAutoCompEvent(int id, Object item) { case AutoCompEvent.AUTOCOMP_BEFORE: ((AutoCompListener) listeners[i + 1]).autoCompBefore(e); break; + default: + break; } } } @@ -260,22 +258,22 @@ protected void fireAutoCompEvent(int id, Object item) { */ @Override public void keyTyped(KeyEvent e) { - if (autocompleteEnabled) { - // if selection is at the end - if (getSelectionEnd() == getText().length()) { - final String oldText = getText().substring(0, getSelectionStart()); - // We got the event before the editor component could see it. Let the editor do its job first. - SwingUtilities.invokeLater(() -> autocomplete(oldText)); - } + // if selection is at the end + if (autocompleteEnabled && getSelectionEnd() == getText().length()) { + final String oldText = getText().substring(0, getSelectionStart()); + // We got the event before the editor component could see it. Let the editor do its job first. + SwingUtilities.invokeLater(() -> autocomplete(oldText)); } } @Override public void keyPressed(KeyEvent e) { + // not interested } @Override public void keyReleased(KeyEvent e) { + // not interested } /* ------------------------------------------------------------------------------------ */ diff --git a/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java b/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java index d057a93f931..64255363c47 100644 --- a/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java +++ b/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java @@ -42,7 +42,7 @@ public abstract class TaggingPresetItem { /** * Display OSM keys as {@linkplain org.openstreetmap.josm.gui.widgets.OsmIdTextField#setHint hint} */ - protected static BooleanProperty DISPLAY_KEYS_AS_HINT = new BooleanProperty("taggingpreset.display-keys-as-hint", true); + protected static final BooleanProperty DISPLAY_KEYS_AS_HINT = new BooleanProperty("taggingpreset.display-keys-as-hint", true); protected void initAutoCompletionField(AutoCompletingTextField field, String... key) { initAutoCompletionField(field, Arrays.asList(key)); @@ -96,7 +96,7 @@ protected List getAllForKeys(List keys) { * @return {@code true} if matches (positive), {@code null} if neutral, {@code false} if mismatches (negative). */ public Boolean matches(Map tags) { - return null; + return null; // NOSONAR } protected static Set getType(String types) throws SAXException { diff --git a/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java b/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java index 89075d26d3b..c130ef37241 100644 --- a/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java +++ b/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java @@ -52,7 +52,7 @@ public final class TaggingPresets { /** * Sort presets menu alphabetically */ - public static BooleanProperty SORT_MENU = new BooleanProperty("taggingpreset.sortvalues", true); + public static final BooleanProperty SORT_MENU = new BooleanProperty("taggingpreset.sortvalues", true); /** * Custom icon sources */ diff --git a/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java b/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java index 923a06ddbd2..4bf8d64ce4e 100644 --- a/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java +++ b/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java @@ -259,7 +259,7 @@ private List getValuesFromCode(String valuesFrom) { */ private List checkListsSameLength(List a, List b, String name) { if (a != null && a.size() != b.size()) { - Logging.error(tr("Broken tagging preset \"{0}-{1}\" - number of items in ''{2}List'' must be the same as in ''values''", + Logging.error(tr("Broken tagging preset \"{0}-{1}\" - number of items in ''{2}'' must be the same as in ''values''", key, text, name)); Logging.error(tr("Detailed information: {0} <> {1}", a, b)); return null; // NOSONAR @@ -291,10 +291,10 @@ protected void initListEntriesFromAttributes() { List localeShortDescriptionsList = splitEscaped(delimiter, locale_short_descriptions); List shortDescriptionsList = splitEscaped(delimiter, short_descriptions); - displayList = checkListsSameLength(displayList, valueList, "display"); - localeDisplayList = checkListsSameLength(localeDisplayList, valueList, "localeDisplay"); - shortDescriptionsList = checkListsSameLength(shortDescriptionsList, valueList, "shortDescriptions"); - localeShortDescriptionsList = checkListsSameLength(localeShortDescriptionsList, valueList, "localeShortDescriptions"); + displayList = checkListsSameLength(displayList, valueList, "display_values"); + localeDisplayList = checkListsSameLength(localeDisplayList, valueList, "locale_display_values"); + shortDescriptionsList = checkListsSameLength(shortDescriptionsList, valueList, "short_descriptions"); + localeShortDescriptionsList = checkListsSameLength(localeShortDescriptionsList, valueList, "locale_short_descriptions"); for (int i = 0; i < valueList.size(); i++) { final PresetListEntry e = new PresetListEntry(valueList.get(i), this); diff --git a/src/org/openstreetmap/josm/gui/widgets/OrientationAction.java b/src/org/openstreetmap/josm/gui/widgets/OrientationAction.java index bd450a719ee..333e474d757 100644 --- a/src/org/openstreetmap/josm/gui/widgets/OrientationAction.java +++ b/src/org/openstreetmap/josm/gui/widgets/OrientationAction.java @@ -34,10 +34,10 @@ */ public class OrientationAction extends AbstractAction implements PropertyChangeListener { /** Default for {@link #RTL_LANGUAGES} */ - public static final List DEFAULT_RTL_LANGUAGES = Arrays.asList("ar", "he", "fa", "iw", "ur", "lld"); + private static final List DEFAULT_RTL_LANGUAGES = Arrays.asList("ar", "he", "fa", "iw", "ur"); /** Default for {@link #LOCALIZED_KEYS} */ - public static final List DEFAULT_LOCALIZED_KEYS = Arrays.asList( + private static final List DEFAULT_LOCALIZED_KEYS = Arrays.asList( "(\\p{Alnum}+_)?name", "addr", "description", "fixme", "note", "source", "strapline", "operator"); /** @@ -56,12 +56,13 @@ public class OrientationAction extends AbstractAction implements PropertyChangeL public static final ListProperty LOCALIZED_KEYS = new ListProperty("properties.localized-keys", DEFAULT_LOCALIZED_KEYS); private static final Pattern LANG_PATTERN = Pattern.compile(":([a-z]{2,3})$"); + private static final String NEW_STATE = "newState"; private Component component; private ImageIcon iconRTL; private ImageIcon iconLTR; - protected static Set RTLLanguages = new HashSet<>(RTL_LANGUAGES.get()); - protected static Pattern localizedKeys = compile_localized_keys(); + protected static final Set RTLLanguages = new HashSet<>(RTL_LANGUAGES.get()); + protected static final Pattern localizedKeys = compileLocalizedKeys(); /** * Constructs a new {@code OrientationAction}. @@ -83,7 +84,7 @@ public OrientationAction(Component component) { @Override public void actionPerformed(ActionEvent e) { - firePropertyChange("orientationAction", null, getValue("newState")); + firePropertyChange("orientationAction", null, getValue(NEW_STATE)); } /** @@ -94,12 +95,12 @@ public void updateState() { putValue(Action.NAME, tr("Right to Left")); putValue(Action.SMALL_ICON, iconRTL); putValue(Action.SHORT_DESCRIPTION, tr("Switch the text orientation to Right-to-Left.")); - putValue("newState", ComponentOrientation.RIGHT_TO_LEFT); + putValue(NEW_STATE, ComponentOrientation.RIGHT_TO_LEFT); } else { putValue(Action.NAME, tr("Left to Right")); putValue(Action.SMALL_ICON, iconLTR); putValue(Action.SHORT_DESCRIPTION, tr("Switch the text orientation to Left-to-Right.")); - putValue("newState", ComponentOrientation.LEFT_TO_RIGHT); + putValue(NEW_STATE, ComponentOrientation.LEFT_TO_RIGHT); } } @@ -205,7 +206,7 @@ public static ComponentOrientation getNamelikeOrientation(String key) { return ComponentOrientation.LEFT_TO_RIGHT; } - private static Pattern compile_localized_keys() { + private static Pattern compileLocalizedKeys() { return Pattern.compile("^(" + String.join("|", LOCALIZED_KEYS.get()) + ")$"); } }