Changeset 18692 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2023-03-14T20:35:09+01:00 (20 months ago)
Author:
taylor.smock
Message:

Fix #21965: Reuse same instance of "<different>" for consistency (patch by gaben)

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java

    r18631 r18692  
    22package org.openstreetmap.josm.gui.dialogs.properties;
    33
     4import static org.openstreetmap.josm.actions.search.SearchAction.searchStateless;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56
     
    109110import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType;
    110111import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
     112import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem;
    111113import org.openstreetmap.josm.gui.util.AbstractTag2LinkPopupListener;
    112114import org.openstreetmap.josm.gui.util.HighlightHelper;
     
    355357        tagRowSorter.setComparator(1, (o1, o2) -> {
    356358            if (o1 instanceof Map && o2 instanceof Map) {
    357                 final String v1 = ((Map) o1).size() == 1 ? (String) ((Map) o1).keySet().iterator().next() : tr("<different>");
    358                 final String v2 = ((Map) o2).size() == 1 ? (String) ((Map) o2).keySet().iterator().next() : tr("<different>");
     359                final String v1 = ((Map) o1).size() == 1 ? (String) ((Map) o1).keySet().iterator().next() : KeyedItem.DIFFERENT_I18N;
     360                final String v2 = ((Map) o2).size() == 1 ? (String) ((Map) o2).keySet().iterator().next() : KeyedItem.DIFFERENT_I18N;
    359361                return AlphanumComparator.getInstance().compare(v1, v2);
    360362            } else {
     
    773775            tagData.addRow(new Object[]{e.getKey(), e.getValue()});
    774776            tags.put(e.getKey(), e.getValue().size() == 1
    775                     ? e.getValue().keySet().iterator().next() : tr("<different>"));
     777                    ? e.getValue().keySet().iterator().next() : KeyedItem.DIFFERENT_I18N);
    776778        }
    777779
     
    12001202                        roleString = r.getRole();
    12011203                    } else if (!roleString.equals(r.getRole())) {
    1202                         roleString = tr("<different>");
     1204                        roleString = KeyedItem.DIFFERENT_I18N;
    12031205                        break;
    12041206                    }
     
    12101212        @Override
    12111213        public String toString() {
    1212             return "MemberInfo{" +
    1213                     "roles='" + roleString + '\'' +
    1214                     ", positions='" + positionString + '\'' +
    1215                     '}';
     1214            return String.format("MemberInfo{roles='%s', positions='%s'}", roleString, positionString);
    12161215        }
    12171216    }
     
    14661465                return;
    14671466            final SearchSetting ss = createSearchSetting(key, sel, sameType);
    1468             org.openstreetmap.josm.actions.search.SearchAction.searchStateless(ss);
     1467            searchStateless(ss);
    14691468        }
    14701469    }
     
    14891488                t = "type:relation ";
    14901489            }
    1491             String token = new StringBuilder(t).append(val).toString();
     1490            String token = t + val;
    14921491            if (consideredTokens.add(token)) {
    14931492                s.append(sep).append('(').append(t).append(SearchCompiler.buildSearchStringForTag(key, val)).append(')');
     
    15101509            try {
    15111510                tagRowSorter.convertRowIndexToModel(tagTable.getSelectedRow());
    1512             } catch (IndexOutOfBoundsException ignore) {
    1513                 Logging.trace(ignore);
     1511            } catch (IndexOutOfBoundsException e) {
     1512                Logging.trace(e);
    15141513                Logging.trace("Clearing tagTable selection");
    15151514                tagTable.clearSelection();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/RelationRoleEditor.java

    r17557 r18692  
    1515import org.openstreetmap.josm.data.osm.RelationMember;
    1616import org.openstreetmap.josm.gui.MainApplication;
     17import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem;
    1718import org.openstreetmap.josm.tools.Utils;
    1819
     
    4243                formatter.formatAsHtmlUnorderedList(relation)),
    4344                oldRole);
    44         if (newRole == null || oldRole.equals(newRole) || tr("<different>").equals(newRole)) {
     45        if (newRole == null || oldRole.equals(newRole) || KeyedItem.DIFFERENT_I18N.equals(newRole)) {
    4546            return;
    4647        }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java

    r18313 r18692  
    8989import org.openstreetmap.josm.gui.tagging.ac.AutoCompListener;
    9090import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionManager;
     91import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem;
    9192import org.openstreetmap.josm.gui.util.GuiHelper;
    9293import org.openstreetmap.josm.gui.util.WindowGeometry;
     
    538539            List<AutoCompletionItem> valueList = autocomplete.getTagValues(getAutocompletionKeys(key), usedValuesAwareComparator);
    539540
    540             final String selection = m.size() != 1 ? tr("<different>") : m.entrySet().iterator().next().getKey();
     541            final String selection = m.size() != 1 ? KeyedItem.DIFFERENT_I18N : m.entrySet().iterator().next().getKey();
    541542
    542543            values = new AutoCompComboBox<>();
     
    586587                value = null; // delete the key instead
    587588            }
    588             if (key.equals(newkey) && tr("<different>").equals(value))
     589            if (key.equals(newkey) && KeyedItem.DIFFERENT_I18N.equals(value))
    589590                return;
    590591            if (key.equals(newkey) || value == null) {
     
    606607                Collection<Command> commands = new ArrayList<>();
    607608                commands.add(new ChangePropertyCommand(sel, key, null));
    608                 if (value.equals(tr("<different>"))) {
     609                if (value.equals(KeyedItem.DIFFERENT_I18N)) {
    609610                    String newKey = newkey;
    610611                    sel.stream()
  • trunk/src/org/openstreetmap/josm/gui/tagging/ac/MaxLengthDocumentFilter.java

    r18236 r18692  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.tagging.ac;
    3 
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    53
    64import javax.swing.text.AttributeSet;
     
    86import javax.swing.text.DocumentFilter;
    97import javax.swing.text.StyleConstants;
     8
     9import org.openstreetmap.josm.gui.tagging.presets.items.KeyedItem;
    1010
    1111/**
     
    1616    /** the document will not accept text longer than this. -1 to disable */
    1717    private int maxLength = -1;
    18     private static final String DIFFERENT = tr("<different>");
    1918
    2019    /**
    2120     * Sets the maximum text length.
    2221     *
    23      * @param length the maximum no. of charactes allowed in this document. -1 to disable
     22     * @param length the maximum no. of characters allowed in this document. -1 to disable
    2423     */
    2524    public void setMaxLength(int length) {
     
    4544    private boolean mustInsertOrReplace(FilterBypass fb, int length, String string, AttributeSet attr) {
    4645        int newLen = fb.getDocument().getLength() - length + ((string == null) ? 0 : string.length());
    47         return (maxLength == -1 || newLen <= maxLength || DIFFERENT.equals(string) ||
     46        return (maxLength == -1 || newLen <= maxLength || KeyedItem.DIFFERENT_I18N.equals(string) ||
    4847                // allow longer text while composing characters or it will be hard to compose
    4948                // the last characters before the limit
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java

    r18257 r18692  
    3030    protected static final String DIFFERENT = "<different>";
    3131    /** Translation of {@code "<different>"}. */
    32     protected static final String DIFFERENT_I18N = tr(DIFFERENT);
     32    public static final String DIFFERENT_I18N = tr("<different>");
    3333
    3434    /** True if the default value should also be set on primitives that already have tags.  */
Note: See TracChangeset for help on using the changeset viewer.