### Eclipse Workspace Patch 1.0
#P libUIComponent
Index: src/org/gvsig/gui/beans/swing/JFileChooser.java
===================================================================
--- src/org/gvsig/gui/beans/swing/JFileChooser.java	(revision 686)
+++ src/org/gvsig/gui/beans/swing/JFileChooser.java	(working copy)
@@ -78,25 +78,7 @@
 	 *        means the user's home directory. 
 	 */
 	public JFileChooser(String fileChooserID, File defaultDirectory) {
-		super();
-		setDragEnabled(true);
-		if (fileChooserID == null) 
-			throw new IllegalArgumentException("JFileChooser's ID cannot be null");
-		
-		this.fileChooserID = fileChooserID;
-
-		setCurrentDirectory(getLastPath(fileChooserID, defaultDirectory));
-
-//		if (defaultDirectory == null)
-//			defaultDirectory = new File(System.getProperty("user.home"));
-//		File currentDirectory;
-//		if (jfcLastPaths.get(fileChooserID) != null)
-//			currentDirectory = new File(jfcLastPaths.get(fileChooserID));
-//		else
-//			currentDirectory = defaultDirectory;
-//		setCurrentDirectory(currentDirectory);
-//		if (defaultDirectory != null)
-//			jfcLastPaths.put(fileChooserID, currentDirectory.getAbsolutePath());
+		this(fileChooserID, defaultDirectory, null);
 	}
 
 	/**
@@ -107,6 +89,12 @@
 	 * @return
 	 */
 	static public File getLastPath(String fileChooserID, File defaultDirectory) {
+		return getLastPath(fileChooserID, defaultDirectory,
+				FileSystemView.getFileSystemView());
+	}
+
+	private static File getLastPath(String fileChooserID,
+			File defaultDirectory, FileSystemView fsv) {
 		File path = jfcLastPaths.get(fileChooserID);
 
 		if (path != null)
@@ -115,7 +103,11 @@
 		if (defaultDirectory != null)
 			return defaultDirectory;
 
-		return FileSystemView.getFileSystemView().getHomeDirectory();
+		if (fsv != null) {
+			return fsv.getDefaultDirectory();
+		} else {
+			return FileSystemView.getFileSystemView().getDefaultDirectory();
+		}
 	}
 
 	/**
@@ -125,7 +117,7 @@
 	 * @return
 	 */
 	public File getLastPath(File defaultDirectory) {
-		return getLastPath(fileChooserID, defaultDirectory);
+		return getLastPath(fileChooserID, defaultDirectory, getFileSystemView());
 	}
 
 	/**
@@ -133,7 +125,7 @@
 	 * @return
 	 */
 	public File getLastPath() {
-		return getLastPath(fileChooserID, null);
+		return getLastPath(fileChooserID, null, getFileSystemView());
 	}
 
 	/**
@@ -177,8 +169,15 @@
      * and <code>FileSystemView</code>.
      */
     public JFileChooser(String fileChooserID, File defaultDirectory, FileSystemView fsv) {
-    	this(fileChooserID, defaultDirectory);
-		setup(fsv);
+		super(fsv);
+		setDragEnabled(true);
+		if (fileChooserID == null)
+			throw new IllegalArgumentException(
+					"JFileChooser's ID cannot be null");
+
+		this.fileChooserID = fileChooserID;
+
+		setCurrentDirectory(getLastPath(fileChooserID, defaultDirectory, fsv));
     }
 
     /**
@@ -186,8 +185,9 @@
      * path and <code>FileSystemView</code>.
      */
     public JFileChooser(String fileChooserID, String defaultDirectoryPath, FileSystemView fsv) {
-	this(fileChooserID, new File(defaultDirectoryPath), fsv);
-		}
+		this(fileChooserID, defaultDirectoryPath == null ? null : new File(
+				defaultDirectoryPath), fsv);
+	}
 
 	@Override
 	public int showDialog(Component parent, String approveButtonText) throws HeadlessException {
#P extSymbology
Index: src/org/gvsig/symbology/fmap/symbols/PictureMarkerSymbol.java
===================================================================
--- src/org/gvsig/symbology/fmap/symbols/PictureMarkerSymbol.java	(revision 686)
+++ src/org/gvsig/symbology/fmap/symbols/PictureMarkerSymbol.java	(working copy)
@@ -118,7 +118,6 @@
 
 import org.apache.log4j.Logger;
 import org.gvsig.symbology.fmap.styles.BackgroundFileStyle;
-import org.gvsig.tools.file.PathGenerator;
 
 import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
 import com.iver.cit.gvsig.fmap.Messages;
@@ -148,7 +147,6 @@
 
 	private BackgroundFileStyle bgImage;
 	private BackgroundFileStyle bgSelImage;
-	private PathGenerator pathGenerator=PathGenerator.getInstance();
 
 	/**
 	 * Constructor method
@@ -239,8 +237,10 @@
 		xml.putProperty("className", getClassName());
 		xml.putProperty("isShapeVisible", isShapeVisible());
 		xml.putProperty("desc", getDescription());
-		xml.putProperty("imagePath", pathGenerator.getURLPath(imagePath));
-		xml.putProperty("selImagePath", pathGenerator.getURLPath(selImagePath));
+		xml.putProperty("imagePath",
+				PicturePathGeneratorUtils.getURLPath(imagePath));
+		xml.putProperty("selImagePath",
+				PicturePathGeneratorUtils.getURLPath(selImagePath));
 		xml.putProperty("size", getSize());
 		xml.putProperty("offsetX", getOffset().getX());
 		xml.putProperty("offsetY", getOffset().getY());
@@ -262,8 +262,10 @@
 	public void setXMLEntity(XMLEntity xml) {
 		setDescription(xml.getStringProperty("desc"));
 		setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
-		imagePath = pathGenerator.getAbsoluteURLPath(xml.getStringProperty("imagePath"));
-		selImagePath = pathGenerator.getAbsoluteURLPath(xml.getStringProperty("selImagePath"));
+		imagePath = PicturePathGeneratorUtils.getAbsoluteURLPath(xml
+				.getStringProperty("imagePath"));
+		selImagePath = PicturePathGeneratorUtils.getAbsoluteURLPath(xml
+				.getStringProperty("selImagePath"));
 		setSize(xml.getDoubleProperty("size"));
 		double offsetX = 0.0;
 		double offsetY = 0.0;
@@ -284,7 +286,9 @@
 				setImage(new URL(imagePath));
 			} catch (MalformedURLException e) {
 				try{
-					setImage(new URL(pathGenerator.getAbsoluteURLPath(imagePath)));
+					setImage(new URL(
+							PicturePathGeneratorUtils
+									.getAbsoluteURLPath(imagePath)));
 				} catch (MalformedURLException e1) {
 					setImage(new URL("file://"+ rootDir.getAbsolutePath() + File.separator +imagePath));
 				}
@@ -299,7 +303,9 @@
 				setSelImage(new URL(selImagePath));
 			} catch (MalformedURLException e) {
 				try{
-					setSelImage(new URL(pathGenerator.getAbsoluteURLPath(selImagePath)));
+					setSelImage(new URL(
+							PicturePathGeneratorUtils
+									.getAbsoluteURLPath(selImagePath)));
 				} catch (MalformedURLException e1) {
 					setSelImage(new URL("file://"+ rootDir.getAbsolutePath() + File.separator +selImagePath));
 				}
Index: src/org/gvsig/symbology/fmap/symbols/PictureLineSymbol.java
===================================================================
--- src/org/gvsig/symbology/fmap/symbols/PictureLineSymbol.java	(revision 686)
+++ src/org/gvsig/symbology/fmap/symbols/PictureLineSymbol.java	(working copy)
@@ -57,7 +57,6 @@
 import org.apache.batik.ext.awt.geom.PathLength;
 import org.apache.log4j.Logger;
 import org.gvsig.symbology.fmap.styles.BackgroundFileStyle;
-import org.gvsig.tools.file.PathGenerator;
 
 import com.iver.cit.gvsig.fmap.Messages;
 import com.iver.cit.gvsig.fmap.ViewPort;
@@ -92,7 +91,6 @@
 	private BackgroundFileStyle bgImage;
 	private BackgroundFileStyle bgSelImage;
 	private PrintRequestAttributeSet properties;
-	private PathGenerator pathGenerator=PathGenerator.getInstance();
 
 	/**
 	 * Constructor method
@@ -260,8 +258,10 @@
 		xml.putProperty("className", getClassName());
 		xml.putProperty("isShapeVisible", isShapeVisible());
 		xml.putProperty("desc", getDescription());
-		xml.putProperty("imagePath", pathGenerator.getURLPath(imagePath));
-		xml.putProperty("selImagePath", pathGenerator.getURLPath(selImagePath));
+		xml.putProperty("imagePath",
+				PicturePathGeneratorUtils.getURLPath(imagePath));
+		xml.putProperty("selImagePath",
+				PicturePathGeneratorUtils.getURLPath(selImagePath));
 		xml.putProperty("lineWidth", getLineWidth());
 		xml.putProperty("xScale", getXScale());
 		xml.putProperty("yScale", getYScale());
@@ -280,8 +280,10 @@
 		System.out.println(this.getClass().getClassLoader());
 		setDescription(xml.getStringProperty("desc"));
 		setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
-		imagePath = pathGenerator.getAbsoluteURLPath(xml.getStringProperty("imagePath"));
-		selImagePath = pathGenerator.getAbsoluteURLPath(xml.getStringProperty("selImagePath"));
+		imagePath = PicturePathGeneratorUtils.getAbsoluteURLPath(xml
+				.getStringProperty("imagePath"));
+		selImagePath = PicturePathGeneratorUtils.getAbsoluteURLPath(xml
+				.getStringProperty("selImagePath"));
 		setLineWidth(xml.getDoubleProperty("lineWidth"));
 		setXScale(xml.getDoubleProperty("xScale"));
 		setYScale(xml.getDoubleProperty("yScale"));
@@ -294,7 +296,9 @@
 				setImage(new URL(imagePath));
 			} catch (MalformedURLException e) {
 				try{
-					setImage(new URL(pathGenerator.getAbsoluteURLPath(imagePath)));
+					setImage(new URL(
+							PicturePathGeneratorUtils
+									.getAbsoluteURLPath(imagePath)));
 				} catch (MalformedURLException e1) {
 					setImage(new URL("file://"+ rootDir.getAbsolutePath() + File.separator +imagePath));
 				}
@@ -303,7 +307,9 @@
 				setSelImage(new URL(selImagePath));
 			} catch (MalformedURLException e) {
 				try{
-					setSelImage(new URL(pathGenerator.getAbsoluteURLPath(selImagePath)));
+					setSelImage(new URL(
+							PicturePathGeneratorUtils
+									.getAbsoluteURLPath(selImagePath)));
 				} catch (MalformedURLException e1) {
 					setSelImage(new URL("file://"+ rootDir.getAbsolutePath() + File.separator +selImagePath));
 				}
Index: src/org/gvsig/symbology/fmap/symbols/PictureFillSymbol.java
===================================================================
--- src/org/gvsig/symbology/fmap/symbols/PictureFillSymbol.java	(revision 686)
+++ src/org/gvsig/symbology/fmap/symbols/PictureFillSymbol.java	(working copy)
@@ -59,7 +59,6 @@
 import org.apache.log4j.Logger;
 import org.gvsig.symbology.fmap.styles.BackgroundFileStyle;
 import org.gvsig.symbology.fmap.styles.SimpleMarkerFillPropertiesStyle;
-import org.gvsig.tools.file.PathGenerator;
 
 import com.iver.cit.gvsig.fmap.Messages;
 import com.iver.cit.gvsig.fmap.ViewPort;
@@ -93,7 +92,6 @@
 	private BackgroundFileStyle bgImage;
 	private BackgroundFileStyle bgSelImage;
 	private PrintRequestAttributeSet properties;
-	private PathGenerator pathGenerator=PathGenerator.getInstance();
 
 	public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp, Cancellable cancel) {
  		Color fillColor = getFillColor();
@@ -240,8 +238,10 @@
 		xml.putProperty("angle", angle);
 		xml.putProperty("scaleX", xScale);
 		xml.putProperty("scaleY", yScale);
-		xml.putProperty("imagePath", pathGenerator.getURLPath(imagePath));
-		xml.putProperty("selImagePath", pathGenerator.getURLPath(selImagePath));
+		xml.putProperty("imagePath",
+				PicturePathGeneratorUtils.getURLPath(imagePath));
+		xml.putProperty("selImagePath",
+				PicturePathGeneratorUtils.getURLPath(selImagePath));
 		if (getFillColor()!=null)
 			xml.putProperty("fillColor", StringUtilities.color2String(getFillColor()));
 
@@ -260,8 +260,10 @@
 
 	public void setXMLEntity(XMLEntity xml) {
 
-		imagePath = pathGenerator.getAbsoluteURLPath(xml.getStringProperty("imagePath"));
-		selImagePath = pathGenerator.getAbsoluteURLPath(xml.getStringProperty("selImagePath"));
+		imagePath = PicturePathGeneratorUtils.getAbsoluteURLPath(xml
+				.getStringProperty("imagePath"));
+		selImagePath = PicturePathGeneratorUtils.getAbsoluteURLPath(xml
+				.getStringProperty("selImagePath"));
 		setDescription(xml.getStringProperty("desc"));
 		setIsShapeVisible(xml.getBooleanProperty("isShapeVisible"));
 		setAngle(xml.getDoubleProperty("angle"));
@@ -280,7 +282,9 @@
 				setImage(new URL(imagePath));
 			} catch (MalformedURLException e) {
 				try{
-					setImage(new URL(pathGenerator.getAbsoluteURLPath(imagePath)));
+					setImage(new URL(
+							PicturePathGeneratorUtils
+									.getAbsoluteURLPath(imagePath)));
 				} catch (MalformedURLException e1) {
 					setImage(new URL("file://"+ rootDir.getAbsolutePath() + File.separator +imagePath));
 				}
@@ -289,7 +293,9 @@
 				setSelImage(new URL(selImagePath));
 			} catch (MalformedURLException e) {
 				try{
-					setSelImage(new URL(pathGenerator.getAbsoluteURLPath(selImagePath)));
+					setSelImage(new URL(
+							PicturePathGeneratorUtils
+									.getAbsoluteURLPath(selImagePath)));
 				} catch (MalformedURLException e1) {
 					setSelImage(new URL("file://"+ rootDir.getAbsolutePath() + File.separator +selImagePath));
 				}
Index: src/org/gvsig/symbology/fmap/symbols/PicturePathGeneratorUtils.java
===================================================================
--- src/org/gvsig/symbology/fmap/symbols/PicturePathGeneratorUtils.java	(revision 0)
+++ src/org/gvsig/symbology/fmap/symbols/PicturePathGeneratorUtils.java	(revision 0)
@@ -0,0 +1,57 @@
+package org.gvsig.symbology.fmap.symbols;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLDecoder;
+
+import com.iver.cit.gvsig.fmap.core.SymbologyFactory;
+
+public class PicturePathGeneratorUtils {
+
+	public static String getAbsoluteURLPath(String path) {
+		try {
+			return new URL(path).toExternalForm();
+		} catch (MalformedURLException e) {
+			File file = new File(path);
+			if (!file.isAbsolute()) {
+				file = new File(SymbologyFactory.SymbolLibraryPath, path);
+			}
+			try {
+				return new URL("file", null, file.getAbsolutePath())
+						.toExternalForm();
+			} catch (MalformedURLException e1) {
+				// Should never fail
+				return path;
+			}
+		}
+	}
+
+	public static String getURLPath(String imagePath) {
+		URL url;
+		try {
+			url = new URL(imagePath);
+			if (url.getProtocol().equals("file")) {
+				File file = new File(url.getFile());
+				assert file.isAbsolute(); // Internally all paths are still
+											// absolute
+				URI relativeURI = new File(SymbologyFactory.SymbolLibraryPath)
+						.toURI().relativize(file.toURI());
+				try {
+					return URLDecoder.decode(relativeURI.getPath(), "UTF-8");
+				} catch (UnsupportedEncodingException e) {
+					// UTF-8 not supported?
+					throw new AssertionError();
+				}
+			} else {
+				return imagePath;
+			}
+		} catch (MalformedURLException e) {
+			// PictureXXXSymbol.xxxImagePath is always created with
+			// url.toExternalForm
+			throw new AssertionError();
+		}
+	}
+}
Index: src/org/gvsig/symbology/gui/styling/PictureMarker.java
===================================================================
--- src/org/gvsig/symbology/gui/styling/PictureMarker.java	(revision 686)
+++ src/org/gvsig/symbology/gui/styling/PictureMarker.java	(working copy)
@@ -68,7 +68,6 @@
 import com.iver.cit.gvsig.fmap.core.symbols.SymbolDrawingException;
 import com.iver.cit.gvsig.gui.styling.AbstractTypeSymbolEditor;
 import com.iver.cit.gvsig.gui.styling.EditorTool;
-import com.iver.cit.gvsig.gui.styling.Mask;
 import com.iver.cit.gvsig.gui.styling.SymbolEditor;
 
 /**
@@ -136,7 +135,7 @@
 					return PluginServices.getText(this, "bitmap_and_svg_image_files");
 				}
 			};
-			JUrlFileChooser jfc = new JUrlFileChooser(getName(), null);
+			JUrlFileChooser jfc = new JUrlFileChooser(getName());
 			jfc.setFileFilter(ff);
 			jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
 			jfc.setSelectedFile(picFile);
@@ -144,9 +143,9 @@
 			int returnVal = jfc.showOpenDialog(PictureMarker.this.owner);
 			if(returnVal == JFileChooser.APPROVE_OPTION) {
 
-				URL url = jfc.getSelectedURL();
+				String url = jfc.getSelectedURLPath();
 				if (url == null) return;
-				targetLbl.setText(url.toString());
+				targetLbl.setText(url);
 				fireSymbolChangedEvent();
 			}
 //			if(returnVal == JFileChooser.APPROVE_OPTION) {
Index: src/org/gvsig/symbology/gui/styling/JUrlFileChooser.java
===================================================================
--- src/org/gvsig/symbology/gui/styling/JUrlFileChooser.java	(revision 686)
+++ src/org/gvsig/symbology/gui/styling/JUrlFileChooser.java	(working copy)
@@ -45,17 +45,19 @@
 import java.net.URL;
 
 import javax.swing.filechooser.FileFilter;
+import javax.swing.filechooser.FileSystemView;
 
 import org.gvsig.gui.beans.swing.JFileChooser;
 
 import com.iver.andami.PluginServices;
+import com.iver.cit.gvsig.fmap.core.SymbologyFactory;
 
 public class JUrlFileChooser extends JFileChooser {
 
 	private static final long serialVersionUID = 1844355534608274984L;
 
-	public JUrlFileChooser(String fileChooserID, String defaultDirectory) {
-		super(fileChooserID, defaultDirectory);
+	public JUrlFileChooser(String fileChooserID) {
+		super(fileChooserID, new SymbolFileSystemView());
 		this.setFileFilter(ff);
 		this.setFileSelectionMode(JFileChooser.FILES_ONLY);
 		this.setMultiSelectionEnabled(false);
@@ -83,38 +85,40 @@
 		}
 	};
 
-	public URL getSelectedURL() {
-		String path;
-		File f = getSelectedFile();  
-
+	public String getSelectedURLPath() {
 		try {
-			if(f.canRead()) {
-				return f.toURL();
-			}
-			else {
-				path = f.toString();
-
-				if (!path.startsWith("http"))
-					if(path.contains("http") && 
-							(path.endsWith(".png")
-									|| path.endsWith(".gif")
-									|| path.endsWith(".jpg")
-									|| path.endsWith(".jpeg")
-									|| path.endsWith(".bmp")
-									|| path.endsWith(".svg"))) {
-
-						path = path.substring(path.indexOf("http"), path.length());
-						path = path.replace('\\', '/');
-						path = path.replaceFirst("/", "//");
-
-						return new URL(path);
-					}
-			}
+			return new URL("file", null, getSelectedFile().getAbsolutePath())
+					.toExternalForm();
 		} catch (MalformedURLException e) {
 			return null;
 		}
-		return null;
 	}
 
+	private static class SymbolFileSystemView extends FileSystemView {
+		private File root = new File(SymbologyFactory.SymbolLibraryPath);
+		private File[] roots = new File[] { root };
+
+		@Override
+		public File createNewFolder(File containingDir) {
+			File folder = new File(containingDir, "New Folder");
+			folder.mkdir();
+			return folder;
+		}
 
+		@Override
+		public File getDefaultDirectory() {
+			return root;
+		}
+
+		@Override
+		public File getHomeDirectory() {
+			return root;
+		}
+
+
+		@Override
+		public File[] getRoots() {
+			return roots;
+		}
+	}
 }
Index: src/org/gvsig/symbology/gui/styling/PictureFill.java
===================================================================
--- src/org/gvsig/symbology/gui/styling/PictureFill.java	(revision 686)
+++ src/org/gvsig/symbology/gui/styling/PictureFill.java	(working copy)
@@ -41,8 +41,6 @@
 package org.gvsig.symbology.gui.styling;
 
 import java.awt.Color;
-import java.awt.Component;
-import java.awt.Container;
 import java.awt.FlowLayout;
 import java.awt.Font;
 import java.awt.GridLayout;
@@ -66,7 +64,6 @@
 import org.gvsig.symbology.fmap.symbols.PictureFillSymbol;
 
 import com.iver.andami.PluginServices;
-import com.iver.andami.messages.NotificationManager;
 import com.iver.cit.gvsig.fmap.core.FShape;
 import com.iver.cit.gvsig.fmap.core.SymbologyFactory;
 import com.iver.cit.gvsig.fmap.core.symbols.ILineSymbol;
@@ -153,7 +150,7 @@
 					return PluginServices.getText(this, "bitmap_and_svg_image_files");
 				}
 			};
-			JUrlFileChooser jfc = new JUrlFileChooser(getName(), null);
+			JUrlFileChooser jfc = new JUrlFileChooser(getName());
 			jfc.setFileFilter(ff);
 			jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
 			jfc.setSelectedFile(picFile);
@@ -179,9 +176,9 @@
 //			}
 			if(returnVal == JFileChooser.APPROVE_OPTION) {
 
-				URL url = jfc.getSelectedURL();
+				String url = jfc.getSelectedURLPath();
 				if (url == null) return;
-				targetLbl.setText(url.toString());
+				targetLbl.setText(url);
 				fireSymbolChangedEvent();
 			}
 			boolean enabled = (lblFileName.getText()!="");
@@ -394,9 +391,6 @@
 	public void refreshControls(ISymbol layer) {
 		PictureFillSymbol sym = (PictureFillSymbol) layer;
 
-		File imageFile = new File(sym.getImagePath());
-		File selImageFile =  new File (sym.getSelImagePath());
-
 //		boolean enabled = imageFile.exists();
 //		setControlsEnabled(enabled);
 
