Ticket #21408: 21408-3.patch

File 21408-3.patch, 9.8 KB (added by marcello@…, 4 years ago)

replaced. try now

  • src/org/openstreetmap/josm/gui/tagging/ac/AutoCompTextField.java

     
    3737    /** true if the combobox should autocomplete */
    3838    private boolean autocompleteEnabled = true;
    3939    /** a filter to enforce max. text length */
    40     private MaxLengthDocumentFilter docFilter;
     40    private transient MaxLengthDocumentFilter docFilter;
    4141    /** the model */
    4242    protected AutoCompComboBoxModel<E> model;
    4343    /** Whether to autocomplete numbers */
     
    202202     *
    203203     * @param l the autoComp listener to be removed
    204204     */
    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);
    211207    }
    212208
    213209    /**
     
    244240                    case AutoCompEvent.AUTOCOMP_BEFORE:
    245241                        ((AutoCompListener) listeners[i + 1]).autoCompBefore(e);
    246242                        break;
     243                    default:
     244                        break;
    247245                }
    248246            }
    249247        }
     
    260258     */
    261259    @Override
    262260    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));
    270266        }
    271267    }
    272268
    273269    @Override
    274270    public void keyPressed(KeyEvent e) {
     271        // not interested
    275272    }
    276273
    277274    @Override
    278275    public void keyReleased(KeyEvent e) {
     276        // not interested
    279277    }
    280278
    281279    /* ------------------------------------------------------------------------------------ */
  • src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetItem.java

     
    4242    /**
    4343     * Display OSM keys as {@linkplain org.openstreetmap.josm.gui.widgets.OsmIdTextField#setHint hint}
    4444     */
    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);
    4646
    4747    protected void initAutoCompletionField(AutoCompletingTextField field, String... key) {
    4848        initAutoCompletionField(field, Arrays.asList(key));
     
    9696     * @return {@code true} if matches (positive), {@code null} if neutral, {@code false} if mismatches (negative).
    9797     */
    9898    public Boolean matches(Map<String, String> tags) {
    99         return null;
     99        return null; // NOSONAR
    100100    }
    101101
    102102    protected static Set<TaggingPresetType> getType(String types) throws SAXException {
  • src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresets.java

     
    5252    /**
    5353     * Sort presets menu alphabetically
    5454     */
    55     public static BooleanProperty SORT_MENU = new BooleanProperty("taggingpreset.sortvalues", true);
     55    public static final BooleanProperty SORT_MENU = new BooleanProperty("taggingpreset.sortvalues", true);
    5656    /**
    5757     * Custom icon sources
    5858     */
  • src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

     
    259259     */
    260260    private List<String> checkListsSameLength(List<String> a, List<String> b, String name) {
    261261        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''",
    263263                            key, text, name));
    264264            Logging.error(tr("Detailed information: {0} <> {1}", a, b));
    265265            return null; // NOSONAR
     
    291291        List<String> localeShortDescriptionsList = splitEscaped(delimiter, locale_short_descriptions);
    292292        List<String> shortDescriptionsList = splitEscaped(delimiter, short_descriptions);
    293293
    294         displayList = checkListsSameLength(displayList, valueList, "display");
    295         localeDisplayList = checkListsSameLength(localeDisplayList, valueList, "localeDisplay");
    296         shortDescriptionsList = checkListsSameLength(shortDescriptionsList, valueList, "shortDescriptions");
    297         localeShortDescriptionsList = checkListsSameLength(localeShortDescriptionsList, valueList, "localeShortDescriptions");
     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");
    298298
    299299        for (int i = 0; i < valueList.size(); i++) {
    300300            final PresetListEntry e = new PresetListEntry(valueList.get(i), this);
  • src/org/openstreetmap/josm/gui/widgets/OrientationAction.java

     
    3434 */
    3535public class OrientationAction extends AbstractAction implements PropertyChangeListener {
    3636    /** Default for {@link #RTL_LANGUAGES} */
    37     public 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");
    3838
    3939    /** Default for {@link #LOCALIZED_KEYS} */
    40     public static final List<String> DEFAULT_LOCALIZED_KEYS = Arrays.asList(
     40    private static final List<String> DEFAULT_LOCALIZED_KEYS = Arrays.asList(
    4141        "(\\p{Alnum}+_)?name", "addr", "description", "fixme", "note", "source", "strapline", "operator");
    4242
    4343    /**
     
    5656    public static final ListProperty LOCALIZED_KEYS = new ListProperty("properties.localized-keys", DEFAULT_LOCALIZED_KEYS);
    5757
    5858    private static final Pattern LANG_PATTERN = Pattern.compile(":([a-z]{2,3})$");
     59    private static final String NEW_STATE = "newState";
    5960
    6061    private Component component;
    6162    private ImageIcon iconRTL;
    6263    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();
    6566
    6667    /**
    6768     * Constructs a new {@code OrientationAction}.
     
    8384
    8485    @Override
    8586    public void actionPerformed(ActionEvent e) {
    86         firePropertyChange("orientationAction", null, getValue("newState"));
     87        firePropertyChange("orientationAction", null, getValue(NEW_STATE));
    8788    }
    8889
    8990    /**
     
    9495            putValue(Action.NAME, tr("Right to Left"));
    9596            putValue(Action.SMALL_ICON, iconRTL);
    9697            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);
    9899        } else {
    99100            putValue(Action.NAME, tr("Left to Right"));
    100101            putValue(Action.SMALL_ICON, iconLTR);
    101102            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);
    103104        }
    104105    }
    105106
     
    205206        return ComponentOrientation.LEFT_TO_RIGHT;
    206207    }
    207208
    208     private static Pattern compile_localized_keys() {
     209    private static Pattern compileLocalizedKeys() {
    209210        return Pattern.compile("^(" + String.join("|", LOCALIZED_KEYS.get()) + ")$");
    210211    }
    211212}