Jaxx-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3898 discussions
r1703 - in trunk: . jaxx-compiler jaxx-demo jaxx-runtime jaxx-swing-action jaxx-widgets maven-jaxx-plugin
by tchemit@users.nuiton.org 23 Dec '09
by tchemit@users.nuiton.org 23 Dec '09
23 Dec '09
Author: tchemit
Date: 2009-12-23 10:14:47 +0100 (Wed, 23 Dec 2009)
New Revision: 1703
Modified:
trunk/jaxx-compiler/pom.xml
trunk/jaxx-demo/pom.xml
trunk/jaxx-runtime/pom.xml
trunk/jaxx-swing-action/pom.xml
trunk/jaxx-widgets/pom.xml
trunk/maven-jaxx-plugin/pom.xml
trunk/pom.xml
Log:
[maven-release-plugin] prepare for next development iteration
Modified: trunk/jaxx-compiler/pom.xml
===================================================================
--- trunk/jaxx-compiler/pom.xml 2009-12-23 09:14:42 UTC (rev 1702)
+++ trunk/jaxx-compiler/pom.xml 2009-12-23 09:14:47 UTC (rev 1703)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3</version>
+ <version>2.0.0-beta-4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-demo/pom.xml
===================================================================
--- trunk/jaxx-demo/pom.xml 2009-12-23 09:14:42 UTC (rev 1702)
+++ trunk/jaxx-demo/pom.xml 2009-12-23 09:14:47 UTC (rev 1703)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3</version>
+ <version>2.0.0-beta-4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-runtime/pom.xml
===================================================================
--- trunk/jaxx-runtime/pom.xml 2009-12-23 09:14:42 UTC (rev 1702)
+++ trunk/jaxx-runtime/pom.xml 2009-12-23 09:14:47 UTC (rev 1703)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3</version>
+ <version>2.0.0-beta-4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-swing-action/pom.xml
===================================================================
--- trunk/jaxx-swing-action/pom.xml 2009-12-23 09:14:42 UTC (rev 1702)
+++ trunk/jaxx-swing-action/pom.xml 2009-12-23 09:14:47 UTC (rev 1703)
@@ -11,7 +11,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3</version>
+ <version>2.0.0-beta-4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-widgets/pom.xml
===================================================================
--- trunk/jaxx-widgets/pom.xml 2009-12-23 09:14:42 UTC (rev 1702)
+++ trunk/jaxx-widgets/pom.xml 2009-12-23 09:14:47 UTC (rev 1703)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3</version>
+ <version>2.0.0-beta-4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- trunk/maven-jaxx-plugin/pom.xml 2009-12-23 09:14:42 UTC (rev 1702)
+++ trunk/maven-jaxx-plugin/pom.xml 2009-12-23 09:14:47 UTC (rev 1703)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3</version>
+ <version>2.0.0-beta-4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-23 09:14:42 UTC (rev 1702)
+++ trunk/pom.xml 2009-12-23 09:14:47 UTC (rev 1703)
@@ -13,7 +13,7 @@
</parent>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3</version>
+ <version>2.0.0-beta-4-SNAPSHOT</version>
<modules>
<module>jaxx-runtime</module>
@@ -401,9 +401,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.0.0-beta-3</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.0.0-beta-3</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/jaxx/tags/jaxx-2.0.0-beta-3</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/jaxx/trunk</url>
</scm>
</project>
1
0
Author: tchemit
Date: 2009-12-23 10:14:42 +0100 (Wed, 23 Dec 2009)
New Revision: 1702
Added:
tags/jaxx-2.0.0-beta-3/
Log:
[maven-scm] copy for tag jaxx-2.0.0-beta-3
1
0
r1701 - in trunk: . jaxx-compiler jaxx-demo jaxx-runtime jaxx-swing-action jaxx-widgets maven-jaxx-plugin
by tchemit@users.nuiton.org 23 Dec '09
by tchemit@users.nuiton.org 23 Dec '09
23 Dec '09
Author: tchemit
Date: 2009-12-23 10:14:38 +0100 (Wed, 23 Dec 2009)
New Revision: 1701
Modified:
trunk/jaxx-compiler/pom.xml
trunk/jaxx-demo/pom.xml
trunk/jaxx-runtime/pom.xml
trunk/jaxx-swing-action/pom.xml
trunk/jaxx-widgets/pom.xml
trunk/maven-jaxx-plugin/pom.xml
trunk/pom.xml
Log:
[maven-release-plugin] prepare release jaxx-2.0.0-beta-3
Modified: trunk/jaxx-compiler/pom.xml
===================================================================
--- trunk/jaxx-compiler/pom.xml 2009-12-23 08:58:25 UTC (rev 1700)
+++ trunk/jaxx-compiler/pom.xml 2009-12-23 09:14:38 UTC (rev 1701)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3-SNAPSHOT</version>
+ <version>2.0.0-beta-3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-demo/pom.xml
===================================================================
--- trunk/jaxx-demo/pom.xml 2009-12-23 08:58:25 UTC (rev 1700)
+++ trunk/jaxx-demo/pom.xml 2009-12-23 09:14:38 UTC (rev 1701)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3-SNAPSHOT</version>
+ <version>2.0.0-beta-3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-runtime/pom.xml
===================================================================
--- trunk/jaxx-runtime/pom.xml 2009-12-23 08:58:25 UTC (rev 1700)
+++ trunk/jaxx-runtime/pom.xml 2009-12-23 09:14:38 UTC (rev 1701)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3-SNAPSHOT</version>
+ <version>2.0.0-beta-3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-swing-action/pom.xml
===================================================================
--- trunk/jaxx-swing-action/pom.xml 2009-12-23 08:58:25 UTC (rev 1700)
+++ trunk/jaxx-swing-action/pom.xml 2009-12-23 09:14:38 UTC (rev 1701)
@@ -11,7 +11,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3-SNAPSHOT</version>
+ <version>2.0.0-beta-3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-widgets/pom.xml
===================================================================
--- trunk/jaxx-widgets/pom.xml 2009-12-23 08:58:25 UTC (rev 1700)
+++ trunk/jaxx-widgets/pom.xml 2009-12-23 09:14:38 UTC (rev 1701)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3-SNAPSHOT</version>
+ <version>2.0.0-beta-3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- trunk/maven-jaxx-plugin/pom.xml 2009-12-23 08:58:25 UTC (rev 1700)
+++ trunk/maven-jaxx-plugin/pom.xml 2009-12-23 09:14:38 UTC (rev 1701)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3-SNAPSHOT</version>
+ <version>2.0.0-beta-3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-23 08:58:25 UTC (rev 1700)
+++ trunk/pom.xml 2009-12-23 09:14:38 UTC (rev 1701)
@@ -1,5 +1,4 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -14,7 +13,7 @@
</parent>
<artifactId>jaxx</artifactId>
- <version>2.0.0-beta-3-SNAPSHOT</version>
+ <version>2.0.0-beta-3</version>
<modules>
<module>jaxx-runtime</module>
@@ -402,9 +401,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/jaxx/trunk</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.0.0-beta-3</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.0.0-beta-3</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/jaxx/tags/jaxx-2.0.0-beta-3</url>
</scm>
</project>
1
0
23 Dec '09
Author: tchemit
Date: 2009-12-23 09:58:25 +0100 (Wed, 23 Dec 2009)
New Revision: 1700
Modified:
trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
Log:
i18n
Modified: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
===================================================================
--- trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-23 08:58:07 UTC (rev 1699)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-23 08:58:25 UTC (rev 1700)
@@ -1,64 +1,64 @@
-aboutframe.about=\u00C0 propos
+aboutframe.about=\u00c0 propos
aboutframe.license=Licence
aboutframe.ok=OK
aboutframe.thirdparty=Tierce partie
-columnselector.action.tip=S\u00E9lectionner les colonnes
+columnselector.action.tip=S\u00e9lectionner les colonnes
config.action.quit=Quitter
-config.action.quit.tip=Quitter l'\u00E9diteur de configuration
+config.action.quit.tip=Quitter l'\u00e9diteur de configuration
config.action.reset=Annuler
-config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie
+config.action.reset.tip=Annuler les modifications de cette cat\u00e9gorie
config.action.save=Enregistrer
-config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie
-config.category.needReloadApplication=Cat\u00E9gorie '%1$s' \:
-config.category.needReloadUI=Cat\u00E9gorie '%1$s' \:
-config.category.saved=La cat\u00E9gorie '%1$s' a \u00E9t\u00E9 modifi\u00E9e \:
+config.action.save.tip=Sauver les modifications de cette cat\u00e9gorie
+config.category.needReloadApplication=Cat\u00e9gorie '%1$s' \:
+config.category.needReloadUI=Cat\u00e9gorie '%1$s' \:
+config.category.saved=La cat\u00e9gorie '%1$s' a \u00e9t\u00e9 modifi\u00e9e \:
config.choice.cancel=Annuler
config.choice.continue=Continuer
config.choice.doNotSave=Ne pas enregistrer
config.choice.ok=Ok
config.choice.save=Enregistrer
-config.defaultValue=Valeur par d\u00E9faut
-config.defaultValue.tip=Valeur par d\u00E9faut de l'option
+config.defaultValue=Valeur par d\u00e9faut
+config.defaultValue.tip=Valeur par d\u00e9faut de l'option
config.descrition=Description
-config.error.category.already.exists=La cat\u00E9gorie de nom '%1$s' existe d\u00E9j\u00E0\!
-config.error.category.not.found=La cat\u00E9gorie de nom '%1$s' n'existe pas\!
+config.error.category.already.exists=La cat\u00e9gorie de nom '%1$s' existe d\u00e9j\u00e0\!
+config.error.category.not.found=La cat\u00e9gorie de nom '%1$s' n'existe pas\!
config.key=Clef
config.key.tip=Clef de l'option
-config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\!
-config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \:
-config.model.needReloadApplication=Des options ont \u00E9t\u00E9 modifi\u00E9s qui n\u00E9cessitent le red\u00E9marrage de l'application.\n
-config.model.needReloadUI=Des options ont \u00E9t\u00E9 modifi\u00E9s qui n\u00E9cessitent le red\u00E9marrage de l'interface graphique.\n
-config.modified=Option modifi\u00E9e (valeur originale \: %1$s)
-config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e >
+config.message.quit.invalid.category=La cat\u00e9gorie '%1$s' n'est pas valide\!
+config.message.quit.valid.and.modified.category=La cat\u00e9gorie '%1$s' poss\u00e8dent des options modifi\u00e9es \:
+config.model.needReloadApplication=Des options ont \u00e9t\u00e9 modifi\u00e9es qui n\u00e9cessitent le red\u00e9marrage de l'application.\n
+config.model.needReloadUI=Des options ont \u00e9t\u00e9 modifi\u00e9es qui n\u00e9cessitent le red\u00e9marrage de l'interface graphique.\n
+config.modified=Option modifi\u00e9e (valeur originale \: %1$s)
+config.no.option.selected=< Pas d'option s\u00e9lectionn\u00e9e >
config.option.final=Option non modifiable
config.option.label=Option '%1$s' (%2$s)
-config.option.modified=Valeur modifi\u00E9e < ancienne valeur \: '%1$s' - nouvelle valeur \: '%2$s' >
-config.title=Pr\u00E9f\u00E9rences
+config.option.modified=Valeur modifi\u00e9e < ancienne valeur \: '%1$s' - nouvelle valeur \: '%2$s' >
+config.title=Pr\u00e9f\u00e9rences
config.title.need.confirm=Une confirmation de votre part est requise...
-config.title.will.reload.application=L'application doit \u00EAtre red\u00E9marrer...
-config.title.will.reload.ui=L'interface graphique doit \u00EAtre relancer...
-config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9
+config.title.will.reload.application=L'application doit \u00eatre red\u00e9marrer...
+config.title.will.reload.ui=L'interface graphique doit \u00eatre relancer...
+config.unmodifiable=Ne peut pas \u00eatre modifi\u00e9
config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s)
config.value=Valeur
config.value.tip=Valeur de l'option
-entitycombobox.action.reset.tip=R\u00E9initialiser la valeur de la liste d\u00E9roulante
-entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00E9roulante
+entitycombobox.action.reset.tip=R\u00e9initialiser la valeur de la liste d\u00e9roulante
+entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00e9roulante
entitycombobox.popup.label=Objet '%1$s'
entitycombobox.popup.title=Modifier le tri
-entitycombobox.sort.off=Cliquer pour activer le tri sur la propri\u00E9t\u00E9 '%1$s'
-entitycombobox.sort.on=Le tri est effectu\u00E9 sur la propri\u00E9t\u00E9 '%1$s'
+entitycombobox.sort.off=Cliquer pour activer le tri sur la propri\u00e9t\u00e9 '%1$s'
+entitycombobox.sort.on=Le tri est effectu\u00e9 sur la propri\u00e9t\u00e9 '%1$s'
entitycombobox.unknown.type=Objet de type inconnu
errorUI.action.close=Fermer
errorUI.message=Une erreur est survenue \!
errorUI.title=Erreur...
-fontsize.action.default.tip=Retour sur la taille par d\u00E9faut
+fontsize.action.default.tip=Retour sur la taille par d\u00e9faut
fontsize.action.down.tip=Diminuer la taille de la police
fontsize.action.up.tip=Augmenter la taille de la police
hidor.hideTip=Cacher
hidor.showTip=Voir
-i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
+i18neditor.empty.locales=< Aucune locale \u00e0 s\u00e9lectionner >
i18neditor.popup.title=Changer de langue
-i18neditor.selected=Langue actuellement utilis\u00E9e \: %1$s
+i18neditor.selected=Langue actuellement utilis\u00e9e \: %1$s
i18neditor.unselected=Pour utiliser cette langue \: %1$s
listSelector.hideList=Cacher la liste
listSelector.showList=Afficher la liste
@@ -74,8 +74,8 @@
numbereditor.7=7
numbereditor.8=8
numbereditor.9=9
-numbereditor.action.reset.tip=R\u00E9initialiser
-numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique
+numbereditor.action.reset.tip=R\u00e9initialiser
+numbereditor.action.show.tip=Afficher le pav\u00e9 num\u00e9rique
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
1
0
r1699 - trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin
by tchemit@users.nuiton.org 23 Dec '09
by tchemit@users.nuiton.org 23 Dec '09
23 Dec '09
Author: tchemit
Date: 2009-12-23 09:58:07 +0100 (Wed, 23 Dec 2009)
New Revision: 1699
Added:
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpFilesMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpIdsMojo.java
Modified:
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
Log:
improve help mojo (dettach it from the jaxx generate mojo)
Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java 2009-12-23 08:49:38 UTC (rev 1698)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java 2009-12-23 08:58:07 UTC (rev 1699)
@@ -20,18 +20,9 @@
import org.apache.maven.plugin.MojoFailureException;
import org.nuiton.i18n.I18n;
-import org.nuiton.plugin.VelocityTemplateGenerator;
-import org.nuiton.util.SortedProperties;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Properties;
+import java.io.*;
+import java.util.*;
/**
* Abstract Mojo to generate help stuff.
@@ -41,16 +32,7 @@
*/
public abstract class AbstractGenerateHelpMojo extends AbstractJaxxMojo {
- protected static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
/**
- * The directory where to create or update help files.
- *
- * @parameter expression="${jaxx.outHelp}" default-value="${project.basedir}/src/main/help"
- * @required
- * @since 1.3
- */
- protected File outHelp;
- /**
* The locales to generate for help, separeted by comma.
* <p/>
* The first locale given is the default locale.
@@ -61,14 +43,32 @@
*/
protected String locales;
/**
- * The name of the helpset to generate.
+ * Where to generate helpIds files.
*
- * @parameter expression="${jaxx.helpsetName}" default-value="${project.artifactId}"
+ * @parameter expression="${jaxx.outputHelpIds}" default-value="target/generated-sources/jaxx"
* @required
* @since 1.3
*/
- protected String helpsetName;
+ private File outputHelpIds;
/**
+ * The store of helpIds generated by the goal {@link GenerateMojo} and then
+ * used by the goal {@link GenerateHelpMojo}.
+ *
+ * @parameter expression="${jaxx.helpIdsFilename}" default-value="helpIds.properties"
+ * @required
+ * @since 1.3
+ */
+ private String helpIdsFilename;
+ /**
+ * The store of cumulate helpIds generated by the goal {@link GenerateMojo} and then
+ * used by the goal {@link GenerateHelpMojo}.
+ *
+ * @parameter expression="${jaxx.mergeHelpIdsFilename}" default-value="helpIds-all.properties"
+ * @required
+ * @since 1.3
+ */
+ private String mergeHelpIdsFilename;
+ /**
* Flag to generate the search index.
*
* @parameter expression="${jaxx.generateSearch}" default-value="true"
@@ -77,28 +77,27 @@
*/
protected boolean generateSearch;
/**
- * The help ids discovered in {@link #helpIdsStore} files.
- */
- protected static Properties helpIds;
- /**
* Default locale (the first locale in {@link #localesToTreate}.
*/
- protected Locale defaultLocale;
+ private Locale defaultLocale;
/**
* Locales to treate
*/
- protected Locale[] localesToTreate;
+ private Locale[] localesToTreate;
/**
* Do the action for the given locale.
*
* @param locale the locale to treate
* @param isDefaultLocale {@code true} if given locale is de the default locale
- * @param localizedTarget where are stored help files for the given locale
+ * @param source where are stored help files for the given locale
* @param localePath the locale path to use (is {@code default} if given locale is default).
* @throws Exception if any pb
*/
- protected abstract void doActionForLocale(Locale locale, boolean isDefaultLocale, File localizedTarget, String localePath) throws Exception;
+ protected abstract void doActionForLocale(Locale locale,
+ boolean isDefaultLocale,
+ File source,
+ String localePath) throws Exception;
/**
* Call back after doing all stuff for all locales declared
@@ -106,22 +105,15 @@
protected abstract void postDoAction();
@Override
- public boolean init() throws Exception {
+ protected boolean init() throws Exception {
- File idsStore = getHelpIdsStore();
-
- if (!idsStore.exists()) {
- getLog().info("no helpIdStore to react at " + idsStore);
- return false;
- }
-
if (locales == null || locales.trim().isEmpty()) {
throw new MojoFailureException("You must set the 'locales' property properly (was " + locales + ").");
}
// check there is a outHelp
- if (outHelp == null) {
- throw new MojoFailureException("You must set the 'outHelp' property.");
+ if (getTargetDirectory() == null) {
+ throw new MojoFailureException("You must set the 'outputHelpXXX' property.");
}
List<Locale> tmp = new ArrayList<Locale>();
@@ -139,32 +131,16 @@
createDirectoryIfNecessary(getTargetDirectory());
- // load ids from idsStore file (only once by session)
-
- if (helpIds == null) {
- helpIds = new SortedProperties();
-
- BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(idsStore), getEncoding()));
- String id;
- while ((id = reader.readLine()) != null) {
- id = id.trim();
- String path = id.replaceAll("\\.", File.separator) + ".html";
- helpIds.put(id, path);
- }
-
- if (helpIds.isEmpty()) {
-
- // no ids detected
- getLog().warn("No helpIds detected, will skip.");
- return false;
- }
- }
return true;
}
@Override
- public final void doAction() throws Exception {
+ protected void doAction() throws Exception {
+ if (skipAction()) {
+ return;
+ }
+
for (Locale locale : localesToTreate) {
boolean isDefaultLocale = locale == defaultLocale;
@@ -173,39 +149,114 @@
String localePath = (isDefaultLocale ? "default" : language);
- File localizedTarget = new File(outHelp, localePath);
+ File source = new File(getTargetDirectory(), localePath);
- createDirectoryIfNecessary(localizedTarget);
+ createDirectoryIfNecessary(source);
- doActionForLocale(locale, isDefaultLocale, localizedTarget, localePath);
+ doActionForLocale(locale, isDefaultLocale, source, localePath);
}
postDoAction();
}
- @Override
- public File getTargetDirectory() {
- return outHelp;
+ protected boolean skipAction() {
+ if (!generateHelp) {
+ getLog().info("generateHelp flag is off, generate nothing.");
+ return true;
+ }
+ return false;
}
- @Override
- public void setTargetDirectory(File targetDirectory) {
- this.outHelp = targetDirectory;
+ public File getOutputHelpIds() {
+ return outputHelpIds;
}
- protected void doGen(File template, File f, Properties env) throws Exception {
- VelocityTemplateGenerator gen = prepareGenerator(template);
- gen.generate(env, f);
+ public void setOutputHelpIds(File outputHelpIds) {
+ this.outputHelpIds = outputHelpIds;
}
- protected VelocityTemplateGenerator prepareGenerator(File template) throws Exception {
- URL templateURL = getTemplate(template);
+ public File getHelpIdsStoreFile() {
+ return outputHelpIds == null ? null : new File(outputHelpIds, helpIdsFilename);
+ }
- if (verbose) {
- getLog().info("using template " + templateURL);
+ public File getMergeHelpIdsStoreFile() {
+ return outputHelpIds == null ? null : new File(outputHelpIds, mergeHelpIdsFilename);
+ }
+
+ public String getHelpIdsFilename() {
+ return helpIdsFilename;
+ }
+
+ public void setHelpIdsFilename(String helpIdsFilename) {
+ this.helpIdsFilename = helpIdsFilename;
+ }
+
+ public String getMergeHelpIdsFilename() {
+ return mergeHelpIdsFilename;
+ }
+
+ public void setMergeHelpIdsFilename(String mergeHelpIdsFilename) {
+ this.mergeHelpIdsFilename = mergeHelpIdsFilename;
+ }
+
+ protected void cleanHelpIdsStore() throws IOException {
+ File idsStore = getHelpIdsStoreFile();
+ if (idsStore.exists()) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("delete id store " + idsStore);
+ }
+ boolean b = idsStore.delete();
+ if (!b) {
+ throw new IOException("could not delete file " + idsStore);
+ }
}
- VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL);
- return gen;
}
+
+ protected Set<String> loadHelpIds(File file) throws IOException {
+
+ BufferedReader reader = null;
+ Set<String> result = new HashSet<String>();
+ try {
+ reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), getEncoding()));
+ String id;
+ while ((id = reader.readLine()) != null) {
+ result.add(id.trim());
+ }
+ if (isVerbose()) {
+ getLog().info("load " + result.size() + " help ids from file " + file);
+ }
+ return result;
+ } finally {
+ if (reader != null) {
+ reader.close();
+ }
+ }
+ }
+
+ protected void storeHelpIds(File file, Set<String> ids) throws IOException {
+
+ createDirectoryIfNecessary(file.getParentFile());
+
+ StringBuilder buffer = new StringBuilder();
+
+ for (String helpId : ids) {
+ buffer.append(removeQuote(helpId)).append('\n');
+ }
+ writeFile(file, buffer.toString(), getEncoding());
+ if (isVerbose()) {
+ getLog().info("stored " + ids.size() + " help ids in " + file);
+ }
+ }
+
+ protected String removeQuote(String txt) {
+ if (txt.startsWith("\"")) {
+ txt = txt.substring(1);
+ }
+ if (txt.endsWith("\"")) {
+ txt = txt.substring(0, txt.length() - 1);
+ }
+ return txt;
+ }
+
}
\ No newline at end of file
Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-12-23 08:49:38 UTC (rev 1698)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-12-23 08:58:07 UTC (rev 1699)
@@ -20,18 +20,17 @@
import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
+import org.nuiton.plugin.AbstractPlugin;
+import org.nuiton.util.FileUtil;
import java.io.File;
import java.io.IOException;
import java.util.List;
-import org.nuiton.plugin.AbstractPlugin;
-
/**
- * Abract Jaxx Mojo.
+ * Abstract Jaxx Mojo.
*
* @author chemit
- *
* @since 1.3
*/
public abstract class AbstractJaxxMojo extends AbstractPlugin {
@@ -39,6 +38,7 @@
public abstract File getTargetDirectory();
public abstract void setTargetDirectory(File targetDirectory);
+
/**
* Dépendance du projet.
*
@@ -46,32 +46,39 @@
* @required
* @readonly
*/
- protected MavenProject project;
+ private MavenProject project;
/**
* Encoding pour la generation des fichiers
*
* @parameter expression="${jaxx.encoding}" default-value="${project.build.sourceEncoding}"
* @since 2.0.0
*/
- protected String encoding;
+ private String encoding;
/**
* verbose flag
*
* @parameter expression="${jaxx.verbose}" default-value="false"
- *
* @since 1.3
*/
- protected boolean verbose;
+ private boolean verbose;
+
/**
- * The store of helpIds generated by the goal {@link GenerateMojo} and then
- * used by the goal {@link GenerateHelpMojo}.
- *
- * @parameter expression="${jaxx.helpIdsStore}" default-value="target/generated-sources/jaxx/helpIds.properties"
- * @required
+ * to force generation of java source for any jaxx files with no timestamp checking.
+ * <p/>
+ * By default, never force generation.
*
+ * @parameter expression="${jaxx.force}" default-value="false"
+ */
+ private boolean force;
+ /**
+ * Flag to activate help id detection while parsing jaxx files.
+ * <p/>
+ * By default, not active.
+ *
+ * @parameter expression="${jaxx.generateHelp}" default-value="false"
* @since 1.3
*/
- protected File helpIdsStore;
+ protected boolean generateHelp;
@Override
protected boolean checkPackaging() {
@@ -98,14 +105,6 @@
this.verbose = verbose;
}
- public File getHelpIdsStore() {
- return helpIdsStore;
- }
-
- public void setHelpIdsStore(File helpIdsStore) {
- this.helpIdsStore = helpIdsStore;
- }
-
public String getEncoding() {
return encoding;
}
@@ -114,6 +113,14 @@
this.encoding = encoding;
}
+ public boolean isForce() {
+ return force;
+ }
+
+ public void setForce(boolean force) {
+ this.force = force;
+ }
+
/**
* TODO-TC20091221 Should move this to AbstractPlugin
* Create the directory if necessary.
@@ -128,7 +135,7 @@
}
boolean b = dir.mkdirs();
if (!b) {
- throw new IOException("could not create directory "+dir);
+ throw new IOException("could not create directory " + dir);
}
}
}
@@ -177,4 +184,37 @@
}
return shouldAdd;
}
+
+
+ class GetLastModifiedFileAction implements FileUtil.FileAction {
+
+ protected File lastFile;
+
+ public GetLastModifiedFileAction(File lastFile) {
+ this.lastFile = lastFile;
+
+ }
+
+ @Override
+ public boolean doAction(File f) {
+
+ if (f.lastModified() > lastFile.lastModified()) {
+ lastFile = f;
+ }
+ return true;
+ }
+
+ public File getLastFile() {
+ return lastFile;
+ }
+ }
+
+ protected Long getLastModified(File dir) {
+ if (!dir.exists()) {
+ return null;
+ }
+ GetLastModifiedFileAction fileAction = new GetLastModifiedFileAction(dir);
+ FileUtil.walkAfter(dir, fileAction);
+ return fileAction.getLastFile().lastModified();
+ }
}
Copied: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpFilesMojo.java (from rev 1687, trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java)
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpFilesMojo.java (rev 0)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpFilesMojo.java 2009-12-23 08:58:07 UTC (rev 1699)
@@ -0,0 +1,519 @@
+/* *##%
+ * JAXX Maven plugin
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*/
+package org.nuiton.jaxx.plugin;
+
+import org.nuiton.plugin.VelocityTemplateGenerator;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.SortedProperties;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Mojo to generate javax help files for your project.
+ *
+ * @author chemit
+ * @goal generate-help-files
+ * @phase process-sources
+ * @requiresProject
+ * @requiresDependencyResolution compile
+ * @execute goal=generate-help-ids
+ * @since 2.0.0
+ */
+public class GenerateHelpFilesMojo extends AbstractGenerateHelpMojo {
+
+ protected static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
+
+ /**
+ * The directory where to create or update help files.
+ *
+ * @parameter expression="${jaxx.outuptHelp}" default-value="${project.basedir}/src/main/help"
+ * @required
+ * @since 2.0.0
+ */
+ protected File outputHelp;
+ /**
+ * The name of the helpset to generate.
+ *
+ * @parameter expression="${jaxx.helpsetName}" default-value="${project.artifactId}"
+ * @required
+ * @since 1.3
+ */
+ protected String helpsetName;
+ /**
+ * The template used to generate helpset file.
+ * <p/>
+ * Must be an existing file or a ressource in class-path
+ *
+ * @parameter expression="${jaxx.helpsetTemplate}" default-value="/defaultHelpSet.hs.vm"
+ * @required
+ * @since 1.3
+ */
+ protected File helpsetTemplate;
+ /**
+ * The template used to generate helpset map file.
+ * <p/>
+ * Must be an existing file or a ressource in class-path
+ *
+ * @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
+ * @required
+ * @since 1.3
+ */
+ protected File mapTemplate;
+ /**
+ * The template used to generate helpset index file.
+ * <p/>
+ * Must be an existing file or a ressource in class-path
+ *
+ * @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
+ * @required
+ * @since 1.3
+ */
+ protected File indexTemplate;
+ /**
+ * The template used to generate helpset toc file.
+ * <p/>
+ * Must be an existing file or a ressource in class-path
+ *
+ * @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
+ * @required
+ * @since 1.3
+ */
+ protected File tocTemplate;
+ /**
+ * The template used to generate helpset content file.
+ * <p/>
+ * Must be an existing file or a ressource in class-path
+ *
+ * @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
+ * @required
+ * @since 1.3
+ */
+ protected File contentTemplate;
+
+ protected String mapFileName;
+ protected String indexFileName;
+ protected String tocFileName;
+ protected int touchedFiles;
+
+ /**
+ * The help ids discovered.
+ */
+ protected Properties helpIds;
+
+ @Override
+ public File getTargetDirectory() {
+ return outputHelp;
+ }
+
+ @Override
+ public void setTargetDirectory(File targetDirectory) {
+ this.outputHelp = targetDirectory;
+ }
+
+ @Override
+ public boolean init() throws Exception {
+ if (!generateHelp) {
+
+ return true;
+ }
+ // check ressources
+ checkResource(helpsetTemplate);
+ checkResource(mapTemplate);
+ checkResource(indexTemplate);
+ checkResource(tocTemplate);
+ checkResource(contentTemplate);
+
+ mapFileName = helpsetName + "Map.jhm";
+ indexFileName = helpsetName + "Index.xml";
+ tocFileName = helpsetName + "TOC.xml";
+ touchedFiles = 0;
+
+ boolean b = super.init();
+ if (!b) {
+ return false;
+ }
+
+ // load ids from idsStore file
+
+ File idsFile;
+
+ if (isForce()) {
+ idsFile = getMergeHelpIdsStoreFile();
+ if (!idsFile.exists()) {
+ if (isVerbose()) {
+ getLog().info("Force flag is on, but no helpIdStore-all to react at " + idsFile);
+ }
+ return true;
+ }
+ } else {
+ idsFile = getHelpIdsStoreFile();
+ if (!idsFile.exists()) {
+ if (isVerbose()) {
+ getLog().info("no helpIdStore to react at " + idsFile);
+ }
+ return true;
+ }
+ }
+
+ helpIds = new SortedProperties();
+
+ // loading all ids
+ Set<String> ids = loadHelpIds(idsFile);
+
+ if (ids.isEmpty()) {
+
+ // no ids detected
+ if (isVerbose()) {
+ getLog().info("No helpIds detected, will skip.");
+ }
+ return true;
+ }
+
+ for (String id : ids) {
+ String path = id.replaceAll("\\.", File.separator) + ".html";
+ helpIds.put(id, path);
+ }
+
+ return true;
+ }
+
+ @Override
+ protected boolean skipAction() {
+ boolean b = super.skipAction();
+ if (!b) {
+ if (helpIds == null || helpIds.isEmpty()) {
+ getLog().info("No help ids to treate.");
+ return true;
+ }
+ }
+ return false;
+ }
+
+// @Override
+// public void doAction() throws Exception {
+//
+// if (skipAction()) {
+// return;
+// }
+//
+// if (helpIds == null || helpIds.isEmpty()) {
+// getLog().info("No help ids to treate.");
+// return;
+// }
+//
+// super.doAction();
+// }
+
+ protected void postDoAction() {
+ getLog().info(touchedFiles + " file(s) treated.");
+ }
+
+ protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File localizedTarget, String localePath) throws Exception {
+
+ String language = locale.getLanguage();
+
+ getLog().info("Generate help for language " + language);
+ if (isVerbose()) {
+ getLog().info(" Localized target : " + localizedTarget);
+ }
+
+ Properties env = new Properties();
+
+ env.put("helpSetName", helpsetName);
+ env.put("locale", language);
+ env.put("localePath", localePath);
+ env.put("separator", " ");
+ env.put("autoremoveLine", AUTOREMOVE_LINE);
+
+ String localeSuffix = isDefaultLocale ? "" : "_" + language;
+ String helpsetFileName = helpsetName + localeSuffix + ".hs";
+
+ env.put("helpSetFileName", helpsetFileName);
+
+ env.put("mapFileName", mapFileName);
+ env.put("indexFileName", indexFileName);
+ env.put("tocFileName", tocFileName);
+ env.put("generateSearch", generateSearch);
+
+ // ---------------------------------------------------------------
+ // --- main helpset file -----------------------------------------
+ // ---------------------------------------------------------------
+
+ File file = new File(getTargetDirectory(), helpsetFileName);
+
+ boolean doCreate = generateHelpsetFile(file, env);
+
+ if (doCreate) {
+ touchedFiles++;
+ }
+
+ // ---------------------------------------------------------------
+ // --- helpset map file ------------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(localizedTarget, mapFileName);
+
+ generateMapFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset index file ----------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(localizedTarget, indexFileName);
+
+ generateIndexFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset toc file ------------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(localizedTarget, tocFileName);
+
+ generateTocFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset content files -------------------------------------
+ // ---------------------------------------------------------------
+
+ touchedFiles += generateContentFiles(localizedTarget, env, localePath);
+ }
+
+ protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception {
+
+ int touchedFiles = 0;
+ VelocityTemplateGenerator gen = prepareGenerator(contentTemplate);
+ Enumeration<?> keys = helpIds.keys();
+ while (keys.hasMoreElements()) {
+ String key = (String) keys.nextElement();
+ String url = (String) helpIds.get(key);
+ url = helpsetName + File.separator + url;
+ File f = new File(localizedTarget, url);
+ boolean exist = f.exists();
+ if (exist) {
+ // check if there is a autoremoveLine in content
+ String content = FileUtil.readAsString(f);
+ if (!content.contains(AUTOREMOVE_LINE)) {
+ // no regenerate marker detected, so skip this file
+ if (isVerbose()) {
+ getLog().debug("skip existing file " + f);
+ }
+ continue;
+ }
+ }
+ createDirectoryIfNecessary(f.getParentFile());
+ if (isVerbose()) {
+ if (exist) {
+ getLog().info("regenerate content file " + f);
+ } else {
+ getLog().info("generate content file " + f);
+ }
+ }
+ env.put("helpId", key);
+ env.put("helpIdUrl", localePath + "/" + url);
+ gen.generate(env, f);
+ touchedFiles++;
+ }
+ return touchedFiles;
+ }
+
+ protected boolean generateHelpsetFile(File file, Properties env) throws Exception {
+
+ if (file.exists()) {
+ // check the autoremove line presence
+ String content = FileUtil.readAsString(file);
+ if (!content.contains(AUTOREMOVE_LINE)) {
+ // no regenerate marker detected, so skip this file
+ if (isVerbose()) {
+ getLog().info("skip existing helpset main file " + file);
+ }
+ return false;
+ }
+ }
+
+ if (isVerbose()) {
+ if (file.exists()) {
+ getLog().info("regenerate helpset main file " + file);
+ } else {
+ getLog().info("generate helpset main file " + file);
+ }
+ }
+ doGen(helpsetTemplate, file, env);
+ return true;
+ }
+
+ protected Properties generateMapFile(File file, Properties env) throws Exception {
+
+ boolean create;
+
+ Properties mergedHelpIds;
+ if (file.exists()) {
+
+ // get back the exisiting data and merge it with incoming ones
+
+ if (isVerbose()) {
+ getLog().info("loading existing helpset map file " + file);
+ }
+
+ mergedHelpIds = XmlHelper.getExistingHelpIds(file, isVerbose(), getLog());
+ create = false;
+
+ } else {
+
+ mergedHelpIds = new SortedProperties();
+ create = true;
+ }
+
+ // inject new helpIds
+
+ for (Object k : helpIds.keySet()) {
+ mergedHelpIds.put(k, helpsetName + "/" + helpIds.get(k));
+ }
+
+ if (!mergedHelpIds.contains("top")) {
+
+ // on ajoute une entree vers le root du helpset
+
+ String topUrl = helpsetName + ".html";
+ helpIds.put("top", topUrl);
+ mergedHelpIds.put("top", helpsetName + "/" + topUrl);
+ if (isVerbose()) {
+ getLog().debug("add top entry with url " + topUrl);
+ }
+ }
+
+ if (isVerbose()) {
+ if (create) {
+ getLog().info("generate helpset map file " + file);
+ } else {
+ getLog().info("udpate helpset map file " + file);
+ }
+ }
+
+ env.put("helpIds", mergedHelpIds);
+ doGen(mapTemplate, file, env);
+ env.remove("helpIds");
+ return mergedHelpIds;
+ }
+
+ protected NodeItem generateIndexFile(File file, Properties env) throws Exception {
+ NodeItem rootItem = null;
+
+ boolean create;
+
+ if (file.exists()) {
+
+ create = false;
+
+ rootItem = XmlHelper.getExistingItems("indexitem", file);
+ } else {
+ create = true;
+ }
+
+ if (rootItem == null) {
+ rootItem = new NodeItem("top", helpsetName);
+ }
+
+ // inject new index entries
+
+ for (Object k : helpIds.keySet()) {
+ NodeItem toc = rootItem.findChild(k + "");
+ if (isVerbose()) {
+ getLog().debug("index " + k + " : " + toc);
+ }
+ }
+
+ if (isVerbose()) {
+ if (create) {
+ getLog().info("generate helpset index file " + file);
+ } else {
+ getLog().info("udpate helpset index file " + file);
+ }
+ }
+
+ env.put("rootItem", rootItem);
+ doGen(indexTemplate, file, env);
+ env.remove("rootItem");
+ return rootItem;
+ }
+
+ protected NodeItem generateTocFile(File file, Properties env) throws Exception {
+ NodeItem rootItem = null;
+
+ boolean create;
+
+ if (file.exists()) {
+
+ create = false;
+
+ rootItem = XmlHelper.getExistingItems("tocitem", file);
+ } else {
+ create = true;
+ }
+
+ if (rootItem == null) {
+ rootItem = new NodeItem("top", helpsetName);
+ }
+ // inject new toc entries
+
+ for (Object k : helpIds.keySet()) {
+ NodeItem toc = rootItem.findChild(k + "");
+ if (isVerbose()) {
+ getLog().debug("toc " + k + " : " + toc);
+ }
+ }
+
+ if (isVerbose()) {
+ if (create) {
+ getLog().info("generate helpset toc file " + file);
+ } else {
+ getLog().info("udpate helpset toc file " + file);
+ }
+ }
+
+ env.put("rootItem", rootItem);
+ doGen(tocTemplate, file, env);
+ env.remove("rootItem");
+ return rootItem;
+ }
+
+
+ protected void doGen(File template, File f, Properties env) throws Exception {
+ VelocityTemplateGenerator gen = prepareGenerator(template);
+ gen.generate(env, f);
+ }
+
+ protected VelocityTemplateGenerator prepareGenerator(File template) throws Exception {
+ URL templateURL = getTemplate(template);
+
+ if (isVerbose()) {
+ getLog().info("using template " + templateURL);
+ }
+ VelocityTemplateGenerator gen = new VelocityTemplateGenerator(getProject(), templateURL);
+ return gen;
+ }
+
+}
\ No newline at end of file
Added: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpIdsMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpIdsMojo.java (rev 0)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpIdsMojo.java 2009-12-23 08:58:07 UTC (rev 1699)
@@ -0,0 +1,110 @@
+package org.nuiton.jaxx.plugin;
+
+import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
+import org.apache.maven.plugin.MojoFailureException;
+
+import java.io.File;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Generate the help ids files from the previous jaxx generation.
+ *
+ * Created: 22 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @author chemit
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ * @goal generate-help-ids
+ * @phase process-sources
+ * @requiresProject
+ * @since 2.0.0
+ */
+public class GenerateHelpIdsMojo extends AbstractGenerateHelpMojo {
+
+ @Override
+ public boolean init() throws Exception {
+ if (!generateHelp) {
+
+ return true;
+ }
+
+ if (!super.init()) {
+ return false;
+ }
+
+ // check there is some bundle
+ if (getHelpIdsFilename() == null) {
+ throw new MojoFailureException("you must set the 'helpIdStore' property.");
+ }
+ if (getMergeHelpIdsFilename() == null) {
+ throw new MojoFailureException("you must set the 'helpIdStoreAll' property.");
+ }
+
+ return true;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ if (skipAction()) {
+ return;
+ }
+
+ Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
+
+ if (helpIds.isEmpty()) {
+// if (isVerbose()) {
+ // no ids detected in this compilation round
+ getLog().info("No helpIds detected.");
+// }
+ cleanHelpIdsStore();
+ return;
+ }
+
+ // store current jaxx session detected help ids
+
+ File idsStore = getHelpIdsStoreFile();
+ getLog().info("Store detected help ids to " + idsStore);
+
+ storeHelpIds(idsStore, helpIds);
+
+ // store merged help ids (to make possible a force on help generation)
+
+
+ File idsStoreAll = getMergeHelpIdsStoreFile();
+ getLog().info("Merge help ids to " + idsStoreAll);
+
+ if (idsStoreAll.exists()) {
+ Set<String> allIds = loadHelpIds(idsStoreAll);
+ helpIds.addAll(allIds);
+ allIds.clear();
+ }
+
+ storeHelpIds(idsStoreAll, helpIds);
+
+ helpIds.clear();
+
+ }
+
+ @Override
+ protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File source, String localePath) throws Exception {
+ }
+
+ @Override
+ protected void postDoAction() {
+ }
+
+ @Override
+ public File getTargetDirectory() {
+ return getOutputHelpIds();
+ }
+
+ @Override
+ public void setTargetDirectory(File targetDirectory) {
+ setOutputHelpIds(targetDirectory);
+ }
+}
Property changes on: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpIdsMojo.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-12-23 08:49:38 UTC (rev 1698)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-12-23 08:58:07 UTC (rev 1699)
@@ -18,376 +18,50 @@
* ##%*/
package org.nuiton.jaxx.plugin;
-import org.nuiton.plugin.VelocityTemplateGenerator;
-import org.nuiton.util.FileUtil;
-import org.nuiton.util.SortedProperties;
-
import java.io.File;
-import java.util.Enumeration;
import java.util.Locale;
-import java.util.Properties;
/**
- * Mojo to generate javax help stuff for your project.
+ * Mojo to generate all the javax help stuff for your project.
* <p/>
- * HelpIds should have been discovered by the JaxxMojo.
+ * This mojo will chain all others help mojo required.
*
* @author chemit
* @goal generate-help
* @phase process-sources
* @requiresProject
* @requiresDependencyResolution compile
+ * @execute goal=generate-help-search
* @since 1.3
*/
public class GenerateHelpMojo extends AbstractGenerateHelpMojo {
-
- /**
- * The template used to generate helpset file.
- * <p/>
- * Must be an existing file or a ressource in class-path
- *
- * @parameter expression="${jaxx.helpsetTemplate}" default-value="/defaultHelpSet.hs.vm"
- * @required
- * @since 1.3
- */
- protected File helpsetTemplate;
- /**
- * The template used to generate helpset map file.
- * <p/>
- * Must be an existing file or a ressource in class-path
- *
- * @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
- * @required
- * @since 1.3
- */
- protected File mapTemplate;
- /**
- * The template used to generate helpset index file.
- * <p/>
- * Must be an existing file or a ressource in class-path
- *
- * @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
- * @required
- * @since 1.3
- */
- protected File indexTemplate;
- /**
- * The template used to generate helpset toc file.
- * <p/>
- * Must be an existing file or a ressource in class-path
- *
- * @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
- * @required
- * @since 1.3
- */
- protected File tocTemplate;
- /**
- * The template used to generate helpset content file.
- * <p/>
- * Must be an existing file or a ressource in class-path
- *
- * @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
- * @required
- * @since 1.3
- */
- protected File contentTemplate;
-
- protected String mapFileName;
- protected String indexFileName;
- protected String tocFileName;
- protected int touchedFiles;
-
@Override
- public boolean init() throws Exception {
-
- // check ressources
- checkResource(helpsetTemplate);
- checkResource(mapTemplate);
- checkResource(indexTemplate);
- checkResource(tocTemplate);
- checkResource(contentTemplate);
-
- mapFileName = helpsetName + "Map.jhm";
- indexFileName = helpsetName + "Index.xml";
- tocFileName = helpsetName + "TOC.xml";
- touchedFiles=0;
- return super.init();
+ public File getTargetDirectory() {
+ return null;
}
- protected void postDoAction() {
- getLog().info(touchedFiles + " file(s) treated.");
+ @Override
+ public void setTargetDirectory(File targetDirectory) {
}
- protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File localizedTarget, String localePath) throws Exception {
+ @Override
+ public boolean init() throws Exception {
- String language = locale.getLanguage();
-
- getLog().info("Generate help for language " + language);
- if (isVerbose()) {
- getLog().info(" Localized target : " + localizedTarget);
- }
-
- Properties env = new Properties();
-
- env.put("helpSetName", helpsetName);
- env.put("locale", language);
- env.put("localePath", localePath);
- env.put("separator", " ");
- env.put("autoremoveLine", AUTOREMOVE_LINE);
-
- String localeSuffix = isDefaultLocale ? "" : "_" + language;
- String helpsetFileName = helpsetName + localeSuffix + ".hs";
-
- env.put("helpSetFileName", helpsetFileName);
-
- env.put("mapFileName", mapFileName);
- env.put("indexFileName", indexFileName);
- env.put("tocFileName", tocFileName);
- env.put("generateSearch", generateSearch);
-
- // ---------------------------------------------------------------
- // --- main helpset file -----------------------------------------
- // ---------------------------------------------------------------
-
- File file = new File(outHelp, helpsetFileName);
-
- boolean doCreate = generateHelpsetFile(file, env);
-
- if (doCreate) {
- touchedFiles++;
- }
-
- // ---------------------------------------------------------------
- // --- helpset map file ------------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(localizedTarget, mapFileName);
-
- generateMapFile(file, env);
- touchedFiles++;
-
- // ---------------------------------------------------------------
- // --- helpset index file ----------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(localizedTarget, indexFileName);
-
- generateIndexFile(file, env);
- touchedFiles++;
-
- // ---------------------------------------------------------------
- // --- helpset toc file ------------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(localizedTarget, tocFileName);
-
- generateTocFile(file, env);
- touchedFiles++;
-
- // ---------------------------------------------------------------
- // --- helpset content files -------------------------------------
- // ---------------------------------------------------------------
-
- touchedFiles += generateContentFiles(localizedTarget, env, localePath);
- }
-
- protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception {
-
- int touchedFiles = 0;
- VelocityTemplateGenerator gen = prepareGenerator(contentTemplate);
- Enumeration<?> keys = helpIds.keys();
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- String url = (String) helpIds.get(key);
- url = helpsetName + File.separator + url;
- File f = new File(localizedTarget, url);
- boolean exist = f.exists();
- if (exist) {
- // check if there is a autoremoveLine in content
- String content = FileUtil.readAsString(f);
- if (!content.contains(AUTOREMOVE_LINE)) {
- // no regenerate marker detected, so skip this file
- if (verbose) {
- getLog().debug("skip existing file " + f);
- }
- continue;
- }
- }
- createDirectoryIfNecessary(f.getParentFile());
- if (verbose) {
- if (exist) {
- getLog().info("regenerate content file " + f);
- } else {
- getLog().info("generate content file " + f);
- }
- }
- env.put("helpId", key);
- env.put("helpIdUrl", localePath + "/" + url);
- gen.generate(env, f);
- touchedFiles++;
- }
- return touchedFiles;
- }
-
- protected boolean generateHelpsetFile(File file, Properties env) throws Exception {
-
- if (file.exists()) {
- // check the autoremove line presence
- String content = FileUtil.readAsString(file);
- if (!content.contains(AUTOREMOVE_LINE)) {
- // no regenerate marker detected, so skip this file
- if (verbose) {
- getLog().info("skip existing helpset main file " + file);
- }
- return false;
- }
- }
-
- if (verbose) {
- if (file.exists()) {
- getLog().info("regenerate helpset main file " + file);
- } else {
- getLog().info("generate helpset main file " + file);
- }
- }
- doGen(helpsetTemplate, file, env);
return true;
}
- protected Properties generateMapFile(File file, Properties env) throws Exception {
+ @Override
+ public void doAction() throws Exception {
- boolean create;
-
- Properties mergedHelpIds;
- if (file.exists()) {
-
- // get back the exisiting data and merge it with incoming ones
-
- if (verbose) {
- getLog().info("loading existing helpset map file " + file);
- }
-
- mergedHelpIds = XmlHelper.getExistingHelpIds(file, verbose, getLog());
- create = false;
-
- } else {
-
- mergedHelpIds = new SortedProperties();
- create = true;
- }
-
- // inject new helpIds
-
- for (Object k : helpIds.keySet()) {
- mergedHelpIds.put(k, helpsetName + "/" + helpIds.get(k));
- }
-
- if (!mergedHelpIds.contains("top")) {
-
- // on ajoute une entree vers le root du helpset
-
- String topUrl = helpsetName + ".html";
- helpIds.put("top", topUrl);
- mergedHelpIds.put("top", helpsetName + "/" + topUrl);
- if (verbose) {
- getLog().debug("add top entry with url " + topUrl);
- }
- }
-
- if (verbose) {
- if (create) {
- getLog().info("generate helpset map file " + file);
- } else {
- getLog().info("udpate helpset map file " + file);
- }
- }
-
- env.put("helpIds", mergedHelpIds);
- doGen(mapTemplate, file, env);
- env.remove("helpIds");
- return mergedHelpIds;
}
- protected NodeItem generateIndexFile(File file, Properties env) throws Exception {
- NodeItem rootItem = null;
-
- boolean create;
-
- if (file.exists()) {
-
- create = false;
-
- rootItem = XmlHelper.getExistingItems("indexitem", file);
- } else {
- create = true;
- }
-
- if (rootItem == null) {
- rootItem = new NodeItem("top", helpsetName);
- }
-
- // inject new index entries
-
- for (Object k : helpIds.keySet()) {
- NodeItem toc = rootItem.findChild(k + "");
- if (verbose) {
- getLog().debug("index " + k + " : " + toc);
- }
- }
-
- if (verbose) {
- if (create) {
- getLog().info("generate helpset index file " + file);
- } else {
- getLog().info("udpate helpset index file " + file);
- }
- }
-
- env.put("rootItem", rootItem);
- doGen(indexTemplate, file, env);
- env.remove("rootItem");
- return rootItem;
+ protected void postDoAction() {
+ //getLog().info(touchedFiles + " file(s) treated.");
}
- protected NodeItem generateTocFile(File file, Properties env) throws Exception {
- NodeItem rootItem = null;
+ protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File localizedTarget, String localePath) throws Exception {
- boolean create;
-
- if (file.exists()) {
-
- create = false;
-
- rootItem = XmlHelper.getExistingItems("tocitem", file);
- } else {
- create = true;
- }
-
- if (rootItem == null) {
- rootItem = new NodeItem("top", helpsetName);
- }
- // inject new toc entries
-
- for (Object k : helpIds.keySet()) {
- NodeItem toc = rootItem.findChild(k + "");
- if (verbose) {
- getLog().debug("toc " + k + " : " + toc);
- }
- }
-
- if (verbose) {
- if (create) {
- getLog().info("generate helpset toc file " + file);
- } else {
- getLog().info("udpate helpset toc file " + file);
- }
- }
-
- env.put("rootItem", rootItem);
- doGen(tocTemplate, file, env);
- env.remove("rootItem");
- return rootItem;
}
}
Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java 2009-12-23 08:49:38 UTC (rev 1698)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java 2009-12-23 08:58:07 UTC (rev 1699)
@@ -22,6 +22,7 @@
import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
+import org.nuiton.plugin.PluginHelper;
import java.io.File;
import java.io.PrintStream;
@@ -31,7 +32,7 @@
import java.util.Locale;
/**
- * Mojo to generate javax search index help stuff for your project.
+ * Generate the javax search index help for your project.
* <p/>
* The current files should be generated always in a generated directory and not in
* your src directories (this is mainly binary files not to be stored in scm system)...
@@ -41,58 +42,136 @@
* @phase process-sources
* @requiresProject
* @requiresDependencyResolution compile
+ * @execute goal=generate-help-files
* @since 2.0.0
*/
public class GenerateHelpSearchMojo extends AbstractGenerateHelpMojo {
- protected File targetRoot;
+ /**
+ * The directory where to create or update help search index files.
+ *
+ * @parameter expression="${jaxx.outputHelpSearch}" default-value="${project.basedir}/target/generated-sources/help"
+ * @required
+ * @since 2.0.0
+ */
+ protected File outputHelpSearch;
+
protected String timestamp;
@Override
public boolean init() throws Exception {
+ if (!generateHelp) {
+
+ return true;
+ }
+
if (!generateSearch) {
- getLog().info("Do not generate search.");
- return false;
+// getLog().info("Do not generate search.");
+ return true;
}
- targetRoot = getFileFromBasedir("target", "generated-sources", "help");
- createDirectoryIfNecessary(targetRoot);
timestamp = "-" + System.currentTimeMillis();
return super.init();
}
@Override
- protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File localizedTarget, String localePath) throws Exception {
+ public File getTargetDirectory() {
+ return outputHelpSearch;
+ }
+ @Override
+ public void setTargetDirectory(File targetDirectory) {
+ this.outputHelpSearch = targetDirectory;
+ }
+
+ protected boolean skipAction() {
+ if (!generateHelp) {
+ getLog().info("generateHelp flag is off, generate nothing.");
+ return true;
+ }
+ if (!generateSearch) {
+ getLog().info("generateHelpsearch flag is off, generate nothing.");
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File source, String localePath) throws Exception {
+
String language = locale.getLanguage();
- File target = new File(targetRoot, localePath + File.separator + "JavaHelpSearch");
+ File target = new File(getTargetDirectory(), localePath + File.separator + "JavaHelpSearch");
- createDirectoryIfNecessary(localizedTarget);
- createDirectoryIfNecessary(target);
+ // detect if need to generate
+ boolean generate = false;
+
+ if (isForce()) {
+
+ // always generate if force flag is no
+ generate = true;
+
+ } else if (!target.exists()) {
+
+ // target does not exist, must generate it
+ generate = true;
+
+ } else {
+
+ // see if there is something new in source
+
+ Long sourceLast = getLastModified(source);
+ Long targetLast = getLastModified(target);
+
+ if (isVerbose()) {
+
+ getLog().info("lastModified of source : " + sourceLast);
+ getLog().info("lastModified of target : " + targetLast);
+ }
+
+ if (targetLast == null || sourceLast == null || targetLast < sourceLast) {
+
+ // something is newer in source than in target
+
+ generate = true;
+ }
+
+ }
+
+ if (!generate) {
+ getLog().info("Nothing to generate for language " + language + " - all files are up to date.");
+ return;
+ }
+
getLog().info("Generate help search index for language " + language);
+
if (isVerbose()) {
- getLog().info(" Localized source : " + localizedTarget);
- getLog().info(" Localized target : " + target);
+ getLog().info(" from " + source);
+ getLog().info(" to " + target);
}
+ createDirectoryIfNecessary(source);
+ createDirectoryIfNecessary(target);
+
// ---------------------------------------------------------------
// --- generate search index -------------------------------------
// ---------------------------------------------------------------
- generateSearchIndex(localizedTarget, target, locale);
+ generateSearchIndex(source, target, locale);
}
@Override
protected void postDoAction() {
// add resources to the project
- addResourceDir(targetRoot, getProject(), "**/*");
+ addResourceDir(getTargetDirectory(), getProject(), "**/*");
}
protected void generateSearchIndex(File source, File target, Locale locale) throws Exception {
+ long t0 = System.nanoTime();
+
Method m = Indexer.class.getDeclaredMethod("main", String[].class);
// remove old index
@@ -100,7 +179,9 @@
//copy resources to a tmp dir (without any VCS infos)
File tmpDir = getFileFromBasedir("target", "jaxx-tmp", "indexer-" + locale + timestamp);
- getLog().info("copy files to " + tmpDir + " for indexing them");
+ if (isVerbose()) {
+ getLog().info("copy files to " + tmpDir + " for indexing them.");
+ }
FileUtils.copyDirectory(source, tmpDir, "**/*", StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ","));
// prepare arguments of Indexer.main calling
@@ -122,7 +203,9 @@
System.setOut(out);
System.setErr(err);
}
- getLog().info("Search Index generated for " + locale);
+ if (isVerbose()) {
+ getLog().info("Search Index generated for " + locale + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
+ }
}
}
\ No newline at end of file
Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-12-23 08:49:38 UTC (rev 1698)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-12-23 08:58:07 UTC (rev 1699)
@@ -18,35 +18,28 @@
* ##%*/
package org.nuiton.jaxx.plugin;
-import java.util.List;
-
+import jaxx.compiler.CompiledObjectDecorator;
import jaxx.compiler.CompilerConfiguration;
import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.JAXXEngine;
import jaxx.compiler.beans.BeanInfoUtil;
-import jaxx.compiler.CompiledObjectDecorator;
import jaxx.compiler.binding.DataBindingHelper;
-import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
import jaxx.compiler.tags.TagManager;
import jaxx.runtime.JAXXContext;
-
+import jaxx.runtime.swing.help.JAXXHelpBroker;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-
import org.nuiton.io.FileUpdaterHelper;
import org.nuiton.io.MirroredFileUpdater;
+import org.nuiton.plugin.PluginHelper;
import java.io.File;
-import java.io.IOException;
-import java.util.Map;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Set;
+import java.util.List;
+import java.util.Map;
-import jaxx.runtime.swing.help.JAXXHelpBroker;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
/**
* Generates some java code from jaxx files.
*
@@ -160,14 +153,6 @@
*/
protected boolean addProjectClassPath;
/**
- * to force generation of java source for any jaxx files with no timestamp checking.
- * <p/>
- * By default, never force generation.
- *
- * @parameter expression="${jaxx.force}" default-value="false"
- */
- protected boolean force;
- /**
* A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots.
*
* @parameter expression="${jaxx.testPhase}" default-value="false"
@@ -247,15 +232,6 @@
*/
protected boolean showBinding;
/**
- * flag to activate help generation process.
- * <p/>
- * By default, not active.
- *
- * @parameter expression="${jaxx.generateHelp}" default-value="false"
- * @since 1.3
- */
- protected boolean generateHelp;
- /**
* the FQN of help broker
* <p/>
* By default, use the JAXX implementation {@link JAXXHelpBroker}.
@@ -315,13 +291,6 @@
@Override
public boolean init() throws Exception {
- if (generateHelp) {
- // check there is some bundle
- if (getHelpIdsStore() == null) {
- throw new MojoFailureException("you must set the 'helpIdStore' property.");
- }
- }
-
fixCompileSourceRoots();
if (includes == null || includes.length == 0) {
@@ -331,7 +300,7 @@
updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
Map<File, String[]> result = new HashMap<File, String[]>();
- getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
+ getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, isForce() ? null : updater);
this.files = result.get(src);
@@ -340,7 +309,7 @@
return true;
}
- cl = initClassLoader(project,
+ cl = initClassLoader(getProject(),
src,
addSourcesToClassPath,
testPhase,
@@ -377,13 +346,13 @@
for (String importS : imports) {
imports[i++] = importS.trim();
}
- if (verbose) {
+ if (isVerbose()) {
getLog().info("extra imports " + java.util.Arrays.toString(imports));
}
extraImports = imports;
}
- if (verbose) {
+ if (isVerbose()) {
getLog().info(toString());
getLog().info("includes : " + Arrays.toString(includes));
for (String file : files) {
@@ -394,10 +363,10 @@
}
@Override
- public void doAction() throws MojoExecutionException {
+ public void doAction() throws Exception {
if (nofiles) {
- getLog().info("No files to treate.");
+ getLog().info("Nothing to generate - all files are uo to date.");
return;
}
@@ -407,9 +376,10 @@
DataBindingHelper.SHOW_LOG = showBinding;
}
try {
+ long t0 = System.nanoTime();
// force compiler init from here, not in a static block
- TagManager.reset(verbose);
+ TagManager.reset(isVerbose());
engine = JAXXEngine.newLaunchor(src, files, this);
int nbFiles = engine.run();
@@ -417,13 +387,8 @@
if (nbFiles == -1) {
throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
}
- getLog().info("Generated " + nbFiles + " file(s). ");
+ getLog().info("Generated " + nbFiles + " file(s) in " + PluginHelper.convertTime(System.nanoTime() - t0));
- if (generateHelp) {
- // generate help
- generateHelp();
- }
-
} catch (MojoExecutionException e) {
getLog().error(e);
throw e;
@@ -541,7 +506,9 @@
}
protected void fixCompileSourceRoots() {
- if (project == null) {
+ //FIXME TC20091222 : why this test ? should always have a project ?
+ // even in tests...
+ if (getProject() == null) {
// no project defined, can not fix anything
// this case could appear if we wanted to do some tests of the plugin
return;
@@ -554,41 +521,6 @@
}
}
- protected void generateHelp() throws IOException {
- Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
- if (helpIds.isEmpty()) {
- if (verbose) {
- // no ids detected in this compilation round
- getLog().info("no helpIds detected.");
- }
- return;
- }
- File idsStore = getHelpIdsStore();
-
- createDirectoryIfNecessary(idsStore.getParentFile());
-
- StringBuilder buffer = new StringBuilder();
-
- for (String helpId : helpIds) {
- buffer.append(removeQuote(helpId)).append('\n');
- }
- writeFile(idsStore, buffer.toString(), encoding);
-
- getLog().info("helpIdStore generated in " + idsStore);
-
- helpIds.clear();
- }
-
- protected String removeQuote(String txt) {
- if (txt.startsWith("\"")) {
- txt = txt.substring(1);
- }
- if (txt.endsWith("\"")) {
- txt = txt.substring(0, txt.length() - 1);
- }
- return txt;
- }
-
protected void report(JAXXEngine engine) {
List<String> warnings = engine.getWarnings();
if (!warnings.isEmpty()) {
1
0
r1698 - trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin
by tchemit@users.nuiton.org 23 Dec '09
by tchemit@users.nuiton.org 23 Dec '09
23 Dec '09
Author: tchemit
Date: 2009-12-23 09:49:38 +0100 (Wed, 23 Dec 2009)
New Revision: 1698
Modified:
trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java
trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java
Log:
use getter from mojo
Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java
===================================================================
--- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-12-23 08:48:34 UTC (rev 1697)
+++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-12-23 08:49:38 UTC (rev 1698)
@@ -228,7 +228,7 @@
long oldTime = dstFile.lastModified();
// second round, no force so will not the file
- mojo.force = false;
+ mojo.setForce(false);
executeMojo();
assertNumberJaxxFiles(0);
@@ -246,7 +246,7 @@
assertTrue(mojo.updater.getMirrorFile(srcFile).lastModified() > oldTime);
// last round, reforce file generation for an no modify source
- mojo.force = true;
+ mojo.setForce(true);
executeMojo();
assertNumberJaxxFiles(1);
assertTrue(mojo.updater.getMirrorFile(srcFile).lastModified() > oldTime);
Modified: trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java
===================================================================
--- trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-12-23 08:48:34 UTC (rev 1697)
+++ trunk/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-12-23 08:49:38 UTC (rev 1698)
@@ -67,7 +67,7 @@
for (String file : files) {
// check we have a the required/forbidden pattern
File f = new File(mojo.outJava, file.substring(0, file.length() - 4) + "java");
- if (mojo.verbose) {
+ if (mojo.isVerbose()) {
log.info("check generated file " + f);
}
1
0
r1697 - trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators
by tchemit@users.nuiton.org 23 Dec '09
by tchemit@users.nuiton.org 23 Dec '09
23 Dec '09
Author: tchemit
Date: 2009-12-23 09:48:34 +0100 (Wed, 23 Dec 2009)
New Revision: 1697
Modified:
trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
Log:
always return a copy of the help ids
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-12-22 17:36:00 UTC (rev 1696)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-12-23 08:48:34 UTC (rev 1697)
@@ -28,12 +28,13 @@
import jaxx.compiler.java.JavaFileGenerator;
import java.lang.reflect.Modifier;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* A decorator to place on a root compiled object to process javaHelp on the file.
- *
+ *
* @author tony
* @since 1.2
*/
@@ -121,6 +122,6 @@
}
public static Set<String> getHelpIds() {
- return helpIds;
+ return new HashSet<String>(helpIds);
}
}
1
0
Author: tchemit
Date: 2009-12-22 18:36:00 +0100 (Tue, 22 Dec 2009)
New Revision: 1696
Modified:
trunk/jaxx-demo/src/main/resources/log4j.properties
Log:
restore log levels
Modified: trunk/jaxx-demo/src/main/resources/log4j.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/log4j.properties 2009-12-22 17:35:06 UTC (rev 1695)
+++ trunk/jaxx-demo/src/main/resources/log4j.properties 2009-12-22 17:36:00 UTC (rev 1696)
@@ -6,7 +6,7 @@
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
log4j.logger.jaxx.demo=INFO
-log4j.logger.jaxx.demo.DemoConfig=DEBUG
+#log4j.logger.jaxx.demo.DemoConfig=DEBUG
log4j.logger.jaxx.runtime.swing.editor.config=INFO
-log4j.logger.jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder=DEBUG
+#log4j.logger.jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder=DEBUG
log4j.logger.org.nuiton=WARN
1
0
r1695 - in trunk/jaxx-demo/src/main: java/jaxx/demo resources resources/i18n
by tchemit@users.nuiton.org 22 Dec '09
by tchemit@users.nuiton.org 22 Dec '09
22 Dec '09
Author: tchemit
Date: 2009-12-22 18:35:06 +0100 (Tue, 22 Dec 2009)
New Revision: 1695
Modified:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
trunk/jaxx-demo/src/main/resources/log4j.properties
Log:
use ConfigModelBuilder api + improve application design
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-12-22 17:34:34 UTC (rev 1694)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-12-22 17:35:06 UTC (rev 1695)
@@ -20,9 +20,11 @@
*/
package jaxx.demo;
+import java.beans.PropertyChangeEvent;
import java.io.IOException;
import java.io.InputStream;
import java.beans.PropertyChangeListener;
+import java.util.Date;
import java.util.Locale;
import java.util.Properties;
@@ -53,11 +55,34 @@
* le projet (version, license,...) et la configuration des ui (icons, ...)
*/
public static final String APPLICATION_PROPERTIES = "/jaxx-demo.properties";
+
+ public static final String PROPERTY_FULLSCREEN = "fullscreen";
+ public static final String PROPERTY_LOCALE = "locale";
+ public static final String PROPERTY_FONT_SIZE = "fontSize";
+ public static final String PROPERTY_ADJUSTING = "adjusting";
+
/**
- * un drapeau pour savoir si on est en mode pleine écran
+ * un drapeau pour bloquer la sauvegarde lors de la modification en masse des options
+ * via les setter.
*/
- protected boolean fullscreen;
+ protected boolean adjusting;
+ protected final PropertyChangeListener saveAction = new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (adjusting) {
+ if (log.isDebugEnabled()) {
+ log.debug("skip save while adjusting");
+ }
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Saving configuration at " + new Date());
+ }
+ saveForUser();
+ }
+ };
+
public DemoConfig() {
setConfigFileName(Option.CONFIG_FILE.defaultValue);
@@ -89,12 +114,27 @@
String sVersion = VersionUtil.removeSnapshot(getOption("application.version"));
Version version = VersionUtil.valueOf(sVersion);
setDefaultOption("version", version.getVersion());
+
+ adjusting = true;
+ addPropertyChangeListener(PROPERTY_FULLSCREEN, saveAction);
+ addPropertyChangeListener(PROPERTY_FONT_SIZE, saveAction);
+ addPropertyChangeListener(PROPERTY_LOCALE, saveAction);
+ adjusting = false;
}
public String getCopyrightText() {
return "Version " + getVersion() + " Codelutin @ 2008-2009";
}
+ @Override
+ public void setOption(String key, String value) {
+ if (key.equals(PROPERTY_ADJUSTING)) {
+ setAdjusting(Boolean.valueOf(value));
+ return;
+ }
+ super.setOption(key, value);
+ }
+
/**
* @return la version de l'application.
*/
@@ -126,23 +166,39 @@
public void setFullscreen(boolean fullscreen) {
Object oldValue = null;
setOption(Option.FULL_SCREEN.key, fullscreen + "");
- saveForUser();
- firePropertyChange("fullscreen", oldValue, fullscreen);
+// saveForUser();
+ firePropertyChange(PROPERTY_FULLSCREEN, oldValue, fullscreen);
}
public void setLocale(Locale newLocale) {
setOption(Option.LOCALE.key, newLocale.toString());
- saveForUser();
- firePropertyChange("locale", null, newLocale);
+// saveForUser();
+ firePropertyChange(PROPERTY_LOCALE, null, newLocale);
}
public void setFontSize(Float newFontSize) {
Float oldValue = getFontSize();
+ if (log.isDebugEnabled()) {
+ log.debug("changing font-size to " + newFontSize);
+ }
setOption(Option.FONT_SIZE.key, newFontSize.toString());
- saveForUser();
- firePropertyChange("fontSize", oldValue, newFontSize);
+// saveForUser();
+ firePropertyChange(PROPERTY_FONT_SIZE, oldValue, newFontSize);
}
+ public boolean isAdjusting() {
+ return adjusting;
+ }
+
+ public void setAdjusting(boolean adjusting) {
+ if (log.isDebugEnabled()) {
+ log.debug("changing adjusting to " + adjusting);
+ }
+ boolean oldValue = this.adjusting;
+ this.adjusting = adjusting;
+ firePropertyChange(PROPERTY_ADJUSTING, oldValue, adjusting);
+ }
+
/**
* Save configuration, in user home directory using the
* {@link #getConfigFileName}. Default, env and commande line note saved
@@ -153,7 +209,7 @@
}
public static final String[] DEFAULT_JAXX_PCS = {
- "fullScreen", "locale", "fontSize"
+ PROPERTY_FULLSCREEN, PROPERTY_LOCALE, PROPERTY_FONT_SIZE, PROPERTY_ADJUSTING
};
public void removeJaxxPropertyChangeListener() {
@@ -180,8 +236,8 @@
CONFIG_FILE(CONFIG_FILE_NAME, _("jaxxdemo.config.configFileName.description"), "jaxxdemo", String.class, true, true),
FULL_SCREEN("ui.fullscreen", _("jaxxdemo.config.ui.fullscreen"), "false", Boolean.class, false, false),
- LOCALE("ui.locale", _("jaxxdemo.config.ui.locale"), Locale.FRANCE.toString(), Locale.class, false, false),
- FONT_SIZE("ui.fontSize", _("jaxxdemo.config.ui.fontSize"), "10f", Float.class, false, false),
+ LOCALE("ui." + PROPERTY_LOCALE, _("jaxxdemo.config.ui." + PROPERTY_LOCALE), Locale.FRANCE.toString(), Locale.class, false, false),
+ FONT_SIZE("ui." + PROPERTY_FONT_SIZE, _("jaxxdemo.config.ui." + PROPERTY_FONT_SIZE), "10f", Float.class, false, false),
DEMO_PATH("ui.demo.path", _("jaxxdemo.config.ui.demo.path"), "$root/jaxxdemo.tree.component.jaxx/jaxxdemo.tree.component.jaxx.tree.navigation/" + FullNavigationTreeDemo.class.getSimpleName(), String.class, false, false);
public final String key;
public final String description;
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2009-12-22 17:34:34 UTC (rev 1694)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2009-12-22 17:35:06 UTC (rev 1695)
@@ -70,7 +70,7 @@
onItemStateChanged='if(event.getStateChange() == ItemEvent.SELECTED) { updateSource(event); }'/>
<javax.swing.Box.Filler
constructorParams='SwingUtil.newMinDimension(), SwingUtil.newMinDimension(), SwingUtil.newMaxXDimension()'/>
- <FontSizor id='fontSizor' opaque='false' showFontSize='true' defaultFontSize='{getConfig().getFontSize()}'/>
+ <FontSizor id='fontSizor' opaque='false' showFontSize='true' fontSize='{getConfig().getFontSize()}'/>
<!--defaultFontSize='{getConfig().getFontSize()}' fontSize='{getConfig().getFontSize()}'/>-->
</JToolBar>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-12-22 17:34:34 UTC (rev 1694)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-12-22 17:35:06 UTC (rev 1695)
@@ -30,6 +30,7 @@
import jaxx.runtime.swing.editor.config.ConfigUI;
import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
+import jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder;
import jaxx.runtime.swing.navigation.NavigationTreeNode;
import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer;
import org.apache.commons.logging.Log;
@@ -61,15 +62,26 @@
* Methode pour initialiser l'ui principale sans l'afficher.
*
* @param rootContext le context applicatif
- * @param fullscreen flag pour indiquer si on doit ouvrir l'ui en model console (pleine ecran).
+ * @param config la configuration a utiliser
* @return l'ui instancie et initialisee mais non visible encore
*/
- public DemoUI initUI(DefaultApplicationContext rootContext, boolean fullscreen) {
+ public DemoUI initUI(DefaultApplicationContext rootContext, DemoConfig config) {
if (log.isDebugEnabled()) {
- log.debug("fullscreen ? " + fullscreen);
+ log.debug("fullscreen ? " + config.isFullScreen());
}
+ DecoratorProvider decoratorProvider = rootContext.getContextValue(DecoratorProvider.class);
+ if (!config.getLocale().equals(I18n.getLoader().getLanguage().getLocale())) {
+ if (log.isInfoEnabled()) {
+ log.info("re-init I18n with locale " + config.getLocale());
+ }
+ // change i18n language
+ I18n.init(config.getLocale());
+ // reload decorators
+ decoratorProvider.reload();
+ }
+
// create restrict context for ui
JAXXInitialContext context = new JAXXInitialContext();
@@ -82,11 +94,10 @@
// share config
context.add(rootContext.getContextValue(DemoConfig.class));
+ // share a unique DecoratorProvider
+ context.add(decoratorProvider);
+
// share a unique DecoratorProviderListCellRenderer
- DecoratorProvider decoratorProvider = rootContext.getContextValue(DecoratorProvider.class);
-
- context.add(decoratorProvider);
-
context.add(new DecoratorProviderListCellRenderer(decoratorProvider));
// instanciate ui
@@ -99,7 +110,7 @@
ErrorDialogUI.init(ui);
// set fullscreen propery on main ui
- ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(fullscreen ? ui : null);
+ ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(config.isFullScreen() ? ui : null);
return ui;
}
@@ -149,9 +160,9 @@
* Permet de recharger l'ui principale et de changer de le mode d'affichage.
*
* @param rootContext le contexte applicatif
- * @param fullscreen le type de fenetre à reouvrir
+ * @param config la configuration a utiliser
*/
- public void reloadUI(DefaultApplicationContext rootContext, boolean fullscreen) {
+ public void reloadUI(DefaultApplicationContext rootContext, DemoConfig config) {
// scan main ui
DemoUI ui = getUI(rootContext);
@@ -167,7 +178,9 @@
if (node != null) {
nodePath = node.getFullPath();
- log.info("selected node " + nodePath);
+ if (log.isDebugEnabled()) {
+ log.debug("selected node " + nodePath);
+ }
}
ErrorDialogUI.init(null);
@@ -177,10 +190,9 @@
ui.setVisible(false);
MAIN_UI_ENTRY_DEF.removeContextValue(rootContext);
-
}
- ui = initUI(rootContext, fullscreen);
+ ui = initUI(rootContext, config);
displayUI(ui, nodePath);
}
@@ -200,10 +212,11 @@
DemoUI ui = getUI(context);
// sauvegarde de l'état dans la configuration
- ui.getConfig().setFullscreen(fullscreen);
+ DemoConfig config = ui.getConfig();
+ config.setFullscreen(fullscreen);
// rechargement de l'ui
- reloadUI(RunDemo.get(), fullscreen);
+ reloadUI(RunDemo.get(), config);
}
public void changeLanguage(JAXXContext context, Locale newLocale) {
@@ -215,11 +228,8 @@
// sauvegarde de la nouvelle locale
config.setLocale(newLocale);
- // chargement de la nouvelle locale dans le système i18n
- I18n.init(newLocale);
-
// rechargement de l'ui
- reloadUI(RunDemo.get(), config.isFullScreen());
+ reloadUI(RunDemo.get(), config);
}
/**
@@ -240,23 +250,49 @@
public void showConfig(JAXXContext context) {
DemoUI ui = getUI(context);
- DemoConfig config = ui.getConfig();
- ConfigUIModel model = new ConfigUIModel(config);
+ final DemoConfig config = ui.getConfig();
+ ConfigUIModelBuilder builder = new ConfigUIModelBuilder();
+
+ builder.createModel(config);
+
+ builder.setReloadUICallback(new Runnable() {
+
+ @Override
+ public void run() {
+ if (log.isInfoEnabled()) {
+ log.info("will reload ui");
+ }
+ DefaultApplicationContext context = RunDemo.get();
+ DemoUI ui = getUI(context);
+ DemoConfig config = ui.getConfig();
+ reloadUI(context, config);
+ }
+ });
+
// categorie repertoires
- model.addCategory(
- n_("jaxxdemo.config.category.directories"),
- n_("jaxxdemo.config.category.directories.description"),
- DemoConfig.Option.CONFIG_FILE);
+ builder.addCategory(n_("jaxxdemo.config.category.directories"),
+ n_("jaxxdemo.config.category.directories.description"));
+
+ builder.addOption(DemoConfig.Option.CONFIG_FILE);
+
// others
- model.addCategory(
- n_("jaxxdemo.config.category.other"),
- n_("jaxxdemo.config.category.other.description"),
- DemoConfig.Option.FULL_SCREEN,
- DemoConfig.Option.FONT_SIZE,
- DemoConfig.Option.LOCALE);
+ builder.addCategory(n_("jaxxdemo.config.category.other"),
+ n_("jaxxdemo.config.category.other.description"));
+ builder.addOption(DemoConfig.Option.FULL_SCREEN);
+ builder.setOptionPropertyName(DemoConfig.PROPERTY_FULLSCREEN);
+ builder.setOptionNeedReloadUI(true);
+
+ builder.addOption(DemoConfig.Option.FONT_SIZE);
+ builder.setOptionPropertyName(DemoConfig.PROPERTY_FONT_SIZE);
+
+ builder.addOption(DemoConfig.Option.LOCALE);
+ builder.setOptionPropertyName(DemoConfig.PROPERTY_LOCALE);
+ builder.setOptionNeedReloadUI(true);
+
+ ConfigUIModel model = builder.flushModel();
ConfigUI configUI = ConfigUIBuilder.newConfigUI(context, model, "jaxxdemo.config.category.directories");
ConfigUIBuilder.showConfigUI(configUI, ui, false);
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-12-22 17:34:34 UTC (rev 1694)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-12-22 17:35:06 UTC (rev 1695)
@@ -126,7 +126,7 @@
// on affiche l'ui principale
DemoUIHandler handler = new DemoUIHandler();
- DemoUI ui = handler.initUI(rootContext, config.isFullScreen());
+ DemoUI ui = handler.initUI(rootContext, config);
log.info(_("jaxxdemo.init.ui.done"));
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-22 17:34:34 UTC (rev 1694)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-22 17:35:06 UTC (rev 1695)
@@ -165,6 +165,7 @@
jaxxdemo.config.category.other=Others
jaxxdemo.config.category.other.description=Others preferences
jaxxdemo.config.configFileName.description=Configuration file name
+jaxxdemo.config.ui.=
jaxxdemo.config.ui.demo.path=
jaxxdemo.config.ui.fontSize=
jaxxdemo.config.ui.fullscreen=To change the screen mode (true for full screen)
Modified: trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-22 17:34:34 UTC (rev 1694)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-22 17:35:06 UTC (rev 1695)
@@ -165,6 +165,7 @@
jaxxdemo.config.category.other=Autre
jaxxdemo.config.category.other.description=Autres options
jaxxdemo.config.configFileName.description=Le nom du fichier de configuration
+jaxxdemo.config.ui.=
jaxxdemo.config.ui.demo.path=
jaxxdemo.config.ui.fontSize=
jaxxdemo.config.ui.fullscreen=Pour afficher l'aplication en mode pleine \u00E9cran
Modified: trunk/jaxx-demo/src/main/resources/log4j.properties
===================================================================
--- trunk/jaxx-demo/src/main/resources/log4j.properties 2009-12-22 17:34:34 UTC (rev 1694)
+++ trunk/jaxx-demo/src/main/resources/log4j.properties 2009-12-22 17:35:06 UTC (rev 1695)
@@ -6,8 +6,7 @@
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
log4j.logger.jaxx.demo=INFO
-log4j.logger.jaxx.runtime.swing.editor.I18nEditor=INFO
-#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeCellRenderer=DEBUG
-#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeNodeRenderer=DEBUG
-#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeModel=DEBUG
+log4j.logger.jaxx.demo.DemoConfig=DEBUG
+log4j.logger.jaxx.runtime.swing.editor.config=INFO
+log4j.logger.jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder=DEBUG
log4j.logger.org.nuiton=WARN
1
0
Author: tchemit
Date: 2009-12-22 18:34:34 +0100 (Tue, 22 Dec 2009)
New Revision: 1694
Added:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
trunk/jaxx-widgets/src/test/
trunk/jaxx-widgets/src/test/java/
trunk/jaxx-widgets/src/test/java/jaxx/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java
trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java
trunk/jaxx-widgets/src/test/resources/
trunk/jaxx-widgets/src/test/resources/log4j.properties
Modified:
trunk/jaxx-widgets/pom.xml
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
Log:
add ConfigModelBuilder api + reload ui and application call back in ConfigUI + fix FontSizor issues
Modified: trunk/jaxx-widgets/pom.xml
===================================================================
--- trunk/jaxx-widgets/pom.xml 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/pom.xml 2009-12-22 17:34:34 UTC (rev 1694)
@@ -41,6 +41,11 @@
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx 2009-12-22 17:34:34 UTC (rev 1694)
@@ -39,7 +39,9 @@
public static final String BINDING_DEFAULT_FONT_SIZE_CALL_BACK = "defaultFontSize.callBack";
public void init() {
- setFontSize(defaultFontSize);
+ if (fontSize == null) {
+ setFontSize(defaultFontSize);
+ }
}
boolean updateDefaultSizeEnabled(Float fontSize, Float defaultFontSize, boolean enabled) {
@@ -69,7 +71,7 @@
setFontSize(defaultFontSize);
}
});
- applyDataBinding(BINDING_DEFAULT_FONT_SIZE_CALL_BACK);
+ //applyDataBinding(BINDING_DEFAULT_FONT_SIZE_CALL_BACK);
}
]]>
</script>
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigCategoryUI.jaxx 2009-12-22 17:34:34 UTC (rev 1694)
@@ -24,7 +24,7 @@
<JPanel layout='{new BorderLayout()}'>
<style source='ConfigCategoryUI.css'/>
-
+
<script><![CDATA[
import jaxx.runtime.swing.editor.config.model.*;
import jaxx.runtime.swing.editor.ColumnSelector;
@@ -82,6 +82,9 @@
]]>
</script>
+ <!-- le modele de l'ui -->
+ <ConfigUIModel id='model' initializer='getContextValue(ConfigUIModel.class)'/>
+
<CategoryModel id='categoryModel' javaBean='getContextValue(CategoryModel.class)'/>
<ConfigTableModel id='tableModel' constructorParams='categoryModel'
@@ -112,8 +115,10 @@
<!-- actions of the category -->
<JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.SOUTH'>
- <JButton id='reset' onActionPerformed='getContextValue(ConfigUIModel.class).reset()'/>
- <JButton id='save' onActionPerformed='getContextValue(ConfigUIModel.class).saveModified()'/>
+ <JButton id='reset' onActionPerformed='model.reset()'/>
+ <JButton id='save' onActionPerformed='model.saveModified()'/>
+ <!--<JButton id='reset' onActionPerformed='getContextValue(ConfigUIModel.class).reset()'/>-->
+ <!--<JButton id='save' onActionPerformed='getContextValue(ConfigUIModel.class).saveModified()'/>-->
</JPanel>
</JPanel>
</JPanel>
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigTableEditor.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -20,6 +20,7 @@
package jaxx.runtime.swing.editor.config;
import jaxx.runtime.swing.editor.config.model.ConfigTableModel;
+
import javax.swing.DefaultCellEditor;
import javax.swing.JTable;
import javax.swing.event.CellEditorListener;
@@ -27,9 +28,11 @@
import java.awt.Component;
import java.util.EventObject;
import java.util.Locale;
+
import jaxx.runtime.swing.editor.ClassCellEditor;
import jaxx.runtime.swing.editor.EnumEditor;
import jaxx.runtime.swing.editor.LocaleEditor;
+import jaxx.runtime.swing.editor.config.model.OptionModel;
/**
* L'éditeur des valeurs des propriétés d'une configuration
@@ -47,7 +50,7 @@
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- delegate = findDelegate(table, model.getEntry(row).getType());
+ delegate = findDelegate(table, model.getEntry(row));
return delegate.getTableCellEditorComponent(table, value, isSelected, row, column);
}
@@ -92,9 +95,11 @@
}
}
- protected TableCellEditor findDelegate(JTable table, Class<?> type) {
+ protected TableCellEditor findDelegate(JTable table, OptionModel option) {
+ Class<?> type = option.getType();
TableCellEditor editor = table.getDefaultEditor(type);
TableCellEditor defaultEditor = table.getDefaultEditor(Object.class);
+ //TODO always Search from option.getEditor() and store editor as cache
if (editor == defaultEditor) {
// find not a specialized editor for the type
if (type.isEnum()) {
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUI.jaxx 2009-12-22 17:34:34 UTC (rev 1694)
@@ -59,7 +59,7 @@
</script>
<!-- le modele de l'ui -->
- <ConfigUIModel id='model' javaBean='getContextValue(ConfigUIModel.class)'/>
+ <ConfigUIModel id='model' initializer='getContextValue(ConfigUIModel.class)'/>
<!-- les differentes categories de la configuration -->
<JTabbedPane id='categories' constraints='BorderLayout.CENTER'
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -20,24 +20,9 @@
*/
package jaxx.runtime.swing.editor.config;
-import java.awt.Frame;
-import java.awt.Window;
-import java.awt.event.ActionEvent;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.List;
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.JRootPane;
-import javax.swing.KeyStroke;
import jaxx.runtime.JAXXContext;
+import jaxx.runtime.SwingUtil;
import jaxx.runtime.context.JAXXInitialContext;
-import jaxx.runtime.SwingUtil;
-
import jaxx.runtime.swing.editor.config.model.CategoryModel;
import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
import jaxx.runtime.swing.editor.config.model.OptionModel;
@@ -45,8 +30,18 @@
import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
/**
* La classe pour construire l'ui
+ *
* @author chemit
*/
public class ConfigUIBuilder {
@@ -56,12 +51,12 @@
/**
* Construire l'ui de configuration (sous forme de panel)
*
- * @param parentContext le context applicatif
- * @param model le modele de l'ui de configuration
+ * @param parentContext le context applicatif
+ * @param model le modele de l'ui de configuration
* @param defaultCategory la categorie a selectionner
* @return l'ui instanciate
*/
- public static ConfigUI newConfigUI(jaxx.runtime.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
+ public static ConfigUI newConfigUI(JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model);
final ConfigUI ui = new ConfigUI(tx);
@@ -78,28 +73,119 @@
return;
}
+ boolean needReloadUI = false;
+ boolean needReloadApplication = false;
+
+ StringBuilder reloadUIBuffer = new StringBuilder();
+
+ StringBuilder reloadApplicationBuffer = new StringBuilder();
+
if (model.isSaved() && !model.isStandalone()) {
+
+
StringBuilder buffer = new StringBuilder();
+
// on doit verifier si des options sauvees necessite
// un redemarrage de l'application
for (CategoryModel cat : model) {
List<OptionModel> savedOptions = cat.getSavedOptions();
+ List<OptionModel> needReloadUIOptions = new ArrayList<OptionModel>();
+ List<OptionModel> needReloadApplicationOptions = new ArrayList<OptionModel>();
if (!savedOptions.isEmpty()) {
+ Iterator<OptionModel> itr = savedOptions.iterator();
buffer.append("\n").append(_("config.category.saved", _(cat.getCategory()))).append("\n");
- for (OptionModel option : savedOptions) {
+ while (itr.hasNext()) {
+ OptionModel option = itr.next();
buffer.append("\n- ").append(option.getKey());
+ if (option.isNeedReloadApplication()) {
+ needReloadApplication = true;
+ needReloadApplicationOptions.add(option);
+ continue;
+ }
+ if (option.isNeedReloadUI()) {
+ needReloadUI = true;
+ needReloadUIOptions.add(option);
+ continue;
+ }
+ itr.remove();
+
}
+ if (!savedOptions.isEmpty()) {
+
+ if (!needReloadApplicationOptions.isEmpty()) {
+ reloadApplicationBuffer.append("\n");
+ reloadApplicationBuffer.append(_("config.category.needReloadApplication", _(cat.getCategory())));
+ reloadApplicationBuffer.append("\n");
+ // second pass to obtain needReloadUI
+ for (OptionModel option : needReloadApplicationOptions) {
+ reloadApplicationBuffer.append("\n- ").append(option.getKey());
+ }
+ }
+
+ if (!needReloadUIOptions.isEmpty()) {
+ reloadUIBuffer.append("\n");
+ reloadUIBuffer.append(_("config.category.needReloadUI", _(cat.getCategory())));
+ reloadUIBuffer.append("\n");
+ // second pass to obtain needReloadUI
+ for (OptionModel option : needReloadUIOptions) {
+ reloadUIBuffer.append("\n- ").append(option.getKey());
+ }
+ }
+ }
+
}
+ }
+ if (log.isInfoEnabled()) {
+ log.info("save options :\n" + buffer.toString());
}
-// askUser(ui,
-// _("config.title.will.reload.application"), buffer.toString(),
-// JOptionPane.INFORMATION_MESSAGE,
-// new Object[]{
-// _("config.choice.ok")},
-// 0);
+
+ if (needReloadApplication) {
+
+ // reloading application implies reloading ui
+ needReloadUI = false;
+
+ askUser(ui,
+ _("config.title.will.reload.application"),
+ _("config.model.needReloadApplication") +
+ reloadApplicationBuffer.toString(),
+ JOptionPane.INFORMATION_MESSAGE,
+ new Object[]{_("config.choice.ok")},
+ 0);
+ }
+
+ if (needReloadUI) {
+ askUser(ui,
+ _("config.title.will.reload.ui"),
+ _("config.model.needReloadUI") +
+ reloadUIBuffer.toString(),
+ JOptionPane.INFORMATION_MESSAGE,
+ new Object[]{_("config.choice.ok")},
+ 0);
+ }
}
+
+ // close the configu ui
ui.getParentContainer(Window.class).dispose();
+
+ if (needReloadApplication) {
+
+ Runnable callback = model.getReloadApplicationCallback();
+ if (callback == null) {
+ throw new IllegalStateException("No reloadApplicationCallback found in model");
+ }
+
+ SwingUtilities.invokeLater(callback);
+ } else if (needReloadUI) {
+
+ Runnable callback = model.getReloadUICallback();
+ if (callback == null) {
+ throw new IllegalStateException("No reloadUICallback found in model");
+ }
+ SwingUtilities.invokeLater(callback);
+ }
+
+
}
};
String tip = quitButton.getToolTipText();
@@ -127,9 +213,9 @@
/**
* Affiche l'ui de configuration dans un boite de dialogue.
- *
- * @param configUI l'ui de configuration
- * @param ui l'ui parent de la boite de dialogue a afficher (peut etre nulle)
+ *
+ * @param configUI l'ui de configuration
+ * @param ui l'ui parent de la boite de dialogue a afficher (peut etre nulle)
* @param undecorated un drapeau pour savoir si on affiche les decorations de fenetre
*/
public static void showConfigUI(final ConfigUI configUI, Frame ui, boolean undecorated) {
@@ -149,9 +235,6 @@
public void windowClosing(WindowEvent e) {
ActionEvent myEvent = new ActionEvent(e.getSource(), 1, "quit");
configUI.getQuit().getAction().actionPerformed(myEvent);
-// if (canQuitCategory(configUI)) {
-// e.getWindow().dispose();
-// }
}
});
f.setUndecorated(undecorated);
@@ -185,8 +268,8 @@
buffer.toString(),
JOptionPane.ERROR_MESSAGE,
new Object[]{
- _("config.choice.continue"),
- _("config.choice.cancel")},
+ _("config.choice.continue"),
+ _("config.choice.cancel")},
0);
switch (reponse) {
@@ -216,9 +299,9 @@
_("config.title.need.confirm"), buffer.toString(),
JOptionPane.WARNING_MESSAGE,
new Object[]{
- _("config.choice.save"),
- _("config.choice.doNotSave"),
- _("config.choice.cancel")},
+ _("config.choice.save"),
+ _("config.choice.doNotSave"),
+ _("config.choice.cancel")},
0);
switch (reponse) {
@@ -242,7 +325,17 @@
public static int askUser(ConfigUI parent, String title, String message, int typeMessage, Object[] options, int defaultOption) {
- int response = JOptionPane.showOptionDialog(parent, message, title, JOptionPane.DEFAULT_OPTION, typeMessage, null, options, options[defaultOption]);
+ int response = JOptionPane.showOptionDialog(
+ parent,
+ message,
+ title,
+ JOptionPane.DEFAULT_OPTION,
+ typeMessage,
+ null,
+ options,
+ options[defaultOption]
+ );
+
return response;
}
}
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/CategoryModel.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -49,6 +49,18 @@
/** suport of modification */
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ protected CategoryModel(String category, String categoryLabel) {
+ super();
+ this.category = category;
+ this.categoryLabel = categoryLabel;
+ this.entries = new ArrayList<OptionModel>();
+ }
+
+ protected void addOption(OptionModel option) {
+ entries.add(option);
+ }
+
+ @Deprecated
public CategoryModel(String category, String categoryLabel, OptionModel[] entries) {
super();
this.category = category;
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModel.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -20,37 +20,41 @@
*/
package jaxx.runtime.swing.editor.config.model;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import org.apache.commons.beanutils.PropertyUtils;
+import static org.nuiton.i18n.I18n._;
import org.nuiton.util.ApplicationConfig;
import org.nuiton.util.ApplicationConfig.OptionDef;
-import static org.nuiton.i18n.I18n._;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.*;
+
/**
* Le modele de l'ui des preferences.
+ * <p/>
+ * Ce modele contient les catégories des options.
*
- * Ce modele contient les catégories des options.
- *
* @author chemit
*/
public class ConfigUIModel implements Iterable<CategoryModel> {
public static final String CATEGORY_MODEL_PROPERTY_NAME = "categoryModel";
- /** le dictionnaire des options disponibles par categorie */
+ /**
+ * le dictionnaire des options disponibles par categorie
+ */
protected final Map<String, CategoryModel> categories;
- /** La configuration de l'application */
+ /**
+ * La configuration de l'application
+ */
protected final ApplicationConfig config;
- /** la cateogrie en cours d'utilisation */
+ /**
+ * la cateogrie en cours d'utilisation
+ */
protected CategoryModel categoryModel;
/**
* un drapeau pour savoir si la configuration a été modifiée au moins une
* fois.
- *
+ * <p/>
* On utilise ce drapeau lors de la sortie pour verifier s'il faut ou non
* redemarer l'application (si non en mode standalone)
*/
@@ -58,12 +62,23 @@
/**
* un drapeau pour savoir si l'ui de configuration a été lancée en mode
* standalone ou pas.
- *
+ * <p/>
* Si pas lancée en mode standalone, et si la confi a été sauvé on vérifie
* s'il ne faut pas relancer l'application.
*/
protected boolean standalone;
- /** suport of modification */
+ /**
+ * call back when reload ui is necessary
+ */
+ protected Runnable reloadUICallback;
+ /**
+ * call back when reload application is necessary
+ */
+ protected Runnable reloadApplicationCallback;
+
+ /**
+ * suport of modification
+ */
protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
public ConfigUIModel(ApplicationConfig config) {
@@ -74,10 +89,12 @@
/**
* Ajoute une categorie dans le modele.
*
- * @param category l'id de la categorie (la clef de traduction du nom de la categorie)
+ * @param category l'id de la categorie (la clef de traduction du nom de la categorie)
* @param categoryLabel la clef de traduction de la description de la categorie
- * @param keys les options de la categorie
+ * @param keys les options de la categorie
+ * @deprecated since 2.0.0 prefer use the {@link #addCategory(CategoryModel)}
*/
+ @Deprecated
public void addCategory(String category, String categoryLabel, OptionDef... keys) {
if (categories.containsKey(category)) {
throw new IllegalArgumentException(_("config.error.category.already.exists", category));
@@ -94,8 +111,20 @@
}
/**
+ * Ajoute une categorie dans le modele.
+ *
+ * @param category la categorie a ajouter au modèle.
+ */
+ public void addCategory(CategoryModel category) {
+ if (categories.containsKey(category.getCategory())) {
+ throw new IllegalArgumentException(_("config.error.category.already.exists", category.getCategory()));
+ }
+ categories.put(category.getCategory(), category);
+ }
+
+ /**
* Change la categorie en cours d'édition.
- *
+ *
* @param category l'id de la categorie courante
*/
public void setCategory(String category) {
@@ -139,25 +168,53 @@
this.standalone = standalone;
}
+ public Runnable getReloadApplicationCallback() {
+ return reloadApplicationCallback;
+ }
+
+ public Runnable getReloadUICallback() {
+ return reloadUICallback;
+ }
+
public void saveModified() {
// compute transients keys (to never be saved)
List<String> transients = new ArrayList<String>();
- for (OptionModel option : categoryModel) {
- if (option.isModified()) {
- Object value = option.getValue();
- //TODO TC-20090245 : should try to seek for a mutator, since
- // mutator could have extra code to be done when modify an option
- config.setOption(option.getKey(), value == null ? null : value.toString());
- // l'option a été sauvegardée, on la marque
- option.setSaved(true);
- // this is the new original value
- option.initValue(value);
+ //TODO TC-20091222 : will be in ApplicationConfig, for the moment catch in your config it...
+// config.setAdjusting(true);
+ config.setOption("adjusting", "true");
+
+ try {
+ for (OptionModel option : categoryModel) {
+ if (option.isModified()) {
+ Object value = option.getValue();
+ //TODO TC-20090245 : should try to seek for a mutator, since
+ if (option.getPropertyName() != null) {
+ // this is a javaBean option
+ try {
+ PropertyUtils.setProperty(config, option.getPropertyName(), value);
+ } catch (Exception e) {
+ throw new RuntimeException("could not set property [" + option.getPropertyName() + "] with value = " + value, e);
+ }
+ } else {
+ // mutator could have extra code to be done when modify an option
+ config.setOption(option.getKey(), value == null ? null : value.toString());
+ }
+ // l'option a été sauvegardée, on la marque
+ option.setSaved(true);
+ // this is the new original value
+ option.initValue(value);
+ }
+ if (option.isTransient()) {
+ transients.add(option.getKey());
+ }
}
- if (option.isTransient()) {
- transients.add(option.getKey());
- }
+ } finally {
+ //TODO TC-20091222 : will be in ApplicationConfig, for the moment catch in your config it...
+// config.setAdjusting(false);
+ config.setOption("adjusting", "false");
}
+
setSaved(true);
// save config
config.saveForUser(transients.toArray(new String[transients.size()]));
@@ -223,4 +280,16 @@
public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
return pcs.getPropertyChangeListeners();
}
+
+ protected void setReloadApplicationCallback(Runnable reloadApplicationCallback) {
+ this.reloadApplicationCallback = reloadApplicationCallback;
+ }
+
+ protected void setReloadUICallback(Runnable reloadUICallback) {
+ this.reloadUICallback = reloadUICallback;
+ }
+
+ protected ApplicationConfig getConfig() {
+ return config;
+ }
}
Added: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java (rev 0)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -0,0 +1,305 @@
+package jaxx.runtime.swing.editor.config.model;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig;
+
+import javax.swing.table.TableCellEditor;
+
+/**
+ * A builder of {@link jaxx.runtime.swing.editor.config.model.ConfigUIModel}
+ * Created: 22 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ * @since 2.0.0
+ */
+public class ConfigUIModelBuilder {
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(ConfigUIModelBuilder.class);
+
+ /**
+ * current model used
+ */
+ ConfigUIModel model;
+ /**
+ * current category used
+ */
+ CategoryModel category;
+ /**
+ * current option used
+ */
+ OptionModel option;
+
+ /**
+ * Create a new model and set it as current model.
+ *
+ * @param config the configuration used in model
+ * @throws IllegalStateException if there is already a current model
+ * @throws NullPointerException if config is {@code null}
+ */
+ public void createModel(ApplicationConfig config) throws IllegalStateException, NullPointerException {
+ checkNoCurrent(model, "model");
+ checkNotNull(config, "createModel", "config");
+ model = new ConfigUIModel(config);
+ if (log.isDebugEnabled()) {
+ log.debug("model created : " + model);
+ }
+ }
+
+ /**
+ * Set the {@code reloadApplicationCallback} of the current model.
+ *
+ * @param callback the call back to set
+ * @throws IllegalStateException if there is not a current model
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see jaxx.runtime.swing.editor.config.model.ConfigUIModel#setReloadApplicationCallback(Runnable)
+ */
+ public void setReloadApplicationCallback(Runnable callback) throws IllegalStateException, NullPointerException {
+ checkCurrent(model, "model");
+ checkNotNull(callback, "setReloadApplicationCallback", "callback");
+ model.setReloadApplicationCallback(callback);
+ }
+
+ /**
+ * Set the {@code reloadUICallback} of the current model.
+ *
+ * @param callback the call back to set
+ * @throws IllegalStateException if there is not a current model
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see jaxx.runtime.swing.editor.config.model.ConfigUIModel#setReloadUICallback(Runnable)
+ */
+ public void setReloadUICallback(Runnable callback) {
+ checkCurrent(model, "model");
+ checkNotNull(callback, "setReloadUICallback", "callback");
+ model.setReloadUICallback(callback);
+ }
+
+ /**
+ * Add a new category, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous category, then store it to the model.
+ *
+ * @param categoryName the name of the new category (can not to be {@code null})
+ * @param categoryLabel the label of the new category (can not to be {@code null})
+ * @throws IllegalStateException if there is not a current model, nor category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public void addCategory(String categoryName, String categoryLabel) throws IllegalStateException, NullPointerException {
+ checkCurrent(model, "model");
+ checkNotNull(categoryName, "addCategory", "categoryName");
+ checkNotNull(categoryLabel, "addCategory", "categoryLabel");
+ flushCategory();
+ category = new CategoryModel(categoryName, categoryLabel);
+ if (log.isDebugEnabled()) {
+ log.debug("category created : " + category);
+ }
+ }
+
+ /**
+ * Add a new option, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous option, then store it to the model.
+ *
+ * @param def the def ot the new option
+ * @throws IllegalStateException if there is not a current model, nor category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public void addOption(ApplicationConfig.OptionDef def) throws IllegalStateException, NullPointerException {
+ checkCurrent(model, "model");
+ checkCurrent(category, "category");
+ checkNotNull(def, "addOption", "def");
+ flushOption();
+ Object value = model.getConfig().getOption(def);
+ option = new OptionModel(def, value);
+ if (log.isDebugEnabled()) {
+ log.debug("option created : " + option);
+ }
+ }
+
+ /**
+ * Add a new option with a propertyName, and set it as current.
+ * <p/>
+ * <b>Note:</b> As side effets, if a previous option, then store it to the model.
+ * <p/>
+ * <b>Note:</b> This method is a short-cut for
+ * {@link #addOption(org.nuiton.util.ApplicationConfig.OptionDef)} then
+ * {@link #setOptionPropertyName(String)}.
+ *
+ * @param def the def ot the new option
+ * @param propertyName the propertyName to set on the option
+ * @throws IllegalStateException if there is not a current model, nor category
+ * @throws NullPointerException if any of parameter is {@code null}
+ */
+ public void addOption(ApplicationConfig.OptionDef def, String propertyName) throws IllegalStateException, NullPointerException {
+ addOption(def);
+ checkNotNull(propertyName, "setOptionPropertyName", "propertyName");
+ option.setPropertyName(propertyName);
+ }
+
+ /**
+ * Set the propertyName on the current option.
+ *
+ * @param propertyName the propertyName to set in the current option.
+ * @throws IllegalStateException if there is not a current option set.
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see jaxx.runtime.swing.editor.config.model.OptionModel#setPropertyName(String)
+ */
+ public void setOptionPropertyName(String propertyName) throws IllegalStateException, NullPointerException {
+ checkCurrent(option, "option");
+ checkNotNull(propertyName, "setOptionPropertyName", "propertyName");
+ option.setPropertyName(propertyName);
+ }
+
+ /**
+ * Set the editor on the current option.
+ *
+ * @param editor the editor to set in the current option.
+ * @throws IllegalStateException if there is not a current option set.
+ * @throws NullPointerException if any of parameter is {@code null}
+ * @see jaxx.runtime.swing.editor.config.model.OptionModel#setEditor(javax.swing.table.TableCellEditor)
+ */
+ public void setOptionEditor(TableCellEditor editor) throws IllegalStateException, NullPointerException {
+ checkCurrent(option, "option");
+ checkNotNull(editor, "setOptionEditor", "editor");
+ option.setEditor(editor);
+ }
+
+ /**
+ * Set the needReloadUI flag on the current option.
+ *
+ * @param needReload new value to set
+ * @throws IllegalStateException if there is not a current option set.
+ * @see jaxx.runtime.swing.editor.config.model.OptionModel#setNeedReloadUI(boolean)
+ */
+ public void setOptionNeedReloadUI(boolean needReload) throws IllegalStateException {
+ checkCurrent(option, "option");
+ option.setNeedReloadUI(needReload);
+ }
+
+ /**
+ * Set the needReloadApplication flag on the current option.
+ *
+ * @param needReload new value to set
+ * @throws IllegalStateException if there is not a current option set.
+ * @see jaxx.runtime.swing.editor.config.model.OptionModel#setNeedReloadUI(boolean)
+ */
+ public void setOptionNeedReloadApplication(boolean needReload) throws IllegalStateException {
+ checkCurrent(option, "option");
+ option.setNeedReloadApplication(needReload);
+ }
+
+ /**
+ * Flush the model and return it.
+ * <p/>
+ * <b>Note:</b> As a side effect, nothing is available in the builder after this operation.
+ * To reuse the builder on a model, use the dedicated setter.
+ *
+ * @return the final model
+ * @throws IllegalStateException if there is not a current model set.
+ */
+ public ConfigUIModel flushModel() throws IllegalStateException {
+ checkCurrent(model, "model");
+ flushCategory();
+ ConfigUIModel result = model;
+ model = null;
+ return result;
+ }
+
+ /**
+ * Set the given model as current model.
+ * <p/>
+ * <b>Note:</b> As side effets, il will clean current category and option.
+ *
+ * @param model the model to use
+ * @throws IllegalStateException if there is already a current model
+ */
+ public void setModel(ConfigUIModel model) throws IllegalStateException {
+ checkNoCurrent(model, "model");
+ this.model = model;
+ if (log.isDebugEnabled()) {
+ log.debug("new current model : " + this.model);
+ }
+ category = null;
+ option = null;
+ }
+
+ /**
+ * Set the given category as current category.
+ * <p/>
+ * <b>Note:</b> As side effets, il will clean current option.
+ *
+ * @param categoryModel the category to use
+ * @throws IllegalStateException if there is not a current model or a current category
+ */
+ public void setCategory(CategoryModel categoryModel) throws IllegalStateException {
+ checkCurrent(model, "model");
+ checkNoCurrent(category, "category");
+ category = categoryModel;
+ if (log.isDebugEnabled()) {
+ log.debug("new current category : " + this.category);
+ }
+ option = null;
+ }
+
+ /**
+ * Sets the given option as current option.
+ *
+ * @param optionModel the option to use
+ * @throws IllegalStateException if there is not a current model, nor category, or a current option
+ */
+ public void setOption(OptionModel optionModel) throws IllegalStateException {
+ checkCurrent(model, "model");
+ checkCurrent(category, "category");
+ checkNoCurrent(option, "option");
+ option = optionModel;
+ if (log.isDebugEnabled()) {
+ log.debug("new current option : " + this.option);
+ }
+ }
+
+ protected CategoryModel flushCategory() {
+ CategoryModel result = category;
+ if (category != null) {
+ flushOption();
+ // add the previous category to the model
+ model.addCategory(category);
+ category = null;
+ }
+ return result;
+ }
+
+ protected OptionModel flushOption() {
+ OptionModel result = option;
+ if (option != null) {
+ // add the previous option to the category
+ category.addOption(option);
+ option = null;
+ }
+ return result;
+ }
+
+ protected void checkCurrent(Object o, String type) {
+ if (o == null) {
+ throw new IllegalStateException("no current " + type + "!");
+ }
+ }
+
+ protected void checkNoCurrent(Object o, String type) {
+ if (o != null) {
+ throw new IllegalStateException("there is already a current " + type + "!");
+ }
+ }
+
+ protected void checkNotNull(Object o, String method, String parameter) {
+ if (o == null) {
+ throw new NullPointerException("method " + method + " does not support null parameter " + parameter + "!");
+ }
+ }
+
+}
Property changes on: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/model/OptionModel.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -22,6 +22,8 @@
import org.nuiton.util.ApplicationConfig.OptionDef;
+import javax.swing.table.TableCellEditor;
+
/**
* le modele d'une option de la configuration a editer.
*
@@ -29,16 +31,42 @@
*/
public class OptionModel implements OptionDef {
- /** la definition de l'option ( venant de la config) */
+ /**
+ * la definition de l'option ( venant de la config)
+ */
protected final OptionDef def;
- /** un drapeau pour savoir si l'option est valide (n'est pas utilisé actuellement) */
+ /**
+ * un drapeau pour savoir si l'option est valide (n'est pas utilisé actuellement)
+ */
protected boolean valid = true;
- /** un drapeau pour savoir si l'option a été sauvée */
+ /**
+ * un drapeau pour savoir si l'option a été sauvée
+ */
protected boolean saved = false;
- /** la valeur non modifié de l'option */
+ /**
+ * un drapeau pour savoir si le changement de l'option nécessite un redémarrage de l'ui.
+ */
+ protected boolean needReloadUI = false;
+ /**
+ * un drapeau pour savoir si le changement de l'option nécessite un redémarrage de l'application.
+ */
+ protected boolean needReloadApplication = false;
+ /**
+ * la valeur non modifié de l'option
+ */
protected Object originalValue;
- /** la valeur actuelle de l'option (peut être la valeur orignal si non modifée)*/
+ /**
+ * la valeur actuelle de l'option (peut être la valeur orignal si non modifée)
+ */
protected Object value;
+ /**
+ * le nom de la propriété javaBean (peut etre null, si option sans support javaBean)
+ */
+ protected String propertyName;
+ /**
+ * l'editeur utilise pour modifier graphiquement l'option
+ */
+ protected TableCellEditor editor;
protected OptionModel(OptionDef def, Object value) {
this.def = def;
@@ -75,6 +103,14 @@
return def.isFinal();
}
+ public boolean isNeedReloadUI() {
+ return needReloadUI;
+ }
+
+ public boolean isNeedReloadApplication() {
+ return needReloadApplication;
+ }
+
public Object getOriginalValue() {
return originalValue;
}
@@ -106,9 +142,33 @@
public void setSaved(boolean saved) {
this.saved = saved;
}
-
+
public void initValue(Object originalValue) {
this.originalValue = originalValue;
this.value = originalValue;
}
+
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public TableCellEditor getEditor() {
+ return editor;
+ }
+
+ protected void setEditor(TableCellEditor editor) {
+ this.editor = editor;
+ }
+
+ protected void setNeedReloadUI(boolean needReloadUI) {
+ this.needReloadUI = needReloadUI;
+ }
+
+ protected void setNeedReloadApplication(boolean needReloadApplication) {
+ this.needReloadApplication = needReloadApplication;
+ }
+
+ protected void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
}
Modified: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
===================================================================
--- trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-22 17:34:34 UTC (rev 1694)
@@ -9,6 +9,8 @@
config.action.reset.tip=Cancel the modifications for the category
config.action.save=Save
config.action.save.tip=Save the modifications for the category
+config.category.needReloadApplication=
+config.category.needReloadUI=
config.category.saved=The category '%1$s' was modified \:
config.choice.cancel=Cancel
config.choice.continue=Continue
@@ -24,6 +26,8 @@
config.key.tip=Key of the option
config.message.quit.invalid.category=The category '%1$s' is not valid\!
config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \:
+config.model.needReloadApplication=
+config.model.needReloadUI=
config.modified=Option was modified (previous value \: %1$s)
config.no.option.selected=< No selected option >
config.option.final=This option can not be modified
@@ -32,6 +36,7 @@
config.title=Preferences
config.title.need.confirm=A confirmation is required
config.title.will.reload.application=The application need to be restarted
+config.title.will.reload.ui=The graphical interface must be relauched
config.unmodifiable=Can not be modified
config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s)
config.value=Value
@@ -46,9 +51,9 @@
errorUI.action.close=Close
errorUI.message=An error wad detected...
errorUI.title=Error...
-fontsize.action.default.tip=
-fontsize.action.down.tip=
-fontsize.action.up.tip=
+fontsize.action.default.tip=Restore default font size
+fontsize.action.down.tip=Decrease font size
+fontsize.action.up.tip=Increase font size
hidor.hideTip=Hide
hidor.showTip=Show
i18neditor.empty.locales=< No locale to select >
@@ -74,5 +79,4 @@
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
-size\ \:\ =
timeeditor.H=H
Modified: trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
===================================================================
--- trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-22 07:45:46 UTC (rev 1693)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-22 17:34:34 UTC (rev 1694)
@@ -9,6 +9,8 @@
config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie
config.action.save=Enregistrer
config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie
+config.category.needReloadApplication=Cat\u00E9gorie '%1$s' \:
+config.category.needReloadUI=Cat\u00E9gorie '%1$s' \:
config.category.saved=La cat\u00E9gorie '%1$s' a \u00E9t\u00E9 modifi\u00E9e \:
config.choice.cancel=Annuler
config.choice.continue=Continuer
@@ -24,6 +26,8 @@
config.key.tip=Clef de l'option
config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\!
config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \:
+config.model.needReloadApplication=Des options ont \u00E9t\u00E9 modifi\u00E9s qui n\u00E9cessitent le red\u00E9marrage de l'application.\n
+config.model.needReloadUI=Des options ont \u00E9t\u00E9 modifi\u00E9s qui n\u00E9cessitent le red\u00E9marrage de l'interface graphique.\n
config.modified=Option modifi\u00E9e (valeur originale \: %1$s)
config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e >
config.option.final=Option non modifiable
@@ -32,6 +36,7 @@
config.title=Pr\u00E9f\u00E9rences
config.title.need.confirm=Une confirmation de votre part est requise...
config.title.will.reload.application=L'application doit \u00EAtre red\u00E9marrer...
+config.title.will.reload.ui=L'interface graphique doit \u00EAtre relancer...
config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9
config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s)
config.value=Valeur
@@ -46,9 +51,9 @@
errorUI.action.close=Fermer
errorUI.message=Une erreur est survenue \!
errorUI.title=Erreur...
-fontsize.action.default.tip=
-fontsize.action.down.tip=
-fontsize.action.up.tip=
+fontsize.action.default.tip=Retour sur la taille par d\u00E9faut
+fontsize.action.down.tip=Diminuer la taille de la police
+fontsize.action.up.tip=Augmenter la taille de la police
hidor.hideTip=Cacher
hidor.showTip=Voir
i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
@@ -74,5 +79,4 @@
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
-size\ \:\ =
timeeditor.H=H
Added: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java
===================================================================
--- trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java (rev 0)
+++ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -0,0 +1,343 @@
+package jaxx.runtime.swing.editor.config.model;
+
+import jaxx.runtime.swing.editor.MyDefaultCellEditor;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.swing.table.TableCellEditor;
+
+/**
+ * Created: 22 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ * @since 2.0.0
+ */
+public class ConfigUIModelBuilderTest {
+
+ ConfigUIModelBuilder builder;
+
+ static MyConfig config;
+
+ @BeforeClass
+ public static void beforeeClass() {
+ config = new MyConfig();
+ }
+
+
+ @Before
+ public void setup() {
+ builder = new ConfigUIModelBuilder();
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testCreateModelLimitCase0() throws Exception {
+ builder.createModel(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testFlushModelLimitCase0() throws Exception {
+ builder.flushModel();
+ }
+
+ @Test
+ public void testCreateModel() throws Exception {
+ builder.createModel(config);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getConfig());
+
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetReloadApplicationCallbackLimitCase0() throws Exception {
+ builder.setReloadApplicationCallback(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testSetReloadApplicationCallbackLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setReloadApplicationCallback(null);
+ }
+
+ @Test
+ public void testSetReloadApplicationCallback() throws Exception {
+ builder.createModel(config);
+ Runnable callback = new Runnable() {
+
+ @Override
+ public void run() {
+ }
+ };
+ builder.setReloadApplicationCallback(callback);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getConfig());
+ Assert.assertEquals(callback, configModel.getReloadApplicationCallback());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetReloadUICallbackLimitCase0() throws Exception {
+ builder.setReloadUICallback(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testSetReloadUICallbackLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setReloadUICallback(null);
+ }
+
+ @Test
+ public void testSetReloadUICallback() throws Exception {
+ builder.createModel(config);
+ Runnable callback = new Runnable() {
+
+ @Override
+ public void run() {
+ }
+ };
+ builder.setReloadUICallback(callback);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNotNull(configModel.getConfig());
+ Assert.assertEquals(callback, configModel.getReloadUICallback());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddCategoryLimitCase0() throws Exception {
+ builder.addCategory(null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddCategoryLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.addCategory(null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddCategoryLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("", null);
+ }
+
+ @Test
+ public void testAddCategory() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ CategoryModel categoryModel = builder.flushCategory();
+ Assert.assertNotNull(categoryModel);
+ Assert.assertEquals("cat0", categoryModel.category);
+ Assert.assertEquals("cat0 label", categoryModel.categoryLabel);
+ Assert.assertEquals(0, categoryModel.entries.size());
+
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddOptionLimitCase0() throws Exception {
+ builder.addOption(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAddOptionLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.addOption(null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAddOptionLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(null);
+ }
+
+ @Test
+ public void testAddOption() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+
+ CategoryModel categoryModel = builder.flushCategory();
+ Assert.assertNotNull(categoryModel);
+ Assert.assertEquals("cat0", categoryModel.category);
+ Assert.assertEquals("cat0 label", categoryModel.categoryLabel);
+ Assert.assertEquals(1, categoryModel.entries.size());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase0() throws Exception {
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionPropertyNameLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionPropertyName(null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void testSetOptionPropertyNameLimitCase3() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionPropertyName(null);
+ }
+
+ @Test
+ public void testSetOptionPropertyName() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionPropertyName(MyConfig.PROPERTY_LOCALE);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+ Assert.assertEquals(MyConfig.PROPERTY_LOCALE, optionModel.propertyName);
+ Assert.assertEquals(false, optionModel.needReloadUI);
+ Assert.assertNull(optionModel.editor);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase0() throws Exception {
+ builder.setOptionEditor(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionEditor(null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionEditorLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionEditor(null);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void testSetOptionEditorLimitCase3() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionEditor(null);
+ }
+
+ @Test
+ public void testSetOptionEditor() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ TableCellEditor cellEditor = MyDefaultCellEditor.newBooleanEditor();
+ builder.setOptionEditor(cellEditor);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+ Assert.assertNull(optionModel.propertyName);
+ Assert.assertEquals(false, optionModel.needReloadUI);
+ Assert.assertEquals(cellEditor, optionModel.editor);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadUILimitCase0() throws Exception {
+ builder.setOptionNeedReloadUI(false);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadUILimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionNeedReloadUI(true);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadUILimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionNeedReloadUI(false);
+ }
+
+ @Test
+ public void testSetOptionNeedReloadUI() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionNeedReloadUI(true);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+ Assert.assertEquals(true, optionModel.needReloadUI);
+ Assert.assertNull(optionModel.propertyName);
+ Assert.assertNull(optionModel.editor);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadApplicationLimitCase0() throws Exception {
+ builder.setOptionNeedReloadApplication(false);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadApplicationLimitCase1() throws Exception {
+ builder.createModel(config);
+ builder.setOptionNeedReloadApplication(true);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testSetOptionNeedReloadApplicationLimitCase2() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.setOptionNeedReloadApplication(false);
+ }
+
+ @Test
+ public void testSetOptionNeedReloadApplication() throws Exception {
+ builder.createModel(config);
+ builder.addCategory("cat0", "cat0 label");
+ builder.addOption(MyConfig.Option.LOCALE);
+ builder.setOptionNeedReloadApplication(true);
+ OptionModel optionModel = builder.flushOption();
+ Assert.assertNotNull(optionModel);
+ Assert.assertEquals(MyConfig.Option.LOCALE, optionModel.def);
+ Assert.assertEquals(true, optionModel.needReloadApplication);
+ Assert.assertNull(optionModel.propertyName);
+ Assert.assertNull(optionModel.editor);
+ }
+
+
+ @Test
+ public void testFlushModel() throws Exception {
+ builder.createModel(config);
+ ConfigUIModel configModel = builder.flushModel();
+ Assert.assertNotNull(configModel);
+ Assert.assertNull(builder.model);
+ }
+
+ @Test
+ public void testSetModel() throws Exception {
+
+ }
+
+ @Test
+ public void testSetCategory() throws Exception {
+ }
+
+ @Test
+ public void testSetOption() throws Exception {
+ }
+
+}
Property changes on: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/ConfigUIModelBuilderTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java (from rev 1693, trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java)
===================================================================
--- trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java (rev 0)
+++ trunk/jaxx-widgets/src/test/java/jaxx/runtime/swing/editor/config/model/MyConfig.java 2009-12-22 17:34:34 UTC (rev 1694)
@@ -0,0 +1,208 @@
+/*
+ * *##%
+ * JAXX Demo
+ * Copyright (C) 2008 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package jaxx.runtime.swing.editor.config.model;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.nuiton.i18n.I18n._;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ * @author chemit
+ * @since 2.0.0
+ */
+public class MyConfig extends org.nuiton.util.ApplicationConfig {
+
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
+ static private Log log = LogFactory.getLog(MyConfig.class);
+
+ public static final String PROPERTY_FULLSCREEN = "fullscreen";
+ public static final String PROPERTY_LOCALE = "locale";
+ public static final String PROPERTY_FONT_SIZE = "fontSize";
+ public static final String PROPERTY_ADJUSTING = "adjusting";
+
+ /**
+ * un drapeau pour bloquer la sauvegarde lors de la modification en masse des options
+ * via les setter.
+ */
+ protected boolean adjusting;
+ protected final PropertyChangeListener saveAction = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (adjusting) {
+ if (log.isDebugEnabled()) {
+ log.debug("skip save while adjusting");
+ }
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Saving configuration at " + new Date());
+ }
+ saveForUser();
+ }
+ };
+
+ @Override
+ public void saveForUser(String... excludeKeys) {
+ // never save anything :)
+ }
+
+ public MyConfig() {
+
+ setConfigFileName(Option.CONFIG_FILE.defaultValue);
+
+ // chargement de la configuration interne
+
+ for (Option o : Option.values()) {
+ setDefaultOption(o.key, o.defaultValue);
+ }
+
+ adjusting = true;
+ addPropertyChangeListener(PROPERTY_FULLSCREEN, saveAction);
+ addPropertyChangeListener(PROPERTY_FONT_SIZE, saveAction);
+ addPropertyChangeListener(PROPERTY_LOCALE, saveAction);
+ adjusting = false;
+ }
+
+ @Override
+ public void setOption(String key, String value) {
+ if (key.equals(PROPERTY_ADJUSTING)) {
+ setAdjusting(Boolean.valueOf(value));
+ return;
+ }
+ super.setOption(key, value);
+ }
+
+
+ public boolean isFullScreen() {
+ Boolean result = getOptionAsBoolean(Option.FULL_SCREEN.key);
+ return result != null && result;
+ }
+
+ public Locale getLocale() {
+ Locale result = getOption(Locale.class, Option.LOCALE.key);
+ return result;
+ }
+
+ public Float getFontSize() {
+ Float result = getOption(Float.class, Option.FONT_SIZE.key);
+ return result;
+ }
+
+ public void setFullscreen(boolean fullscreen) {
+ Object oldValue = null;
+ setOption(Option.FULL_SCREEN.key, fullscreen + "");
+// saveForUser();
+ firePropertyChange(PROPERTY_FULLSCREEN, oldValue, fullscreen);
+ }
+
+ public void setLocale(Locale newLocale) {
+ setOption(Option.LOCALE.key, newLocale.toString());
+// saveForUser();
+ firePropertyChange(PROPERTY_LOCALE, null, newLocale);
+ }
+
+ public void setFontSize(Float newFontSize) {
+ Float oldValue = getFontSize();
+ if (log.isDebugEnabled()) {
+ log.debug("changing font-size to " + newFontSize);
+ }
+ setOption(Option.FONT_SIZE.key, newFontSize.toString());
+// saveForUser();
+ firePropertyChange(PROPERTY_FONT_SIZE, oldValue, newFontSize);
+ }
+
+ public boolean isAdjusting() {
+ return adjusting;
+ }
+
+ public void setAdjusting(boolean adjusting) {
+ if (log.isDebugEnabled()) {
+ log.debug("changing adjusting to " + adjusting);
+ }
+ boolean oldValue = this.adjusting;
+ this.adjusting = adjusting;
+ firePropertyChange(PROPERTY_ADJUSTING, oldValue, adjusting);
+ }
+
+ //////////////////////////////////////////////////
+ // Toutes les options disponibles
+ //////////////////////////////////////////////////
+ public static enum Option implements OptionDef {
+
+ CONFIG_FILE(CONFIG_FILE_NAME, _("jaxxdemo.config.configFileName.description"), "jaxxdemo", String.class, true, true),
+ FULL_SCREEN("ui.fullscreen", _("jaxxdemo.config.ui.fullscreen"), "false", Boolean.class, false, false),
+ LOCALE("ui." + PROPERTY_LOCALE, _("jaxxdemo.config.ui." + PROPERTY_LOCALE), Locale.FRANCE.toString(), Locale.class, false, false),
+ FONT_SIZE("ui." + PROPERTY_FONT_SIZE, _("jaxxdemo.config.ui." + PROPERTY_FONT_SIZE), "10f", Float.class, false, false);
+ public final String key;
+ public final String description;
+ public final String defaultValue;
+ public final Class<?> type;
+ public final boolean _transient;
+ public final boolean _final;
+
+ private Option(String key, String description, String defaultValue, Class<?> type, boolean _transient, boolean _final) {
+ this.key = key;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.type = type;
+ this._final = _final;
+ this._transient = _transient;
+ }
+
+ @Override
+ public boolean isFinal() {
+ return _final;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public Class<?> getType() {
+ return type;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/jaxx-widgets/src/test/resources/log4j.properties
===================================================================
--- trunk/jaxx-widgets/src/test/resources/log4j.properties (rev 0)
+++ trunk/jaxx-widgets/src/test/resources/log4j.properties 2009-12-22 17:34:34 UTC (rev 1694)
@@ -0,0 +1,10 @@
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+log4j.logger.jaxx.swing=INFO
+#log4j.logger.jaxx.runtime.swing.editor.config.model.ConfigUIModelBuilder=DEBUG
+log4j.logger.org.nuiton=WARN
1
0