From: <had...@us...> - 2008-10-13 08:19:40
|
Revision: 4055 http://fudaa.svn.sourceforge.net/fudaa/?rev=4055&view=rev Author: hadouxad Date: 2008-10-13 08:15:09 +0000 (Mon, 13 Oct 2008) Log Message: ----------- MAJ Modified Paths: -------------- branches/Prepro-0.92-SNAPSHOT/ctulu/src/org/fudaa/ctulu/CtuluLibGenerator.java branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGraphePersist.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliScene.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetCreatorGraphe.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetCreatorLegende.java branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/persist/ManagerWidgetPersist.java branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/persist/TrPostPersistenceManager.java Added Paths: ----------- branches/Prepro-0.92-SNAPSHOT/ctulu/src/org/fudaa/ctulu/CtuluRemoveContentDirectory.java Removed Paths: ------------- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/GraphePersist.java Modified: branches/Prepro-0.92-SNAPSHOT/ctulu/src/org/fudaa/ctulu/CtuluLibGenerator.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ctulu/src/org/fudaa/ctulu/CtuluLibGenerator.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/ctulu/src/org/fudaa/ctulu/CtuluLibGenerator.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -24,7 +24,7 @@ /** * Tous les nombres seront inf\xE9rieurs a Max-1 */ - private static long MAX=65535; + private long max=65535; /** * Pour avoir toujours la meme sequence, il suffit de mettre le mode debug a true, @@ -80,7 +80,7 @@ public long useCongruenceLineaireGenerateur(){ - old= (a_*old + c_)% MAX; + old= (a_*old + c_)% max; return old; } @@ -100,13 +100,19 @@ * @return */ public long deliverUniqueId(){ + int nbTentatives=0; Long id; do{ + nbTentatives++; + if(nbTentatives>max-1){ + clear(); + } + id=new Long(useCongruenceLineaireGenerateur()); } while(constraints_.contains(id)); addConstraint(id); - FuLog.warning("Generation ID="+id); + return id; } @@ -144,4 +150,12 @@ long val=Long.parseLong(value); constraints_.remove(new Long(val)); } + + public long getMax() { + return max; + } + + public void setMax(long max) { + this.max = max; + } } Added: branches/Prepro-0.92-SNAPSHOT/ctulu/src/org/fudaa/ctulu/CtuluRemoveContentDirectory.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ctulu/src/org/fudaa/ctulu/CtuluRemoveContentDirectory.java (rev 0) +++ branches/Prepro-0.92-SNAPSHOT/ctulu/src/org/fudaa/ctulu/CtuluRemoveContentDirectory.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -0,0 +1,95 @@ +package org.fudaa.ctulu; + +import java.io.File; +/** + * Classe qui permet de faire le m\xE9nage dans un repertoire. + * On fournit le repertoire cible. + * le thread supprime le contenu du repertoire (tous les fichiers du repertoire.) + * @author Adrien Hadoux + * + */ +public class CtuluRemoveContentDirectory { + + + public File[] listing; + + public File Finit; + + /** + * Methode statique a appeler pour effacer recursivemetn le contenu d un repertoire + * @param file + */ + public static void contentDirectoryRemover(File file){ + new CtuluRemoveContentDirectory (file).demarrerSupression(); + } + + + public CtuluRemoveContentDirectory(File Finit) { + // on recupere le parametre + this.Finit = Finit; + + } + + + + + public void demarrerSupression() { + // on verifie si c'est un repertoire ..... + if (Finit.isDirectory()) { + // si s'en est un on liste son contenu + listing = Finit.listFiles(); + + + // tant qu'il y a des sous repertoires .... + while (listing.length > 0) { + // poiur chaque sous repertoire ... + for (int i = 0; i < listing.length; i++) { + // ...on verifie si c'est des fichier ... + if (listing[i].isFile()) { + // ... si ca en est on les supprime + boolean b = listing[i].delete(); + // on verifie si tout c'est bien passe + System.out.println("suppession de :" + listing[i] + ":" + + b); + } + // si c'est un repertoire on demare une methode... +// else{ +// // on demare la methode +// removeDirectoryContentRecursivly(listing[i]); +// } + } + } + + } + + + } + + + + private void removeDirectoryContentRecursivly(File ToDel) { + + File[] listing2 = ToDel.listFiles(); + + if(listing2==null || listing2.length==0) + return; + for (int i= 0;i<listing2.length; i++) { + // ...verifie si c'est un fichier + if (listing2[i].isFile()) { + // on le supprime et on verifie que c'est bon + boolean b = listing2[i].delete(); + + } + // sinon c'est un repertoire + else { + // on applique de nouveau la methode sur le repertoire + removeDirectoryContentRecursivly(listing2[i]); + } + } + } + + + + + +} Modified: branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/dodico/src/org/fudaa/dodico/telemac/io/ScopeStructure.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -563,10 +563,10 @@ List<Double> listeX=getListValueForVariableForSeparator(getSeparator(separatorX), varX+1); List<Double> listeY=getListValueForVariableForSeparator(getSeparator(separatorY), varY+1); - double[] tabX = new double[listeX.size()]; - double[] tabY = new double[listeY.size()]; + double[] tabX = new double[Math.min(listeX.size(), listeY.size())]; + double[] tabY = new double[Math.min(listeX.size(), listeY.size())]; - for (int j = 0; j < listeX.size(); j++) { + for (int j = 0; j < Math.min(listeX.size(), listeY.size()); j++) { tabX[j] = listeX.get(j); tabY[j] = listeY.get(j); Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGraphePersist.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGraphePersist.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/EGGraphePersist.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -8,9 +8,11 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Map; +import org.fudaa.ctulu.CtuluRemoveContentDirectory; import org.fudaa.ebli.visuallibrary.persist.EbliSceneSerializeXml; import org.fudaa.ebli.visuallibrary.persist.EbliWidgetSerializeXml; @@ -96,7 +98,16 @@ return new XmlArrayList( new FileStreamStrategy(getDirectoryCurves())); } + /** + * Methode qui nettoie le contenu des datas + */ + private void clearDatas(List<EGCourbePersist> list ){ + CtuluRemoveContentDirectory.contentDirectoryRemover(getDirectoryCurves()); + + } + + /** * Enrtegistre le graphe au format persistant xml. * @param parameters des parametres supplementaires utiles. * @throws IOException @@ -108,13 +119,14 @@ //-- enregistrement des courbes --// // strategy pour la liste xml: aun fichier par courbe. File fichierCourbes=getDirectoryCurves(); - if(fichierCourbes.mkdir()){ - StreamStrategy strategy = new FileStreamStrategy(fichierCourbes); + if(fichierCourbes.mkdir() || fichierCourbes.isDirectory() ){ + //StreamStrategy strategy = new FileStreamStrategy(fichierCourbes); // creates the list of curves: - List<EGCourbePersist> list = getPersitantCurvesList(); + List<EGCourbePersist> list = new ArrayList<EGCourbePersist>(); + clearDatas(list); List<EGGroupPersist> listeGroupePersistance=new ArrayList<EGGroupPersist>(grapheTopersist.getModel().getNbEGObject()); - - for(int i=0;i<grapheTopersist.getModel().getNbEGObject();i++){ + int nbEgObjects=grapheTopersist.getModel().getNbEGObject(); + for(int i=0;i<nbEgObjects;i++){ EGObject objet=grapheTopersist.getModel().getEGObject(i); if(objet instanceof EGGroup){ EGGroup groupe=(EGGroup) objet; @@ -131,7 +143,8 @@ list.add(new EGCourbePersist((EGCourbeChild) objet,-1)); } } - + List<EGCourbePersist> listPersitante = getPersitantCurvesList(); + listPersitante.addAll(list); //--on enregistre des infos bidons pour l'utilisateur --// String nbCurves="Nombre courbes: "+grapheTopersist.getModel().getCourbes().length; out.writeObject(nbCurves); Deleted: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/GraphePersist.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/GraphePersist.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/courbe/GraphePersist.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -1,13 +0,0 @@ -package org.fudaa.ebli.courbe; - - -/** - * Classe qui r\xE9cup\xE8re les donn\xE9es courbes d'un graphe et enregistre les parametres - * @author Adrien Hadoux - * - */ -public class GraphePersist { - - - -} Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliScene.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliScene.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliScene.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -306,5 +306,24 @@ public EbliWidgetJXTreeTableModel getTreeModel() { return treeModel_; } - + + /** + * Methode qui retourne l'ebliNode correspondant a l id de widget. + * Retourne null sinon. + * @param id + * @return + */ + public EbliNode findByWidgetId(String id) + { + + for(Object objet:this.getObjects()){ + if(objet instanceof EbliNode){ + EbliNode cible=(EbliNode)objet; + if(cible.getWidget().getId().equals(id)) + return cible; + } + } + return null; + + } } Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/EbliWidget.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -25,6 +25,8 @@ import org.netbeans.api.visual.model.ObjectState; import org.netbeans.api.visual.widget.Widget; +import com.memoire.fu.FuLog; + /** * Widget version EBLI * @@ -70,6 +72,7 @@ public EbliWidget(final EbliScene scene) { super(scene); id_ = scene.generateId(); + FuLog.warning("Generation frame ID="+id_); setScene(scene); // -- remplisage de la map de propriete grahiques --// Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetCreatorGraphe.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetCreatorGraphe.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetCreatorGraphe.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -20,6 +20,7 @@ import org.fudaa.ebli.visuallibrary.EbliWidgetBordureSingle; import org.fudaa.ebli.visuallibrary.EbliWidgetWithBordure; import org.fudaa.ebli.visuallibrary.creator.EbliWidgetCreator; +import org.fudaa.ebli.visuallibrary.persist.ManagerWidgetPersist; import org.w3c.dom.Element; import com.hexidec.ekit.FudaaAlignAction; @@ -117,12 +118,12 @@ public Object getPersistData(Map parameters) { // TODO Auto-generated method stub //-- generation d'un identifiant unique pour le repertoire du graphe --// - String pathUnique=parameters.get("pathGraphes")+File.separator+FuLib.clean(File.separator+parameters.get("nodeName"))+res.getIntern().getId(); - + // String pathUnique=parameters.get("pathGraphes")+File.separator+FuLib.clean(File.separator+parameters.get("nodeName"))+res.getIntern().getId(); + String pathUnique=ManagerWidgetPersist.generateGraphPath((String)parameters.get("pathGraphes"), res.getEbliScene().findByWidgetId(res.getId())); //- sauvegarde du contenu de l eggraphe dans un repertoire a part --// try { File createRep=new File(pathUnique); - if( createRep.mkdir()) + if( createRep.mkdir() || createRep.isDirectory()) new EGGraphePersist(pathUnique,parameters).savePersitGrapheXml(getGraphe()); } catch (IOException e) { // TODO Auto-generated catch block Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetCreatorLegende.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetCreatorLegende.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/graphe/EbliWidgetCreatorLegende.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -13,6 +13,7 @@ import org.fudaa.ebli.visuallibrary.EbliWidgetWithBordure; import org.fudaa.ebli.visuallibrary.calque.EbliWidgetControllerCalque; import org.fudaa.ebli.visuallibrary.creator.EbliWidgetCreator; +import org.fudaa.ebli.visuallibrary.persist.ManagerWidgetPersist; import org.netbeans.api.visual.widget.Widget; import org.w3c.dom.Element; @@ -21,11 +22,11 @@ EGGraphe g; // EbliWidget res; EbliWidgetWithBordure res; - private String IdPossessor_; + private String idPossessor_; public EbliWidgetCreatorLegende(EGGraphe g,String id) { super(); this.g = g; - IdPossessor_=id; + idPossessor_=id; } public EbliWidgetCreatorLegende(){ @@ -61,7 +62,8 @@ @Override public Object getPersistData(Map parameters) { // TODO Auto-generated method stub - return IdPossessor_; + + return idPossessor_; } @@ -69,26 +71,45 @@ // TODO Auto-generated method stub if(data==null) g=new EGGraphe(new EGGrapheTreeModel()); +// else{ +// String idGraphe=(String) data; +// +// EbliScene scene=(EbliScene) parameters.get("scene"); +// //-- recherche de la widget qui contient l'id et rejouer l'action ajouter legende --// +// for(Widget widget: scene.getLayerVisu().getChildren()){ +// EbliWidget candidat=null; +// if(widget instanceof EbliWidgetBordureSingle) +// candidat=((EbliWidgetBordureSingle) widget).getIntern(); +// else +// candidat=(EbliWidget) widget; +// +// if(candidat.getId().equals(idGraphe)){ +// //--on a le bon, on rejoue la legende --// +// ((EbliWidgetControllerGraphe)candidat.getController()).ajoutLegende(); +// return; +// } +// } +// } else{ - String idGraphe=(String) data; - - EbliScene scene=(EbliScene) parameters.get("scene"); - //-- recherche de la widget qui contient l'id et rejouer l'action ajouter legende --// - for(Widget widget: scene.getLayerVisu().getChildren()){ - EbliWidget candidat=null; - if(widget instanceof EbliWidgetBordureSingle) - candidat=((EbliWidgetBordureSingle) widget).getIntern(); + //--recuperation de l'id du graphe parent--// + if(data instanceof String){ + idPossessor_=(String) data; + + //-- recuperation du node graphe--// + EbliNode nodeGraphe=((EbliScene) parameters.get("scene")).findByWidgetId(idPossessor_); + + if(nodeGraphe!=null && nodeGraphe.getCreator() instanceof EbliWidgetControllerGraphe){ + //-- on recupere le graphe --// + g=((EbliWidgetControllerGraphe)nodeGraphe.getCreator()).getGraphe(); + } else - candidat=(EbliWidget) widget; + g=new EGGraphe(new EGGrapheTreeModel()); - if(candidat.getId().equals(idGraphe)){ - //--on a le bon, on rejoue la legende --// - ((EbliWidgetControllerGraphe)candidat.getController()).ajoutLegende(); - return; - } + } + else + g=new EGGraphe(new EGGrapheTreeModel()); } - } Modified: branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/persist/ManagerWidgetPersist.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/persist/ManagerWidgetPersist.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/ebli/src/org/fudaa/ebli/visuallibrary/persist/ManagerWidgetPersist.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -18,10 +18,12 @@ import org.fudaa.ctulu.gui.CtuluFileChooser; import org.fudaa.ctulu.gui.CtuluLibSwing; import org.fudaa.ebli.ressource.EbliResource; +import org.fudaa.ebli.visuallibrary.EbliNode; import org.fudaa.ebli.visuallibrary.EbliScene; import org.w3c.dom.Document; import org.w3c.dom.Element; +import com.memoire.fu.FuLib; import com.memoire.fu.FuLog; import com.sun.org.apache.xml.internal.serialize.OutputFormat; import com.sun.org.apache.xml.internal.serialize.XMLSerializer; @@ -36,68 +38,22 @@ public class ManagerWidgetPersist { - - - - public ManagerWidgetPersist() { - super(); - + /** + * Methode qui genere le path vers le graphe. + * + * @return + */ + public static String generateGraphPath(String path, EbliNode nodeGraphe){ + + return path+File.separator+File.separator+FuLib.clean(nodeGraphe.getTitle())+nodeGraphe.getWidget().getId(); + } - - - - /** - * Fichier qui cree le fichier qui indique les diff\xE9rents fichiers layout a - * lire. Cela permettra pour la lecture de proposer de charger ou non certains - * layout - * - * @return - */ - public static Document createDescriptorScenes(Document document, ArrayList<String> titles,String path, String baliseScene, String descriptorScene,String extension, String attribute) { - // creation du root - Element rootEle = document.createElement(baliseScene); - document.appendChild(rootEle); - // On cree des objets sans contenus qui decrivent simplement les fichiers - // scenes - Iterator<String> it = titles.iterator(); - int cpt = 1; - while (it.hasNext()) { - it.next(); - // contient le path absolu vers le fichier qui decrit le layout - rootEle.setAttribute(attribute+cpt, path + File.separator + descriptorScene + (cpt++) - + extension); -// Element sceneEle = document.createElement(path + File.separator + descriptorScene + cpt -// + extension); -// rootEle.appendChild(sceneEle); - } - return document; - } - + - /** - * Genere un document type dom - * - * @return Document - */ - public static Document createDocument() { - // get an instance of factory - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - try { - // get an instance of builder - DocumentBuilder db = dbf.newDocumentBuilder(); - // create an instance of DOM - Document dom = db.newDocument(); - return dom; - } catch (ParserConfigurationException pce) { - FuLog.debug("Error while trying to instantiate DocumentBuilder " + pce); - return null; - } - } - } Modified: branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/persist/TrPostPersistenceManager.java =================================================================== --- branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/persist/TrPostPersistenceManager.java 2008-10-12 14:20:03 UTC (rev 4054) +++ branches/Prepro-0.92-SNAPSHOT/fudaa/src/org/fudaa/fudaa/tr/post/persist/TrPostPersistenceManager.java 2008-10-13 08:15:09 UTC (rev 4055) @@ -387,6 +387,7 @@ //-- sauvegarde du persitant --// parametres.put("dimensions", fille.getSize()); parametres.put("location", fille.getLocation()); + parametres.put("scene", scene); savePersitSceneXml(scene,title,file,parametres); cpt++; @@ -525,14 +526,16 @@ while(it.hasNext()){ Widget widget=it.next(); - EbliNode nodeGroupe=(EbliNode) scene.findObject(widget); - //ecriture de l objet - if(nodeGroupe !=null) - listeGroupes.add(new EbliWidgetSerializeXml(nodeGroupe,parametres)); + if(widget instanceof EbliWidgetGroup){ - //-- cas widget group, il faut recuper ses child car on se fout du groupe --// - for(Widget child:widget.getChildren()) { + //-- cas widget group, il faut recuper ses child --// + EbliNode nodeGroupe=(EbliNode) scene.findObject(widget); + //ecriture de l objet + if(nodeGroupe !=null) + listeGroupes.add(new EbliWidgetSerializeXml(nodeGroupe,parametres)); + + for(Widget child:widget.getChildren()) { EbliNode node=(EbliNode) scene.findObject(child); //ecriture de l objet if(node !=null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |