Ignore:
Timestamp:
24.01.2010 14:20:12 (2 years ago)
Author:
stoecker
Message:

close #4418 - support zip files for styles and presets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java

    r2813 r2889  
    1212import java.awt.event.ActionEvent; 
    1313import java.io.BufferedReader; 
     14import java.io.File; 
    1415import java.io.IOException; 
     16import java.io.InputStream; 
    1517import java.io.InputStreamReader; 
    1618import java.io.Reader; 
     
    1820import java.util.Arrays; 
    1921import java.util.Collection; 
     22import java.util.Collections; 
    2023import java.util.HashMap; 
    2124import java.util.LinkedHashMap; 
     
    7275    public String locale_name; 
    7376    public final static String OPTIONAL_TOOLTIP_TEXT = "Optional tooltip text"; 
     77    private static File zipIcons = null; 
    7478 
    7579    public static abstract class Item { 
     
    550554    public void setIcon(String iconName) { 
    551555        Collection<String> s = Main.pref.getCollection("taggingpreset.icon.sources", null); 
    552         ImageIcon icon = ImageProvider.getIfAvailable(s, "presets", null, iconName); 
     556        ImageIcon icon = ImageProvider.getIfAvailable(s, "presets", null, iconName, zipIcons); 
    553557        if (icon == null) 
    554558        { 
     
    636640            try { 
    637641                MirroredInputStream s = new MirroredInputStream(source); 
     642                InputStream zip = s.getZipEntry("xml","preset"); 
     643                if(zip != null) 
     644                    zipIcons = s.getFile(); 
    638645                InputStreamReader r; 
    639646                try 
    640647                { 
    641                     r = new InputStreamReader(s, "UTF-8"); 
     648                    r = new InputStreamReader(zip == null ? s : zip, "UTF-8"); 
    642649                } 
    643650                catch (UnsupportedEncodingException e) 
    644651                { 
    645                     r = new InputStreamReader(s); 
     652                    r = new InputStreamReader(zip == null ? s: zip); 
    646653                } 
    647654                allPresets.addAll(TaggingPreset.readAll(new BufferedReader(r))); 
     
    663670                ); 
    664671            } 
     672            zipIcons = null; 
    665673        } 
    666674        return allPresets; 
Note: See TracChangeset for help on using the changeset viewer.