From: <bma...@us...> - 2008-11-18 17:25:36
|
Revision: 4223 http://fudaa.svn.sourceforge.net/fudaa/?rev=4223&view=rev Author: bmarchan Date: 2008-11-18 17:25:33 +0000 (Tue, 18 Nov 2008) Log Message: ----------- Enregistrement du num?\195?\169ro de version software dans le fichier projet. Modified Paths: -------------- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/save/FudaaSaveProject.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlImplementation.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigProjectPersistence.java branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/all/TestJProjectSave.java Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java 2008-11-18 17:19:43 UTC (rev 4222) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/ZScene.java 2008-11-18 17:25:33 UTC (rev 4223) @@ -706,9 +706,6 @@ * @param _calque Peut \xEAtre null. */ public void setCalqueActif(BCalque _calque) { - if (FuLog.isTrace()) { - FuLog.trace("EBL: calque actif=" + (_calque == null ? "null" : _calque.getTitle())); - } boolean sendEvent=false; @@ -804,7 +801,6 @@ * @see javax.swing.event.TreeModelListener#treeNodesInserted(javax.swing.event.TreeModelEvent) */ public void treeNodesInserted(TreeModelEvent e) { - FuLog.warning("ZScene.treeNodesInserted"); refreshRequested(); } @@ -812,7 +808,6 @@ * @see javax.swing.event.TreeModelListener#treeNodesRemoved(javax.swing.event.TreeModelEvent) */ public void treeNodesRemoved(TreeModelEvent e) { - FuLog.warning("ZScene.treeNodesRemoved"); refreshRequested(); } @@ -820,7 +815,6 @@ * @see javax.swing.event.TreeModelListener#treeStructureChanged(javax.swing.event.TreeModelEvent) */ public void treeStructureChanged(TreeModelEvent e) { - FuLog.warning("ZScene.treeStructureChanged"); refreshRequested(); } Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java 2008-11-18 17:19:43 UTC (rev 4222) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/ebli/src/org/fudaa/ebli/calque/edition/ZEditorDefault.java 2008-11-18 17:25:33 UTC (rev 4223) @@ -704,9 +704,6 @@ } updatePalette(); activeCurrentState(); - if (FuLog.isTrace()) { - FuLog.trace("EBL:target=" + _o); - } } public final void setDesktop(final BuDesktop _desktop) { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/save/FudaaSaveProject.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/save/FudaaSaveProject.java 2008-11-18 17:19:43 UTC (rev 4222) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/commun/save/FudaaSaveProject.java 2008-11-18 17:25:33 UTC (rev 4223) @@ -22,6 +22,7 @@ import com.memoire.bu.BuIcon; import com.memoire.bu.BuInformationsDocument; +import com.memoire.bu.BuInformationsSoftware; import com.memoire.bu.BuLib; import com.memoire.fu.FuLog; @@ -45,10 +46,10 @@ private FudaaSaveProject() {} /** - * Enregistre les informations fichier (version, format, etc.) sur le flux courant. + * Enregistre les informations li\xE9es au syst\xE8me de mod\xE9lisation (syst\xE8me, version, etc.) sur le flux courant. * * @param _writer Le flux pour l'ecriture. - * @param _soft Les informations fichier. + * @param _soft Les informations syst\xE8me de mod\xE9lisation. Peut \xEAtre null. * @throws IOException En cas d'erreur d'\xE9criture dans le zip. */ public static void saveIn(final FudaaSaveZipWriter _writer, final FileFormatSoftware _soft) throws IOException { @@ -64,15 +65,17 @@ } } + /** - * Enregistre les donn\xE9es g\xE9n\xE9rales du projet sur le flux courant. Le nom de l'auteur, le titre, etc. + * Enregistre les donn\xE9es g\xE9n\xE9rales du document sur le flux courant. Le nom de l'auteur, le titre, etc. * @param _writer Le flux pour l'ecriture. - * @param _soft Les donn\xE9es g\xE9n\xE9rales. + * @param _doc Les donn\xE9es g\xE9n\xE9rales du document. Peut \xEAtre null. + * @param _soft Les infos du soft qui a g\xE9n\xE9r\xE9 le document. Peut \xEAtre null. * @throws IOException En cas d'erreur d'\xE9criture dans le zip. */ - public static void saveIn(final FudaaSaveZipWriter _writer, final BuInformationsDocument _soft) throws IOException { - if (_soft != null) { + public static void saveIn(final FudaaSaveZipWriter _writer, final BuInformationsDocument _doc, final BuInformationsSoftware _soft) throws IOException { + if (_doc != null) { String logo = null; _writer.startEntry("project.xml"); final CtuluXmlWriter writer = new CtuluXmlWriter(_writer.getOutStream()); @@ -81,38 +84,51 @@ writer.setMainTag("document"); writer.writeComment("Dernier enregistrement"); writer.writeComment("Last save session"); - writer.writeEntry("date", FudaaLib.getDefaultDateFormat().format(new Date())); - if (_soft.name != null) { + + // Infos sur le software. + if (_soft!=null) { + if (_soft.name!=null) { + writer.writeComment("Nom de l'application"); + writer.writeComment("Software name"); + writer.writeEntry("software.name", _soft.name); + } + if (_soft.version!=null) { + writer.writeComment("Version de l'application"); + writer.writeComment("Software version"); + writer.writeEntry("software.version", _soft.version); + } + } + if (_doc.name != null) { writer.writeComment("Le nom du projet"); writer.writeComment("The title of the project"); - writer.writeEntry("title", _soft.name); + writer.writeEntry("title", _doc.name); } writer.write(CtuluLibString.LINE_SEP); writer.writeComment("Le responsable"); writer.writeComment("The author"); writer.write(CtuluLibString.LINE_SEP); - if (_soft.author != null) { + if (_doc.author != null) { writer.writeComment("Le responsable du projet"); writer.writeComment("The responsable of the author"); - writer.writeEntry("author", _soft.author); + writer.writeEntry("author", _doc.author); } - if (_soft.organization != null) { + if (_doc.organization != null) { writer.writeComment("L'organisation du responsable"); writer.writeComment("The author's organization"); - writer.writeEntry("organization", _soft.organization); + writer.writeEntry("organization", _doc.organization); } - if (_soft.department != null) { + if (_doc.department != null) { writer.writeComment("Le d\xE9partement du responsable"); writer.writeComment("The author's department"); - writer.writeEntry("department", _soft.department); + writer.writeEntry("department", _doc.department); } - if (_soft.contact != null) { + if (_doc.contact != null) { writer.writeComment("Un contact pour le responsable (email, tel, ..)"); writer.writeComment("how to contact the author (email, phone, ...)"); - writer.writeEntry("contact", _soft.contact); + writer.writeEntry("contact", _doc.contact); } - if (_soft.logo != null) { + if (_doc.logo != null) { writer.writeComment("Le nom du fichier image contenant le logo ( present dans l'archive)"); writer.writeComment("The filename of the logo"); logo = "author-logo.png"; @@ -121,20 +137,21 @@ writer.write(CtuluLibString.LINE_SEP); writer.writeComment("Description du projet"); writer.writeComment("Project's description"); - if (_soft.comment != null) { + if (_doc.comment != null) { writer.writeComment("Description g\xE9n\xE9ral sur le projet"); writer.writeComment("General description of the project"); - writer.writeEntry("description", _soft.comment); + writer.writeEntry("description", _doc.comment); } writer.write(CtuluLibString.LINE_SEP); - final Object o = _soft.data; + final Object o = _doc.data; if (o != null && o instanceof FudaaCommentModel) { ((FudaaCommentModel) o).writeIn(writer); } writer.finish(); + if (logo != null) { _writer.startEntry(logo); - ImageIO.write(BuLib.convert(_soft.logo.getImage()), "png", _writer.getOutStream()); + ImageIO.write(BuLib.convert(_doc.logo.getImage()), "png", _writer.getOutStream()); _writer.getOutStream().flush(); } } @@ -185,6 +202,40 @@ } /** + * Charge les infos software du projet depuis le flux courant. Le nom de l'application, la version, etc. + * @param _loader Le flux pour le chargement. + * @return Les infos software. + * @throws IOException En cas d'erreur de lecture, si le fichier n'est pas pr\xE9sent dans le zip. + */ + public static BuInformationsSoftware getSoftwareInfos(final FudaaSaveZipLoader _loader) throws IOException { + if (_loader == null) { + return null; + } + final InputStream in = _loader.getInputStream("project.xml"); + if (in == null) { + return null; + } + CtuluXmlReaderHelper reader = null; + try { + reader = new CtuluXmlReaderHelper(in); + } catch (final SAXException _evt) { + FuLog.error(_evt); + + } catch (final ParserConfigurationException _evt) { + FuLog.error(_evt); + + } + if (reader == null) { + return null; + } + final BuInformationsSoftware soft = new BuInformationsSoftware(); + soft.name = reader.getTrimTextFor("software.name"); + soft.version = reader.getTrimTextFor("software.version"); + return soft; + + } + + /** * Charge les informations fichier (version, format, etc.) depuis le flux courant. * @param _loader Le flux pour le chargement. * @return Les informations fichier. Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlImplementation.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlImplementation.java 2008-11-18 17:19:43 UTC (rev 4222) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/modeleur/MdlImplementation.java 2008-11-18 17:25:33 UTC (rev 4223) @@ -46,6 +46,7 @@ import org.fudaa.fudaa.commun.impl.FudaaLookPreferencesPanel; import org.fudaa.fudaa.commun.impl.FudaaStartupExitPreferencesPanel; import org.fudaa.fudaa.commun.save.FudaaSaveLib; +import org.fudaa.fudaa.commun.save.FudaaSaveProject; import org.fudaa.fudaa.commun.save.FudaaSaveZipLoader; import org.fudaa.fudaa.sig.FSigLib; import org.fudaa.fudaa.sig.FSigProjectPersistence; @@ -86,7 +87,7 @@ protected static BuInformationsSoftware isMdl_ = new BuInformationsSoftware(); static { isMdl_.name = "Modeleur"; - isMdl_.version = "0.07"; + isMdl_.version = "0.08-alpha"; isMdl_.date = "2008-11-12"; isMdl_.rights = "Tous droits r\xE9serv\xE9s. CETMEF (c)1999-2008"; isMdl_.license = "GPL2"; @@ -156,8 +157,6 @@ * Mise \xE0 jour de l'\xE9tat des boutons. */ void updateActionsState() { - FuLog.trace("Project state change"); - boolean bprjOpen=project_!=null; boolean bprjModPar=bprjOpen && project_.getProjectState().isParamsModified(); boolean buiMod=bprjOpen && project_.getProjectState().isUIModified(); @@ -346,7 +345,18 @@ project_.setOpening(true); Runnable r = null; try { - r = FudaaSaveLib.restoreFille(MdlImplementation.this, currentFrame_, _proj, f); + try { + FudaaSaveZipLoader loader=new FudaaSaveZipLoader(f); + // Recup des infos pour utilisateur. + BuInformationsSoftware is=FudaaSaveProject.getSoftwareInfos(loader); + FuLog.warning("File version : "+(is.version==null ? "Undefined":is.version)); + + r= FudaaSaveLib.restoreFille(MdlImplementation.this, currentFrame_, _proj,loader); + } catch (final IOException _evt) { + FuLog.error(_evt); + + } + project_.setParamFile(f); } finally { Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigProjectPersistence.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigProjectPersistence.java 2008-11-18 17:19:43 UTC (rev 4222) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/src/org/fudaa/fudaa/sig/FSigProjectPersistence.java 2008-11-18 17:25:33 UTC (rev 4223) @@ -68,7 +68,7 @@ writer = new FudaaSaveZipWriter(zipFile); FSigLib.addReadmeFile(writer); FudaaSaveProject.saveIn(writer, _proj.getSystemVersion()); - FudaaSaveProject.saveIn(writer, _proj.getInformationsDocument()); + FudaaSaveProject.saveIn(writer, _proj.getInformationsDocument(), _impl.getInformationsSoftware()); final ObjectContainer cont = writer.getDb(); // final FudaaSaveMainData data = new FudaaSaveMainData(); // data.infoDoc_ = _proj.getInformationsDocument(); Modified: branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/all/TestJProjectSave.java =================================================================== --- branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/all/TestJProjectSave.java 2008-11-18 17:19:43 UTC (rev 4222) +++ branches/FudaaModeleur_TC1Bis/fudaa_devel/fudaa/test/org/fudaa/fudaa/all/TestJProjectSave.java 2008-11-18 17:25:33 UTC (rev 4223) @@ -13,6 +13,7 @@ import junit.framework.TestCase; import com.memoire.bu.BuInformationsDocument; +import com.memoire.bu.BuInformationsSoftware; import org.fudaa.ctulu.CtuluXmlReaderHelper; import org.fudaa.ctulu.CtuluXmlWriter; @@ -64,12 +65,15 @@ f = File.createTempFile("toto", ".fzip"); assertNotNull(f); final BuInformationsDocument doc = new BuInformationsDocument(null); + final BuInformationsSoftware soft=new BuInformationsSoftware(); + soft.name="TesterSoft"; + soft.version="0.01"; doc.author = "Auteur"; doc.comment = "commentaires\n sur des lignes"; // doc.logo = FudaaResource.FUDAA.getIcon("fudaa-logo.png"); doc.data = createComment(); final FudaaSaveZipWriter writer = new FudaaSaveZipWriter(f); - FudaaSaveProject.saveIn(writer, doc); + FudaaSaveProject.saveIn(writer, doc,soft); writer.close(); final FudaaSaveZipLoader loader = new FudaaSaveZipLoader(f); final BuInformationsDocument doc2 = FudaaSaveProject.loadInfo(loader); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |