Revision 10666

View differences:

branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/ProjectExtension.java
77 77
import com.iver.cit.gvsig.gui.layout.Layout;
78 78
import com.iver.cit.gvsig.project.Project;
79 79
import com.iver.cit.gvsig.project.ProjectFactory;
80
import com.iver.cit.gvsig.project.documents.ProjectDocument;
80 81
import com.iver.cit.gvsig.project.documents.exceptions.OpenException;
81 82
import com.iver.cit.gvsig.project.documents.gui.ProjectWindow;
82 83
import com.iver.cit.gvsig.project.documents.layout.ProjectMap;
......
297 298
			if (!modificado()) {
298 299
				return;
299 300
			}
300
			ProjectView.numViews=0;
301
            ProjectMap.numMaps = 0;
301
			ProjectDocument.initializeNUMS();
302 302
			PluginServices.getMDIManager().closeAllWindows();
303 303
			p = ProjectFactory.createProject();
304 304
			p.setName(PluginServices.getText(this, "untitled"));
......
309 309
		} else if (actionCommand.equals("ABRIR")) {
310 310
			//Si est? modificado se pregunta si se quiere guardar el anterior
311 311
			if (!modificado()) {
312
				ProjectView.numViews=0;
313
                ProjectMap.numMaps = 0;
312
				ProjectDocument.initializeNUMS();
314 313
				return;
315 314
			}
316 315

  
......
324 323
					PluginServices.getText(this, "tipo_fichero_proyecto")));
325 324

  
326 325
			if (jfc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) {
327
				ProjectView.numViews=0;
328
                ProjectMap.numMaps = 0;
326
				ProjectDocument.initializeNUMS();
329 327
				PluginServices.getMDIManager().closeAllWindows();
330 328

  
331 329
				File projectFile = jfc.getSelectedFile();
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/ProjectDocument.java
45 45
import java.io.Serializable;
46 46
import java.text.DateFormat;
47 47
import java.util.Date;
48
import java.util.HashMap;
49
import java.util.Iterator;
48 50

  
49 51
import com.hardcode.driverManager.DriverLoadException;
50 52
import com.iver.andami.messages.NotificationManager;
......
69 71
 * @author Fernando Gonz?lez Cort?s
70 72
 */
71 73
public abstract class ProjectDocument implements Serializable {
74
	public static HashMap NUMS = new HashMap();
72 75
	protected PropertyChangeSupport change;
73 76
	protected Project project;
74 77
	protected int index;
......
271 274
					e);
272 275
			}
273 276
			ProjectDocument pe=pde.create(p);
274
			pe.setProjectDocumentFactory(pde);		
277
			pe.setProjectDocumentFactory(pde);
275 278
			return pe;
276 279
		}catch (Exception e) {
277 280
			throw new OpenException(e,pde.getNameType());
......
291 294
	 */
292 295
	public void setXMLEntity(XMLEntity xml)
293 296
		throws XMLException, DriverException, DriverIOException, OpenException{
294
		
297

  
295 298
		this.setComment(xml.getStringProperty("comment"));
296 299
		this.setCreationDate(xml.getStringProperty("creationDate"));
297 300
		this.setName(xml.getStringProperty("name"));
298 301
		this.setOwner(xml.getStringProperty("owner"));
299
		
302

  
300 303
	}
301 304

  
302 305
	/**
......
311 314
	 */
312 315
	public void setXMLEntity03(XMLEntity xml)
313 316
		throws XMLException, DriverException, DriverIOException{
314
			
317

  
315 318
			this.setComment(xml.getStringProperty("comment"));
316 319
			this.setCreationDate(xml.getStringProperty("creationDate"));
317 320
			this.setName(xml.getStringProperty("name"));
318 321
			this.setOwner(xml.getStringProperty("owner"));
319
			
322

  
320 323
		}
321 324

  
322 325
	/**
......
380 383
	public ProjectDocumentFactory getProjectDocumentFactory() {
381 384
		return projectDocumentFactory;
382 385
	}
383
	
386

  
384 387
	public abstract void exportToXML(XMLEntity root, Project project)  throws SaveException ;
385
	
388

  
386 389
	public abstract void importFromXML(XMLEntity root, XMLEntity typeRoot,int elementIndex ,Project project, boolean removeDocumentsFromRoot) throws XMLException, DriverException, OpenException;
387
		
388
	
390

  
391

  
389 392
	public void importFromXML(XMLEntity root, XMLEntity typeRoot,int elementIndex ,Project project) throws XMLException, DriverException, OpenException{
390 393
		importFromXML(root,typeRoot, elementIndex,project,false);
391 394
	}
392
	
395

  
393 396
	/**
394 397
	 * Get the layout properties (size, position, state of the components)
395 398
	 * of the window associated with this ProjectDocument.
396 399
	 * This is used to re-open the window with the same properties it had
397 400
	 * when it was closed.
398
	 * 
401
	 *
399 402
	 * @return A WindowData object storing the properties of the window.
400 403
	 */
401 404
	public WindowData getWindowData() {
402 405
		return windowData;
403 406
	}
404
	
407

  
405 408
	/**
406 409
	 * Store the layout properties (size, position, state of the components)
407 410
	 * of the window associated with this ProjectDocument.
......
411 414
	public void storeWindowData(WindowData data) {
412 415
		windowData = data;
413 416
	}
417
	public static void initializeNUMS() {
418
		NUMS.clear();
419
		ExtensionPoints extensionPoints =
420
			ExtensionPointsSingleton.getInstance();
421
		ExtensionPoint extensionPoint =(ExtensionPoint)extensionPoints.get("Documents");
422
		Iterator iterator = extensionPoint.keySet().iterator();
423
		while (iterator.hasNext()) {
424
			try {
425
				ProjectDocumentFactory documentFactory = (ProjectDocumentFactory)extensionPoint.create((String)iterator.next());
426
				NUMS.put(documentFactory.getRegisterName(),new Integer(0));
427
			} catch (InstantiationException e) {
428
				e.printStackTrace();
429
			} catch (IllegalAccessException e) {
430
				e.printStackTrace();
431
			} catch (ClassCastException e) {
432
				e.printStackTrace();
433
			}
434
		}
435

  
436

  
437
	}
414 438
}
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/ProjectTableFactory.java
212 212

  
213 213
        t.setName(name);
214 214
        t.setCreationDate(DateFormat.getInstance().format(new Date()));
215
        ProjectTable.numTables++;
215
        int numTables=((Integer)ProjectDocument.NUMS.get(registerName)).intValue();
216
        ProjectDocument.NUMS.put(registerName,new Integer(numTables++));
216 217

  
217 218
        return t;
218 219
    }
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/ProjectTable.java
88 88
 * @author Fernando Gonz?lez Cort?s
89 89
 */
90 90
public class ProjectTable extends ProjectDocument {
91
	public static int numTables = 0;
91
	//public static int numTables = 0;
92 92

  
93 93
	private IEditableSource esModel;
94 94

  
......
322 322
		XMLEntity xml = super.getXMLEntity();
323 323
		try {
324 324
			// xml.putProperty("nameClass", this.getClass().getName());
325
			int numTables=((Integer)ProjectDocument.NUMS.get(ProjectTableFactory.registerName)).intValue();
325 326
			xml.putProperty("numTables", numTables);
326 327

  
327 328
			if (getLinkTable() != null) {
......
376 377
	public void setXMLEntity03(XMLEntity xml)
377 378
		throws XMLException, DriverException, DriverIOException{
378 379
		super.setXMLEntity03(xml);
379
		numTables = xml.getIntProperty("numTables");
380
		int numTables = xml.getIntProperty("numTables");
381
		ProjectDocument.NUMS.put(ProjectTableFactory.registerName,new Integer(numTables));
380 382

  
381 383
		if (xml.getStringProperty("type").equals("otherDriverFile")) {
382 384
			LayerFactory.getDataSourceFactory().addFileDataSource(
......
434 436
		try {
435 437
			super.setXMLEntity(xml);
436 438
			setName(xml.getStringProperty("name"));
437
			numTables = xml.getIntProperty("numTables");
439
			int numTables = xml.getIntProperty("numTables");
440
			ProjectDocument.NUMS.put(ProjectTableFactory.registerName,new Integer(numTables));
438 441

  
439 442
			setSelectableDataSource(xml);
440 443

  
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/ProjectViewFactory.java
61 61
    public ProjectDocument create(Project project) {
62 62
        String viewName = "";
63 63
        String aux = PluginServices.getText(this, "untitled");
64
        viewName = aux + " - " + ProjectView.numViews++;
65

  
64
        int numViews=((Integer)ProjectDocument.NUMS.get(registerName)).intValue();
65
		viewName = aux + " - " + numViews++;
66 66
        if (project != null) {
67 67
            // Buscamos si alguna vista ya ten?a este nombre:
68
            while (existViewName(project, viewName)) {
69
                viewName = aux + " - " + ProjectView.numViews++;
68
            while (existName(project, viewName)) {
69
                viewName = aux + " - " + numViews++;
70 70
            }
71 71
        }
72

  
72
		ProjectDocument.NUMS.put(registerName,new Integer(numViews));
73 73
        ProjectView vista = createView(viewName);
74 74
        vista.setProject(project, 0);
75 75
        vista.setProjectDocumentFactory(this);
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/ProjectView.java
56 56
import com.iver.cit.gvsig.fmap.layers.XMLException;
57 57
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
58 58
import com.iver.cit.gvsig.project.Project;
59
import com.iver.cit.gvsig.project.documents.ProjectDocument;
59 60
import com.iver.cit.gvsig.project.documents.ProjectDocumentFactory;
60 61
import com.iver.cit.gvsig.project.documents.exceptions.OpenException;
61 62
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
......
72 73
 * @author Fernando Gonz?lez Cort?s
73 74
 */
74 75
public class ProjectView extends ProjectViewBase {
75
	public static int numViews = 0;
76
	//public static int numViews = 0;
76 77

  
77 78
	//public static int METROS = 0;
78 79
	//public static int KILOMETROS = 1;
......
90 91
		XMLEntity xml = super.getXMLEntity();
91 92
		//xml.putProperty("nameClass", this.getClass().getName());
92 93
		try{
94
		int numViews=((Integer)ProjectDocument.NUMS.get(ProjectViewFactory.registerName)).intValue();
93 95
		xml.putProperty("numViews", numViews);
94 96
		xml.putProperty("m_selectedField", m_selectedField);
95 97
		xml.putProperty("m_typeLink", m_typeLink);
......
126 128
	public void setXMLEntity03(XMLEntity xml)
127 129
		throws XMLException, DriverException, DriverIOException {
128 130
		super.setXMLEntity03(xml);
129
		numViews = xml.getIntProperty("numViews");
131
		int numViews = xml.getIntProperty("numViews");
132
		ProjectDocument.NUMS.put(ProjectViewFactory.registerName,new Integer(numViews));
130 133
		m_selectedField = xml.getStringProperty("m_selectedField");
131 134
		m_typeLink = xml.getIntProperty("m_typeLink");
132 135
		m_extLink = xml.getStringProperty("m_extLink");
......
155 158
		try{
156 159
			super.setXMLEntity(xml);
157 160
			int currentChild=0;
158
			numViews = xml.getIntProperty("numViews");
161
			int numViews = xml.getIntProperty("numViews");
162
			ProjectDocument.NUMS.put(ProjectViewFactory.registerName,new Integer(numViews));
159 163
			m_selectedField = xml.getStringProperty("m_selectedField");
160 164
			m_typeLink = xml.getIntProperty("m_typeLink");
161 165
			m_extLink = xml.getStringProperty("m_extLink");
......
192 196
	public String getFrameName() {
193 197
		return PluginServices.getText(this,"Vista");
194 198
	}
195
	
199

  
196 200
	public IWindow createWindow() {
197 201
		com.iver.cit.gvsig.project.documents.view.gui.View view = new com.iver.cit.gvsig.project.documents.view.gui.View();
198 202
		if (windowData != null)
......
207 211
	}
208 212

  
209 213
	public void exportToXML(XMLEntity root, Project project) throws SaveException {
210
		XMLEntity viewsRoot = project.getExportXMLTypeRootNode(root,ProjectViewFactory.registerName);		
214
		XMLEntity viewsRoot = project.getExportXMLTypeRootNode(root,ProjectViewFactory.registerName);
211 215
		viewsRoot.addChild(this.getXMLEntity());
212 216
		this.exportToXMLLayerDependencies(this.getMapContext().getLayers(),root,project);
213 217
		if (this.getMapOverViewContext() != null) {
214 218
			this.exportToXMLLayerDependencies(this.getMapOverViewContext().getLayers(),root,project);
215 219
		}
216 220
	}
217
	
221

  
218 222
	private void exportToXMLLayerDependencies(FLayer layer, XMLEntity root,Project project)
219 223
		throws SaveException  {
220
		
224

  
221 225
		if (layer instanceof FLayers) {
222 226
			FLayers layers = (FLayers)layer;
223 227
			for (int i=0;i< layers.getLayersCount();i++) {
......
230 234
				} catch (DriverException e) {
231 235
					throw new SaveException(e,layer.getName());
232 236
				}
233
				
237

  
234 238
				ProjectTable pt = project.getTable((AlphanumericData) layer);
235 239
				if (pt != null) {
236 240
					pt.exportToXML(root,project);
......
241 245

  
242 246
	public void importFromXML(XMLEntity root, XMLEntity typeRoot, int elementIndex, Project project, boolean removeDocumentsFromRoot) throws XMLException, DriverException, OpenException {
243 247
		XMLEntity element = typeRoot.getChild(elementIndex);
244
		
248

  
245 249
		try {
246 250
			this.setXMLEntity(element);
247 251
		} catch (DriverIOException e) {
248 252
			throw new OpenException(e,"Open error");
249
		}		
253
		}
250 254
		project.addDocument(this);
251 255
		if (removeDocumentsFromRoot) {
252 256
			typeRoot.removeChild(elementIndex);
253 257
		}
254 258

  
255
		
256
		
257
		
259

  
260

  
261

  
258 262
		//Cargamos las tables vinculadas:
259
				
263

  
260 264
		//Recuperamos todos los nombres
261 265
		XMLEntity tablesRoot = project.getExportXMLTypeRootNode(root,ProjectTableFactory.registerName);
262 266
		int childIndex;
......
266 270
		Iterator iterTables = tablesRoot.findChildren("viewName",this.getName());
267 271
		while (iterTables.hasNext()){
268 272
			child = (XMLEntity)iterTables.next();
269
			tablesName.put(child.getStringProperty("name"),child.getStringProperty("name"));			
273
			tablesName.put(child.getStringProperty("name"),child.getStringProperty("name"));
270 274
		}
271 275

  
272
		
276

  
273 277
		XMLEntity tableXML;
274
		
278

  
275 279
		// Construimos un diccionario ordenado inversamente por el indice
276 280
		// del elemento (por si se van eliminando elementos al importar) y
277 281
		// como valor el nombre de la vista
278 282
		TreeMap tablesToImport = new TreeMap( new Comparator() {
279 283

  
280 284
			public int compare(Object o1, Object o2) {
281
				
285

  
282 286
				if (((Integer)o1).intValue() > ((Integer)o2).intValue()) {
283 287
					return -1; //o1 first
284 288
				} else if (((Integer)o1).intValue() < ((Integer)o2).intValue()){
......
286 290
				}
287 291
				return 0;
288 292
			}
289
			
293

  
290 294
		});
291 295
		Iterator iterTablesName = tablesName.keySet().iterator();
292 296
		int tableIndex;
......
296 300
			tableIndex = tablesRoot.firstIndexOfChild("name",tableName);
297 301
			tablesToImport.put(new Integer(tableIndex),tableName);
298 302
		}
299
		
303

  
300 304
		ProjectTable table;
301 305
		ProjectDocumentFactory tableFactory = project.getProjectDocumentFactory(ProjectTableFactory.registerName);
302
				
306

  
303 307
		Iterator iterTablesToImport = tablesToImport.entrySet().iterator();
304 308
		Entry entry;
305 309
		// Nos recorremos las vistas a importar
......
308 312
			tableName = (String)entry.getValue();
309 313
			tableIndex = ((Integer)entry.getKey()).intValue();
310 314
			table = (ProjectTable)tableFactory.create(project);
311
			table.importFromXML(root,tablesRoot,tableIndex,project,removeDocumentsFromRoot);			
315
			table.importFromXML(root,tablesRoot,tableIndex,project,removeDocumentsFromRoot);
312 316

  
313
			
317

  
314 318
		}
315
		
319

  
316 320
	}
317 321

  
318 322

  
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/ProjectDocumentFactory.java
1 1
package com.iver.cit.gvsig.project.documents;
2 2

  
3 3
import java.security.KeyException;
4
import java.util.ArrayList;
4 5
import java.util.Hashtable;
5 6
import java.util.Map;
6 7

  
......
131 132
    public static void register(String registerName, Object obj, String alias) {
132 133
        ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
133 134
        extensionPoints.add("Documents", registerName, obj);
134

  
135
		ProjectDocument.NUMS.put(registerName,new Integer(0));
135 136
        ExtensionPoint extPoint = ((ExtensionPoint) extensionPoints.get(
136 137
                "Documents"));
137 138

  
......
150 151
    public static void register(String registerName, Object obj) {
151 152
        ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
152 153
        extensionPoints.add("Documents", registerName, obj);
154
    	 ProjectDocument.NUMS.put(registerName,new Integer(0));
153 155
    }
154 156

  
155 157
    /**
......
181 183
     * @return true if all the conflicts are resolved , else false
182 184
     */
183 185
    public abstract boolean resolveImportXMLConflicts(XMLEntity root,Project project, Hashtable conflicts);
186
 	/**
187
    * Return true if the name exists to another document.
188
    *
189
    * @param project
190
    * @param documentName
191
    *
192
    * @return True if the name exists.
193
    */
194
   public boolean existName(Project project, String documentName) {
195
       ArrayList documentList = project.getDocumentsByType(getRegisterName());
196

  
197
       for (int i = 0; i < documentList.size(); i++) {
198
           ProjectDocument pd = (ProjectDocument) documentList.get(i);
199
           String title = pd.getName();
200

  
201
           if (title.compareTo(documentName) == 0) {
202
               return true;
203
           }
204
       }
205

  
206
       return false;
207
   }
184 208
}
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/ProjectMapFactory.java
58 58
     * @return ProjectDocument.
59 59
     */
60 60
    public ProjectDocument create(Project project) {
61
        ProjectMap map = createMap(PluginServices.getText(this, "untitled"));
61
       String mapName = "";
62
    	String aux = PluginServices.getText(this, "untitled");
63
    	int numMaps=((Integer)ProjectDocument.NUMS.get(registerName)).intValue();
64
    	mapName = aux + " - " + numMaps++;
65
    	if (project != null) {
66
            while (existName(project, mapName)) {
67
                mapName = aux + " - " + numMaps++;
68
            }
69
        }
70
    	ProjectDocument.NUMS.put(registerName,new Integer(numMaps));
71
        ProjectMap map = createMap(mapName);
62 72
        map.setModel(new Layout());
63 73
        map.getModel().setProjectMap(map);
64 74
        map.setProject(project, 0);
......
93 103
     * @return ProjectMap.
94 104
     */
95 105
    public static ProjectMap createMap(String baseName) {
96
        ProjectMap m = new ProjectMap();
97
        m.setName(baseName + " - " + ProjectMap.numMaps);
106
       ProjectMap m = new ProjectMap();
107
        m.setName(baseName);
98 108
        m.setCreationDate(DateFormat.getInstance().format(new Date()));
99
        ProjectMap.numMaps++;
100 109
        return m;
101 110
    }
102 111

  
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/ProjectMap.java
66 66

  
67 67

  
68 68
/**
69
 * DOCUMENT ME!
69
 * Modelo del Layout.
70 70
 *
71 71
 * @author Fernando Gonz?lez Cort?s
72 72
 */
73 73
public class ProjectMap extends ProjectDocument {
74
	public static int numMaps = 0;
74
	//public static int numMaps = 0;
75 75
	private Layout model;
76 76

  
77 77
	/**
......
115 115
		XMLEntity xml = super.getXMLEntity();
116 116
		try{
117 117
		//xml.putProperty("nameClass", this.getClass().getName());
118
		int numMaps=((Integer)ProjectDocument.NUMS.get(ProjectMapFactory.registerName)).intValue();
118 119
		xml.putProperty("numMaps", numMaps);
119 120
		xml.addChild(model.getXMLEntity());
120 121
		}catch (Exception e) {
......
130 131
	public void setXMLEntity(XMLEntity xml) throws OpenException {
131 132
		try {
132 133
			super.setXMLEntity(xml);
133
			numMaps = xml.getIntProperty("numMaps");
134
			int numMaps=xml.getIntProperty("numMaps");
135
			ProjectDocument.NUMS.put(ProjectMapFactory.registerName,new Integer(numMaps));
134 136
			for (int i=0; i<xml.getChildrenCount(); i++)
135 137
			{
136 138
				XMLEntity child = xml.getChild(i);
......
154 156
		throws XMLException, DriverException, DriverIOException{
155 157

  
156 158
		super.setXMLEntity03(xml);
157
		numMaps = xml.getIntProperty("numMaps");
159
		int numMaps=xml.getIntProperty("numMaps");
160
		ProjectDocument.NUMS.put(ProjectMapFactory.registerName,new Integer(numMaps));
158 161
		model = Layout.createLayout03(xml.getChild(0), getProject());
159 162
	}
160 163

  
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/project/Project.java
1283 1283
				return pView.getName();
1284 1284
		}
1285 1285

  
1286
		throw new RuntimeException("The layer is not in a view");
1286
		throw new RuntimeException("The layer '"+layer.getName()+"' is not in a view");
1287 1287
	}
1288 1288

  
1289 1289
	public boolean isView(FLayers layers, FLayer layer) {
branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerFactory.java
118 118
	 * Crea un RandomVectorialFile con el driver que se le pasa como par?metro y
119 119
	 * guard?ndose el nombre del fichero para realizar los accesos, la capa
120 120
	 * tendr? asociada la proyecci?n que se pasa como parametro tambi?n
121
	 * 
121
	 *
122 122
	 * @param layerName Nombre de la capa. @param driverName Nombre del driver.
123 123
	 * @param f fichero. @param proj Proyecci?n.
124
	 * 
124
	 *
125 125
	 * @return FLayer. @throws DriverException
126
	 * 
126
	 *
127 127
	 * @throws DriverException @throws DriverIOException
128 128
	 */
129 129
	public static FLayer createLayer(String layerName, String driverName,
......
146 146
			//las excepciones de este metodo se dejan subir todas, puesto
147 147
			//que las excepciones de los dos otros metodos createLayer si que
148 148
			//se atrapan
149
			DriverNotLoadedExceptionType exceptionType = 
149
			DriverNotLoadedExceptionType exceptionType =
150 150
				new DriverNotLoadedExceptionType();
151 151
			exceptionType.setDriverName(driverName);
152
			DriverException exception = 
153
				new DriverException(e, exceptionType);		
152
			DriverException exception =
153
				new DriverException(e, exceptionType);
154 154
			throw exception;
155 155
		}
156 156

  
......
160 160
	/**
161 161
	 * It creates a FLayer (FLyrVect) which reads its data from a file driver,
162 162
	 * projected in the specified projection.
163
	 * 
163
	 *
164 164
	 * @param layerName
165 165
	 *            name of the layer
166 166
	 * @param d
......
169 169
	 *            file associated to the driver
170 170
	 * @param proj
171 171
	 *            layer projection
172
	 * 
172
	 *
173 173
	 * @return FLayer new vectorial layer
174
	 * 
174
	 *
175 175
	 * @throws DriverException
176 176
	 */
177 177
	public static FLayer createLayer(String layerName, VectorialFileDriver d,
178
			File f, IProjection proj) 
179
	
178
			File f, IProjection proj)
179

  
180 180
	/*throws DriverException*/ {
181 181

  
182 182
		// TODO Comprobar si hay un adaptador ya
......
206 206
				capa.setLegend(LegendFactory.createSingleSymbolLegend(capa
207 207
						.getShapeType()));
208 208
			}
209
			
209

  
210 210
		} catch (FieldNotFoundException e) {
211 211
			//this exception is caused in legend creation
212
			LegendDriverExceptionType excepType = 
213
				new LegendDriverExceptionType("Error al construir la leyenda"); 
212
			LegendDriverExceptionType excepType =
213
				new LegendDriverExceptionType("Error al construir la leyenda");
214 214
			//TODO Para hacer esto extensible tiene que usarse puntos
215 215
			//de extension, y comparar las clases de leyendas registradas
216
			VectorialLegend legend = (VectorialLegend) 
216
			VectorialLegend legend = (VectorialLegend)
217 217
				((WithDefaultLegend)d).getDefaultLegend();
218
			
218

  
219 219
			excepType.setLegendLabelField(legend.getLabelField());
220 220
			excepType.setLegendHeightField(legend.getLabelHeightField());
221 221
			excepType.setLegendRotationField(legend.getLabelRotationField());
222 222
			DriverException exception = new DriverException(e, excepType);
223 223
			capa.setAvailable(false);
224 224
			capa.addError(exception);
225
			
225

  
226 226
		} catch (DriverIOException e) {
227 227
			//this error is caused for file IO problems
228
			DriverIOExceptionType excepType = 
228
			DriverIOExceptionType excepType =
229 229
				new DriverIOExceptionType();
230 230
			excepType.setFile(f);
231 231
			DriverException exception = new DriverException(e, excepType);
232 232
			capa.setAvailable(false);
233 233
			capa.addError(exception);
234 234
		}
235
		
235

  
236 236
		/*
237 237
		 * catch(DriverException e){
238 238
		 * ESTO HAY QUE CAPTURARLO,DE FORMA QUE CREATELAYER NO LANCE NINGUNA
......
251 251
	/**
252 252
	 * Creates a new vectorial layer from a generic layer (by generic whe mean
253 253
	 * that we dont know a priory its origin: file, memory, jdbc database, etc.
254
	 * 
254
	 *
255 255
	 * @param layerName
256 256
	 * @param d
257 257
	 * @param proj
......
259 259
	 * @throws DriverException
260 260
	 */
261 261
	public static FLayer createLayer(String layerName, VectorialDriver d,
262
			IProjection proj) 
262
			IProjection proj)
263 263
	/*
264
	throws DriverException 
264
	throws DriverException
265 265
	*/{
266 266
		VectorialAdapter adapter = null;
267 267
		if (d instanceof VectorialFileDriver) {
......
296 296
			}
297 297
		} catch (FieldNotFoundException e) {
298 298
//			this exception is caused in legend creation
299
			LegendDriverExceptionType excepType = 
299
			LegendDriverExceptionType excepType =
300 300
				new LegendDriverExceptionType("error al construir la leyenda, campo no encontrado");
301 301

  
302 302
			//TODO Para hacer esto extensible tiene que usarse puntos
303 303
			//de extension, y comparar las clases de leyendas registradas
304
			VectorialLegend legend = (VectorialLegend) 
304
			VectorialLegend legend = (VectorialLegend)
305 305
				((WithDefaultLegend)d).getDefaultLegend();
306 306
			excepType.setDriverName(d.getName());
307 307
			excepType.setLegendLabelField(legend.getLabelField());
308 308
			excepType.setLegendHeightField(legend.getLabelHeightField());
309 309
			excepType.setLegendRotationField(legend.getLabelRotationField());
310
			
310

  
311 311
			DriverException exception = new DriverException(e, excepType);
312 312
			capa.setAvailable(false);
313 313
			capa.addError(exception);
314 314
		} catch (DriverIOException e) {
315 315
			//by design, start and stop calls to adapter could
316 316
			//cause this exception.
317
			
317

  
318 318
			//but JDBC implementations catchs all exceptions,
319
			//and rest of layers (WFSLayer, etc.) dont use LayerFactory	
319
			//and rest of layers (WFSLayer, etc.) dont use LayerFactory
320 320
			ExceptionDescription type = null;
321 321
			if (d instanceof VectorialFileDriver) {
322 322
				File f = ((VectorialFileDriver)adapter).getFile();
323
				type = 
324
					new DriverIOExceptionType(); 
323
				type =
324
					new DriverIOExceptionType();
325 325
				((DriverIOExceptionType)type).setFile(f);
326
				
326

  
327 327
			}else{
328 328
				type = new GenericDriverExceptionType();
329 329
			}
......
342 342

  
343 343
	/**
344 344
	 * Crea una capa Raster a partir del nombre driver, fichero y proyecci?n.
345
	 * 
345
	 *
346 346
	 * @param layerName
347 347
	 *            Nombre de la capa.
348 348
	 * @param d
......
351 351
	 *            Fichero.
352 352
	 * @param proj
353 353
	 *            Proyecci?n.
354
	 * 
354
	 *
355 355
	 * @return Nueva capa de tipo raster.
356
	 * 
356
	 *
357 357
	 * @throws DriverIOException
358 358
	 */
359 359
	public static FLyrRaster createLayer(String layerName, RasterDriver d,
......
384 384
	 * coordenadas de georeferenciaci?n. Esta funci?n es para georeferenciar
385 385
	 * capas raster. Para imagenes que no tienen georeferenciaci?n hay que
386 386
	 * asignarle una temporal, normalmente a partir de la vista activa.
387
	 * 
387
	 *
388 388
	 * @param layerName
389 389
	 *            Nombre de la capa.
390 390
	 * @param d
......
395 395
	 *            Proyecci?n.
396 396
	 * @param extent
397 397
	 *            Extent de la vista activa
398
	 * 
398
	 *
399 399
	 * @return Nueva capa de tipo raster.
400
	 * 
400
	 *
401 401
	 * @throws DriverIOException
402 402
	 */
403 403
	public static FLyrRaster createLayer(String layerName, RasterDriver d,
......
423 423

  
424 424
		return capa;
425 425
	}
426
	
426

  
427 427
	/**
428 428
	 * Creates a new raster layer in memory. To create this layer type we have to set a data
429 429
	 * buffer and a bounding box instead of a file. Don't use without CMS raster library that
......
431 431
	 * @param layerName Layer name
432 432
	 * @param d raster driver
433 433
	 * @param buf data buffer
434
	 * @param ext bounding box 
435
	 * @param proj projection 
434
	 * @param ext bounding box
435
	 * @param proj projection
436 436
	 * @return raster layer
437 437
	 * @throws DriverException
438 438
	 */
......
443 443

  
444 444
		FLyrRaster capa = new FLyrRaster();
445 445
		capa.setName(layerName);
446
		
446

  
447 447
		// TODO Meter esto dentro de la comprobaci?n de si hay memoria
448 448
		if (false) {
449 449
		} else {
......
504 504
	/**
505 505
	 * Crea un RandomVectorialWFS con el driver que se le pasa como par?metro y
506 506
	 * guard?ndose la URL del servidor que se pasa como par?metro
507
	 * 
507
	 *
508 508
	 * @param driver
509 509
	 * @param host
510 510
	 * @param port
......
513 513
	 * @param dbName
514 514
	 * @param tableName
515 515
	 * @param proj
516
	 * 
516
	 *
517 517
	 * @return Capa creada.
518
	 * 
518
	 *
519 519
	 * @throws UnsupportedOperationException
520 520
	 */
521 521
	public static FLayer createLayer(VectorialDatabaseDriver driver,
......
552 552
				// que implementan IDelayedDriver, el driver es responsable
553 553
				// de avisar cu?ndo est? listo
554 554
				capa.getFLayerStatus().setDriverLoaded(false);
555
				((IDelayedDriver) driver).addDriverEventListener(new DefaultDelayedDriverListener(capa)); 
555
				((IDelayedDriver) driver).addDriverEventListener(new DefaultDelayedDriverListener(capa));
556 556
			}
557 557
			// PARCHE: Llamamos a getXmlEntity del driver para que se rellenen
558 558
			// los valores de host, port, etc, necesarios para un posible reload
559 559
			driver.setXMLEntity(driver.getXMLEntity());
560 560

  
561 561
		} catch (FieldNotFoundException e) {
562
			LegendDriverExceptionType excepType = 
562
			LegendDriverExceptionType excepType =
563 563
				new LegendDriverExceptionType("Error al construir la leyenda, campo no encontrado");
564 564
			//TODO Para hacer esto extensible tiene que usarse puntos
565 565
			//de extension, y comparar las clases de leyendas registradas
566
			VectorialLegend legend = (VectorialLegend) 
566
			VectorialLegend legend = (VectorialLegend)
567 567
				((WithDefaultLegend)driver).getDefaultLegend();
568
			
568

  
569 569
			excepType.setLegendLabelField(legend.getLabelField());
570 570
			excepType.setLegendHeightField(legend.getLabelHeightField());
571 571
			excepType.setLegendRotationField(legend.getLabelRotationField());
......
575 575
			return capa;
576 576
			// throw new UnsupportedOperationException(e.getMessage());
577 577
		} catch (DriverException e) {
578
			DBDriverExceptionType excepType = 
578
			DBDriverExceptionType excepType =
579 579
				new DBDriverExceptionType();
580 580
			excepType.setDriverName(driver.getName());
581 581
			excepType.setTableName(driver.getTableName());
......
697 697
	/**
698 698
	 * Crea una FLyrComplexRaster que ataca al driver que se pasa como
699 699
	 * par?metro.
700
	 * 
700
	 *
701 701
	 * @param driver
702 702
	 * @param f
703 703
	 * @param proj
704
	 * 
704
	 *
705 705
	 * @throws IllegalArgumentException
706 706
	 *             Si se pasa un driver que no implementa
707 707
	 *             GeorreferencedRasterDriver o NotGeorreferencedRasterDriver
......
712 712

  
713 713
	/**
714 714
	 * Devuelve el DriverManager.
715
	 * 
715
	 *
716 716
	 * @return DriverManager.
717 717
	 */
718 718
	public static DriverManager getDM() {
......
723 723

  
724 724
	/**
725 725
	 * Devuelve el WriterManager.
726
	 * 
726
	 *
727 727
	 * @return WriterManager.
728 728
	 */
729 729
	public static WriterManager getWM() {
......
774 774

  
775 775
	/**
776 776
	 * sets drivers Directory
777
	 * 
777
	 *
778 778
	 * @param path
779 779
	 */
780 780
	public static void setDriversPath(String path) {
......
784 784

  
785 785
	/**
786 786
	 * sets writers Directory
787
	 * 
787
	 *
788 788
	 * @param path
789 789
	 */
790 790
	public static void setWritersPath(String path) {

Also available in: Unified diff