Ignore:
Timestamp:
2020-04-12T23:25:37+02:00 (4 years ago)
Author:
simon04
Message:

see #8352 - PropertiesDialog: preview color as colored square

File:
1 edited

Legend:

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

    r15501 r16283  
    2727import org.openstreetmap.josm.tools.I18n;
    2828import org.openstreetmap.josm.tools.Pair;
     29import org.openstreetmap.josm.tools.Utils;
    2930
    3031/**
     
    112113                }
    113114            }
    114             boolean knownNameKey = false;
     115            boolean enableHTML = false;
    115116            if (column == 0 && str != null) {
    116117                Pair<String, Boolean> label = I18n.getLocalizedLanguageName(str);
    117                 if (label != null) {
    118                     knownNameKey = label.b;
    119                     if (knownNameKey) {
    120                         str = new StringBuilder("<html><body>").append(str)
    121                                 .append(" <i>&lt;").append(label.a).append("&gt;</i></body></html>").toString();
    122                     }
     118                if (label != null && label.b) {
     119                    enableHTML = true;
     120                    str = "<html><body>" + str + " <i>&lt;" + label.a + "&gt;</i></body></html>";
    123121                }
     122            } else if (column == 1 && str != null && String.valueOf(table.getModel().getValueAt(row, 0)).contains("colour")) {
     123                enableHTML = true;
     124                // U+25A0 BLACK SQUARE
     125                String escaped = Utils.escapeReservedCharactersHTML(str);
     126                str = "<html><body><span color='" + escaped + "'>\u25A0</span> " + escaped + "</body></html>";
    124127            }
    125             ((JLabel) c).putClientProperty("html.disable", knownNameKey ? null : Boolean.TRUE); // Fix #8730
     128            ((JLabel) c).putClientProperty("html.disable", enableHTML ? null : Boolean.TRUE); // Fix #8730
    126129            ((JLabel) c).setText(str);
    127130            if (DISCARDABLE.get()) {
Note: See TracChangeset for help on using the changeset viewer.