From: Frederic D. <de...@us...> - 2004-04-27 16:09:45
|
Update of /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/hydraulique1d In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1589/src/org/fudaa/fudaa/hydraulique1d Modified Files: Hydraulique1dProjet.java Log Message: Modif DObjets Index: Hydraulique1dProjet.java =================================================================== RCS file: /cvsroot/fudaa/fudaa_devel/fudaa/src/org/fudaa/fudaa/hydraulique1d/Hydraulique1dProjet.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Hydraulique1dProjet.java 20 Feb 2004 19:30:23 -0000 1.8 --- Hydraulique1dProjet.java 27 Apr 2004 16:09:36 -0000 1.9 *************** *** 8,13 **** --- 8,17 ---- */ package org.fudaa.fudaa.hydraulique1d; + import org.fudaa.ctulu.CtuluLib; import org.fudaa.dodico.hydraulique1d.*; + import org.fudaa.dodico.boony.BoonyXmlDeserializer; + import org.fudaa.dodico.boony.BoonyXmlSerializer; import org.fudaa.dodico.corba.hydraulique1d.*; + import org.fudaa.fudaa.commun.FudaaLib; import org.fudaa.fudaa.hydraulique1d.*; import org.fudaa.fudaa.hydraulique1d.reseau.*; *************** *** 35,39 **** protected int etatMenu_= 0; protected File fichier_; ! private static String FORMAT_DJA_VERSION= "0.01"; protected Hydraulique1dProjet(){} --- 39,47 ---- protected int etatMenu_= 0; protected File fichier_; ! private static String FORMAT_DJA_VERSION= "0.02"; ! private static String FORMAT_DJA_VERSION_OLD_READER= "0.01"; ! private static String FORMAT_DJA_VERSION_NEW_READER= "0.02"; ! ! protected Hydraulique1dProjet(){} *************** *** 94,98 **** String versionEtude= "" + FluxLu.readChar() + FluxLu.readChar() + FluxLu.readChar(); ! if (ietude1d_.versionFormat().compareTo(versionEtude) > 0) { new BuDialogError( (BuCommonInterface)Hydraulique1dBaseApplication.FRAME, --- 102,110 ---- String versionEtude= "" + FluxLu.readChar() + FluxLu.readChar() + FluxLu.readChar(); ! if(versionEtude.equals(DEtude1d.FORMAT_VERSION_WITH_OLD_READER) && DEtude1d.FORMAT_VERSION.equals(DEtude1d.FORMAT_VERSION_WITH_NEW_READER)){ ! System.out.println("ancienne sauv"); ! if(CtuluLib.DEBUG) CtuluLib.debug("ancienne sauvegarde"); ! } ! else if (ietude1d_.versionFormat().compareTo(versionEtude) > 0) { new BuDialogError( (BuCommonInterface)Hydraulique1dBaseApplication.FRAME, *************** *** 122,131 **** .activate(); return false; ! } else { byte[] binaireEtudeServeur= new byte[FluxLu.readInt()]; FluxLu.read(binaireEtudeServeur); ! ietude1d_= ietude1d_.initFromByteArray(binaireEtudeServeur, true); binaireEtudeServeur= null; - } // initialisation de la fenêtre contenant le réseau hydraulique (DJA) String versionDJA= --- 134,143 ---- .activate(); return false; ! } ! byte[] binaireEtudeServeur= new byte[FluxLu.readInt()]; FluxLu.read(binaireEtudeServeur); ! ietude1d_= ietude1d_.initFromByteArray(binaireEtudeServeur, true,versionEtude); binaireEtudeServeur= null; // initialisation de la fenêtre contenant le réseau hydraulique (DJA) String versionDJA= *************** *** 135,139 **** + FluxLu.readChar() + FluxLu.readChar(); ! if (FORMAT_DJA_VERSION.compareTo(versionDJA) > 0) { new BuDialogError( (BuCommonInterface)Hydraulique1dBaseApplication.FRAME, --- 147,156 ---- + FluxLu.readChar() + FluxLu.readChar(); ! //special nouvelle version ! if(versionDJA.equals(FORMAT_DJA_VERSION_OLD_READER) && FORMAT_DJA_VERSION.equals(FORMAT_DJA_VERSION_NEW_READER)){ ! if(CtuluLib.DEBUG) ! CtuluLib.debug("Dja: Read old version"); ! } ! else if (FORMAT_DJA_VERSION.compareTo(versionDJA) > 0) { new BuDialogError( (BuCommonInterface)Hydraulique1dBaseApplication.FRAME, *************** *** 163,172 **** .activate(); return true; ! } else { byte[] binaireDja= new byte[FluxLu.readInt()]; FluxLu.read(binaireDja); ! initDjaFrameFromByteArray(binaireDja); etatMenu_= ietude1d_.etatMenu(); - } FluxLu.close(); } catch (IOException ex) { --- 180,188 ---- .activate(); return true; ! } byte[] binaireDja= new byte[FluxLu.readInt()]; FluxLu.read(binaireDja); ! initDjaFrameFromByteArray(binaireDja,versionDJA); etatMenu_= ietude1d_.etatMenu(); FluxLu.close(); } catch (IOException ex) { *************** *** 236,240 **** in.read(binaireEtude); in.close(); ! ietude1d_= ietude1d_.initFromByteArray(binaireEtude, false); if (fichierReseau != null) { // initialisation de la fenêtre contenant le réseau hydraulique (DJA) --- 252,262 ---- in.read(binaireEtude); in.close(); ! try{ ! ietude1d_= ietude1d_.initFromByteArray(binaireEtude, false,DEtude1d.FORMAT_VERSION); ! } ! catch( NoSuchElementException e){ ! if(ietude1d_==null) ! ietude1d_.initFromByteArray(binaireEtude, false,DEtude1d.FORMAT_VERSION_WITH_OLD_READER); ! } if (fichierReseau != null) { // initialisation de la fenêtre contenant le réseau hydraulique (DJA) *************** *** 245,249 **** FileInputStream fos= new FileInputStream(fichierReseau); fos.read(binaireDja); ! initDjaFrameFromByteArray(binaireDja); fos.close(); } --- 267,280 ---- FileInputStream fos= new FileInputStream(fichierReseau); fos.read(binaireDja); ! //on le met a null pour le test ! f_=null; ! try{ ! initDjaFrameFromByteArray(binaireDja,FORMAT_DJA_VERSION); ! } ! catch(Exception e){ ! //si prob on essaie avec l'ancien reader ! if(f_==null ) initDjaFrameFromByteArray(binaireDja,FORMAT_DJA_VERSION_OLD_READER); ! } ! fos.close(); } *************** *** 314,318 **** infosDja[3]= f_.getGrid().getObjects(); try { ! YapodSerializer fluxEcrit= new YapodXmlSerializer(); fluxEcrit.open(baos); fluxEcrit.write(infosDja); --- 345,349 ---- infosDja[3]= f_.getGrid().getObjects(); try { ! YapodSerializer fluxEcrit= new BoonyXmlSerializer(false); fluxEcrit.open(baos); fluxEcrit.write(infosDja); *************** *** 324,328 **** return baos.toByteArray(); } ! protected void initDjaFrameFromByteArray(byte[] buffer) { if (buffer == null) return; --- 355,359 ---- return baos.toByteArray(); } ! protected void initDjaFrameFromByteArray(byte[] buffer,String _version) { if (buffer == null) return; *************** *** 331,345 **** try { ByteArrayInputStream bais= new ByteArrayInputStream(buffer); ! YapodDeserializer fluxLu= new YapodXmlDeserializer(); fluxLu.open(bais); Object[] infosDja= (Object[])fluxLu.read(); fluxLu.close(); String version= ((String)infosDja[0]).trim(); ! if (FORMAT_DJA_VERSION.compareTo(version) > 0) { System.err.println("le format de fichier est désuet : "); System.err.println(" Version fichier DJA ou Mascaret : " + version); System.err.println( " Version actuel DJA ou Mascaret : " + FORMAT_DJA_VERSION); ! } else if (FORMAT_DJA_VERSION.compareTo(version) > 0) { System.err.println( "le fichier est incorrect (n° version impossible) : "); --- 362,384 ---- try { ByteArrayInputStream bais= new ByteArrayInputStream(buffer); ! boolean isOldVersionReader=(FORMAT_DJA_VERSION.equals(FORMAT_DJA_VERSION_NEW_READER)) && ((_version.compareTo(FORMAT_DJA_VERSION_OLD_READER)<=0)); ! YapodDeserializer fluxLu= null; ! if(isOldVersionReader){ ! System.out.println("Dja ancien reader"); ! fluxLu=new YapodXmlDeserializer(); ! } ! else{ ! fluxLu= new BoonyXmlDeserializer(false); ! } fluxLu.open(bais); Object[] infosDja= (Object[])fluxLu.read(); fluxLu.close(); String version= ((String)infosDja[0]).trim(); ! if (!isOldVersionReader && FORMAT_DJA_VERSION.compareTo(version) > 0) { System.err.println("le format de fichier est désuet : "); System.err.println(" Version fichier DJA ou Mascaret : " + version); System.err.println( " Version actuel DJA ou Mascaret : " + FORMAT_DJA_VERSION); ! } else if (FORMAT_DJA_VERSION.compareTo(version) < 0) { System.err.println( "le fichier est incorrect (n° version impossible) : "); |