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


Ignore:
Timestamp:
2021-03-20T15:53:51+01:00 (4 years ago)
Author:
simon04
Message:

fix #19554 - Tagging presets: Icons for all preset input boxes

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Check.java

    r16276 r17605  
    1010import java.util.List;
    1111
    12 import javax.swing.ImageIcon;
    1312import javax.swing.JLabel;
    1413import javax.swing.JPanel;
    15 import javax.swing.SwingConstants;
    1614
    1715import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1816import org.openstreetmap.josm.data.osm.OsmUtils;
    1917import org.openstreetmap.josm.data.osm.Tag;
    20 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
    2118import org.openstreetmap.josm.gui.widgets.QuadStateCheckBox;
    2219import org.openstreetmap.josm.tools.GBC;
     
    9693            JPanel checkPanel = new JPanel(new GridBagLayout());
    9794            checkPanel.add(check, GBC.std());
    98             JLabel label = new JLabel(locale_text, getIcon(), SwingConstants.LEFT);
     95            JLabel label = new JLabel(locale_text);
     96            addIcon(label);
    9997            label.addMouseListener(new MouseAdapter() {
    10098                @Override
     
    129127    }
    130128
    131     /**
    132      * Returns the entry icon, if any.
    133      * @return the entry icon, or {@code null}
    134      * @since 15437
    135      */
    136     public ImageIcon getIcon() {
    137         return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), (int) icon_size);
    138     }
    139 
    140129    @Override
    141130    public Collection<String> getValues() {
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/ComboMultiSelect.java

    r17077 r17605  
    216216
    217217        final JLabel label = new JLabel(tr("{0}:", locale_text));
     218        addIcon(label);
    218219        label.setToolTipText(getKeyTooltipText());
    219220        label.setComponentPopupMenu(getPopupMenu());
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Label.java

    r16042 r17605  
    44import java.util.Collection;
    55
    6 import javax.swing.Icon;
    7 import javax.swing.ImageIcon;
    86import javax.swing.JLabel;
    97import javax.swing.JPanel;
    108
    119import org.openstreetmap.josm.data.osm.OsmPrimitive;
    12 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
    1310import org.openstreetmap.josm.tools.GBC;
    1411
     
    1815public class Label extends TextItem {
    1916
    20     /** The location of icon file to display (optional) */
    21     public String icon; // NOSONAR
    22     /** The size of displayed icon. If not set, default is 16px */
    23     public short icon_size = 16; // NOSONAR
    24 
    2517    @Override
    2618    public boolean addToPanel(JPanel p, Collection<OsmPrimitive> sel, boolean presetInitiallyMatches) {
    2719        initializeLocaleText(null);
    28         addLabel(p, getIcon(), locale_text);
     20        JLabel label = new JLabel(locale_text);
     21        addIcon(label);
     22        p.add(label, GBC.eol().fill(GBC.HORIZONTAL));
    2923        return true;
    3024    }
    3125
    32     /**
    33      * Adds a new {@code JLabel} to the given panel.
    34      * @param p The panel
    35      * @param icon the icon (optional, can be null)
    36      * @param label The text label
    37      */
    38     public static void addLabel(JPanel p, Icon icon, String label) {
    39         p.add(new JLabel(label, icon, JLabel.LEADING), GBC.eol().fill(GBC.HORIZONTAL));
    40     }
    41 
    42     /**
    43      * Returns the label icon, if any.
    44      * @return the label icon, or {@code null}
    45      */
    46     public ImageIcon getIcon() {
    47         return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), (int) icon_size);
    48     }
    4926}
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Link.java

    r15423 r17605  
    4444        final String url = getUrl();
    4545        if (wiki != null) {
    46             return new UrlLabel(url, locale_text, 2) {
     46            UrlLabel urlLabel = new UrlLabel(url, locale_text, 2) {
    4747                @Override
    4848                public void mouseClicked(MouseEvent e) {
     
    5757                }
    5858            };
     59            addIcon(urlLabel);
     60            return urlLabel;
    5961        } else if (href != null || locale_href != null) {
    60             return new UrlLabel(url, locale_text, 2);
     62            UrlLabel urlLabel = new UrlLabel(url, locale_text, 2);
     63            addIcon(urlLabel);
     64            return urlLabel;
    6165        }
    6266        return null;
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/Text.java

    r16643 r17605  
    164164            value = pnl;
    165165        }
    166         final JLabel label = new JLabel(locale_text + ':');
     166        final JLabel label = new JLabel(tr("{0}:", locale_text));
     167        addIcon(label);
    167168        label.setToolTipText(getKeyTooltipText());
    168169        label.setComponentPopupMenu(getPopupMenu());
  • trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/TextItem.java

    r9665 r17605  
    66import org.openstreetmap.josm.data.osm.Tag;
    77import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItem;
     8import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader;
     9
     10import javax.swing.ImageIcon;
     11import javax.swing.JLabel;
     12import javax.swing.SwingConstants;
    813
    914/**
     
    2126    /** The localized version of {@link #text} */
    2227    public String locale_text; // NOSONAR
     28
     29    /** The location of icon file to display */
     30    public String icon; // NOSONAR
     31    /** The size of displayed icon. If not set, default is 16px */
     32    public short icon_size = 16; // NOSONAR
     33
    2334
    2435    protected final void initializeLocaleText(String defaultText) {
     
    3950    }
    4051
     52    /**
     53     * Defines the label icon from this entry's icon
     54     * @param label the component
     55     * @since 17605
     56     */
     57    protected void addIcon(JLabel label) {
     58        label.setIcon(getIcon());
     59        label.setHorizontalAlignment(SwingConstants.LEADING);
     60    }
     61
     62    /**
     63     * Returns the entry icon, if any.
     64     * @return the entry icon, or {@code null}
     65     * @since 17605
     66     */
     67    public ImageIcon getIcon() {
     68        return icon == null ? null : loadImageIcon(icon, TaggingPresetReader.getZipIcons(), (int) icon_size);
     69    }
     70
    4171    @Override
    4272    public String toString() {
  • trunk/src/org/openstreetmap/josm/gui/widgets/UrlLabel.java

    r17299 r17605  
    6060
    6161    /**
    62      * Constructs a new {@code UrlLabel} for the given URL, description and font increase.
     62     * Constructs a new {@code UrlLabel} for the given URL, description and image.
    6363     * @param url The URL to use
    6464     * @param description The description to display
Note: See TracChangeset for help on using the changeset viewer.