### Eclipse Workspace Patch 1.0
#P libFMap
Index: src/com/iver/cit/gvsig/fmap/drivers/gvl/FMapGVLDriver.java
===================================================================
--- src/com/iver/cit/gvsig/fmap/drivers/gvl/FMapGVLDriver.java	(revision 686)
+++ src/com/iver/cit/gvsig/fmap/drivers/gvl/FMapGVLDriver.java	(working copy)
@@ -12,7 +12,6 @@
 import org.exolab.castor.xml.Marshaller;
 import org.exolab.castor.xml.ValidationException;
 
-
 import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
 import com.iver.cit.gvsig.fmap.core.FShape;
 import com.iver.cit.gvsig.fmap.drivers.legend.IFMapLegendDriver;
@@ -40,7 +39,7 @@
 		String fName = f.getAbsolutePath();
 		if (fName!=null) {
 			fName = fName.toLowerCase();
-			return fName.endsWith(".gvl");
+			return fName.endsWith("." + FILE_EXTENSION);
 		}
 		return false;
 	}
@@ -54,9 +53,10 @@
 		return FILE_EXTENSION;
 	}
 
-	public Hashtable read(FLayers layers,FLayer layer, File file) throws LegendDriverException {
+	public Hashtable<FLayer, IVectorLegend> read(FLayers layers,
+			FLayer layer, File file) throws LegendDriverException {
 
-		Hashtable table = new Hashtable();
+		Hashtable<FLayer, IVectorLegend> table = new Hashtable<FLayer, IVectorLegend>();
 		File xmlFile = new File(file.getAbsolutePath());
 		FileReader reader = null;
 
@@ -64,7 +64,8 @@
 			reader = new FileReader(xmlFile);
 
 			XmlTag tag = (XmlTag) XmlTag.unmarshal(reader);
-			ILegend myLegend = LegendFactory.createFromXML(new XMLEntity(tag));
+			IVectorLegend myLegend = LegendFactory.createFromXML(new XMLEntity(
+					tag));
 
 			if(myLegend != null ) {
 				//CAPA DE LINEAS
Index: src/com/iver/cit/gvsig/fmap/drivers/legend/IFMapLegendDriver.java
===================================================================
--- src/com/iver/cit/gvsig/fmap/drivers/legend/IFMapLegendDriver.java	(revision 686)
+++ src/com/iver/cit/gvsig/fmap/drivers/legend/IFMapLegendDriver.java	(working copy)
@@ -24,5 +24,6 @@
 	
 	void write(FLayers layers, FLayer layer, ILegend legend, File file, String version) throws LegendDriverException;
 	
-	Hashtable<FLayer, ILegend> read(FLayers layers, FLayer layer, File file) throws LegendDriverException;
+	Hashtable<FLayer, ? extends ILegend> read(FLayers layers, FLayer layer,
+			File file) throws LegendDriverException;
 }
#P appgvSIG
Index: src/com/iver/cit/gvsig/addlayer/fileopen/vectorial/VectorialFileOpen.java
===================================================================
--- src/com/iver/cit/gvsig/addlayer/fileopen/vectorial/VectorialFileOpen.java	(revision 686)
+++ src/com/iver/cit/gvsig/addlayer/fileopen/vectorial/VectorialFileOpen.java	(working copy)
@@ -22,6 +22,7 @@
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Comparator;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.TreeSet;
 
@@ -34,10 +35,15 @@
 import com.iver.andami.messages.NotificationManager;
 import com.iver.cit.gvsig.AddLayer;
 import com.iver.cit.gvsig.addlayer.fileopen.AbstractFileOpen;
+import com.iver.cit.gvsig.exceptions.layers.LegendLayerException;
 import com.iver.cit.gvsig.fmap.MapControl;
 import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
+import com.iver.cit.gvsig.fmap.drivers.gvl.FMapGVLDriver;
+import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException;
 import com.iver.cit.gvsig.fmap.layers.FLayer;
+import com.iver.cit.gvsig.fmap.layers.FLyrVect;
 import com.iver.cit.gvsig.fmap.layers.LayerFactory;
+import com.iver.cit.gvsig.fmap.rendering.IVectorLegend;
 import com.iver.utiles.XMLEntity;
 /**
  * Clase que indicar� que ficheros puede tratar al panel de apertura de ficheros
@@ -138,10 +144,31 @@
 				AddLayer.checkProjection(lyr, mapControl.getViewPort());
 				mapControl.getMapContext().getLayers().addLayer(lyr);
 
+				String path = file.getAbsolutePath();
+				// last index + 1 because FmapGVLDriver.FILE_EXTENSION
+				// does not contain the dot
+				FMapGVLDriver legendDriver = new FMapGVLDriver();
+				File legendFile = new File(path.substring(0,
+						path.lastIndexOf('.') + 1)
+						+ legendDriver.getFileExtension());
+
+				if (legendFile.exists() && lyr instanceof FLyrVect) {
+					FLyrVect lyrVect = (FLyrVect) lyr;
+					Hashtable<FLayer, IVectorLegend> map = legendDriver.read(
+							mapControl
+							.getMapContext().getLayers(), lyr, legendFile);
+					if (map.containsKey(lyr)) {
+						lyrVect.setLegend(map.get(lyr));
+					}
+				}
 				return lyr.getFullExtent();
 			}
 		} catch (ReadDriverException e) {
 			errors.add(e);
+		} catch (LegendDriverException e) {
+			errors.add(e);
+		} catch (LegendLayerException e) {
+			errors.add(e);
 		}
 		return null;
 	}
Index: src/com/iver/cit/gvsig/project/documents/view/legend/gui/LegendManager.java
===================================================================
--- src/com/iver/cit/gvsig/project/documents/view/legend/gui/LegendManager.java	(revision 686)
+++ src/com/iver/cit/gvsig/project/documents/view/legend/gui/LegendManager.java	(working copy)
@@ -76,8 +76,6 @@
 import com.iver.andami.PluginServices;
 import com.iver.andami.messages.NotificationManager;
 import com.iver.cit.gvsig.exceptions.layers.LegendLayerException;
-import com.iver.cit.gvsig.fmap.core.FShape;
-import com.iver.cit.gvsig.fmap.core.FShapeM;
 import com.iver.cit.gvsig.fmap.drivers.gvl.FMapGVLDriver;
 import com.iver.cit.gvsig.fmap.drivers.legend.IFMapLegendDriver;
 import com.iver.cit.gvsig.fmap.drivers.legend.LegendDriverException;
@@ -121,7 +119,7 @@
 	private boolean isTreeListenerDisabled;
 	private JButton btnSaveLegend;
 	private JButton btnLoadLegend;
-	private Hashtable<FLayer, ILegend> table = null;
+	private Hashtable<FLayer, ? extends ILegend> table = null;
 	private boolean empty = true;
 	private JLabel iconLabel;
 
@@ -778,7 +776,8 @@
 		}
 	}
 
-	private void applyRestOfLegends(Hashtable<FLayer, ILegend> table2,FLayers layers) {
+	private void applyRestOfLegends(
+			Hashtable<FLayer, ? extends ILegend> table2, FLayers layers) {
 
 		for(int i = 0; i < layers.getLayersCount(); i++) {
 			FLayer my_layer= layers.getLayer(i);
