Ignore:
Timestamp:
2016-01-15T00:26:24+01:00 (8 years ago)
Author:
Don-vip
Message:

checkstyle + add basic unit test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r9284 r9454  
    6363import org.openstreetmap.josm.gui.mappaint.StyleElementList;
    6464import org.openstreetmap.josm.gui.mappaint.styleelement.MapImage;
     65import org.openstreetmap.josm.gui.mappaint.styleelement.NodeElement;
    6566import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
    6667import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
     
    8182import com.kitfox.svg.SVGDiagram;
    8283import com.kitfox.svg.SVGUniverse;
    83 import org.openstreetmap.josm.gui.mappaint.styleelement.NodeElement;
    8484
    8585/**
     
    10571057        }
    10581058        // Try user-data directory
    1059         String dir = new File(Main.pref.getUserDataDirectory(), "images").getAbsolutePath();
    1060         try {
    1061             u = getImageUrl(dir, imageName, additionalClassLoaders);
    1062             if (u != null)
    1063                 return u;
    1064         } catch (SecurityException e) {
    1065             Main.warn(tr(
    1066                     "Failed to access directory ''{0}'' for security reasons. Exception was: {1}", dir, e
    1067                     .toString()));
     1059        if (Main.pref != null) {
     1060            String dir = new File(Main.pref.getUserDataDirectory(), "images").getAbsolutePath();
     1061            try {
     1062                u = getImageUrl(dir, imageName, additionalClassLoaders);
     1063                if (u != null)
     1064                    return u;
     1065            } catch (SecurityException e) {
     1066                Main.warn(tr(
     1067                        "Failed to access directory ''{0}'' for security reasons. Exception was: {1}", dir, e
     1068                        .toString()));
     1069            }
    10681070        }
    10691071
     
    10791081
    10801082        // Try all other resource directories
    1081         for (String location : Main.pref.getAllPossiblePreferenceDirs()) {
    1082             u = getImageUrl(location + "images", imageName, additionalClassLoaders);
    1083             if (u != null)
    1084                 return u;
    1085             u = getImageUrl(location, imageName, additionalClassLoaders);
    1086             if (u != null)
    1087                 return u;
     1083        if (Main.pref != null) {
     1084            for (String location : Main.pref.getAllPossiblePreferenceDirs()) {
     1085                u = getImageUrl(location + "images", imageName, additionalClassLoaders);
     1086                if (u != null)
     1087                    return u;
     1088                u = getImageUrl(location, imageName, additionalClassLoaders);
     1089                if (u != null)
     1090                    return u;
     1091            }
    10881092        }
    10891093
Note: See TracChangeset for help on using the changeset viewer.