Jaxx-commits
Threads by month
- ----- 2026 -----
- August
- July
- 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
December 2009
- 2 participants
- 44 discussions
r1704 - in trunk: . jaxx-demo jaxx-demo/src/main/resources/i18n jaxx-widgets/src/main/resources/i18n maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin
by tchemit@users.nuiton.org Dec. 29, 2009
by tchemit@users.nuiton.org Dec. 29, 2009
Dec. 29, 2009
Author: tchemit
Date: 2009-12-29 18:45:48 +0100 (Tue, 29 Dec 2009)
New Revision: 1704
Modified:
trunk/jaxx-demo/pom.xml
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-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
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/GenerateHelpFilesMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpIdsMojo.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
trunk/pom.xml
Log:
use last version of mavenpom and i18n
Modified: trunk/jaxx-demo/pom.xml
===================================================================
--- trunk/jaxx-demo/pom.xml 2009-12-23 09:14:47 UTC (rev 1703)
+++ trunk/jaxx-demo/pom.xml 2009-12-29 17:45:48 UTC (rev 1704)
@@ -179,6 +179,7 @@
<execution>
<goals>
<goal>parserJava</goal>
+ <goal>gen</goal>
<goal>bundle</goal>
</goals>
</execution>
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-23 09:14:47 UTC (rev 1703)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-29 17:45:48 UTC (rev 1704)
@@ -34,7 +34,6 @@
Editable=
Email\ Address\:=
Email\:=
-Empty\ I18n\ editor\:=
Enabled=
EnumEditor\ (country)\ \:=
EnumEditor\ (language)\ \:=
@@ -49,9 +48,6 @@
Green\:=
Greet=
Help=
-I18n\ editor\ with\ no\ icon\ \:=
-I18n\ editor\ with\ no\ text\ \:=
-I18n\ editor\:=
Inc\ (+)=
Italic=
JAXX\ Demo=
@@ -111,7 +107,6 @@
edit=Edit
edit2=Edit 2
edit3=Edit 3
-editor.getSelectedLocale()=
f0=
f1=
file...=
@@ -167,9 +162,7 @@
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)
-jaxxdemo.config.ui.locale=Locale of the application
jaxxdemo.i18neditor.configuration=Configuration
jaxxdemo.i18neditor.popupBorderText=Popup title
jaxxdemo.i18neditor.selected.locale=Selected Language
@@ -230,19 +223,9 @@
model1.isF0()\ ||\ model1.isF1()=
model1.isF1()=
movies=Movies
-numbereditor.normal.float=Signed float
-numbereditor.normal.int=Signed integer
-numbereditor.positive.float=Positive float
-numbereditor.positive.int=Positive integer
-numbereditor.type=Type
-numbereditor.with.auto.popup=With auto popup
-numbereditor.without.auto.popup=Without auto popup
-show/hide\ label1=
-show/hide\ label2=
t0.isSelected()=
t0.isSelected()\ &&\ t1.isSelected()=
t0.isSelected()\ ||\ t1.isSelected()=
t1.isSelected()=
-test=
valid=
x=
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-23 09:14:47 UTC (rev 1703)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-29 17:45:48 UTC (rev 1704)
@@ -34,7 +34,6 @@
Editable=Editable
Email\ Address\:=Courriel
Email\:=Courriel
-Empty\ I18n\ editor\:=Editeur I18n vide
Enabled=Activ\u00E9
EnumEditor\ (country)\ \:=Editeur de pays
EnumEditor\ (language)\ \:=Editeur de langue
@@ -49,9 +48,6 @@
Green\:=Vert \:
Greet=
Help=
-I18n\ editor\ with\ no\ icon\ \:=Editeur I18n sans icone \:
-I18n\ editor\ with\ no\ text\ \:=Editeur I18n sans texte \:
-I18n\ editor\:=Editeur I18n
Inc\ (+)=Incr\u00E9menter (+)
Italic=Italique
JAXX\ Demo=
@@ -111,7 +107,6 @@
edit=Editer
edit2=Editer 2
edit3=Editer 3
-editor.getSelectedLocale()=
f0=
f1=
file...=
@@ -167,9 +162,7 @@
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
-jaxxdemo.config.ui.locale=Langue utilis\u00E9e par l'application (fr_FR, en_GB ou es_ES)
jaxxdemo.i18neditor.configuration=Configuration
jaxxdemo.i18neditor.popupBorderText=Titre de la popup
jaxxdemo.i18neditor.selected.locale=Langue s\u00E9lectionn\u00E9e
@@ -230,19 +223,9 @@
model1.isF0()\ ||\ model1.isF1()=
model1.isF1()=
movies=Films
-numbereditor.normal.float=D\u00E9cimal primitif \: [%1$s]
-numbereditor.normal.int=Entier primitif \: [%1$s]
-numbereditor.positive.float=D\u00E9cimal primitif positif \: [%1$s]
-numbereditor.positive.int=Entier primitif positif \: [%1$s]
-numbereditor.type=Type d'\u00E9diteur
-numbereditor.with.auto.popup=Avec popup auto
-numbereditor.without.auto.popup=Sans popup auto
-show/hide\ label1=
-show/hide\ label2=
t0.isSelected()=
t0.isSelected()\ &&\ t1.isSelected()=
t0.isSelected()\ ||\ t1.isSelected()=
t1.isSelected()=
-test=
valid=valide
x=x
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 09:14:47 UTC (rev 1703)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-29 17:45:48 UTC (rev 1704)
@@ -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\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.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=+/-
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 09:14:47 UTC (rev 1703)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java 2009-12-29 17:45:48 UTC (rev 1704)
@@ -18,6 +18,7 @@
* ##%*/
package org.nuiton.jaxx.plugin;
+import org.apache.commons.lang.StringUtils;
import org.apache.maven.plugin.MojoFailureException;
import org.nuiton.i18n.I18n;
@@ -105,9 +106,10 @@
protected abstract void postDoAction();
@Override
- protected boolean init() throws Exception {
+ protected void init() throws Exception {
+// protected boolean init() throws Exception {
- if (locales == null || locales.trim().isEmpty()) {
+ if (StringUtils.isEmpty(locales)) {
throw new MojoFailureException("You must set the 'locales' property properly (was " + locales + ").");
}
@@ -123,7 +125,7 @@
}
if (tmp.isEmpty()) {
- throw new MojoFailureException("you must set the 'locales' property.");
+ throw new MojoFailureException("No locale to react, you must set the 'locales' property.");
}
localesToTreate = tmp.toArray(new Locale[tmp.size()]);
@@ -131,15 +133,24 @@
createDirectoryIfNecessary(getTargetDirectory());
+// return true;
+ }
+
+ @Override
+ protected boolean checkSkip() {
+ if (!generateHelp) {
+ getLog().info("generateHelp flag is off, will skip goal.");
+ return false;
+ }
return true;
}
@Override
protected void doAction() throws Exception {
- if (skipAction()) {
- return;
- }
+// if (skipAction()) {
+// return;
+// }
for (Locale locale : localesToTreate) {
@@ -160,13 +171,13 @@
postDoAction();
}
- protected boolean skipAction() {
- if (!generateHelp) {
- getLog().info("generateHelp flag is off, generate nothing.");
- return true;
- }
- return false;
- }
+// protected boolean skipAction() {
+// if (!generateHelp) {
+// getLog().info("generateHelp flag is off, will skip goal.");
+// return true;
+// }
+// return false;
+// }
public File getOutputHelpIds() {
return outputHelpIds;
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 09:14:47 UTC (rev 1703)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-12-29 17:45:48 UTC (rev 1704)
@@ -18,14 +18,11 @@
* ##%*/
package org.nuiton.jaxx.plugin;
-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;
/**
* Abstract Jaxx Mojo.
@@ -82,7 +79,9 @@
@Override
protected boolean checkPackaging() {
- return project != null && !"pom".equals(project.getPackaging()) && !"site".equals(project.getPackaging());
+ // not accept pom modules
+ return !acceptPackaging(Packaging.pom);
+// return project != null && !"pom".equals(project.getPackaging()) && !"site".equals(project.getPackaging());
}
@Override
@@ -121,78 +120,12 @@
this.force = force;
}
- /**
- * TODO-TC20091221 Should move this to AbstractPlugin
- * Create the directory if necessary.
- *
- * @param dir the directory to create if not already existing
- * @throws IOException if could not create the directory
- */
- protected void createDirectoryIfNecessary(File dir) throws IOException {
- if (!dir.exists()) {
- if (verbose) {
- getLog().info("mkdir " + dir);
- }
- boolean b = dir.mkdirs();
- if (!b) {
- throw new IOException("could not create directory " + dir);
- }
- }
- }
-
- //TODO-TC20091221 move this api to PluginHelper
- public static boolean addResourceDir(File dir, MavenProject project, String... includes) {
- List<?> resources = project.getResources();
- boolean added = addResourceDir(dir, project, resources, includes);
- return added;
- }
-
- //TODO-TC20091221 move this api to PluginHelper
- public static boolean addTestResourceDir(File newresourceDir, MavenProject project, String... includes) {
- List<?> resources = project.getTestResources();
- boolean added = addResourceDir(newresourceDir, project, resources, includes);
- return added;
- }
-
- //TODO-TC20091221 move this api to PluginHelper
- public static boolean addResourceDir(File dir, MavenProject project, List<?> resources, String... includes) {
- String newresourceDir = dir.getAbsolutePath();
- boolean shouldAdd = true;
- for (Object o : resources) {
- Resource r = (Resource) o;
- if (!r.getDirectory().equals(newresourceDir)) {
- continue;
- }
-
- for (String i : includes) {
- if (!r.getIncludes().contains(i)) {
- r.addInclude(i);
- }
- }
- shouldAdd = false;
- break;
- }
- if (shouldAdd) {
- Resource r = new Resource();
- r.setDirectory(newresourceDir);
- for (String i : includes) {
- if (!r.getIncludes().contains(i)) {
- r.addInclude(i);
- }
- }
- project.addResource(r);
- }
- return shouldAdd;
- }
-
-
class GetLastModifiedFileAction implements FileUtil.FileAction {
protected File lastFile;
public GetLastModifiedFileAction(File lastFile) {
this.lastFile = lastFile;
-
}
@Override
Modified: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpFilesMojo.java
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpFilesMojo.java 2009-12-23 09:14:47 UTC (rev 1703)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpFilesMojo.java 2009-12-29 17:45:48 UTC (rev 1704)
@@ -31,7 +31,7 @@
/**
* Mojo to generate javax help files for your project.
- *
+ *
* @author chemit
* @goal generate-help-files
* @phase process-sources
@@ -115,6 +115,7 @@
protected String indexFileName;
protected String tocFileName;
protected int touchedFiles;
+ protected File idsFile;
/**
* The help ids discovered.
@@ -132,11 +133,13 @@
}
@Override
- public boolean init() throws Exception {
+ public void init() throws Exception {
+// public boolean init() throws Exception {
if (!generateHelp) {
+ return;
+// return true;
+ }
- return true;
- }
// check ressources
checkResource(helpsetTemplate);
checkResource(mapTemplate);
@@ -149,68 +152,96 @@
tocFileName = helpsetName + "TOC.xml";
touchedFiles = 0;
- boolean b = super.init();
- if (!b) {
- return false;
- }
+ super.init();
+// boolean b = super.init();
+// if (!b) {
+// return false;
+// }
+
// load ids from idsStore file
- File idsFile;
+// 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;
- }
+// 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;
- }
+// if (!idsFile.exists()) {
+// if (isVerbose()) {
+// getLog().info("no helpIdStore to react at " + idsFile);
+// }
+// return true;
+// }
}
+ if (!idsFile.exists()) {
+ return;
+ }
+
helpIds = new SortedProperties();
// loading all ids
Set<String> ids = loadHelpIds(idsFile);
- if (ids.isEmpty()) {
+// if (ids.isEmpty()) {
+//
+// // no ids detected
+// if (isVerbose()) {
+// getLog().info("No helpIds detected, will skip.");
+// }
+// return true;
+// }
- // 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;
+// return true;
}
@Override
- protected boolean skipAction() {
- boolean b = super.skipAction();
- if (!b) {
+ protected boolean checkSkip() {
+ boolean b = super.checkSkip();
+ if (b) {
+
+ if (!idsFile.exists()) {
+ // pas de fichier a traiter
+ if (isForce()) {
+ getLog().info("Force flag is on, but no helpIdStore-all to react at " + idsFile);
+ } else {
+ getLog().info("no helpIdStore to react at " + idsFile);
+ }
+ return false;
+ }
if (helpIds == null || helpIds.isEmpty()) {
getLog().info("No help ids to treate.");
- return true;
+ return false;
}
}
- return false;
+ return b;
}
// @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()) {
Modified: 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 2009-12-23 09:14:47 UTC (rev 1703)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpIdsMojo.java 2009-12-29 17:45:48 UTC (rev 1704)
@@ -9,7 +9,7 @@
/**
* Generate the help ids files from the previous jaxx generation.
- *
+ * <p/>
* Created: 22 déc. 2009
*
* @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
@@ -25,17 +25,26 @@
*/
public class GenerateHelpIdsMojo extends AbstractGenerateHelpMojo {
+ /**
+ * help ids to react.
+ */
+ protected Set<String> helpIds;
+
@Override
- public boolean init() throws Exception {
+ public void init() throws Exception {
+// public boolean init() throws Exception {
if (!generateHelp) {
- return true;
+ return;
+// return true;
}
- if (!super.init()) {
- return false;
- }
+ super.init();
+// if (!super.init()) {
+// return false;
+// }
+
// check there is some bundle
if (getHelpIdsFilename() == null) {
throw new MojoFailureException("you must set the 'helpIdStore' property.");
@@ -44,27 +53,48 @@
throw new MojoFailureException("you must set the 'helpIdStoreAll' property.");
}
- return true;
+ helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
+
+ // always clean helpIdsStore before all
+ cleanHelpIdsStore();
+
+// return true;
}
@Override
- public void doAction() throws Exception {
+ protected boolean checkSkip() {
+ boolean b = super.checkSkip();
+ if (b) {
- if (skipAction()) {
- return;
- }
-
- Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
-
- if (helpIds.isEmpty()) {
+ if (helpIds.isEmpty()) {
// if (isVerbose()) {
- // no ids detected in this compilation round
- getLog().info("No helpIds detected.");
+ // no ids detected in this compilation round
+ getLog().info("No help ids to treate, will skip goal.");
// }
- cleanHelpIdsStore();
- return;
+ return false;
+ }
}
+ return b;
+ }
+ @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();
@@ -92,6 +122,7 @@
@Override
protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File source, String localePath) throws Exception {
+ // nothing to do specific to locale
}
@Override
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 09:14:47 UTC (rev 1703)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-12-29 17:45:48 UTC (rev 1704)
@@ -45,12 +45,12 @@
public void setTargetDirectory(File targetDirectory) {
}
- @Override
- public boolean init() throws Exception {
+// @Override
+// public boolean init() throws Exception {
+//
+// return true;
+// }
- return true;
- }
-
@Override
public void doAction() throws Exception {
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 09:14:47 UTC (rev 1703)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java 2009-12-29 17:45:48 UTC (rev 1704)
@@ -59,19 +59,22 @@
protected String timestamp;
@Override
- public boolean init() throws Exception {
- if (!generateHelp) {
+ public void init() throws Exception {
+// public boolean init() throws Exception {
+ if (!generateHelp || !generateSearch) {
- return true;
+ return;
+// return true;
}
- if (!generateSearch) {
-// getLog().info("Do not generate search.");
- return true;
- }
+// if (!generateSearch) {
+//// getLog().info("Do not generate search.");
+// return true;
+// }
timestamp = "-" + System.currentTimeMillis();
- return super.init();
+ super.init();
+// return super.init();
}
@Override
@@ -84,18 +87,30 @@
this.outputHelpSearch = targetDirectory;
}
- protected boolean skipAction() {
- if (!generateHelp) {
- getLog().info("generateHelp flag is off, generate nothing.");
- return true;
+ @Override
+ protected boolean checkSkip() {
+ boolean b = super.checkSkip();
+ if (b) {
+ if (!generateSearch) {
+ getLog().info("generateHelpsearch flag is off, will skip goal.");
+ return false;
+ }
}
- if (!generateSearch) {
- getLog().info("generateHelpsearch flag is off, generate nothing.");
- return true;
- }
- return false;
+ return b;
}
+// 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 {
@@ -165,7 +180,7 @@
protected void postDoAction() {
// add resources to the project
- addResourceDir(getTargetDirectory(), getProject(), "**/*");
+ addResourceDir(getTargetDirectory(), "**/*");
}
protected void generateSearchIndex(File source, File target, Locale locale) throws Exception {
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 09:14:47 UTC (rev 1703)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-12-29 17:45:48 UTC (rev 1704)
@@ -289,7 +289,8 @@
@SuppressWarnings("unchecked")
@Override
- public boolean init() throws Exception {
+ public void init() throws Exception {
+// public boolean init() throws Exception {
fixCompileSourceRoots();
@@ -306,7 +307,8 @@
nofiles = files == null || files.length == 0;
if (nofiles) {
- return true;
+ return;
+// return true;
}
cl = initClassLoader(getProject(),
@@ -359,16 +361,25 @@
getLog().info("will parse " + file);
}
}
+// return true;
+ }
+
+ @Override
+ protected boolean checkSkip() {
+ if (nofiles) {
+ getLog().info("Nothing to generate - all files are up to date.");
+ return false;
+ }
return true;
}
@Override
public void doAction() throws Exception {
- if (nofiles) {
- getLog().info("Nothing to generate - all files are uo to date.");
- return;
- }
+// if (nofiles) {
+// getLog().info("Nothing to generate - all files are uo to date.");
+// return;
+// }
getLog().info("Detects " + files.length + " modified jaxx file(s). ");
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-23 09:14:47 UTC (rev 1703)
+++ trunk/pom.xml 2009-12-29 17:45:48 UTC (rev 1704)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.1.3</version>
+ <version>1.1.4-SNAPSHOT</version>
</parent>
<artifactId>jaxx</artifactId>
@@ -355,7 +355,7 @@
<projectId>jaxx</projectId>
<lutinutil.version>1.1.0</lutinutil.version>
- <i18n.version>1.0.1</i18n.version>
+ <i18n.version>1.0.2-SNAPSHOT</i18n.version>
<jxlayer.version>3.0.3</jxlayer.version>
1
0
r1703 - in trunk: . jaxx-compiler jaxx-demo jaxx-runtime jaxx-swing-action jaxx-widgets maven-jaxx-plugin
by tchemit@users.nuiton.org Dec. 23, 2009
by tchemit@users.nuiton.org Dec. 23, 2009
Dec. 23, 2009
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 Dec. 23, 2009
by tchemit@users.nuiton.org Dec. 23, 2009
Dec. 23, 2009
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
Dec. 23, 2009
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 Dec. 23, 2009
by tchemit@users.nuiton.org Dec. 23, 2009
Dec. 23, 2009
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 Dec. 23, 2009
by tchemit@users.nuiton.org Dec. 23, 2009
Dec. 23, 2009
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 Dec. 23, 2009
by tchemit@users.nuiton.org Dec. 23, 2009
Dec. 23, 2009
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 Dec. 22, 2009
by tchemit@users.nuiton.org Dec. 22, 2009
Dec. 22, 2009
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
Dec. 22, 2009
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
r1693 - in trunk: jaxx-demo/src/main/java/jaxx/demo jaxx-demo/src/main/java/jaxx/demo/feature/databinding jaxx-demo/src/main/java/jaxx/demo/feature/validation jaxx-demo/src/main/resources/i18n jaxx-widgets/src/main/java/jaxx/runtime/swing
by tchemit@users.nuiton.org Dec. 22, 2009
by tchemit@users.nuiton.org Dec. 22, 2009
Dec. 22, 2009
Author: tchemit
Date: 2009-12-22 08:45:46 +0100 (Tue, 22 Dec 2009)
New Revision: 1693
Modified:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
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-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
Log:
improve FontSizor with callback + demo
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoConfig.java 2009-12-22 07:45:46 UTC (rev 1693)
@@ -36,15 +36,17 @@
/**
* La configuration de l'application.
+ * <p/>
+ * Il s'agit de l'objet partagé par toutes les démos.
*
- * Il s'agit de l'objet partagé par toutes les démos.
- *
* @author chemit
* @since 1.7.2
*/
public class DemoConfig extends org.nuiton.util.ApplicationConfig {
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * to use log facility, just put in your code: log.info(\"...\");
+ */
static private Log log = LogFactory.getLog(DemoConfig.class);
/**
* le fichier de configuration de l'application avec les informations sur
@@ -116,6 +118,11 @@
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 + "");
@@ -129,6 +136,13 @@
firePropertyChange("locale", null, newLocale);
}
+ public void setFontSize(Float newFontSize) {
+ Float oldValue = getFontSize();
+ setOption(Option.FONT_SIZE.key, newFontSize.toString());
+ saveForUser();
+ firePropertyChange("fontSize", oldValue, newFontSize);
+ }
+
/**
* Save configuration, in user home directory using the
* {@link #getConfigFileName}. Default, env and commande line note saved
@@ -137,8 +151,9 @@
// shoudl we never save any conf ?
super.saveForUser();
}
+
public static final String[] DEFAULT_JAXX_PCS = {
- "fullScreen", "locale"
+ "fullScreen", "locale", "fontSize"
};
public void removeJaxxPropertyChangeListener() {
@@ -166,6 +181,7 @@
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),
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/DemoPanel.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -66,9 +66,10 @@
<JPanel id='demoPanel'/>
</tab>
- <tab id='tabDemoSources' tabComponent='{sourceTabs.getSourcesHeader()}'>
+ <tab id='tabDemoSources' title='Sources'>
<DemoSources id='sourceTabs'
sources='{java.util.Arrays.asList(getSources())}'
- incomingClass='{getClass()}'/>
+ incomingClass='{getClass()}'
+ constructorParams='this'/>
</tab>
</JTabbedPane>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -25,17 +25,32 @@
import jaxx.runtime.swing.FontSizor;
public void init() {
+ //fontSizor.setDefaultFontSize(getConfig().getFontSize());
fontSizor.init();
+ fontSizor.setCallBack(new Runnable() {
+
+ @Override
+ public void run() {
+ log.info("update font size : " + fontSizor.getFontSize());
+ getConfig().setFontSize(fontSizor.getFontSize());
+ }
+ });
handler.init(this);
}
+
+public DemoConfig getConfig() {
+ return getContextValue(DemoConfig.class);
+}
+
+public void updateSource(ItemEvent event) {
+ setCurrentSource((String) sourceTabs.getSelectedItem());
+ editor.setText(handler.getSourceContent(this, getCurrentSource()));
+ editor.setSyntaxEditingStyle(handler.getSourceEditingStyle(this, getCurrentSource()));
+ editor.setCaretPosition(0);
+}
]]>
</script>
- <JPanel id="sourcesHeader" opaque='false'>
- <JLabel text='Sources' opaque='false'/>
- <FontSizor id='fontSizor' opaque='false' showFontSize='true' defaultFontSize='10f' fontSize='10f'/>
- </JPanel>
-
<DemoSourcesHandler id='handler'/>
<Class id='incomingClass' javaBean='null'/>
@@ -44,21 +59,35 @@
<java.util.List id='sources' genericType='String' javaBean='null'/>
- <JTabbedPane id='sourceTabs'
- constraints='BorderLayout.CENTER'
- tabPlacement='{JTabbedPane.BOTTOM}'
- onStateChanged='handler.updateSource(this)'/>
+ <JToolBar id='editorPaneHeader'
+ floatable='false'
+ borderPainted='false'
+ opaque='false'
+ constraints='BorderLayout.SOUTH'>
- <RSyntaxTextArea id='editor'
- constraints='BorderLayout.SOUTH'
- font-size='{fontSizor.getFontSize()}'
- text='{handler.getSourceContent(DemoSources.this, getCurrentSource())}'
- syntaxEditingStyle='{handler.getSourceEditingStyle(DemoSources.this, getCurrentSource())}'
- minimumSize="{jaxx.runtime.SwingUtil.newMinDimension()}"
- textAntiAliasHint='{RenderingHints.KEY_ANTIALIASING.toString()}'
- editable="false"
- wrapStyleWord="false"
- columns="80"
- lineWrap="true"/>
+ <JComboBox id='sourceTabs'
+ model='{new DefaultComboBoxModel()}'
+ 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()}'/>
+ <!--defaultFontSize='{getConfig().getFontSize()}' fontSize='{getConfig().getFontSize()}'/>-->
+ </JToolBar>
+ <JScrollPane id='editorPane' columnHeaderView='{editorPaneHeader}' constraints='BorderLayout.CENTER'>
+ <RSyntaxTextArea id='editor'
+ font-size='{getConfig().getFontSize()}'
+ minimumSize="{jaxx.runtime.SwingUtil.newMinDimension()}"
+ textAntiAliasHint='{RenderingHints.KEY_ANTIALIASING.toString()}'
+ editable="false"
+ wrapStyleWord="false"
+ columns="80"
+ lineWrap="true"/>
+ <!--font-size='{updateSize(getFontSizor().getFontSize())}'-->
+ <!-- TC-20091221 : can not use binding since we want to do something after assigment... -->
+ <!--text='{handler.getSourceContent(DemoSources.this, getCurrentSource())}'-->
+ <!--syntaxEditingStyle='{handler.getSourceEditingStyle(DemoSources.this, getCurrentSource())}'-->
+ </JScrollPane>
+
+
</JPanel>
\ No newline at end of file
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java 2009-12-22 07:45:46 UTC (rev 1693)
@@ -1,12 +1,12 @@
package jaxx.demo;
+import jaxx.runtime.SwingUtil;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
-import javax.swing.*;
-import java.awt.*;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -27,9 +27,9 @@
*/
private static final Log log = LogFactory.getLog(DemoSourcesHandler.class);
- protected Map<String, String> sourcesCache;
+ protected static Map<String, String> sourcesCache;
- public Map<String, String> getSourcesCache() {
+ public static Map<String, String> getSourcesCache() {
if (sourcesCache == null) {
sourcesCache = new TreeMap<String, String>();
}
@@ -44,9 +44,10 @@
if (result == null) {
try {
if (log.isDebugEnabled()) {
- log.debug(name + " from " + getClass());
+ log.debug(name + " from " + ui.getIncomingClass());
}
- result = IOUtils.toString(ui.getIncomingClass().getResourceAsStream(name));
+ String path = name.substring(ui.getIncomingClass().getPackage().getName().length() + 1);
+ result = IOUtils.toString(ui.getIncomingClass().getResourceAsStream(path));
if (log.isDebugEnabled()) {
log.debug("source [" + name + "], loaded content =\n" + result);
}
@@ -64,6 +65,7 @@
if (source == null) {
return "";
}
+ ui.getEditor().setFractionalFontMetricsEnabled(true);
String s = null;
if (source.matches(".*\\.jaxx") || source.matches(".*\\.xml")) {
s = RSyntaxTextArea.SYNTAX_STYLE_XML;
@@ -72,8 +74,8 @@
} else if (source.matches(".*\\.css")) {
s = RSyntaxTextArea.SYNTAX_STYLE_CSS;
}
- if (log.isInfoEnabled()) {
- log.info("source [" + source + "] style = " + s);
+ if (log.isDebugEnabled()) {
+ log.debug("source [" + source + "] style = " + s);
}
return s;
}
@@ -83,42 +85,22 @@
if (sources == null) {
return;
}
- for (String source : sources) {
- if (log.isInfoEnabled()) {
- log.info("adding tab for resource " + source);
+ List<String> toFill = new ArrayList<String>();
+ String prefix = ui.getIncomingClass() == null ? "" : (ui.getIncomingClass().getPackage().getName() + ".");
+ for (String source : sources) {
+ String path = prefix + source;
+ if (log.isDebugEnabled()) {
+ log.debug("adding resource " + path);
}
- JScrollPane pane = new JScrollPane(
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- pane.setBorder(null);
- // ajout de l'onglet
- ui.sourceTabs.addTab(source, pane);
- int index = ui.sourceTabs.indexOfComponent(pane);
- JLabel l = new JLabel(source);
- l.setFont(l.getFont().deriveFont((float) 10));
- ui.sourceTabs.setTabComponentAt(index, l);
+ toFill.add(path);
}
- }
-
- public void updateSource(DemoSources ui) {
- JTabbedPane sourceTabs = ui.getSourceTabs();
- int index = sourceTabs.getSelectedIndex();
- String sourceName = sourceTabs.getTitleAt(index);
-
- if (log.isInfoEnabled()) {
- log.info("new current Source : " + sourceName);
+ SwingUtil.fillComboBox(ui.getSourceTabs(), toFill, null);
+ if (!toFill.isEmpty()) {
+ ui.getSourceTabs().setSelectedIndex(0);
}
- // attach editor to correct selected tab and reset it
- JScrollPane pane = (JScrollPane) sourceTabs.getComponentAt(index);
- pane.getViewport().add(ui.getEditor());
- ui.getEditor().setText("");
- ui.getEditor().setCaretPosition(0);
- ui.getEditor().setTextAntiAliasHint(RenderingHints.KEY_ANTIALIASING.toString());
-
- // change the current source to release the editor
- ui.setCurrentSource(sourceName);
-
+ toFill.clear();
+ ui.getEditor().discardAllEdits();
}
}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUI.css 2009-12-22 07:45:46 UTC (rev 1693)
@@ -49,7 +49,7 @@
toolTipText:"jaxxdemo.action.configuration.tip";
actionIcon:"config";
mnemonic:C;
- enabled:false;
+ /*enabled:false;*/
_help:{"ui.main.menu.file.configuration"};
}
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-12-22 07:45:46 UTC (rev 1693)
@@ -254,6 +254,7 @@
n_("jaxxdemo.config.category.other"),
n_("jaxxdemo.config.category.other.description"),
DemoConfig.Option.FULL_SCREEN,
+ DemoConfig.Option.FONT_SIZE,
DemoConfig.Option.LOCALE);
ConfigUI configUI = ConfigUIBuilder.newConfigUI(context, model, "jaxxdemo.config.category.directories");
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -227,7 +227,7 @@
</cell>
</row>
- <row>
+ <row weighty="1">
<cell columns="3">
<JPanel layout="{new BorderLayout()}">
<JTextArea id="bindingsLabel" editable='false' text='{$bindings.size() + " bindings."}'/>
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationListDemo.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -24,12 +24,17 @@
<script><![CDATA[
import static org.nuiton.i18n.I18n.n_;
import jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorMessageListModel;
void $afterCompleteSetup() {
}
+
@Override
protected String[] getSources() {
- return new String[]{ getDefaultSource(), "Validation.css", "Model.java", "Identity.java" };
+ return new String[]{ getDefaultSource(), "Validation.css",
+ "Identity.java", "Identity-error-validation.xml", "Identity-info-validation.xml", "Identity-warning-validation.xml",
+ "Model.java", "Model-error-validation.xml", "Model-info-validation.xml", "Model-warning-validation.xml"
+ };
}
]]>
</script>
@@ -41,8 +46,8 @@
<!-- errors model -->
<!-- Not existing :) -->
<!--jaxx.runtime.validator.gwt.GWTValidatorMessageListModel id='errors'-->
- <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'
- onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
+ <SwingValidatorMessageListModel id='errors'
+ onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
<!-- validators -->
<BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/validation/ValidationTableDemo.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -21,16 +21,33 @@
<jaxx.demo.DemoPanel>
<style source="Validation.css"/>
- <!-- models -->
+ <script><![CDATA[
+import static org.nuiton.i18n.I18n.n_;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableModel;
+
+void $afterCompleteSetup() {
+ SwingValidatorUtil.installUI(errorTable, new SwingValidatorMessageTableRenderer());
+}
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "Validation.css",
+ "Identity.java", "Identity-error-validation.xml", "Identity-info-validation.xml", "Identity-warning-validation.xml",
+ "Model.java", "Model-error-validation.xml", "Model-info-validation.xml", "Model-warning-validation.xml"
+ };
+}
+]]></script>
+
+ <!-- models -->
<Model id='model1'/>
<Model id='model2'/>
<Identity id='identity'/>
<!-- errors model -->
- <!-- Not existing :) -->
- <!--jaxx.runtime.validator.gwt.GWTValidatorMessageTableModel id='errors2'/-->
- <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errors2'
- onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
+ <SwingValidatorMessageTableModel id='errors2'
+ onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
<!-- validators -->
<BeanValidator id='validator' bean='model1' uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI">
@@ -47,22 +64,7 @@
uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI">
<field name="email" component="email2"/>
</BeanValidator>
-
- <script><![CDATA[
-import static org.nuiton.i18n.I18n.n_;
-import jaxx.runtime.validator.swing.SwingValidatorUtil;
-import jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer;
-
-void $afterCompleteSetup() {
- SwingValidatorUtil.installUI(errorTable, new SwingValidatorMessageTableRenderer());
-}
-
-@Override
-protected String[] getSources() {
- return new String[]{ getDefaultSource(), "Validation.css", "Model.java", "Identity.java" };
-}
-]]></script>
-
+
<Table fill='both' id='demoPanel'>
<row>
<cell weightx='1' weighty='1' insets='6, 3, 0, 0'>
@@ -77,7 +79,7 @@
<JTextField id='text' text='{model1.getText()}'
onKeyReleased='model1.setText(text.getText())'
_validatorLabel='{n_("form.text")}'
- />
+ />
</cell>
</row>
<row>
@@ -88,7 +90,7 @@
<JTextField id='text2' text='{model1.getText2()}'
onKeyReleased='model1.setText2(text2.getText())'
_validatorLabel='{n_("form.text2")}'
- />
+ />
</cell>
</row>
@@ -97,7 +99,7 @@
<JLabel text='Ratio:'/>
</cell>
<cell>
- <JSlider id='ratio' minimum='0' maximum='100'
+ <JSlider id='ratio' minimum='0' maximum='100'
value='{model1.getRatio()}'
_validatorLabel='{n_("form.ratio")}'
onStateChanged='model1.setRatio(ratio.getValue())'/>
@@ -170,7 +172,7 @@
<JLabel text='Ratio:'/>
</cell>
<cell>
- <JSlider id='_ratio' minimum='0' maximum='100'
+ <JSlider id='_ratio' minimum='0' maximum='100'
value='{model2.getRatio()}'
_validatorLabel='{n_("form2.ratio")}'
onStateChanged='model2.setRatio(_ratio.getValue())'/>
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-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-22 07:45:46 UTC (rev 1693)
@@ -166,6 +166,7 @@
jaxxdemo.config.category.other.description=Others preferences
jaxxdemo.config.configFileName.description=Configuration file name
jaxxdemo.config.ui.demo.path=
+jaxxdemo.config.ui.fontSize=
jaxxdemo.config.ui.fullscreen=To change the screen mode (true for full screen)
jaxxdemo.config.ui.locale=Locale of the application
jaxxdemo.i18neditor.configuration=Configuration
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-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-22 07:45:46 UTC (rev 1693)
@@ -166,6 +166,7 @@
jaxxdemo.config.category.other.description=Autres options
jaxxdemo.config.configFileName.description=Le nom du fichier de configuration
jaxxdemo.config.ui.demo.path=
+jaxxdemo.config.ui.fontSize=
jaxxdemo.config.ui.fullscreen=Pour afficher l'aplication en mode pleine \u00E9cran
jaxxdemo.config.ui.locale=Langue utilis\u00E9e par l'application (fr_FR, en_GB ou es_ES)
jaxxdemo.i18neditor.configuration=Configuration
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-21 20:11:57 UTC (rev 1692)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx 2009-12-22 07:45:46 UTC (rev 1693)
@@ -34,6 +34,10 @@
<Boolean id='showFontSize' javaBean='false'/>
<script><![CDATA[
+
+public static final String BINDING_FONT_SIZE_CALL_BACK = "fontSize.callBack";
+public static final String BINDING_DEFAULT_FONT_SIZE_CALL_BACK = "defaultFontSize.callBack";
+
public void init() {
setFontSize(defaultFontSize);
}
@@ -44,6 +48,29 @@
}
return !fontSize.equals(defaultFontSize) && enabled;
}
+
+public void setCallBack(final Runnable action) {
+ removeDataBinding(BINDING_FONT_SIZE_CALL_BACK);
+ registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_FONT_SIZE_CALL_BACK, true ,"fontSize") {
+
+ @Override
+ public void processDataBinding() {
+ action.run();
+ }
+ });
+ applyDataBinding(BINDING_FONT_SIZE_CALL_BACK);
+}
+
+void $afterCompleteSetup() {
+ registerDataBinding(new SimpleJAXXObjectBinding(this, BINDING_DEFAULT_FONT_SIZE_CALL_BACK, true ,"defaultFontSize") {
+
+ @Override
+ public void processDataBinding() {
+ setFontSize(defaultFontSize);
+ }
+ });
+ applyDataBinding(BINDING_DEFAULT_FONT_SIZE_CALL_BACK);
+}
]]>
</script>
<JToolBar floatable='false'
@@ -76,7 +103,7 @@
onActionPerformed='setFontSize(fontSize + 1)'/>
<JLabel visible='{isShowFontSize()}'
- text='{"" + getFontSize()}'/>
+ text='{SwingUtil.getStringValue(getFontSize())}'/>
</JToolBar>
</JPanel>
1
0
r1692 - in trunk/jaxx-demo/src/main: java/jaxx/demo java/jaxx/demo/component/jaxx/editor java/jaxx/demo/feature/databinding java/jaxx/demo/fun resources/i18n
by tchemit@users.nuiton.org Dec. 21, 2009
by tchemit@users.nuiton.org Dec. 21, 2009
Dec. 21, 2009
Author: tchemit
Date: 2009-12-21 21:11:57 +0100 (Mon, 21 Dec 2009)
New Revision: 1692
Added:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java
trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java
Modified:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
Log:
add FontSizor widget + ExtremeDatabinding demo + use FontSizor on sources
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
@@ -22,8 +22,6 @@
<JTabbedPane id='top'>
<script><![CDATA[
-import org.apache.commons.io.IOUtils;
-import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
protected String[] getSources() {
if (getClass() == DemoPanel.class) {
@@ -48,20 +46,6 @@
return getLabel() + " Demo";
}
-public String loadSource(String filename) {
- try {
- if (log.isDebugEnabled()) {
- log.debug(filename + " from " + getClass());
- }
- String result = IOUtils.toString(getClass().getResourceAsStream(filename));
-
- return result;
- } catch (Exception e) {
- log.error("could not load file " + filename, e);
- return "could not load file " + filename;
- }
-}
-
private void $afterCompleteSetup() {
SwingUtilities.invokeLater(new Runnable() {
@@ -71,48 +55,20 @@
top.remove(sourceTabs);
return;
}
- for (String extra : getSources()) {
- JScrollPane pane = new JScrollPane(
- JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- pane.setBorder(null);
- //pane.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
- // creation du contenu du fichier
- RSyntaxTextArea content = new RSyntaxTextArea();
- if (extra.matches(".*\\.jaxx") || extra.matches(".*\\.xml")){
- content.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_XML);
- } else if (extra.matches(".*\\.java")){
- content.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_JAVA);
- } else if (extra.matches(".*\\.css")){
- content.setSyntaxEditingStyle(RSyntaxTextArea.SYNTAX_STYLE_CSS);
- }
- content.setFont(content.getFont().deriveFont((float) 11));
- content.setMinimumSize(jaxx.runtime.SwingUtil.newMinDimension());
- content.setEditable(false);
- content.setWrapStyleWord(false);
- content.setText(loadSource(extra));
- content.setColumns(80);
- content.setLineWrap(true);
- pane.getViewport().add(content);
- content.setCaretPosition(0);
- // ajout de l'onglet
- sourceTabs.addTab(extra, pane);
- int index = sourceTabs.indexOfComponent(pane);
- JLabel l = new JLabel(extra);
- l.setFont(l.getFont().deriveFont((float) 10));
- sourceTabs.setTabComponentAt(index,l);
- }
+ sourceTabs.init();
}
});
}
]]>
</script>
- <tab title='{getDemoTabTitle()}'>
+ <tab id='tabDemoPanel' title='{getDemoTabTitle()}'>
<JPanel id='demoPanel'/>
</tab>
- <tab title='Sources'>
- <JTabbedPane id='sourceTabs' tabPlacement='{JTabbedPane.BOTTOM}'/>
+ <tab id='tabDemoSources' tabComponent='{sourceTabs.getSourcesHeader()}'>
+ <DemoSources id='sourceTabs'
+ sources='{java.util.Arrays.asList(getSources())}'
+ incomingClass='{getClass()}'/>
</tab>
-</JTabbedPane>
+</JTabbedPane>
\ No newline at end of file
Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx (from rev 1686, trunk/jaxx-demo/src/main/java/jaxx/demo/DemoPanel.jaxx)
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSources.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,64 @@
+<!--
+ *##%
+ 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>.
+ ##%*
+-->
+<JPanel layout='{new BorderLayout()}'>
+
+ <script><![CDATA[
+import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
+import jaxx.runtime.swing.FontSizor;
+
+public void init() {
+ fontSizor.init();
+ handler.init(this);
+}
+ ]]>
+ </script>
+
+ <JPanel id="sourcesHeader" opaque='false'>
+ <JLabel text='Sources' opaque='false'/>
+ <FontSizor id='fontSizor' opaque='false' showFontSize='true' defaultFontSize='10f' fontSize='10f'/>
+ </JPanel>
+
+ <DemoSourcesHandler id='handler'/>
+
+ <Class id='incomingClass' javaBean='null'/>
+
+ <String id='currentSource' javaBean='null'/>
+
+ <java.util.List id='sources' genericType='String' javaBean='null'/>
+
+ <JTabbedPane id='sourceTabs'
+ constraints='BorderLayout.CENTER'
+ tabPlacement='{JTabbedPane.BOTTOM}'
+ onStateChanged='handler.updateSource(this)'/>
+
+ <RSyntaxTextArea id='editor'
+ constraints='BorderLayout.SOUTH'
+ font-size='{fontSizor.getFontSize()}'
+ text='{handler.getSourceContent(DemoSources.this, getCurrentSource())}'
+ syntaxEditingStyle='{handler.getSourceEditingStyle(DemoSources.this, getCurrentSource())}'
+ minimumSize="{jaxx.runtime.SwingUtil.newMinDimension()}"
+ textAntiAliasHint='{RenderingHints.KEY_ANTIALIASING.toString()}'
+ editable="false"
+ wrapStyleWord="false"
+ columns="80"
+ lineWrap="true"/>
+
+</JPanel>
\ No newline at end of file
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,124 @@
+package jaxx.demo;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * Created: 21 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ */
+public class DemoSourcesHandler {
+
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(DemoSourcesHandler.class);
+
+ protected Map<String, String> sourcesCache;
+
+ public Map<String, String> getSourcesCache() {
+ if (sourcesCache == null) {
+ sourcesCache = new TreeMap<String, String>();
+ }
+ return sourcesCache;
+ }
+
+ public String getSourceContent(DemoSources ui, String name) {
+ if (name == null) {
+ return "";
+ }
+ String result = getSourcesCache().get(name);
+ if (result == null) {
+ try {
+ if (log.isDebugEnabled()) {
+ log.debug(name + " from " + getClass());
+ }
+ result = IOUtils.toString(ui.getIncomingClass().getResourceAsStream(name));
+ if (log.isDebugEnabled()) {
+ log.debug("source [" + name + "], loaded content =\n" + result);
+ }
+ } catch (Exception e) {
+ log.error("could not load file " + name, e);
+ result = "could not load file " + name;
+ }
+ getSourcesCache().put(name, result);
+ }
+ return result;
+ }
+
+ public String getSourceEditingStyle(DemoSources ui, String source) {
+
+ if (source == null) {
+ return "";
+ }
+ String s = null;
+ if (source.matches(".*\\.jaxx") || source.matches(".*\\.xml")) {
+ s = RSyntaxTextArea.SYNTAX_STYLE_XML;
+ } else if (source.matches(".*\\.java")) {
+ s = RSyntaxTextArea.SYNTAX_STYLE_JAVA;
+ } else if (source.matches(".*\\.css")) {
+ s = RSyntaxTextArea.SYNTAX_STYLE_CSS;
+ }
+ if (log.isInfoEnabled()) {
+ log.info("source [" + source + "] style = " + s);
+ }
+ return s;
+ }
+
+ public void init(DemoSources ui) {
+ List<String> sources = ui.getSources();
+ if (sources == null) {
+ return;
+ }
+ for (String source : sources) {
+
+ if (log.isInfoEnabled()) {
+ log.info("adding tab for resource " + source);
+ }
+ JScrollPane pane = new JScrollPane(
+ JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ pane.setBorder(null);
+ // ajout de l'onglet
+ ui.sourceTabs.addTab(source, pane);
+ int index = ui.sourceTabs.indexOfComponent(pane);
+ JLabel l = new JLabel(source);
+ l.setFont(l.getFont().deriveFont((float) 10));
+ ui.sourceTabs.setTabComponentAt(index, l);
+ }
+ }
+
+ public void updateSource(DemoSources ui) {
+ JTabbedPane sourceTabs = ui.getSourceTabs();
+ int index = sourceTabs.getSelectedIndex();
+ String sourceName = sourceTabs.getTitleAt(index);
+
+ if (log.isInfoEnabled()) {
+ log.info("new current Source : " + sourceName);
+ }
+ // attach editor to correct selected tab and reset it
+ JScrollPane pane = (JScrollPane) sourceTabs.getComponentAt(index);
+ pane.getViewport().add(ui.getEditor());
+ ui.getEditor().setText("");
+ ui.getEditor().setCaretPosition(0);
+ ui.getEditor().setTextAntiAliasHint(RenderingHints.KEY_ANTIALIASING.toString());
+
+ // change the current source to release the editor
+ ui.setCurrentSource(sourceName);
+
+ }
+
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoSourcesHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-12-21 20:11:57 UTC (rev 1692)
@@ -29,6 +29,7 @@
import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo;
import jaxx.demo.component.swing.*;
import jaxx.demo.feature.databinding.BeanDataBindingDemo;
+import jaxx.demo.feature.databinding.BindingExtremeDemo;
import jaxx.demo.feature.validation.ValidationListDemo;
import jaxx.demo.feature.validation.ValidationTableDemo;
import jaxx.demo.fun.CalculatorDemo;
@@ -116,6 +117,7 @@
goUp().
addText(n_("jaxxdemo.tree.feature")).
addText(n_("jaxxdemo.tree.features.databinding")).
+ addDemo(BindingExtremeDemo.class).
addDemo(BeanDataBindingDemo.class).
goUp().
addText(n_("jaxxdemo.tree.features.validation")).
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
@@ -86,97 +86,4 @@
</row>
</Table>
</jaxx.demo.DemoPanel>
- <!--row>
- <cell>
- <NumberEditor id='positifIntegerEditor'
- property='positifInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- <cell>
- <NumberEditor id='positifIntegerEditor2'
- property='positifInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.normal.int", demoModel.getNormalInteger())}'/>
- </cell>
- <cell>
- <NumberEditor id='normalIntegerEditor'
- property='normalInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- <cell>
- <NumberEditor id='normalIntegerEditor2'
- property='normalInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.positive.float", demoModel.getPositifFloat())}'/>
- </cell>
- <cell>
- <NumberEditor id='positifFloatEditor'
- property='positifFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- <cell>
- <NumberEditor id='positifFloatEditor2'
- property='positifFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/>
- </cell>
- <cell>
- <NumberEditor id='normalFloatEditor'
- property='normalFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- <cell>
- <NumberEditor id='normalFloatEditor2'
- property='normalFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- </row-->
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/BindingExtremeDemo.jaxx 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,243 @@
+<!--
+ *##%
+ 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>.
+ ##%*
+-->
+
+<jaxx.demo.DemoPanel id='mainFrame' implements='DemoUIModel'>
+
+ <style>
+ JTextArea { editable:false; }
+
+ JCheckBox { enabled:false; }
+
+ .nobinding { background:{Color.GRAY}; }
+ </style>
+
+ <script><![CDATA[
+public JToggleButton getT3() { return t0; }
+
+private void $afterCompleteSetup() {
+ for (Object o : $objectMap.values()) {
+ if (o instanceof JCheckBox) {
+ JCheckBox c = (JCheckBox) o;
+ c.setBackground($bindings.containsKey(c.getName() + ".selected") ? Color.WHITE : Color.RED);
+ }
+ }
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ DefaultListModel m = (DefaultListModel) bindings.getModel();
+ for (JAXXBinding b : getDataBindings()) {
+ m.addElement(b.getId());
+ }
+ }
+ });
+}
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "DemoUIModel.java", "DefaultDemoUIModel.java" };
+}
+ ]]>
+ </script>
+
+ <Boolean id='f0' javaBean='Boolean.FALSE'/>
+ <Boolean id='f1' javaBean='Boolean.FALSE'/>
+ <java.io.File id='file' javaBean='new java.io.File(".")'/>
+
+ <DefaultDemoUIModel id='model0' initializer='new DefaultDemoUIModel()'/>
+
+ <DemoUIModel id='model1' javaBean='new DefaultDemoUIModel()'/>
+
+
+ <Table id='demoPanel' fill="both" constraints='BorderLayout.NORTH'>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cf0' selected='{isF0()}' text='isF0()'/>
+ <JCheckBox id='cf1' selected='{isF1()}' text='isF1()'/>
+ <JCheckBox id='cf0O1' selected='{isF0() || isF1()}' text='isF0() || isF1()'/>
+ <JCheckBox id='cf0A1' selected='{isF0() && isF1()}' text='isF0() && isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='ct0' selected='{t0.isSelected()}' text='t0.isSelected()'/>
+ <JCheckBox id='ct1' selected='{t1.isSelected()}' text='t1.isSelected()'/>
+ <JCheckBox id='ct0O1' selected='{t0.isSelected() || t1.isSelected()}'
+ text='t0.isSelected() || t1.isSelected()'/>
+ <JCheckBox id='ct0A1' selected='{t0.isSelected() && t1.isSelected()}'
+ text='t0.isSelected() && t1.isSelected()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cgett0' selected='{getT0().isSelected()}' text='getT0().isSelected()'/>
+ <JCheckBox id='cgett1' selected='{getT1().isSelected()}' text='getT1().isSelected()'/>
+ <JCheckBox id='cgett0O1' selected='{getT0().isSelected() || getT1().isSelected()}'
+ text='getT0().isSelected() || getT1().isSelected()'/>
+ <JCheckBox id='cgett0A1' selected='{getT0().isSelected() && getT1().isSelected()}'
+ text='getT0().isSelected() && getT1().isSelected()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JTextArea id='cfile' border='{new TitledBorder("file.getAbsolutePath()")}'
+ text='{file.getAbsolutePath()}' visible='{!$bindings.containsKey("cfile.text")}'
+ styleClass="nobinding"/>
+ <JTextArea id='cgetfile' border='{new TitledBorder("getFile().getAbsolutePath()")}'
+ text='{getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cgetfile.text")}'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row weightx='1'>
+ <cell>
+ <JToggleButton id='t0' text='f0' onActionPerformed='setF0(!f0)'/>
+ </cell>
+ <cell>
+ <JToggleButton id='t1' text='f1' onActionPerformed='setF1(!f1)' javaBean='new JToggleButton()'/>
+ </cell>
+ <cell>
+ <JButton text="file..."
+ onActionPerformed='setFile(org.nuiton.util.FileUtil.getFile(this, new String[0]))'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cmt0' selected='{model0.isF0()}' text='model0.isF0()'/>
+ <JCheckBox id='cmt1' selected='{model0.isF1()}' text='model0.isF1()'/>
+ <JCheckBox id='cmt0O1' selected='{model0.isF0() || model0.isF1()}'
+ text='model0.isF0() || model0.isF1()'/>
+ <JCheckBox id='cmt0A1' selected='{model0.isF0() && model0.isF1()}'
+ text='model0.isF0() && model0.isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cmgett0' selected='{getModel0().isF0()}' text='getModel0().isF0()'/>
+ <JCheckBox id='cmgett1' selected='{getModel0().isF1()}' text='getModel0().isF1()'/>
+ <JCheckBox id='cmgett0O1' selected='{getModel0().isF0() || getModel0().isF1()}'
+ text='getModel0().isF0() || getModel0().isF1()'/>
+ <JCheckBox id='cmgett0A1' selected='{getModel0().isF0() && getModel0().isF1()}'
+ text='getModel0().isF0() && getModel0().isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JTextArea id='cMfile' border='{new TitledBorder("model0.getFile().getAbsolutePath()")}'
+ text='{model0.getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cMfile.text")}'/>
+ <JTextArea id='cMgetfile' border='{new TitledBorder("getModel0().getFile().getAbsolutePath()")}'
+ text='{getModel0().getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cMgetfile.text")}'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JToggleButton id='Mt0' text='model0.f0' onActionPerformed='model0.setF0(!model0.isF0())'/>
+ </cell>
+ <cell>
+ <JToggleButton id='Mt1' text='model0.f1' onActionPerformed='model0.setF1(!model0.isF1())'
+ javaBean='new JToggleButton()'/>
+ </cell>
+ <cell>
+ <JButton text="model0.file..."
+ onActionPerformed='model0.setFile(org.nuiton.util.FileUtil.getFile(this,new String[0]))'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cit0' selected='{((DemoUIModel)model1).isF0()}' text='model1.isF0()'/>
+ <JCheckBox id='cit1' selected='{((DemoUIModel)model1).isF1()}' text='model1.isF1()'/>
+ <JCheckBox id='cit0O1' selected='{((DemoUIModel)model1).isF0() || ((DemoUIModel)model1).isF1()}'
+ text='model1.isF0() || model1.isF1()'/>
+ <JCheckBox id='cit0A1'
+ selected='{((DemoUIModel)model1).isF0() && ((DemoUIModel)model1).isF1()}'
+ text='model1.isF0() && model1.isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JCheckBox id='cigett0' selected='{getModel1().isF0()}' text='getModel1().isF0()'/>
+ <JCheckBox id='cigett1' selected='{getModel1().isF1()}' text='getModel1().isF1()'/>
+ <JCheckBox id='cigett0O1' selected='{getModel1().isF0() || getModel1().isF1()}'
+ text='getModel1().isF0() || getModel1().isF1()'/>
+ <JCheckBox id='cigett0A1' selected='{getModel1().isF0() && getModel1().isF1()}'
+ text='getModel1().isF0() && getModel1().isF1()'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new GridLayout(1,0)}">
+ <JTextArea id='cIfile' border='{new TitledBorder("model1.getFile().getAbsolutePath()")}'
+ text='{model1.getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cIfile.text")}'/>
+ <JTextArea id='cIgetfile' border='{new TitledBorder("getModel1().getFile().getAbsolutePath()")}'
+ text='{getModel1().getFile().getAbsolutePath()}'
+ visible='{$bindings.containsKey("cIgetfile.text")}'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JToggleButton id='It0' text='model1.f0' onActionPerformed='model1.setF0(!model1.isF0())'/>
+ </cell>
+ <cell>
+ <JToggleButton id='It1' text='model1.f1' onActionPerformed='model1.setF1(!model1.isF1())'
+ javaBean='new JToggleButton()'/>
+ </cell>
+ <cell>
+ <JButton text="model1.file..."
+ onActionPerformed='model1.setFile(org.nuiton.util.FileUtil.getFile(this,new String[0]))'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell columns="3">
+ <JPanel layout="{new BorderLayout()}">
+ <JTextArea id="bindingsLabel" editable='false' text='{$bindings.size() + " bindings."}'/>
+ <JScrollPane constraints='BorderLayout.CENTER' columnHeaderView='{bindingsLabel}'>
+ <JList id="bindings" model='{new DefaultListModel()}' font-size='10'/>
+ </JScrollPane>
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+
+
+</jaxx.demo.DemoPanel>
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,137 @@
+package jaxx.demo.feature.databinding;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ * Created: 3 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ */
+public class DefaultDemoUIModel implements DemoUIModel {
+
+
+ protected java.io.File file;
+ protected java.io.File file1;
+ protected java.lang.Boolean f1 = false;
+ protected java.lang.Boolean f0 = false;
+
+ protected javax.swing.JToggleButton t1;
+ protected javax.swing.JToggleButton t0;
+
+ public static final String PROPERTY_T1 = "t1";
+ public static final String PROPERTY_F1 = "f1";
+ public static final String PROPERTY_F0 = "f0";
+ public static final String PROPERTY_FILE = "file";
+
+ protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ protected static final Log log = LogFactory.getLog(DefaultDemoUIModel.class);
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- public acessor methods -------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+
+ public java.lang.Boolean getF0() {
+ return f0;
+ }
+
+ public java.lang.Boolean getF1() {
+ return f1;
+ }
+
+ @Override
+ public java.io.File getFile() {
+ return file;
+ }
+
+ public java.io.File getFile1() {
+ return file1;
+ }
+
+ @Override
+ public javax.swing.JToggleButton getT0() {
+ return t0;
+ }
+
+ @Override
+ public javax.swing.JToggleButton getT1() {
+ return t1;
+ }
+
+ @Override
+ public java.lang.Boolean isF0() {
+ return f0 != null && f0;
+ }
+
+ @Override
+ public java.lang.Boolean isF1() {
+ return f1 != null && f1;
+ }
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- public mutator methods -------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+
+ @Override
+ public void setF0(java.lang.Boolean newValue) {
+ java.lang.Boolean oldValue = this.f0;
+ this.f0 = newValue;
+ firePropertyChange(PROPERTY_F0, oldValue, newValue);
+ }
+
+ @Override
+ public void setF1(java.lang.Boolean newValue) {
+ java.lang.Boolean oldValue = this.f1;
+ this.f1 = newValue;
+ firePropertyChange(PROPERTY_F1, oldValue, newValue);
+ }
+
+ @Override
+ public void setFile(java.io.File newValue) {
+ java.io.File oldValue = this.file;
+ this.file = newValue;
+ firePropertyChange(PROPERTY_FILE, oldValue, newValue);
+ }
+
+
+ public void setT1(javax.swing.JToggleButton newValue) {
+ javax.swing.JToggleButton oldValue = this.t1;
+ this.t1 = newValue;
+ firePropertyChange(PROPERTY_T1, oldValue, newValue);
+ }
+
+ @Override
+ public void firePropertyChange(String name, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(name, oldValue, newValue);
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ @Override
+ public void addPropertyChangeListener(String property, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(property, listener);
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ @Override
+ public void removePropertyChangeListener(String property, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(property, listener);
+ }
+
+
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DefaultDemoUIModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java 2009-12-21 20:11:57 UTC (rev 1692)
@@ -0,0 +1,74 @@
+package jaxx.demo.feature.databinding;
+
+import javax.swing.*;
+import java.io.File;
+
+/**
+ * Created: 2 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ */
+public interface DemoUIModel {
+
+ Boolean isF0();
+
+ Boolean isF1();
+
+ void setF0(Boolean b);
+
+ void setF1(Boolean b);
+
+ JToggleButton getT0();
+
+ JToggleButton getT1();
+
+ File getFile();
+
+ void setFile(File newValue);
+
+ /**
+ * All <code>JAXXObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and
+ * furthermore (for technical reasons) must allow code in outside packages, specifically the JAXX runtime,
+ * to trigger these events.
+ *
+ * @param name the name of the property which changed
+ * @param oldValue the old value of the property
+ * @param newValue the new value of the property
+ */
+ void firePropertyChange(String name, Object oldValue, Object newValue);
+
+ /**
+ * Register a general {@link java.beans.PropertyChangeListener}.
+ *
+ * @param listener the listener to register
+ */
+ void addPropertyChangeListener(java.beans.PropertyChangeListener listener);
+
+ /**
+ * Register a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}.
+ *
+ * @param property the property name to listen
+ * @param listener the listener to register
+ */
+ void addPropertyChangeListener(String property, java.beans.PropertyChangeListener listener);
+
+ /**
+ * Unregister a general {@link java.beans.PropertyChangeListener}.
+ *
+ * @param listener the listener to unregister
+ */
+ void removePropertyChangeListener(java.beans.PropertyChangeListener listener);
+
+ /**
+ * Unregister a {@link java.beans.PropertyChangeListener}. for the given {@code propertyName}.
+ *
+ * @param property the property name to listen
+ * @param listener the listener to unregister
+ */
+ void removePropertyChangeListener(String property, java.beans.PropertyChangeListener listener);
+
+}
Property changes on: trunk/jaxx-demo/src/main/java/jaxx/demo/feature/databinding/DemoUIModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css 2009-12-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/fun/Calculator.css 2009-12-21 20:11:57 UTC (rev 1692)
@@ -39,8 +39,12 @@
foreground: red;
}
-JButton:mouseover {
+/*JButton:mouseover {
font-weight: bold;
+}*/
+
+JButton.operator:mouseover {
+ font-weight: bold;
}
JButton.operator:mouseover {
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-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-21 20:11:57 UTC (rev 1692)
@@ -112,13 +112,32 @@
edit2=Edit 2
edit3=Edit 3
editor.getSelectedLocale()=
+f0=
+f1=
+file...=
form.ratio=Ratio
form.text=Text
form.text2=Text 2
form2.ratio=Form 2 Ratio
form2.text=Form 2 Text
form2.text2=Form 2 Text 2
+getModel0().isF0()=
+getModel0().isF0()\ &&\ getModel0().isF1()=
+getModel0().isF0()\ ||\ getModel0().isF1()=
+getModel0().isF1()=
+getModel1().isF0()=
+getModel1().isF0()\ &&\ getModel1().isF1()=
+getModel1().isF0()\ ||\ getModel1().isF1()=
+getModel1().isF1()=
+getT0().isSelected()=
+getT0().isSelected()\ &&\ getT1().isSelected()=
+getT0().isSelected()\ ||\ getT1().isSelected()=
+getT1().isSelected()=
i18neditor.popup.title=
+isF0()=
+isF0()\ &&\ isF1()=
+isF0()\ ||\ isF1()=
+isF1()=
jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>For more informations, viste the <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">website of the project</a>.
jaxxdemo.action.about=About...
jaxxdemo.action.about.tip=About JAXXDemo...
@@ -194,6 +213,20 @@
jaxxdemo.tree.fun=Fun
jaxxdemo.warning.nimbus.landf=Could not init nymbus look and feel, you need at leasr version 1.6u10 of java.
jaxxdemo.warning.no.ui=No ui environnement detected
+model0.f0=
+model0.f1=
+model0.file...=
+model0.isF0()=
+model0.isF0()\ &&\ model0.isF1()=
+model0.isF0()\ ||\ model0.isF1()=
+model0.isF1()=
+model1.f0=
+model1.f1=
+model1.file...=
+model1.isF0()=
+model1.isF0()\ &&\ model1.isF1()=
+model1.isF0()\ ||\ model1.isF1()=
+model1.isF1()=
movies=Movies
numbereditor.normal.float=Signed float
numbereditor.normal.int=Signed integer
@@ -204,6 +237,10 @@
numbereditor.without.auto.popup=Without auto popup
show/hide\ label1=
show/hide\ label2=
+t0.isSelected()=
+t0.isSelected()\ &&\ t1.isSelected()=
+t0.isSelected()\ ||\ t1.isSelected()=
+t1.isSelected()=
test=
valid=
x=
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-21 20:11:01 UTC (rev 1691)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-21 20:11:57 UTC (rev 1692)
@@ -112,13 +112,32 @@
edit2=Editer 2
edit3=Editer 3
editor.getSelectedLocale()=
+f0=
+f1=
+file...=
form.ratio=Form \: ratio
form.text=Form \: text
form.text2=Form \: text2
form2.ratio=Form2 \: ratio
form2.text=Form2 \: text
form2.text2=Form2 \: text2
+getModel0().isF0()=
+getModel0().isF0()\ &&\ getModel0().isF1()=
+getModel0().isF0()\ ||\ getModel0().isF1()=
+getModel0().isF1()=
+getModel1().isF0()=
+getModel1().isF0()\ &&\ getModel1().isF1()=
+getModel1().isF0()\ ||\ getModel1().isF1()=
+getModel1().isF1()=
+getT0().isSelected()=
+getT0().isSelected()\ &&\ getT1().isSelected()=
+getT0().isSelected()\ ||\ getT1().isSelected()=
+getT1().isSelected()=
i18neditor.popup.title=
+isF0()=
+isF0()\ &&\ isF1()=
+isF0()\ ||\ isF1()=
+isF1()=
jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">site du projet</a>.
jaxxdemo.action.about=A propos
jaxxdemo.action.about.tip=A propos de JAXX Demo...
@@ -194,6 +213,20 @@
jaxxdemo.tree.fun=Fun
jaxxdemo.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java.
jaxxdemo.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9
+model0.f0=
+model0.f1=
+model0.file...=
+model0.isF0()=
+model0.isF0()\ &&\ model0.isF1()=
+model0.isF0()\ ||\ model0.isF1()=
+model0.isF1()=
+model1.f0=
+model1.f1=
+model1.file...=
+model1.isF0()=
+model1.isF0()\ &&\ model1.isF1()=
+model1.isF0()\ ||\ model1.isF1()=
+model1.isF1()=
movies=Films
numbereditor.normal.float=D\u00E9cimal primitif \: [%1$s]
numbereditor.normal.int=Entier primitif \: [%1$s]
@@ -204,6 +237,10 @@
numbereditor.without.auto.popup=Sans popup auto
show/hide\ label1=
show/hide\ label2=
+t0.isSelected()=
+t0.isSelected()\ &&\ t1.isSelected()=
+t0.isSelected()\ ||\ t1.isSelected()=
+t1.isSelected()=
test=
valid=valide
x=x
1
0
r1691 - in trunk/jaxx-widgets/src/main: java/jaxx/runtime/swing resources/i18n resources/icons
by tchemit@users.nuiton.org Dec. 21, 2009
by tchemit@users.nuiton.org Dec. 21, 2009
Dec. 21, 2009
Author: tchemit
Date: 2009-12-21 21:11:01 +0100 (Mon, 21 Dec 2009)
New Revision: 1691
Added:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
trunk/jaxx-widgets/src/main/resources/icons/action-font-size-down.png
trunk/jaxx-widgets/src/main/resources/icons/action-font-size-up.png
trunk/jaxx-widgets/src/main/resources/icons/action-font-size.png
Modified:
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 FontSizor widget + ExtremeDatabinding demo + use FontSizor on sources
Added: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx (rev 0)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/FontSizor.jaxx 2009-12-21 20:11:01 UTC (rev 1691)
@@ -0,0 +1,82 @@
+<!--
+
+/**
+ * *##% jaxx-runtime-swing-widget
+ * 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>. ##%*
+ */
+
+-->
+
+<JPanel layout='{new BorderLayout()}'>
+
+ <!-- default size of font -->
+ <Float id='defaultFontSize' javaBean='12f'/>
+
+ <!-- size of font -->
+ <Float id='fontSize' javaBean='null'/>
+
+ <Boolean id='showDefaultFontSize' javaBean='true'/>
+
+ <Boolean id='showFontSize' javaBean='false'/>
+
+ <script><![CDATA[
+public void init() {
+ setFontSize(defaultFontSize);
+}
+
+boolean updateDefaultSizeEnabled(Float fontSize, Float defaultFontSize, boolean enabled) {
+ if (fontSize==null || defaultFontSize==null) {
+ return false;
+ }
+ return !fontSize.equals(defaultFontSize) && enabled;
+}
+ ]]>
+ </script>
+ <JToolBar floatable='false'
+ borderPainted='false'
+ opaque='{isOpaque()}'
+ constraints='BorderLayout.CENTER'>
+
+ <JButton id='downSize'
+ actionIcon='font-size-down'
+ toolTipText='fontsize.action.down.tip'
+ focusable='false'
+ focusPainted='false'
+ enabled='{isEnabled()}'
+ onActionPerformed='setFontSize(fontSize - 1)'/>
+
+ <JButton id='defaultSize'
+ actionIcon='font-size'
+ toolTipText='fontsize.action.default.tip'
+ focusable='false'
+ focusPainted='false'
+ visible='{isShowDefaultFontSize()}'
+ enabled='{updateDefaultSizeEnabled(getFontSize(), getDefaultFontSize(), isEnabled())}'
+ onActionPerformed='setFontSize(defaultFontSize)'/>
+ <JButton id='upSize'
+ actionIcon='font-size-up'
+ toolTipText='fontsize.action.up.tip'
+ focusable='false'
+ focusPainted='false'
+ enabled='{isEnabled()}'
+ onActionPerformed='setFontSize(fontSize + 1)'/>
+
+ <JLabel visible='{isShowFontSize()}'
+ text='{"" + getFontSize()}'/>
+ </JToolBar>
+
+</JPanel>
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-21 20:09:52 UTC (rev 1690)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-21 20:11:01 UTC (rev 1691)
@@ -46,6 +46,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=
hidor.hideTip=Hide
hidor.showTip=Show
i18neditor.empty.locales=< No locale to select >
@@ -71,4 +74,5 @@
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-21 20:09:52 UTC (rev 1690)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-21 20:11:01 UTC (rev 1691)
@@ -46,6 +46,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=
hidor.hideTip=Cacher
hidor.showTip=Voir
i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
@@ -71,4 +74,5 @@
numbereditor.clearAll=C
numbereditor.clearOne=CE
numbereditor.toggleSign=+/-
+size\ \:\ =
timeeditor.H=H
Added: trunk/jaxx-widgets/src/main/resources/icons/action-font-size-down.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-widgets/src/main/resources/icons/action-font-size-down.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-widgets/src/main/resources/icons/action-font-size-up.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-widgets/src/main/resources/icons/action-font-size-up.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jaxx-widgets/src/main/resources/icons/action-font-size.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-widgets/src/main/resources/icons/action-font-size.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
Author: tchemit
Date: 2009-12-21 21:09:52 +0100 (Mon, 21 Dec 2009)
New Revision: 1690
Modified:
trunk/pom.xml
Log:
bump rsyntaxtextarea to 1.4.0
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-21 20:09:23 UTC (rev 1689)
+++ trunk/pom.xml 2009-12-21 20:09:52 UTC (rev 1690)
@@ -234,7 +234,7 @@
<dependency>
<groupId>org.nuiton.thirdparty</groupId>
<artifactId>rsyntaxtextarea</artifactId>
- <version>1.3.3</version>
+ <version>1.4.0</version>
</dependency>
<!-- swinglabs dependencies -->
1
0
r1689 - trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing
by tchemit@users.nuiton.org Dec. 21, 2009
by tchemit@users.nuiton.org Dec. 21, 2009
Dec. 21, 2009
Author: tchemit
Date: 2009-12-21 21:09:23 +0100 (Mon, 21 Dec 2009)
New Revision: 1689
Modified:
trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java
trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java
Log:
add tabComponent support for TabInfo
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-12-21 20:09:08 UTC (rev 1688)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-12-21 20:09:23 UTC (rev 1689)
@@ -133,6 +133,11 @@
appendAdditionCode(getId() + ".setDisabledIconAt(" + tabIndex + ", " + disabledIcon + ");");
}
+ String tabComponent= tabInfo.getTabComponentStr();
+ if (tabComponent != null) {
+ appendAdditionCode(getId() + ".setTabComponentAt(" + tabIndex + ", " + tabComponent + ");");
+ }
+
tabInfo = USED;
}
}
Modified: trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-12-21 20:09:08 UTC (rev 1688)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-12-21 20:09:23 UTC (rev 1689)
@@ -128,6 +128,9 @@
Color background = (Color) TypeManager.convertFromString(value, Color.class);
tabInfo.setBackground(background);
compiledTabInfo.appendInitializationCode(id + ".setBackground(" + TypeManager.getJavaCode(background) + ");");
+ } else if (name.equals("tabComponent")) {
+ tabInfo.setTabComponentStr(TypeManager.getJavaCode(value));
+ compiledTabInfo.appendInitializationCode(id + ".setTabComponent(" + TypeManager.getJavaCode(value) + ");");
} else {
compiler.reportError("The <tab> tag does not support the attribute '" + name + "'");
}
1
0
r1688 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing
by tchemit@users.nuiton.org Dec. 21, 2009
by tchemit@users.nuiton.org Dec. 21, 2009
Dec. 21, 2009
Author: tchemit
Date: 2009-12-21 21:09:08 +0100 (Mon, 21 Dec 2009)
New Revision: 1688
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java
Log:
add tabComponent support for TabInfo
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-12-21 13:02:20 UTC (rev 1687)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfo.java 2009-12-21 20:09:08 UTC (rev 1688)
@@ -20,7 +20,7 @@
*/
package jaxx.runtime.swing;
-import javax.swing.Icon;
+import javax.swing.*;
import javax.swing.event.SwingPropertyChangeSupport;
import java.awt.Color;
import java.beans.PropertyChangeListener;
@@ -29,6 +29,8 @@
public class TabInfo {
public static String BACKGROUND_PROPERTY = "background";
+ public static String TAB_COMPONENT_PROPERTY = "tabComponent";
+ public static String TAB_COMPONENT_STR_PROPERTY = "tabComponentStr";
public static String DISABLED_ICON_PROPERTY = "disabledIcon";
public static String DISPLAYED_MNEMONIC_INDEX_PROPERTY = "displayedMnemonicIndex";
public static String ENABLED_PROPERTY = "enabled";
@@ -47,6 +49,8 @@
private int mnemonic = -1;
private String title;
private String toolTipText;
+ private JComponent tabComponent;
+ private String tabComponentStr;
private PropertyChangeSupport propertyChangeSupport;
public TabInfo() {
@@ -150,6 +154,27 @@
firePropertyChange(TOOL_TIP_TEXT_PROPERTY, oldValue, toolTipText);
}
+ public JComponent getTabComponent() {
+ return tabComponent;
+ }
+
+ public void setTabComponent(JComponent tabComponent) {
+ JComponent oldValue = this.tabComponent;
+ this.tabComponent = tabComponent;
+ firePropertyChange(TAB_COMPONENT_PROPERTY, oldValue, tabComponent);
+ }
+
+
+ public String getTabComponentStr() {
+ return tabComponentStr;
+ }
+
+ public void setTabComponentStr(String tabComponentStr) {
+ String oldValue = this.tabComponentStr;
+ this.tabComponentStr = tabComponentStr;
+ firePropertyChange(TAB_COMPONENT_STR_PROPERTY, oldValue, tabComponent);
+ }
+
private PropertyChangeSupport getPropertyChangeSupport() {
if (propertyChangeSupport == null) {
propertyChangeSupport = new SwingPropertyChangeSupport(this);
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-12-21 13:02:20 UTC (rev 1687)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/TabInfoPropertyChangeListener.java 2009-12-21 20:09:08 UTC (rev 1688)
@@ -22,7 +22,7 @@
import javax.swing.Icon;
import javax.swing.JTabbedPane;
-import java.awt.Color;
+import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -55,6 +55,8 @@
tabs.setIconAt(tabIndex, (Icon) e.getNewValue());
} else if (name.equals(TabInfo.DISABLED_ICON_PROPERTY)) {
tabs.setDisabledIconAt(tabIndex, (Icon) e.getNewValue());
+ }else if (name.equals(TabInfo.TAB_COMPONENT_PROPERTY)) {
+ tabs.setTabComponentAt(tabIndex, (Component) e.getNewValue());
}
}
}
1
0
r1687 - in trunk/maven-jaxx-plugin/src: main/java/org/nuiton/jaxx/plugin site site/rst
by tchemit@users.nuiton.org Dec. 21, 2009
by tchemit@users.nuiton.org Dec. 21, 2009
Dec. 21, 2009
Author: tchemit
Date: 2009-12-21 14:02:20 +0100 (Mon, 21 Dec 2009)
New Revision: 1687
Added:
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java
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/GenerateHelpMojo.java
trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
trunk/maven-jaxx-plugin/src/site/rst/index.rst
trunk/maven-jaxx-plugin/src/site/site.xml
Log:
Evolution #172: G?\195?\169n?\195?\169rer les index de l'aide dans un goal sp?\195?\169cific
Copied: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java (from rev 1686, trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java)
===================================================================
--- trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java (rev 0)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -0,0 +1,211 @@
+/* *##%
+ * 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.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;
+
+/**
+ * Abstract Mojo to generate help stuff.
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+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.
+ *
+ * @parameter expression="${jaxx.locales}"
+ * @required
+ * @since 2.0.0
+ */
+ protected String locales;
+ /**
+ * The name of the helpset to generate.
+ *
+ * @parameter expression="${jaxx.helpsetName}" default-value="${project.artifactId}"
+ * @required
+ * @since 1.3
+ */
+ protected String helpsetName;
+ /**
+ * Flag to generate the search index.
+ *
+ * @parameter expression="${jaxx.generateSearch}" default-value="true"
+ * @required
+ * @since 1.3
+ */
+ 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;
+ /**
+ * Locales to treate
+ */
+ protected 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 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;
+
+ /**
+ * Call back after doing all stuff for all locales declared
+ */
+ protected abstract void postDoAction();
+
+ @Override
+ public 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.");
+ }
+
+ List<Locale> tmp = new ArrayList<Locale>();
+ for (String loc : locales.split(",")) {
+ Locale l = I18n.newLocale(loc);
+ tmp.add(l);
+ }
+
+ if (tmp.isEmpty()) {
+ throw new MojoFailureException("you must set the 'locales' property.");
+ }
+
+ localesToTreate = tmp.toArray(new Locale[tmp.size()]);
+ defaultLocale = localesToTreate[0];
+
+ 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 {
+
+ for (Locale locale : localesToTreate) {
+
+ boolean isDefaultLocale = locale == defaultLocale;
+
+ String language = locale.getLanguage();
+
+ String localePath = (isDefaultLocale ? "default" : language);
+
+ File localizedTarget = new File(outHelp, localePath);
+
+ createDirectoryIfNecessary(localizedTarget);
+
+ doActionForLocale(locale, isDefaultLocale, localizedTarget, localePath);
+
+ }
+
+ postDoAction();
+ }
+
+ @Override
+ public File getTargetDirectory() {
+ return outHelp;
+ }
+
+ @Override
+ public void setTargetDirectory(File targetDirectory) {
+ this.outHelp = targetDirectory;
+ }
+
+ 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 (verbose) {
+ getLog().info("using template " + templateURL);
+ }
+ VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL);
+ return gen;
+ }
+}
\ No newline at end of file
Property changes on: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractGenerateHelpMojo.java
___________________________________________________________________
Added: svn:mergeinfo
+
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-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -18,9 +18,13 @@
* ##%*/
package org.nuiton.jaxx.plugin;
+import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
import org.nuiton.plugin.AbstractPlugin;
/**
@@ -109,4 +113,68 @@
public void setEncoding(String encoding) {
this.encoding = encoding;
}
+
+ /**
+ * TODO-TC20091221 Should move this to AbstractPlugin
+ * Create the directory if necessary.
+ *
+ * @param dir the directory to create if not already existing
+ * @throws IOException if could not create the directory
+ */
+ protected void createDirectoryIfNecessary(File dir) throws IOException {
+ if (!dir.exists()) {
+ if (verbose) {
+ getLog().info("mkdir " + dir);
+ }
+ boolean b = dir.mkdirs();
+ if (!b) {
+ throw new IOException("could not create directory "+dir);
+ }
+ }
+ }
+
+ //TODO-TC20091221 move this api to PluginHelper
+ public static boolean addResourceDir(File dir, MavenProject project, String... includes) {
+ List<?> resources = project.getResources();
+ boolean added = addResourceDir(dir, project, resources, includes);
+ return added;
+ }
+
+ //TODO-TC20091221 move this api to PluginHelper
+ public static boolean addTestResourceDir(File newresourceDir, MavenProject project, String... includes) {
+ List<?> resources = project.getTestResources();
+ boolean added = addResourceDir(newresourceDir, project, resources, includes);
+ return added;
+ }
+
+ //TODO-TC20091221 move this api to PluginHelper
+ public static boolean addResourceDir(File dir, MavenProject project, List<?> resources, String... includes) {
+ String newresourceDir = dir.getAbsolutePath();
+ boolean shouldAdd = true;
+ for (Object o : resources) {
+ Resource r = (Resource) o;
+ if (!r.getDirectory().equals(newresourceDir)) {
+ continue;
+ }
+
+ for (String i : includes) {
+ if (!r.getIncludes().contains(i)) {
+ r.addInclude(i);
+ }
+ }
+ shouldAdd = false;
+ break;
+ }
+ if (shouldAdd) {
+ Resource r = new Resource();
+ r.setDirectory(newresourceDir);
+ for (String i : includes) {
+ if (!r.getIncludes().contains(i)) {
+ r.addInclude(i);
+ }
+ }
+ project.addResource(r);
+ }
+ return shouldAdd;
+ }
}
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-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -18,185 +18,89 @@
* ##%*/
package org.nuiton.jaxx.plugin;
-import com.sun.java.help.search.Indexer;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import org.apache.maven.plugin.MojoFailureException;
+import org.nuiton.plugin.VelocityTemplateGenerator;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.SortedProperties;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.PrintStream;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.ArrayList;
import java.util.Enumeration;
-import java.util.List;
import java.util.Locale;
import java.util.Properties;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.StringUtils;
-import org.nuiton.i18n.I18n;
-import org.nuiton.plugin.VelocityTemplateGenerator;
-import org.nuiton.util.FileUtil;
-import org.nuiton.util.SortedProperties;
/**
* Mojo to generate javax help stuff for your project.
- *
+ * <p/>
* HelpIds should have been discovered by the JaxxMojo.
*
* @author chemit
* @goal generate-help
* @phase process-sources
- *
* @requiresProject
* @requiresDependencyResolution compile
* @since 1.3
*/
-public class GenerateHelpMojo extends AbstractJaxxMojo {
+public class GenerateHelpMojo extends AbstractGenerateHelpMojo {
- private static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
+
/**
- * The directory where to generate 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, seprated by comma.
- *
- * The first locale given is the default locale.
- *
- * @parameter expression="${jaxx.locales}"
- * @required
- *
- * @since 2.0.0
- */
- protected String locales;
- /**
- * 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;
- /**
- * Flag to generate the search index.
- *
- * @parameter expression="${jaxx.generateSearch}" default-value="true"
- * @required
- *
- * @since 1.3
- */
- protected boolean generateSearch;
- /**
- * The help ids discovered in {@link #helpIdsStore} files.
- */
- private Properties helpIds;
- /**
- * Default locale (the first locale in {@link #localesToTreate}.
- */
- private Locale defaultLocale;
- /**
- * Locales to treate
- */
- private Locale[] localesToTreate;
+ protected String mapFileName;
+ protected String indexFileName;
+ protected String tocFileName;
+ protected int touchedFiles;
+
@Override
public 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 'target' property.");
- }
-
- List<Locale> tmp = new ArrayList<Locale>();
- for (String loc : locales.split(",")) {
- Locale l = I18n.newLocale(loc);
- tmp.add(l);
- }
-
- if (tmp.isEmpty()) {
- throw new MojoFailureException("you must set the 'locales' property.");
- }
-
- localesToTreate = tmp.toArray(new Locale[tmp.size()]);
- defaultLocale = localesToTreate[0];
-
// check ressources
checkResource(helpsetTemplate);
checkResource(mapTemplate);
@@ -204,147 +108,90 @@
checkResource(tocTemplate);
checkResource(contentTemplate);
- if (!getTargetDirectory().exists()) {
- getLog().info("mkdir " + getTargetDirectory());
- getTargetDirectory().mkdirs();
- }
+ mapFileName = helpsetName + "Map.jhm";
+ indexFileName = helpsetName + "Index.xml";
+ tocFileName = helpsetName + "TOC.xml";
+ touchedFiles=0;
+ return super.init();
+ }
- // load ids from idsStore file
+ protected void postDoAction() {
+ getLog().info(touchedFiles + " file(s) treated.");
+ }
- helpIds = new SortedProperties();
+ protected void doActionForLocale(Locale locale, boolean isDefaultLocale, File localizedTarget, String localePath) throws Exception {
- BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(idsStore), getEncoding()));
- String id = null;
- while ((id = reader.readLine()) != null) {
- id = id.trim();
- String path = id.replaceAll("\\.", File.separator) + ".html";
- helpIds.put(id, path);
- }
+ String language = locale.getLanguage();
- if (helpIds.isEmpty()) {
-
- // no ids detected
- getLog().warn("No helpIds detected, will skip.");
- return false;
+ getLog().info("Generate help for language " + language);
+ if (isVerbose()) {
+ getLog().info(" Localized target : " + localizedTarget);
}
- return true;
- }
- @Override
- public void doAction() throws Exception {
+ Properties env = new Properties();
- int touchedFiles = 0;
+ env.put("helpSetName", helpsetName);
+ env.put("locale", language);
+ env.put("localePath", localePath);
+ env.put("separator", " ");
+ env.put("autoremoveLine", AUTOREMOVE_LINE);
- String mapFileName = helpsetName + "Map.jhm";
- String indexFileName = helpsetName + "Index.xml";
- String tocFileName = helpsetName + "TOC.xml";
+ String localeSuffix = isDefaultLocale ? "" : "_" + language;
+ String helpsetFileName = helpsetName + localeSuffix + ".hs";
- for (Locale locale : localesToTreate) {
+ env.put("helpSetFileName", helpsetFileName);
- boolean isDefaultLocale = locale == defaultLocale;
+ env.put("mapFileName", mapFileName);
+ env.put("indexFileName", indexFileName);
+ env.put("tocFileName", tocFileName);
+ env.put("generateSearch", generateSearch);
- String language = locale.getLanguage();
+ // ---------------------------------------------------------------
+ // --- main helpset file -----------------------------------------
+ // ---------------------------------------------------------------
- String localePath = (isDefaultLocale ? "default" : language);
+ File file = new File(outHelp, helpsetFileName);
- File localizedTarget = new File(outHelp, localePath);
+ boolean doCreate = generateHelpsetFile(file, env);
- if (!localizedTarget.exists()) {
- localizedTarget.mkdirs();
- }
- 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);
+ if (doCreate) {
touchedFiles++;
+ }
- // ---------------------------------------------------------------
- // --- helpset index file ----------------------------------------
- // ---------------------------------------------------------------
+ // ---------------------------------------------------------------
+ // --- helpset map file ------------------------------------------
+ // ---------------------------------------------------------------
- file = new File(localizedTarget, indexFileName);
+ file = new File(localizedTarget, mapFileName);
- generateIndexFile(file, env);
- touchedFiles++;
+ generateMapFile(file, env);
+ touchedFiles++;
- // ---------------------------------------------------------------
- // --- helpset toc file ------------------------------------------
- // ---------------------------------------------------------------
+ // ---------------------------------------------------------------
+ // --- helpset index file ----------------------------------------
+ // ---------------------------------------------------------------
- file = new File(localizedTarget, tocFileName);
+ file = new File(localizedTarget, indexFileName);
- generateTocFile(file, env);
- touchedFiles++;
+ generateIndexFile(file, env);
+ touchedFiles++;
- // ---------------------------------------------------------------
- // --- helpset content files -------------------------------------
- // ---------------------------------------------------------------
+ // ---------------------------------------------------------------
+ // --- helpset toc file ------------------------------------------
+ // ---------------------------------------------------------------
- touchedFiles += generateContentFiles(localizedTarget, env, localePath);
+ file = new File(localizedTarget, tocFileName);
- // ---------------------------------------------------------------
- // --- generate search index -------------------------------------
- // ---------------------------------------------------------------
-
- if (generateSearch) {
+ generateTocFile(file, env);
+ touchedFiles++;
- generateSearchIndex(localizedTarget, locale);
- }
+ // ---------------------------------------------------------------
+ // --- helpset content files -------------------------------------
+ // ---------------------------------------------------------------
-
- }
-
- getLog().info(touchedFiles + " file(s) treated.");
+ touchedFiles += generateContentFiles(localizedTarget, env, localePath);
}
- @Override
- public File getTargetDirectory() {
- return outHelp;
- }
-
- @Override
- public void setTargetDirectory(File targetDirectory) {
- this.outHelp = targetDirectory;
- }
-
protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception {
int touchedFiles = 0;
@@ -367,7 +214,7 @@
continue;
}
}
- f.getParentFile().mkdirs();
+ createDirectoryIfNecessary(f.getParentFile());
if (verbose) {
if (exist) {
getLog().info("regenerate content file " + f);
@@ -412,7 +259,7 @@
boolean create;
- Properties mergedHelpIds = null;
+ Properties mergedHelpIds;
if (file.exists()) {
// get back the exisiting data and merge it with incoming ones
@@ -503,35 +350,6 @@
return rootItem;
}
- protected void generateSearchIndex(File localizedTarget, Locale locale) throws IllegalArgumentException, IOException, InvocationTargetException, SecurityException, IllegalAccessException, NoSuchMethodException {
-
- Method m = Indexer.class.getDeclaredMethod("main", String[].class);
- File indexDir = new File(localizedTarget, "JavaHelpSearch");
- // remove old index
- FileUtils.deleteDirectory(indexDir);
- //copy resources to a tmp dir (without any VCS infos)
- File tmpDir = new File(project.getBasedir(), "target" + File.separator + "jaxx-tmp" + File.separator + "indexer-" + locale + "-" + System.nanoTime());
- getLog().info("copy files to " + tmpDir + " for indexing them");
- FileUtils.copyDirectory(localizedTarget, tmpDir, "**/*", StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ","));
- List<String> params = new ArrayList<String>();
- params.add("-verbose");
- params.add("-db");
- params.add(indexDir.getAbsolutePath());
- params.add("-logfile");
- File logFile = new File(project.getBasedir(), "target" + File.separator + "generated-sources" + File.separator + "jaxx" + File.separator + "indexer-" + locale + ".log");
- params.add(logFile.getAbsolutePath());
- params.add(tmpDir.getAbsolutePath());
- PrintStream out = System.out;
- PrintStream err = System.err;
- try {
- m.invoke(null, (Object) params.toArray(new String[params.size()]));
- } finally {
- System.setOut(out);
- System.setErr(err);
- }
- getLog().info("Search Index generated");
- }
-
protected NodeItem generateTocFile(File file, Properties env) throws Exception {
NodeItem rootItem = null;
@@ -572,18 +390,4 @@
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 (verbose) {
- getLog().info("using template " + templateURL);
- }
- VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL);
- return gen;
- }
}
Copied: trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java (from rev 1686, 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 (rev 0)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpSearchMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -0,0 +1,128 @@
+/* *##%
+ * 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 com.sun.java.help.search.Indexer;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * Mojo to generate javax search index help stuff 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)...
+ *
+ * @author chemit
+ * @goal generate-help-search
+ * @phase process-sources
+ * @requiresProject
+ * @requiresDependencyResolution compile
+ * @since 2.0.0
+ */
+public class GenerateHelpSearchMojo extends AbstractGenerateHelpMojo {
+
+ protected File targetRoot;
+ protected String timestamp;
+
+ @Override
+ public boolean init() throws Exception {
+ if (!generateSearch) {
+ getLog().info("Do not generate search.");
+ return false;
+ }
+ 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 {
+
+ String language = locale.getLanguage();
+
+ File target = new File(targetRoot, localePath + File.separator + "JavaHelpSearch");
+
+ createDirectoryIfNecessary(localizedTarget);
+ createDirectoryIfNecessary(target);
+
+ getLog().info("Generate help search index for language " + language);
+ if (isVerbose()) {
+ getLog().info(" Localized source : " + localizedTarget);
+ getLog().info(" Localized target : " + target);
+ }
+
+ // ---------------------------------------------------------------
+ // --- generate search index -------------------------------------
+ // ---------------------------------------------------------------
+
+ generateSearchIndex(localizedTarget, target, locale);
+ }
+
+ @Override
+ protected void postDoAction() {
+
+ // add resources to the project
+ addResourceDir(targetRoot, getProject(), "**/*");
+ }
+
+ protected void generateSearchIndex(File source, File target, Locale locale) throws Exception {
+
+ Method m = Indexer.class.getDeclaredMethod("main", String[].class);
+
+ // remove old index
+ FileUtils.deleteDirectory(target);
+
+ //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");
+ FileUtils.copyDirectory(source, tmpDir, "**/*", StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ","));
+
+ // prepare arguments of Indexer.main calling
+ List<String> params = new ArrayList<String>();
+ params.add("-verbose");
+ params.add("-db");
+ params.add(target.getAbsolutePath());
+ params.add("-logfile");
+ File logFile = getFileFromBasedir("target", "generated-sources", "jaxx", "indexer-" + locale + ".log");
+ params.add(logFile.getAbsolutePath());
+ params.add(tmpDir.getAbsolutePath());
+ PrintStream out = System.out;
+ PrintStream err = System.err;
+
+ // invoke Indexer.main
+ try {
+ m.invoke(null, (Object) params.toArray(new String[params.size()]));
+ } finally {
+ System.setOut(out);
+ System.setErr(err);
+ }
+ getLog().info("Search Index generated for " + locale);
+ }
+
+}
\ 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-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-12-21 13:02:20 UTC (rev 1687)
@@ -367,9 +367,7 @@
BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
}
- if (!getTargetDirectory().exists()) {
- getTargetDirectory().mkdirs();
- }
+ createDirectoryIfNecessary(getTargetDirectory());
// compute extra imports (can not use java classes since some of
// imports can not be still compiled)
@@ -567,9 +565,7 @@
}
File idsStore = getHelpIdsStore();
- if (!idsStore.getParentFile().exists()) {
- idsStore.getParentFile().mkdirs();
- }
+ createDirectoryIfNecessary(idsStore.getParentFile());
StringBuilder buffer = new StringBuilder();
Modified: trunk/maven-jaxx-plugin/src/site/rst/index.rst
===================================================================
--- trunk/maven-jaxx-plugin/src/site/rst/index.rst 2009-12-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/site/rst/index.rst 2009-12-21 13:02:20 UTC (rev 1687)
@@ -9,8 +9,10 @@
The plugin permits to generate java files from jaxx files via the `generate`_ goal.
-You can also generate the java help system via the `generate-help`_ goal.
+You can also generate the java help system via the `generate-help`_ goal and generate search index via
+the `generate-help-search`_ goal.
+
Default layout
--------------
@@ -20,7 +22,8 @@
* the jaxx files should be under *src/main/java*
* the generated java files should be under *target/generated-sources/java*
* the java help files should be under *src/main/help*
-
+ * the generated help search index should be under *target/generated-sources/help*
+
.. _generate: generate-mojo.html
-
.. _generate-help: generate-help-mojo.html
+.. _generate-help-search: generate-help-search-mojo.html
Modified: trunk/maven-jaxx-plugin/src/site/site.xml
===================================================================
--- trunk/maven-jaxx-plugin/src/site/site.xml 2009-12-20 19:57:10 UTC (rev 1686)
+++ trunk/maven-jaxx-plugin/src/site/site.xml 2009-12-21 13:02:20 UTC (rev 1687)
@@ -20,6 +20,7 @@
<item name="Détail goals" href="plugin-info.html">
<item name="generate" href="generate-mojo.html"/>
<item name="generate-help" href="generate-help-mojo.html"/>
+ <item name="generate-help-search" href="generate-help-search-mojo.html"/>
<item name="help" href="help-mojo.html"/>
</item>
</menu>
1
0
r1686 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor
by tchemit@users.nuiton.org Dec. 20, 2009
by tchemit@users.nuiton.org Dec. 20, 2009
Dec. 20, 2009
Author: tchemit
Date: 2009-12-20 20:57:10 +0100 (Sun, 20 Dec 2009)
New Revision: 1686
Modified:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
Log:
- fix Anomalie #152: NumberEditor avec un Double ou BigDecimal
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-12-18 13:34:23 UTC (rev 1685)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/NumberEditorHandler.java 2009-12-20 19:57:10 UTC (rev 1686)
@@ -288,16 +288,16 @@
return f;
}
if (modelType == Double.class) {
- return f.doubleValue();
+ return f;
}
if (modelType == Long.class) {
return f.longValue();
}
if (modelType == BigInteger.class) {
- return BigInteger.valueOf(f.longValue());
+ return new BigInteger(f.longValue() + "");
}
if (modelType == BigDecimal.class) {
- return BigDecimal.valueOf(f.doubleValue());
+ return new BigDecimal(f + "");
}
if (editor.isUseFloat()) {
// use default float value
1
0
Author: tchemit
Date: 2009-12-18 14:34:23 +0100 (Fri, 18 Dec 2009)
New Revision: 1685
Modified:
trunk/pom.xml
Log:
use mavenpom 1.1.3
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-14 11:44:49 UTC (rev 1684)
+++ trunk/pom.xml 2009-12-18 13:34:23 UTC (rev 1685)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.1.1</version>
+ <version>1.1.3</version>
</parent>
<artifactId>jaxx</artifactId>
1
0
r1684 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime: . context
by sletellier@users.nuiton.org Dec. 14, 2009
by sletellier@users.nuiton.org Dec. 14, 2009
Dec. 14, 2009
Author: sletellier
Date: 2009-12-14 12:44:49 +0100 (Mon, 14 Dec 2009)
New Revision: 1684
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
Log:
Revert : Map in JaxxContextEntryDef is not possible
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-12-14 11:01:53 UTC (rev 1683)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-12-14 11:44:49 UTC (rev 1684)
@@ -114,16 +114,6 @@
return contextEntryDef;
}
- public static <K,V> JAXXContextEntryDef<Map<K,V>> newMapContextEntryDef() {
- return newMapContextEntryDef(null);
- }
-
- public static <K,V> JAXXContextEntryDef<Map<K,V>> newMapContextEntryDef(String name) {
- Class<Map<K, V>> castList = Util.castMap();
- JAXXContextEntryDef<Map<K, V>> contextEntryDef = new JAXXContextEntryDef<Map<K, V>>(name, castList);
- return contextEntryDef;
- }
-
// public static DefaultJAXXBinding registerBinding(Map<String, DefaultJAXXBinding> bindings, DefaultJAXXBinding binding) {
// bindings.put(binding.getId(), binding);
//// binding.applyDataBinding();
@@ -159,11 +149,6 @@
return (Class<List<O>>) Collections.emptyList().getClass();
}
- @SuppressWarnings({"unchecked"})
- protected static <K, V> Class<Map<K, V>> castMap() {
- return (Class<Map<K, V>>) Collections.emptyMap().getClass();
- }
-
/**
* Method to initialize the context of a ui.
*
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-12-14 11:01:53 UTC (rev 1683)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-12-14 11:44:49 UTC (rev 1684)
@@ -21,12 +21,14 @@
package jaxx.runtime.context;
import java.util.List;
+import java.util.Map;
+
import jaxx.runtime.JAXXContext;
/**
* To qualify an entry in a {@link JAXXContext}.
* <p/>
- * Use the factory methods <code>newContextEntryDef</code>, newMapContextEntryDef and <code>newListContextEntryDef</code< to obtain new instances.
+ * Use the factory methods <code>newContextEntryDef</code> and <code>newListContextEntryDef</code< to obtain new instances.
*
* @param <O> type of the entry associated to the definition
* @author chemit
1
0
r1683 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime: . context
by sletellier@users.nuiton.org Dec. 14, 2009
by sletellier@users.nuiton.org Dec. 14, 2009
Dec. 14, 2009
Author: sletellier
Date: 2009-12-14 12:01:53 +0100 (Mon, 14 Dec 2009)
New Revision: 1683
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
Log:
Adding Map JaxxContextEntryDef
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-12-09 18:19:54 UTC (rev 1682)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-12-14 11:01:53 UTC (rev 1683)
@@ -114,6 +114,16 @@
return contextEntryDef;
}
+ public static <K,V> JAXXContextEntryDef<Map<K,V>> newMapContextEntryDef() {
+ return newMapContextEntryDef(null);
+ }
+
+ public static <K,V> JAXXContextEntryDef<Map<K,V>> newMapContextEntryDef(String name) {
+ Class<Map<K, V>> castList = Util.castMap();
+ JAXXContextEntryDef<Map<K, V>> contextEntryDef = new JAXXContextEntryDef<Map<K, V>>(name, castList);
+ return contextEntryDef;
+ }
+
// public static DefaultJAXXBinding registerBinding(Map<String, DefaultJAXXBinding> bindings, DefaultJAXXBinding binding) {
// bindings.put(binding.getId(), binding);
//// binding.applyDataBinding();
@@ -149,6 +159,11 @@
return (Class<List<O>>) Collections.emptyList().getClass();
}
+ @SuppressWarnings({"unchecked"})
+ protected static <K, V> Class<Map<K, V>> castMap() {
+ return (Class<Map<K, V>>) Collections.emptyMap().getClass();
+ }
+
/**
* Method to initialize the context of a ui.
*
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-12-09 18:19:54 UTC (rev 1682)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-12-14 11:01:53 UTC (rev 1683)
@@ -26,7 +26,7 @@
/**
* To qualify an entry in a {@link JAXXContext}.
* <p/>
- * Use the factory methods <code>newContextEntryDef</code> and <code>newListContextEntryDef</code< to obtain new instances.
+ * Use the factory methods <code>newContextEntryDef</code>, newMapContextEntryDef and <code>newListContextEntryDef</code< to obtain new instances.
*
* @param <O> type of the entry associated to the definition
* @author chemit
1
0
Author: tchemit
Date: 2009-12-09 19:19:54 +0100 (Wed, 09 Dec 2009)
New Revision: 1682
Modified:
trunk/jaxx-demo/
Log:
svn:ignore
Property changes on: trunk/jaxx-demo
___________________________________________________________________
Modified: svn:ignore
- target
*.iml
*.ipr
*.iws
+ target
*.iml
*.ipr
*.iws
*.log
1
0
r1681 - trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing
by tchemit@users.nuiton.org Dec. 9, 2009
by tchemit@users.nuiton.org Dec. 9, 2009
Dec. 9, 2009
Author: tchemit
Date: 2009-12-09 18:33:50 +0100 (Wed, 09 Dec 2009)
New Revision: 1681
Modified:
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx
Log:
improve HidorButton + add demo of it in jaxx-demo
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx 2009-12-09 17:31:41 UTC (rev 1680)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/ListSelectorUI.jaxx 2009-12-09 17:33:50 UTC (rev 1681)
@@ -181,8 +181,8 @@
target='{list}'
visible='{isShowHidor()}'
enabled='{isEnabled()}'
- collapseTip='{_("listSelector.hideList")}'
- expandTip='{_("listSelector.showList")}'
+ hideTip='{_("listSelector.hideList")}'
+ showTip='{_("listSelector.showList")}'
targetVisible='{true}'/>
</JToolBar>
</cell>
1
0
r1680 - in trunk: jaxx-demo/src/main/java/jaxx/demo jaxx-demo/src/main/java/jaxx/demo/component/swing jaxx-demo/src/main/resources/i18n jaxx-widgets/src/main/java/jaxx/runtime/swing jaxx-widgets/src/main/resources/i18n
by tchemit@users.nuiton.org Dec. 9, 2009
by tchemit@users.nuiton.org Dec. 9, 2009
Dec. 9, 2009
Author: tchemit
Date: 2009-12-09 18:31:41 +0100 (Wed, 09 Dec 2009)
New Revision: 1680
Added:
trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/HidorButtonDemo.jaxx
Modified:
trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.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-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx
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:
improve HidorButton + add demo of it in jaxx-demo
Modified: trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-12-08 17:21:03 UTC (rev 1679)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-12-09 17:31:41 UTC (rev 1680)
@@ -20,35 +20,33 @@
*/
package jaxx.demo;
+import jaxx.demo.component.jaxx.BoxedDecoratorDemo;
+import jaxx.demo.component.jaxx.StatusMessagePanelDemo;
+import jaxx.demo.component.jaxx.editor.ComboEditorDemo;
+import jaxx.demo.component.jaxx.editor.I18nEditorDemo;
+import jaxx.demo.component.jaxx.editor.NumberEditorDemo;
+import jaxx.demo.component.jaxx.navigation.FullNavigationTreeDemo;
+import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo;
+import jaxx.demo.component.swing.*;
+import jaxx.demo.feature.databinding.BeanDataBindingDemo;
+import jaxx.demo.feature.validation.ValidationListDemo;
+import jaxx.demo.feature.validation.ValidationTableDemo;
+import jaxx.demo.fun.CalculatorDemo;
+import jaxx.demo.fun.CounterDemo;
+import jaxx.demo.fun.LabelStyleDemo;
import jaxx.runtime.JAXXContext;
-import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
+import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.swing.CardLayout2;
import jaxx.runtime.swing.ErrorDialogUI;
-
-import jaxx.runtime.swing.navigation.NavigationTreeHelper;
-import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout;
-import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
-import jaxx.runtime.swing.navigation.NavigationTreeModel;
-import jaxx.runtime.swing.navigation.NavigationTreeNode;
-import jaxx.runtime.swing.navigation.NavigationTreeHandler;
+import jaxx.runtime.swing.navigation.*;
import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy;
-
-import jaxx.demo.component.swing.*;
-import jaxx.demo.component.jaxx.*;
-import jaxx.demo.component.jaxx.editor.*;
-import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo;
-import jaxx.demo.component.jaxx.navigation.FullNavigationTreeDemo;
-import jaxx.demo.feature.databinding.BeanDataBindingDemo;
-import jaxx.demo.feature.validation.*;
-import jaxx.demo.fun.*;
-
-import static org.nuiton.i18n.I18n.n_;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import static org.nuiton.i18n.I18n.n_;
+import javax.swing.*;
import java.util.Stack;
-import javax.swing.JPanel;
/**
*
@@ -103,6 +101,7 @@
addDemo(JProgressBarDemo.class).
goUp().
addText(n_("jaxxdemo.tree.component.jaxx")).
+ addDemo(HidorButtonDemo.class).
addText(n_("jaxxdemo.tree.component.jaxx.editor")).
addDemo(NumberEditorDemo.class).
addDemo(ComboEditorDemo.class).
Copied: trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/HidorButtonDemo.jaxx (from rev 1674, trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/JToggleButtonDemo.jaxx)
===================================================================
--- trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/HidorButtonDemo.jaxx (rev 0)
+++ trunk/jaxx-demo/src/main/java/jaxx/demo/component/swing/HidorButtonDemo.jaxx 2009-12-09 17:31:41 UTC (rev 1680)
@@ -0,0 +1,39 @@
+<!--
+ *##%
+ 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>.
+ ##%*
+-->
+<jaxx.demo.DemoPanel>
+ <JPanel id='demoPanel' layout='{new GridLayout(0,1)}'>
+ <HBox horizontalAlignment='center' verticalAlignment='middle'>
+
+ <jaxx.runtime.swing.HidorButton target='{hidor1}' showText="show label1" hideText='hide label1'
+ targetVisible='{true}'/>
+
+ <JLabel id='hidor1' text='Label 1'/>
+ </HBox>
+ <HBox horizontalAlignment='center' verticalAlignment='middle'>
+
+ <jaxx.runtime.swing.HidorButton target='{hidor2}' showText="show label2" hideText='hide label2'
+ targetVisible='{false}'/>
+
+ <JLabel id='hidor2' text='Label 2'/>
+ </HBox>
+ </JPanel>
+
+</jaxx.demo.DemoPanel>
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-08 17:21:03 UTC (rev 1679)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-12-09 17:31:41 UTC (rev 1680)
@@ -56,6 +56,8 @@
Italic=
JAXX\ Demo=
JMenu\ demo=
+Label\ 1=
+Label\ 2=
Last\ Name\:=
LastName\:=
Locale\ editor\:=
@@ -200,6 +202,8 @@
numbereditor.type=Type
numbereditor.with.auto.popup=With auto popup
numbereditor.without.auto.popup=Without auto popup
+show/hide\ label1=
+show/hide\ label2=
test=
valid=
x=
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-08 17:21:03 UTC (rev 1679)
+++ trunk/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-12-09 17:31:41 UTC (rev 1680)
@@ -56,6 +56,8 @@
Italic=Italique
JAXX\ Demo=
JMenu\ demo=
+Label\ 1=
+Label\ 2=
Last\ Name\:=Nom \:
LastName\:=Nom
Locale\ editor\:=Editeur de locale
@@ -200,6 +202,8 @@
numbereditor.type=Type d'\u00E9diteur
numbereditor.with.auto.popup=Avec popup auto
numbereditor.without.auto.popup=Sans popup auto
+show/hide\ label1=
+show/hide\ label2=
test=
valid=valide
x=x
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx 2009-12-08 17:21:03 UTC (rev 1679)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/HidorButton.jaxx 2009-12-09 17:31:41 UTC (rev 1680)
@@ -1,15 +1,21 @@
<JToggleButton id='hidor'
+ text='{updateText(isTargetVisible())}'
toolTipText='{updateToolTipText(isTargetVisible())}'
- icon='{SwingUtil.createActionIcon("collapse")}'
- pressedIcon='{SwingUtil.createActionIcon("expand")}'
+ icon="{updateIcon(isTargetVisible())}"
+ _hideIcon='{SwingUtil.createActionIcon("collapse")}'
+ _showIcon='{SwingUtil.createActionIcon("expand")}'
onActionPerformed='setTargetVisible(!targetVisible)'>
-
- <Boolean id='targetVisible' javaBean='null'/>
- <String id='collapseTip' javaBean='_("hidor.collapseTip")'/>
-
- <String id='expandTip' javaBean='_("hidor.expandTip")'/>
+ <Boolean id='targetVisible' javaBean='null'/>
+ <String id='hideText' javaBean='""'/>
+
+ <String id='showText' javaBean='""'/>
+
+ <String id='hideTip' javaBean='_("hidor.hideTip")'/>
+
+ <String id='showTip' javaBean='_("hidor.showTip")'/>
+
<script><![CDATA[
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -41,17 +47,27 @@
}
public void setExpandIcon(Icon icon) {
- setSelectedIcon(icon);
+ putClientProperty("expandIcon", icon);
}
-public void setCollapseIcon(Icon icon) {
- setIcon(icon);
+public void setHideIcon(Icon icon) {
+ putClientProperty("hideIcon", icon);
}
protected String updateToolTipText(boolean c) {
- String i = c ? collapseTip : expandTip;
+ String i = c ? hideTip : showTip;
return i;
}
+
+protected String updateText(boolean c) {
+ String i = c ? hideText : showText;
+ return i;
+}
+
+protected Icon updateIcon(boolean c) {
+ String key = c ? "hideIcon" : "showIcon";
+ return (Icon) getClientProperty(key);
+}
]]>
</script>
</JToggleButton>
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-08 17:21:03 UTC (rev 1679)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-12-09 17:31:41 UTC (rev 1680)
@@ -46,8 +46,8 @@
errorUI.action.close=Close
errorUI.message=An error wad detected...
errorUI.title=Error...
-hidor.collapseTip=Hide
-hidor.expandTip=Show
+hidor.hideTip=Hide
+hidor.showTip=Show
i18neditor.empty.locales=< No locale to select >
i18neditor.popup.title=Change language
i18neditor.selected=Selected language \: %1$s
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-08 17:21:03 UTC (rev 1679)
+++ trunk/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-12-09 17:31:41 UTC (rev 1680)
@@ -46,8 +46,8 @@
errorUI.action.close=Fermer
errorUI.message=Une erreur est survenue \!
errorUI.title=Erreur...
-hidor.collapseTip=Cacher
-hidor.expandTip=Voir
+hidor.hideTip=Cacher
+hidor.showTip=Voir
i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
i18neditor.popup.title=Changer de langue
i18neditor.selected=Langue actuellement utilis\u00E9e \: %1$s
1
0