Ignore:
Timestamp:
2019-07-06T22:15:55+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #13458 - display external resources icons in the preferences

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r14214 r15211  
    33
    44import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
     5import static org.openstreetmap.josm.tools.I18n.marktr;
    56import static org.openstreetmap.josm.tools.I18n.tr;
    67
     8import java.awt.Color;
    79import java.awt.Component;
    810import java.awt.Dimension;
     
    4244import javax.swing.DefaultListModel;
    4345import javax.swing.DefaultListSelectionModel;
    44 import javax.swing.ImageIcon;
    4546import javax.swing.JButton;
    4647import javax.swing.JCheckBox;
     
    5859import javax.swing.ListCellRenderer;
    5960import javax.swing.ListSelectionModel;
     61import javax.swing.UIManager;
    6062import javax.swing.event.CellEditorListener;
    6163import javax.swing.event.ChangeEvent;
     
    7476import org.openstreetmap.josm.actions.ExtensionFileFilter;
    7577import org.openstreetmap.josm.data.Version;
     78import org.openstreetmap.josm.data.preferences.NamedColorProperty;
    7679import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry;
    7780import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
     
    13531356    static class SourceEntryListCellRenderer extends JLabel implements ListCellRenderer<ExtendedSourceEntry> {
    13541357
    1355         private final ImageIcon GREEN_CHECK = ImageProvider.getIfAvailable("misc", "green_check");
    1356         private final ImageIcon GRAY_CHECK = ImageProvider.getIfAvailable("misc", "gray_check");
     1358        private static final NamedColorProperty SOURCE_ENTRY_ACTIVE_BACKGROUND_COLOR = new NamedColorProperty(
     1359                marktr("External resource entry: Active"),
     1360                new Color(200, 255, 200));
     1361        private static final NamedColorProperty SOURCE_ENTRY_INACTIVE_BACKGROUND_COLOR = new NamedColorProperty(
     1362                marktr("External resource entry: Inactive"),
     1363                new Color(200, 200, 200));
     1364
    13571365        private final Map<String, SourceEntry> entryByUrl = new HashMap<>();
    13581366
     
    13741382            setOpaque(true);
    13751383            setToolTipText(value.getTooltip());
    1376             final SourceEntry sourceEntry = entryByUrl.get(value.url);
    1377             setIcon(sourceEntry == null ? null : sourceEntry.active ? GREEN_CHECK : GRAY_CHECK);
     1384            if (!isSelected) {
     1385                final SourceEntry sourceEntry = entryByUrl.get(value.url);
     1386                GuiHelper.setBackgroundReadable(this, sourceEntry == null ? UIManager.getColor("Table.background") :
     1387                    sourceEntry.active ? SOURCE_ENTRY_ACTIVE_BACKGROUND_COLOR.get() : SOURCE_ENTRY_INACTIVE_BACKGROUND_COLOR.get());
     1388            }
     1389            final ImageSizes size = ImageSizes.TABLE;
     1390            setIcon(value.icon == null ? ImageProvider.getEmpty(size) : value.icon.getImageIcon(size.getImageDimension()));
    13781391            return this;
    13791392        }
     
    14751488                            } else if ("version".equals(key)) {
    14761489                                last.version = value;
     1490                            } else if ("icon".equals(key) && last.icon == null) {
     1491                                last.icon = new ImageProvider(value).setOptional(true).getResource();
    14771492                            } else if ("link".equals(key) && last.link == null) {
    14781493                                last.link = value;
Note: See TracChangeset for help on using the changeset viewer.