Ticket #7840: 7840-2.patch

File 7840-2.patch, 2.4 KB (added by bastiK, 13 years ago)
  • src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

     
    303303        public String icon;
    304304        public String locale_display_value;
    305305        public String locale_short_description;
     306        private final File zipIcons = TaggingPreset.zipIcons;
    306307
    307308        public String getListDisplay() {
    308309            if (value.equals(DIFFERENT))
     
    324325        }
    325326
    326327        public ImageIcon getIcon() {
    327             return icon == null ? null : ImageProvider.getIfAvailable(icon);
     328            return icon == null ? null : loadImageIcon(icon, zipIcons);
    328329        }
    329330
    330331        public PresetListEntry() {
     
    12271228        return group != null ? group.getRawName() + "/" + name : name;
    12281229    }
    12291230
     1231    protected static ImageIcon loadImageIcon(String iconName, File zipIcons) {
     1232        final Collection<String> s = Main.pref.getCollection("taggingpreset.icon.sources", null);
     1233        return new ImageProvider(iconName).setDirs(s).setId("presets").setArchive(zipIcons).setOptional(true).get();
     1234    }
     1235
    12301236    /*
    12311237     * Called from the XML parser to set the icon.
    12321238     * This task is performed in the background in order to speedup startup.
     
    12351241     * and the 16x16 icons for SMALL_ICON.
    12361242     */
    12371243    public void setIcon(final String iconName) {
    1238         final File zipIcons = this.zipIcons;
     1244        final File zipIcons = TaggingPreset.zipIcons;
    12391245        Main.worker.submit(new Runnable() {
    12401246
    12411247            @Override
    12421248            public void run() {
    1243                 final Collection<String> s = Main.pref.getCollection("taggingpreset.icon.sources", null);
    1244                 ImageIcon icon = new ImageProvider(iconName).setDirs(s).setId("presets").setArchive(zipIcons).setOptional(true).get();
     1249                ImageIcon icon = loadImageIcon(iconName, zipIcons);
    12451250                if (icon == null) {
    12461251                    System.out.println("Could not get presets icon " + iconName);
    12471252                    icon = new ImageIcon(iconName);
     
    14301435                        JOptionPane.ERROR_MESSAGE
    14311436                        );
    14321437            }
    1433             zipIcons = null;
    14341438        }
    14351439        return allPresets;
    14361440    }