Index: trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 5032)
+++ trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 5033)
@@ -27,4 +27,5 @@
 import java.net.URL;
 import java.net.URLDecoder;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -216,10 +217,28 @@
         return get(true);
     }
-    
+
     /**
      * Execute the image request.
+     * @param warn If the requested image has been set as optional and is not found, prints an error message on System.err.
      */
     public ImageIcon get(boolean warn) {
-        ImageResource ir = getIfAvailableImpl();
+        return get(warn, null);
+    }
+
+    /**
+     * Execute the image request.
+     * @param additionalClassLoaders A collection of additional class loaders to search image for.
+     */
+    public ImageIcon get(Collection<ClassLoader> additionalClassLoaders) {
+        return get(true, additionalClassLoaders);
+    }
+
+    /**
+     * Execute the image request.
+     * @param warn If the requested image has been set as optional and is not found, prints an error message on System.err.
+     * @param additionalClassLoaders A collection of additional class loaders to search image for.
+     */
+    public ImageIcon get(boolean warn, Collection<ClassLoader> additionalClassLoaders) {
+        ImageResource ir = getIfAvailableImpl(additionalClassLoaders);
         if (ir == null) {
             if (!optional) {
@@ -228,5 +247,5 @@
             } else {
                 if (warn) {
-                    System.out.println(tr("Failed to locate image ''{0}''", name));
+                    System.err.println(tr("Failed to locate image ''{0}''", name));
                 }
                 return null;
@@ -270,5 +289,5 @@
             "^data:([a-zA-Z]+/[a-zA-Z+]+)?(;base64)?,(.+)$");
 
-    private ImageResource getIfAvailableImpl() {
+    private ImageResource getIfAvailableImpl(Collection<ClassLoader> additionalClassLoaders) {
         if (name == null)
             return null;
@@ -371,5 +390,5 @@
                         // and don't bother to create a URL unless we're actually
                         // creating the image.
-                        URL path = getImageUrl(full_name, dirs);
+                        URL path = getImageUrl(full_name, dirs, additionalClassLoaders);
                         if (path == null) {
                             continue;
@@ -510,8 +529,12 @@
     }
 
-    private static URL getImageUrl(String path, String name) {
+    private static URL getImageUrl(String path, String name, Collection<ClassLoader> additionalClassLoaders) {
         if (path != null && path.startsWith("resource://")) {
             String p = path.substring("resource://".length());
-            for (ClassLoader source : PluginHandler.getResourceClassLoaders()) {
+            Collection<ClassLoader> classLoaders = new ArrayList<ClassLoader>(PluginHandler.getResourceClassLoaders());
+            if (additionalClassLoaders != null) {
+                classLoaders.addAll(additionalClassLoaders);
+            }
+            for (ClassLoader source : classLoaders) {
                 URL res;
                 if ((res = source.getResource(p + name)) != null)
@@ -529,5 +552,5 @@
     }
 
-    private static URL getImageUrl(String imageName, Collection<String> dirs) {
+    private static URL getImageUrl(String imageName, Collection<String> dirs, Collection<ClassLoader> additionalClassLoaders) {
         URL u = null;
 
@@ -536,5 +559,5 @@
             for (String name : dirs) {
                 try {
-                    u = getImageUrl(name, imageName);
+                    u = getImageUrl(name, imageName, additionalClassLoaders);
                     if (u != null)
                         return u;
@@ -550,5 +573,5 @@
         String dir = Main.pref.getPreferencesDir() + "images";
         try {
-            u = getImageUrl(dir, imageName);
+            u = getImageUrl(dir, imageName, additionalClassLoaders);
             if (u != null)
                 return u;
@@ -560,10 +583,10 @@
 
         // Absolute path?
-        u = getImageUrl(null, imageName);
+        u = getImageUrl(null, imageName, additionalClassLoaders);
         if (u != null)
             return u;
 
         // Try plugins and josm classloader
-        u = getImageUrl("resource://images/", imageName);
+        u = getImageUrl("resource://images/", imageName, additionalClassLoaders);
         if (u != null)
             return u;
@@ -571,8 +594,8 @@
         // Try all other resource directories
         for (String location : Main.pref.getAllPossiblePreferenceDirs()) {
-            u = getImageUrl(location + "images", imageName);
+            u = getImageUrl(location + "images", imageName, additionalClassLoaders);
             if (u != null)
                 return u;
-            u = getImageUrl(location, imageName);
+            u = getImageUrl(location, imageName, additionalClassLoaders);
             if (u != null)
                 return u;
