Ticket #7552: 7552_alpha.patch

File 7552_alpha.patch, 2.9 KB (added by simon04, 12 years ago)
  • src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    diff --git a/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java b/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
    index 5d23549..5501c96 100644
    a b  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.gui.tagging;
    33
     4import java.awt.Color;
    45import static org.openstreetmap.josm.tools.I18n.tr;
    56import static org.openstreetmap.josm.tools.I18n.trc;
    67import static org.openstreetmap.josm.tools.I18n.trn;
    78
    89import java.awt.Component;
    910import java.awt.Dimension;
     11import java.awt.Font;
    1012import java.awt.GridBagLayout;
    1113import java.awt.Image;
    1214import java.awt.Insets;
    public class TaggingPreset extends AbstractAction implements MapView.LayerChange  
    212214                res.append(value);
    213215            }
    214216            res.append("</b>");
    215             if (short_description != null) {
     217            if (short_description != null && !short_description.startsWith("img:")) {
    216218                // wrap in table to restrict the text width
    217                 res.append("<br><table><td width='232'>(").append(short_description).append(")</td></table>");
     219                res.append("<div style=\"width:300px; padding:0 0 5px 5ppx\">").append(short_description).append("</div>");
    218220            }
    219221            return res.toString();
    220222        }
    221223
     224        public ImageIcon getIcon() {
     225            if (short_description != null && short_description.startsWith("img:")) {
     226                return ImageProvider.getIfAvailable(short_description.substring("img:".length()));
     227            } else {
     228                return null;
     229            }
     230        }
     231
    222232        public PresetListEntry(String value) {
    223233            this.value = value;
    224234            this.display_value = value;
    public class TaggingPreset extends AbstractAction implements MapView.LayerChange  
    575585        protected ListCellRenderer getListCellRenderer() {
    576586            return new ListCellRenderer() {
    577587
    578                 HtmlPanel lbl = new HtmlPanel();
     588                JLabel lbl = new JLabel();
    579589                JComponent dummy = new JComponent() {
    580590                };
    581591
    public class TaggingPreset extends AbstractAction implements MapView.LayerChange  
    594604                    }
    595605
    596606                    PresetListEntry item = (PresetListEntry) value;
    597                     String s = item.getListDisplay();
    598                     lbl.setText(s);
     607                    lbl.setOpaque(true);
     608                    lbl.setFont(lbl.getFont().deriveFont(Font.PLAIN));
     609                    lbl.setText("<html>" + item.getListDisplay() + "</html>");
     610                    lbl.setIcon(item.getIcon());
    599611                    lbl.setEnabled(list.isEnabled());
    600612                    // We do not want the editor to have the maximum height of all
    601613                    // entries. Return a dummy with bogus height.