Changeset 13853 in josm for trunk/src


Ignore:
Timestamp:
2018-05-26T23:13:23+02:00 (15 months ago)
Author:
Don-vip
Message:

fix #11949 - History dialog: insert <wbr> in username labels to preserve dialog layout for long usernames

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java

    r13535 r13853  
    264264                username = user.getName();
    265265            }
    266             lblUser.setDescription(username);
     266            lblUser.setDescription(insertWbr(username), false);
    267267            if (user != null && user != User.getAnonymous()) {
    268268                lblUser.setUrl(getUserUrl(username));
     
    276276                lblUser.setUrl(null);
    277277            } else {
    278                 lblUser.setDescription(username);
     278                lblUser.setDescription(insertWbr(username), false);
    279279                lblUser.setUrl(getUserUrl(username));
    280280            }
     
    293293    }
    294294
     295    private static String insertWbr(String s) {
     296        return Utils.escapeReservedCharactersHTML(s).replace("_", "_<wbr>");
     297    }
     298
    295299    protected static void updateText(Changeset cs, String attr, JTextArea textArea, JLabel label, Changeset oppCs, JComponent container) {
    296300        final String text = cs != null ? cs.get(attr) : null;
  • trunk/src/org/openstreetmap/josm/gui/widgets/UrlLabel.java

    r11416 r13853  
    1313import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    1414import org.openstreetmap.josm.tools.OpenBrowser;
     15import org.openstreetmap.josm.tools.Utils;
    1516
    1617/**
     
    102103     */
    103104    public final void setDescription(String description) {
     105        setDescription(description, true);
     106    }
     107
     108    /**
     109     * Sets the text part of the URL label. Defaults to the empty string if description is null.
     110     *
     111     * @param description the description
     112     * @param escapeReservedCharacters if {@code true}, HTML reserved characters will be escaped
     113     * @since 13853
     114     */
     115    public final void setDescription(String description, boolean escapeReservedCharacters) {
    104116        this.description = description == null ? "" : description;
    105         this.description = this.description.replace("&", "&amp;").replace(">", "&gt;").replace("<", "&lt;");
     117        if (escapeReservedCharacters) {
     118            this.description = Utils.escapeReservedCharactersHTML(this.description);
     119        }
    106120        refresh();
    107121    }
Note: See TracChangeset for help on using the changeset viewer.