Index: trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java	(revision 990)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java	(revision 991)
@@ -150,5 +150,5 @@
 				{
 					if (atts.getQName(count).equals("src"))
-						rule.icon.icon = MapPaintStyles.getIcon(atts.getValue(count));
+						rule.icon.icon = MapPaintStyles.getIcon(atts.getValue(count), styleName);
 					else if (atts.getQName(count).equals("annotate"))
 						rule.icon.annotate = Boolean.parseBoolean (atts.getValue(count));
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java	(revision 990)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java	(revision 991)
@@ -6,4 +6,6 @@
 import java.net.URL;
 import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Iterator;
 
@@ -13,4 +15,6 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.gui.mappaint.ElemStyles;
+import org.openstreetmap.josm.io.MirroredInputStream;
+import org.openstreetmap.josm.tools.ImageProvider;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
@@ -19,9 +23,6 @@
 public class MapPaintStyles {
 
-	private static String styleDir;
-	private static String imageDir;
-	private static String internalImageDir;
-	private static Boolean isInternal = false;
 	private static ElemStyles styles = new ElemStyles();
+	private static String iconDirs;
 	
 	public static ElemStyles getStyles()
@@ -30,89 +31,60 @@
 	}
 
-	public static ImageIcon getIcon(String name)
+	public static ImageIcon getIcon(String name, String styleName)
 	{
-		try {
-			if(isInternal)
-			{
-				String imageFile = imageDir+name;
-				File f = new File(imageFile);
-				if(f.exists())
-				{
-					//open icon from user directory
-					return new ImageIcon(imageFile);
-				}
-			}
-			URL path = Main.class.getResource(internalImageDir+name);
-			if(path == null)
-				path = Main.class.getResource("/images/styles/"+name);
-			if(path == null)
-			{
-				System.out.println("Mappaint: Icon " + name + " not found, using default icon");
-				path = Main.class.getResource(internalImageDir+"misc/no_icon.png");
-			}
-			return new ImageIcon(Toolkit.getDefaultToolkit().createImage(path));
+		List<String> dirs = new LinkedList<String>();
+		for(String fileset : iconDirs.split(";"))
+		{
+			String[] a;
+			if(fileset.indexOf("=") >= 0)
+				a = fileset.split("=", 2);
+			else
+				a = new String[] {"", fileset};
+
+			/* non-prefixed path is generic path, always take it */
+			if(a[0].length() == 0 || styleName.equals(a[0]))
+				dirs.add(a[1]);
 		}
-		catch (Exception e)
+		ImageIcon i = ImageProvider.getIfAvailable(dirs, "mappaint."+styleName, null, name);		
+		if(i == null)
 		{
-			URL path = Main.class.getResource(internalImageDir+"incomming/amenity.png");
-			return new ImageIcon(Toolkit.getDefaultToolkit().createImage(path));
+			System.out.println("Mappaint-Style \""+styleName+"\" icon \"" + name + "\" not found.");
+			i = ImageProvider.getIfAvailable(dirs, "mappaint."+styleName, null, "misc/no_icon.png");
 		}
+		return i;
 	}
 
 	public static void readFromPreferences() {
-		String styleName = Main.pref.get("mappaint.style", "standard");
-		// fallback to standard name for internal case, as we only have one internal style
-		String internalStyleName = "standard";
-		styleDir = Main.pref.get("mappaint.styledir", Main.pref.getPreferencesDir()+"plugins/mappaint/"+styleName+"/");
-		String elemStylesFile = styleDir+"elemstyles.xml";
-		imageDir = styleDir+"icons/";
-		internalImageDir = "/images/styles/"+internalStyleName+"/";
+		/* don't prefix icon path, as it should be generic */
+		String internalicon = "resource://images/styles/standard/;resource://images/styles/";
+		String internalfile = "standard=resource://styles/standard/elemstyles.xml";
 
-//		System.out.println("mappaint: Using style: " + styleName);
-//		System.out.println("mappaint: Using style dir: " + styleDir);
-//		System.out.println("mappaint: Using style file: " + elemStylesFile);
+		iconDirs = Main.pref.get("mappaint.iconpaths");
+		iconDirs = iconDirs == null || iconDirs.length() == 0 ? internalicon : iconDirs + ";" + internalicon;
 
-		File f = new File(elemStylesFile);
-		if (f.exists())
+		String file = Main.pref.get("mappaint.sources");
+		file = file == null || file.length() == 0 ? internalfile : internalfile + ";" + file;
+
+		for(String fileset : file.split(";"))
 		{
-			try// reading file from file system
+			try
 			{
-//				System.out.println("mappaint: Using style file: \"" + f + "\"");
+				String[] a;
+				if(fileset.indexOf("=") >= 0)
+					a = fileset.split("=", 2);
+				else
+					a = new String[] {"standard", fileset};
 				XMLReader xmlReader = XMLReaderFactory.createXMLReader();
-				ElemStyleHandler handler = new ElemStyleHandler(styleName);
+				ElemStyleHandler handler = new ElemStyleHandler(a[0]);
 				xmlReader.setContentHandler(handler);
 				xmlReader.setErrorHandler(handler);
-//				temporary only!
-				xmlReader.parse(new InputSource(new FileReader(f)));
+				xmlReader.parse(new InputSource(new MirroredInputStream(a[1])));
 			}
 			catch (Exception e)
 			{
-				throw new RuntimeException(e);
+				System.out.println("Mappaint-Style problems: \"" + fileset + "\"");
 			}
 		} 
-		else {// reading the builtin file from the plugin jar file
-			URL elemStylesPath = Main.class.getResource("/styles/"+internalStyleName+"/elemstyles.xml");
-
-//			System.out.println("mappaint: Using jar's elemstyles.xml: \"" + elemStylesPath + "\"");
-			if (elemStylesPath != null)
-			{
-				isInternal = true;
-				try
-				{
-					XMLReader xmlReader = XMLReaderFactory.createXMLReader();
-					ElemStyleHandler handler = new ElemStyleHandler(internalStyleName);
-					xmlReader.setContentHandler(handler);
-					xmlReader.setErrorHandler(handler);
-//					temporary only!
-					xmlReader.parse(new InputSource(elemStylesPath.openStream()));
-				}
-				catch (Exception e)
-				{
-					throw new RuntimeException(e);
-				}
-			} else {
-				System.out.println("mappaint: Couldn't find style: \"" + styleDir + "elemstyles.xml\"");
-			}
-		}
+		iconDirs = null;
 	}
 
Index: trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 990)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPreset.java	(revision 991)
@@ -405,5 +405,6 @@
 	 */
 	public void setIcon(String iconName) {
-		ImageIcon icon = ImageProvider.getIfAvailable(null, iconName);
+		String s = Main.pref.get("taggingpreset.iconpaths");
+		ImageIcon icon = ImageProvider.getIfAvailable((s != null ? s.split(";") : null), "presets", null, iconName);
 		if (icon == null)
 		{
Index: trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 990)
+++ trunk/src/org/openstreetmap/josm/tools/ImageProvider.java	(revision 991)
@@ -14,4 +14,6 @@
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -63,9 +65,19 @@
 	}
 
+	public static ImageIcon getIfAvailable(String subdir, String name)
+	{
+		return getIfAvailable((Collection<String>)null, null, subdir, name);
+	}
+	public static final ImageIcon getIfAvailable(String[] dirs, String id, String subdir, String name)
+	{
+		return getIfAvailable(Arrays.asList(dirs), id, subdir, name);
+	}
+
 	/**
 	 * Like {@link #get(String)}, but does not throw and return <code>null</code>
 	 * in case of nothing is found. Use this, if the image to retrieve is optional.
 	 */
-	public static ImageIcon getIfAvailable(String subdir, String name) {
+	public static ImageIcon getIfAvailable(Collection<String> dirs, String id, String subdir, String name)
+	{
 		if (name == null)
 			return null;
@@ -76,6 +88,10 @@
 		String ext = name.indexOf('.') != -1 ? "" : ".png";
 		String full_name = subdir+name+ext;
-
-		Image img = cache.get(full_name);
+		String cache_name = full_name;
+		/* cache separately */
+		if(dirs != null && dirs.size() > 0)
+			cache_name = "id:"+id+":"+full_name;
+
+		Image img = cache.get(cache_name);
 		if (img == null) {
 			// getImageUrl() does a ton of "stat()" calls and gets expensive
@@ -84,9 +100,9 @@
 			// and don't bother to create a URL unless we're actually
 			// creating the image.
-			URL path = getImageUrl(full_name);
+			URL path = getImageUrl(full_name, dirs);
 			if (path == null)
 				return null;
 			img = Toolkit.getDefaultToolkit().createImage(path);
-			cache.put(full_name, img);
+			cache.put(cache_name, img);
 		}
 	
@@ -94,28 +110,57 @@
 	}
 
-	private static URL getImageUrl(String imageName) {
-	    URL path = null;
-	    // Try user-preference directory first
-    	try {
-    		if (new File(Main.pref.getPreferencesDir()+"images/"+imageName).exists())
-    			return new URL("file", "", Main.pref.getPreferencesDir()+"images/"+imageName);
-    	} catch (MalformedURLException e) {
-    	}
-
-	    // Try plugins and josm classloader
-	    for (ClassLoader source : sources)
-			if ((path = source.getResource("images/"+imageName)) != null)
-				return path;
-
-	    // Try all other ressource directories
-	    for (String location : Main.pref.getAllPossiblePreferenceDirs()) {
-	    	try {
-	    		if (new File(location+"images/"+imageName).exists())
-	    			return new URL("file", "", location+"images/"+imageName);
-	    	} catch (MalformedURLException e) {
-	    	}
-	    }
-	    return null;
-    }
+	private static URL getImageUrl(String path, String name)
+	{
+		if(path.startsWith("resource://"))
+		{
+			String p = path.substring("resource://".length());
+			for (ClassLoader source : sources)
+			{
+				URL res;
+				if ((res = source.getResource(p+name)) != null)
+					return res;
+			}
+		}
+		else
+		{
+			try {
+				File f = new File(path, name);
+				if(f.exists())
+					return f.toURI().toURL();
+			} catch (MalformedURLException e) {}
+		}
+		return null;
+	}
+
+	private static URL getImageUrl(String imageName, Collection<String> dirs)
+	{
+		URL u;
+		// Try passed directories first
+		if(dirs != null)
+		{
+			for (String name : dirs)
+			{
+				u = getImageUrl(name, imageName);
+				if(u != null) return u;
+			}
+		}
+		// Try user-preference directory
+		u = getImageUrl(Main.pref.getPreferencesDir()+"images", imageName);
+		if(u != null) return u;
+
+		// Try plugins and josm classloader
+		u = getImageUrl("resource://images/", imageName);
+		if(u != null) return u;
+
+		// Try all other ressource directories
+		for (String location : Main.pref.getAllPossiblePreferenceDirs())
+		{
+			u = getImageUrl(location+"images", imageName);
+			if(u != null) return u;
+			u = getImageUrl(location, imageName);
+			if(u != null) return u;
+		}
+		return null;
+	}
 
 	/**
