Revision 33399

View differences:

branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/Project.java
14 14
import org.gvsig.fmap.mapcontext.layers.FLayer;
15 15
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
16 16
import org.gvsig.tools.persistence.Persistent;
17
import org.gvsig.tools.persistence.exception.PersistenceException;
17 18

  
18 19
public interface Project extends Iterable<Document>,  Persistent{
19 20

  
......
187 188
	 */
188 189
	public Document getDocument(String name, String type);
189 190

  
190
	public void saveState(File out);
191
	public void saveState(File out) throws PersistenceException;
191 192
	
192
	public void saveState(OutputStream out);
193
	public void saveState(OutputStream out) throws PersistenceException;
193 194

  
194 195
	public void loadState(InputStream in);
195 196

  
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/DefaultProject.java
527 527
		}
528 528
	}
529 529

  
530
	public void saveState(File out) {
530
	public void saveState(File out) throws PersistenceException {
531 531
		FileOutputStream fout;
532 532
		try {
533 533
			fout = new FileOutputStream(out);
534 534
			saveState(fout, new File(out.getParent()));
535 535
		} catch (FileNotFoundException e) {
536
			// TODO Auto-generated catch block
537
			e.printStackTrace();
536
			throw new PersistenceException(e);
538 537
		}
539 538
	}
540 539
	
541
	public void saveState(OutputStream out) {
540
	public void saveState(OutputStream out) throws PersistenceException {
542 541
		saveState(out, null);
543 542
	}
544 543
	
545
	public void saveState(OutputStream out, File rootFolder) {
544
	public void saveState(OutputStream out, File rootFolder) throws PersistenceException {
546 545
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
547
		try {
548 546
			PersistentState state = manager.getState(this);
549 547
			if( rootFolder!=null ) {
550 548
				relativizeFiles(state, rootFolder);
551 549
			}
552 550
			manager.saveState( state, out);
553
		} catch (PersistenceTypeNotSupportedException e) {
554
			LOG.warn("Can't save state of project.",e);
555
		} catch (PersistenceClassNotRegistered e) {
556
			LOG.warn("Can't save state of project.",e);
557
		} catch (PersistenceException e) {
558
			LOG.warn("Can't save state of project.",e);
559
		} catch (PersistenceValidateExceptions e) {
560
			LOG.warn("Can't save state of project.",e);
561
		}
562 551
	}
563 552
	
564 553
	private void relativizeFiles(PersistentState state, File rootFolder) {
......
666 655
				}
667 656
			}
668 657
		}
669
		state.set("windowsInformation", windowsStates);
658
		LOG.warn("DefaultProject::saveToState, falta por persistir 'windowsInformation'");
659
		//state.set("windowsInformation", windowsStates);
670 660
		
671 661
	}
672 662
			
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/extension/ProjectExtension.java
56 56
import org.exolab.castor.xml.MarshalException;
57 57
import org.exolab.castor.xml.ValidationException;
58 58
import org.gvsig.andami.Launcher;
59
import org.gvsig.andami.Launcher.TerminationProcess;
59 60
import org.gvsig.andami.PluginServices;
60
import org.gvsig.andami.Launcher.TerminationProcess;
61 61
import org.gvsig.andami.messages.NotificationManager;
62 62
import org.gvsig.andami.plugins.Extension;
63 63
import org.gvsig.andami.plugins.IExtension;
......
79 79
import org.gvsig.gui.beans.swing.JFileChooser;
80 80
import org.gvsig.tools.ToolsLocator;
81 81
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
82
import org.gvsig.tools.persistence.exception.PersistenceException;
82 83
import org.gvsig.utils.GenericFileFilter;
83 84
import org.gvsig.utils.XMLEntity;
84 85
import org.gvsig.utils.save.AfterSavingListener;
......
461 462
		try {
462 463
			fireBeforeSavingFileEvent(new SaveEvent(this, SaveEvent.BEFORE_SAVING, file));
463 464
			p.saveState(file);
464
//            FileOutputStream fos = new FileOutputStream(file.getAbsolutePath());
465
//            OutputStreamWriter writer = new OutputStreamWriter(fos, PROJECTENCODING);
466
//			Marshaller m = new Marshaller(writer);
467
//			m.setEncoding(PROJECTENCODING);
468
//			p.setName(file.getName());
469
//			// p.setPath(file.toString());
470
//			//p.setModificationDate(DateFormat.getDateInstance().format(new Date()));
471
//			p.setModified(false);
472
//			XMLEntity xml = p.getXMLEntity();
473
//			xml.putProperty("followHeaderEncoding", true, false);
474
//			m.marshal(xml.getXmlTag());
475 465
			fireAfterSavingFileEvent(new SaveEvent(this, SaveEvent.AFTER_SAVING, file));
476 466
			PluginServices.getMainFrame().setTitle(file.getName());
477 467
			setPath(file.toString());
478 468

  
469
		} catch (PersistenceException e) {
470
			String messagestack = e.getLocalizedMessageStack(); 
471
			NotificationManager.addError(
472
				PluginServices.getText(this,
473
					"error_writing_project")+ 
474
					": "+
475
					file.getName()+
476
					"\n"+
477
					messagestack,
478
				e
479
			);
480
			return false;
479 481
		} catch (Exception e) {
480 482
			NotificationManager.addError(PluginServices.getText(this,"error_writing_project")+ ": "+file.getName(), e);
481 483
			return false;

Also available in: Unified diff