Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3157 discussions
Author: tchemit
Date: 2009-08-23 14:11:01 +0200 (Sun, 23 Aug 2009)
New Revision: 1675
Added:
tags/nuiton-utils-1.1.0/
Log:
[maven-scm] copy for tag nuiton-utils-1.1.0
Property changes on: tags/nuiton-utils-1.1.0
___________________________________________________________________
Added: svn:ignore
+ target
velocity.log
maven.log
.eclipse
.classpath
lutinutil.iml
lutinutil.ipr
lutinutil.iws
.settings
.project
Added: svn:mergeinfo
+
1
0
Author: tchemit
Date: 2009-08-23 14:10:57 +0200 (Sun, 23 Aug 2009)
New Revision: 1674
Modified:
trunk/pom.xml
Log:
[maven-release-plugin] prepare release nuiton-utils-1.1.0
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-23 11:32:29 UTC (rev 1673)
+++ trunk/pom.xml 2009-08-23 12:10:57 UTC (rev 1674)
@@ -14,7 +14,7 @@
</parent>
<artifactId>nuiton-utils</artifactId>
- <version>1.1.0-rc-9-SNAPSHOT</version>
+ <version>1.1.0</version>
<dependencies>
@@ -133,9 +133,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/nuiton-utils/trunk</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/tags/nuiton-utils-1.1.0</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/nuiton-utils/tags/nuiton-utils-1.1.0</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/nuiton-utils/tags/nuiton-utils-1.…</url>
</scm>
<profiles>
1
0
r1673 - in trunk: . src/main/java/org/nuiton/util src/site src/site/apt
by tchemit@users.nuiton.org 23 Aug '09
by tchemit@users.nuiton.org 23 Aug '09
23 Aug '09
Author: tchemit
Date: 2009-08-23 13:32:29 +0200 (Sun, 23 Aug 2009)
New Revision: 1673
Added:
trunk/src/site/apt/
trunk/src/site/apt/LutinUtil.apt
trunk/src/site/apt/Todo.apt
trunk/src/site/apt/index.apt
Modified:
trunk/pom.xml
trunk/src/main/java/org/nuiton/util/VersionUtil.java
trunk/src/site/site.xml
Log:
no more use of jrst (this is a dependency of jrst...), add a main method in VersionUtil to sort a incoming list of versions
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-08-16 08:15:41 UTC (rev 1672)
+++ trunk/pom.xml 2009-08-23 11:32:29 UTC (rev 1673)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.0.0-rc-5-SNAPSHOT</version>
+ <version>1.0.0</version>
</parent>
<artifactId>nuiton-utils</artifactId>
@@ -85,7 +85,7 @@
<packaging>jar</packaging>
<properties>
- <i18n.version>1.0.0-rc-4</i18n.version>
+ <i18n.version>1.0.0</i18n.version>
</properties>
<build>
Modified: trunk/src/main/java/org/nuiton/util/VersionUtil.java
===================================================================
--- trunk/src/main/java/org/nuiton/util/VersionUtil.java 2009-08-16 08:15:41 UTC (rev 1672)
+++ trunk/src/main/java/org/nuiton/util/VersionUtil.java 2009-08-23 11:32:29 UTC (rev 1673)
@@ -18,8 +18,11 @@
*/
package org.nuiton.util;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Comparator;
+import java.util.List;
import java.util.regex.Pattern;
/**
@@ -299,4 +302,60 @@
return o1.classifierNumber - o2.classifierNumber;
}
}
+
+ /**
+ * Trier un ensemble de versions données en entrees
+ *
+ * On affiche le resultat dans la console
+ * @param args les versions
+ */
+ public static void main(String... args) {
+ //System.err.println(VersionUtil.class.getName() + "#main(" + Arrays.asList(args) + ")");
+
+ //I18n.init();
+ List<Version> list = new ArrayList<Version>();
+ List<Version> snapshots = new ArrayList<Version>();
+
+ for (String a : args) {
+ //System.err.println("convert value : " + a);
+ if (a.endsWith("-SNAPSHOT")) {
+ snapshots.add(valueOf(a.substring(0, a.length() - "-SNAPSHOT".length())));
+ continue;
+ }
+ Version v = valueOf(a);
+ list.add(v);
+ }
+ Collections.sort(list);
+ List<String> asString = new ArrayList<String>();
+ for (Version v : list) {
+ asString.add(v.toString());
+ }
+ // repositionnement des snapshots
+ for (Version snap : snapshots) {
+ String v = snap.toString();
+ if (list.contains(snap)) {
+ // on ajoute juste avant
+ int index = asString.indexOf(v);
+ asString.add(index, v + "-SNAPSHOT");
+ } else {
+ // ajout dans la liste initiale
+ list.add(snap);
+ Collections.sort(list);
+ int index = list.indexOf(snap);
+ if (index == 0) {
+ asString.add(0, v + "-SNAPSHOT");
+ } else {
+ Version v2 = list.get(index - 1);
+ index = asString.indexOf(v2.toString());
+ asString.add(index + 1, v + "-SNAPSHOT");
+ }
+ list.remove(snap);
+ }
+ }
+ StringBuilder buffer = new StringBuilder();
+ for (String s : asString) {
+ buffer.append(s).append("\n");
+ }
+ System.out.println(buffer.toString());
+ }
}
Copied: trunk/src/site/apt/LutinUtil.apt (from rev 1672, trunk/src/site/rst/LutinUtil.rst)
===================================================================
--- trunk/src/site/apt/LutinUtil.apt (rev 0)
+++ trunk/src/site/apt/LutinUtil.apt 2009-08-23 11:32:29 UTC (rev 1673)
@@ -0,0 +1,312 @@
+----
+Documentation - LutinUtil
+----
+----
+2009-08-23
+----
+
+ LutinUtil contient un ensemble de librairies trop petites pour avoir
+ leur propre projet. Elles sont aussi utile à la plupart des projets de
+ Code Lutin.
+
+
+Resource
+
+ Cette librairie permet de rechercher une ressource dans le maximum
+ d'endroit possible et si elle est trouvée l'url de la ressource est
+ retournée.
+
+------------------------------------------------------------------------------
+ import org.nuiton.util.Resource;
+ import java.net.URL;
+ ...
+ URL image = Resource.getURL("/images/bidulle.png");
+ ...
+------------------------------------------------------------------------------
+
+ Dans cet exemple l'image est recherchée sur le système de fichier
+ local, si elle n'est pas trouvée, elle est recherché dans le
+ classpath, et si elle n'est toujours pas trouvée une exception est
+ alors levée.
+
+ArgumentsParser
+
+ Cette librairie permet de traiter les arguments de la ligne de commande de
+ façon simple mais évoluable. Son principe de fonctionnement est que l'on
+ déclare les arguements que l'on attend sur la ligne de commande avec le nombre
+ de paramètre qu'ils prennent et une petite description de l'option. Ensuite
+ on dispose de toutes les fonctions utiles pour le traitement de la ligne de
+ commande.
+
+ Voici un exemple d'utilisation
+
+------------------------------------------------------------------------------
+ import org.nuiton.util.ArgumentsParser;
+ ...
+ ArgumentsParser parser = new ArgumentsParser("ToPIA");
+
+ parser.addOption("version", "affiche le numéro de version", new String[]{"--version", "-v"}, 0).setRepetitionMax(1);
+
+ parser.addOption("help", "affiche l'aide de topia", new String[]{"--help", "-h"}, 0).setRepetitionMax(1);
+
+ parser.addOption("start", "Lancement d'une application", new
+ String[]{"--start", "-s"}, 1).setRepetitionMax(1);
+
+ System.out.println(parser.checkCoherence());
+ parser.parse(args);
+
+ if(parser.hasParsedOption("help")){
+ System.out.println(parser.usage());
+ }else if (parser.hasParsedOption("start")){
+ System.out.println ("--> Executing application: ");
+ String arg = parser.getParsedOption("start")
+ new Application(arg);
+ }else if (parser.hasParsedOption("version")){
+ System.out.println( "- Topia version 0.01 - " +
+ "Get new release at http://www.codelutin.com/ -" );
+ }
+------------------------------------------------------------------------------
+
+ Cette librairie permet d'afficher l'aide de la ligne de commande::
+
+------------------------------------------------------------------------------
+ System.out.println(parser.usage());
+------------------------------------------------------------------------------
+
+ Elle permet aussi de vérifier le nombre de fois qu'une option de la ligne de
+ commande est présente et que ce nombre est bien compris dans l'ensemble des
+ valeurs acceptées, grâce au méthode *setRepetitionMax*, et *setRepetitionMin*.
+
+ Si l'implantation par défaut du parseur d'option ne convient pas pour une de vos
+ option, par exemple si le nombre de paramètre de l'option varie suivant la valeur
+ du premier paramètre vous pouvez alors écrire votre propre Parser pour cette
+ Option et l'utilisée avec les autres.
+
+Log
+
+ Cette objet permet de suivre ce que fait une application simplement. Le
+ développeur indique grâce à cette classe l'état dans lequel l'application est.
+
+ Ensuite, il peut mettre des listeners sur cette classe qui afficheront
+ les messages qui ont été envoyés. Ou afficheront l'état d'une tâche en train
+ de s'exécuter.
+
+
+Liste des librairies
+
+ Cette liste répertorie l'ensemble des librairies de LutinUtil.
+
+
+* Configuration
+
+ Gestion de la configuration d'une l'application, de l'internationalisation,
+ des numéros de versions, des ressources...
+
+** ApplicationConfig
+
+ Gestion des fichiers de configuration, des variables d'environnement
+ et des arguments de la ligne de commande.
+
+** Resource
+
+ Recherche d'un fichier dans le système de fichiers et dans le classpath
+ (.jar, .zip).
+
+** ClassLoaderUtil
+
+ Récupération des urls d'un URLClassLoader.
+
+** LocaleConverter
+
+ Conversion d'une chaîne en Locale.
+
+** SortedProperties
+
+ Fichier de propriétés trié par ordre alphabétique.
+
+** RecursiveProperties
+
+ Fichier de propriétés contenant des références à des propriétés de ce
+ même fichier.
+
+** Version
+
+ Représentation d'un numéro de version pour une application.
+
+** VersionConverter
+
+ Conversion d'une chaine en VersionNumber.
+
+** VersionUtil
+
+ Manipulation de numéros de version sous forme de chaînes
+ (comparaison, incrémentation...).
+
+
+* Fichiers
+
+ Gestion de fichiers.
+
+** FileUtil
+
+ Opérations sur des fichiers. Copie, suppression, renommage,
+ recherche, fichiers d'un répertoire, sous-répertoires d'un répertoire,
+ récupération du basename ou de l'extension, création d'un fichier
+ temporaire, comparaison de dates de création, récupération d'une chaîne,
+ d'un Reader ou d'un Writer à partir d'un fichier, récupération du fichier
+ saisi dans une boîte de dialogue, conversions en byte[], en Stream...
+
+** IOUtils
+
+ Copie d'un fichier, chemin temporaire...
+
+** ZipUtil
+
+ Opérations sur des fichiers Zip. Compression et décompression avec ou
+ sans filtres, scan des fichiers créés ou écrasés lors de la décompression...
+
+** ZipStreamEncoder
+
+ Encodage de fichiers Zip dans des threads.
+
+* Collections
+
+ Gestion de collections et de tableaux.
+
+** CollectionUtil
+
+ Manipulation des collections. Ajout de plusieurs éléments à une
+ collection, conversion d'une collection non typée en collection typée.
+
+** ArrayUtil
+
+ Opérations sur des tableaux. Concaténation, somme, recherche,
+ conversion d'une liste en tableau, d'un String[] en int[].
+
+** BoundedList
+
+ ArrayList avec un nombre d'élément minimum et maximum.
+
+** HashList
+ Liste d'objets uniques.
+
+** TransformedList
+ Liste d'objets transformables (interface Transformer).
+
+
+* Chaînes de caractères
+
+ Gestion des chaînes de caractères.
+
+** StringUtil
+
+ Manipulation de chaînes de caractères. Découpage, suppression
+ d'accents, vérification de parenthésage, conversions vers un nombre,
+ un tableau, une couleur, une date...
+
+** URIConverter
+
+ Conversion d'une chaîne en URI.
+
+** URLConverter
+
+ Conversion d'une chaîne en URL.
+
+** GZUtil
+
+ Compression et décompression de chaînes de caractères.
+
+
+* Analyse
+
+ Analyse du code et monitoring.
+
+** CallAnalyse
+
+ Analyse sur des appels de méthodes. Temps d'éxecution, mémoire
+ utilisée et nombre d'appels.
+
+* Log
+ Mise en place de logs dans une application.
+
+** LoggingPatternFormatter
+ Formattage des logs.
+
+
+* Énumérations
+
+ Gestion des énumérations et énumérations utiles.
+
+** EnumConverter
+
+ Conversion d'une chaîne en Enum.
+
+** EnumEditor
+
+ Editeur d'Enum en Swing.
+
+** H2TypeEnum
+
+ Énumération pour représenter les différents types d'implantation dans H2.
+
+** MonthEnum
+
+ Énumération pour représenter les mois d'une année.
+
+** SimplePaginationEnum
+
+ Énumération pour définir les tailles de liste.
+
+* Introspection
+
+ Introspection et manipulations sur des objets et des classes.
+
+** ObjectUtil
+
+ Outils pour manipuler des objets. Création d'un objet à partir d'une chaîne
+ le décrivant, conversion d'un objet en Object, récupération de méthodes
+ à partir de leur nom, de constructeurs à partir de leurs paramètres...
+
+** ReflectUtil
+
+ Introspection sur une classe. Détermine si un attribut est constant,
+ recherche de constantes d'un type donné, conversion d'une classe en
+ Enum...
+
+** FormatConverter
+
+ Conversion d'une représentation d'un objet à une autre représentation.
+ (Java, SQL, XML...).
+
+
+* Divers
+
+ Autres librairies utiles n'appartenant à aucune des catégories précédentes.
+
+** CardinalityHelper
+
+ Méthodes pour tester des cardinalités.
+
+** ListenerSet
+
+ Mise en place de listeners.
+
+** CategorisedListenerSet
+
+ Gestion des catégories de listeners.
+
+** ConverterUtil
+
+ Méthodes sur des converters.
+
+** DigestGenerator
+
+ Fonctionnalités de Digest XML.
+
+** MD5
+
+ Implémentation des MD5 hash.
+
+** MD5InputStream
+
+ MD5 dans un flux.
Copied: trunk/src/site/apt/Todo.apt (from rev 1672, trunk/src/site/rst/Todo.rst)
===================================================================
--- trunk/src/site/apt/Todo.apt (rev 0)
+++ trunk/src/site/apt/Todo.apt 2009-08-23 11:32:29 UTC (rev 1673)
@@ -0,0 +1,91 @@
+----
+TODO
+----
+----
+2009-08-23
+----
+
+Un nouveau parser d'argument
+
+ L'idée est d'avoir une description simple des arguments et de leur type et
+ que soit généré une classe à partir de cette description. Dans le
+ programme il suffirat de demander à la classe généré les inforamtions.
+
+ Les options sont chargées par leur valeur par defaut, puis sont surchargées
+ par les valeurs des fichiers de configurations, puis surchargé
+ par les valeurs des variables d'environnement, et enfin surchargé par les
+ valeurs de la ligne de commande.
+
+ Les fichiers de configuraiton sont lu dans l'ordre suivant: /etc/ + chemin
+ indiqué, puis $HOME/. + chemin indiqué.
+
+ si le chemin indiqué est titi/toto.conf et que l'on est sur un système Linux
+ les fichiers de configuration seront: /etc/titi/toto.conf et
+ ~/.titi/toto.conf
+
+* exemple de description
+
+ Par exemple on pourrait avoir le fichier Toto.java.conf dans les sources du
+ projet qui fournirait le fichier Toto.java::
+
+----------------------------------------------------------------------------
+ configfile: titi/toto.conf
+
+ outFile: le fichier de sortie
+ short: o
+ long: outfile
+ default: -
+ type: File
+ environment: toto
+
+ number: Le nombre de fichier à produire
+ required: 1
+ short: n
+ default: 1
+ long: number
+ condition: 0<Number && Number<10
+ type: int
+----------------------------------------------------------------------------
+
+ La description commence l'option non obligatoire *configfile* qui donne le
+ nom du fichier de configuration à utiliser pour l'application. Puis on
+ trouve les options. Une option commence par un nom, puis sa description
+ ensuite l'option peut avoir plusieurs options:
+
+
+ * short: l'option courte sur la ligne de commande. Si absente pas d'option
+ courte
+
+ * long: l'option longue sur la ligne de commande, si pas d'option, on
+ reprend le nom de l'option
+
+ * type: le type de l'option (int, Float, String, char, File, ...)
+
+ * default: la valeur par default, si elle n'est pas specifier sur la ligne
+ de commande, ni dans les variables d'environnement ni dans le fichier de
+ configuration. Pour une option de type File si default faut -, alors
+ le fichier est la sortie standard.
+
+ * condition: la condition que doit respecter l'option pour être valide
+ la condition est une expression java contenant le nom de l'option comme
+ valeur de variable.
+
+ * environment: le nom de la variable d'environnement qu'il faut utiliser
+ si l'option n'est pas retrouve sur la ligne de commande. Si cette option
+ n'est pas indiqué alors, la variable d'environnement recherchée est le nom
+ du fichier de description suivi d'un point, suivi du nom de l'option.
+ par exemple toto.outfile
+
+
+ L'objet résultat sera Toto placé dans le fichier Toto.java. L'extension
+ java.conf est obligatoire pour détecter un fichier de configuration à
+ parser. Cet objet aurai les méthodes getOutputFile():File et getNumber():int
+
+* Librairies utilisé
+
+ Sans doute utilisé, le parser redwood pour le fichier de configuration
+ {{http://www.isellrenohomes.com/parser/}}. Il lit directement des EBNF.
+
+* projet de parsage d'argument
+
+ {{http://www.martiansoftware.com/jsap/}}
Copied: trunk/src/site/apt/index.apt (from rev 1672, trunk/src/site/rst/index.rst)
===================================================================
(Binary files differ)
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2009-08-16 08:15:41 UTC (rev 1672)
+++ trunk/src/site/site.xml 2009-08-23 11:32:29 UTC (rev 1673)
@@ -1,29 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="${project.name}">
- <publishDate format="dd/MM/yyyy"/>
-
- <skin>
- <groupId>org.nuiton</groupId>
- <artifactId>maven-nuiton-skin</artifactId>
- <version>1.0.0</version>
- </skin>
-
<bannerLeft>
<name>${project.name}</name>
<href>index.html</href>
</bannerLeft>
- <bannerRight>
- <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
- <href>${project.organization.url}</href>
- </bannerRight>
-
<poweredBy>
<logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/>
- <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="images/jrst-logo.png"/>
+ <!--logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="images/jrst-logo.png"/>
<logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText"
- img="images/restructuredtext-logo.png"/>
+ img="images/restructuredtext-logo.png"/-->
</poweredBy>
<body>
1
0
Author: tchemit
Date: 2009-08-16 10:15:41 +0200 (Sun, 16 Aug 2009)
New Revision: 1672
Modified:
trunk/src/site/site.xml
Log:
update skin
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2009-08-13 09:28:56 UTC (rev 1671)
+++ trunk/src/site/site.xml 2009-08-16 08:15:41 UTC (rev 1672)
@@ -6,7 +6,7 @@
<skin>
<groupId>org.nuiton</groupId>
<artifactId>maven-nuiton-skin</artifactId>
- <version>1.0.0-rc-1</version>
+ <version>1.0.0</version>
</skin>
<bannerLeft>
1
0
Bonjour à tous,
Dans l'optique de dissocier au maximum les projets libres initiés par
la société Code Lutin de celle-ci et permettre une meilleur implication
de la communauté du libre dans ces derniers, nous vous annonçons que le
site de développement du projet n'est plus hébergé sur le labs
libre-entreprise mais sur la plateforme www.nuiton.org. La plupart de la
migration a été réalisée, nous vous invitons à utiliser d'ors et déjà la
plateforme http://www.nuiton.org (le projet sur le labs libre-entreprise n'est
plus accessible publiquement)
Les listes de diffusions ont été migrées et tous les utilisateurs ont
normalement du être réabonnés aux nouvelles listes.
La nouvelle adresse de cette liste: nuiton-utils-commits(a)list.nuiton.org
Nous sommes désolés des désagréments causés et vous remercions de votre
soutien.
Cordialement,
L'équipe de développement.
----------------------------
Dear all,
In order to separate the libre projects that Code Lutin has initiated
and the company itself, and also to encourage the implication of the
libre community, we recently moved the project's development site from
the libre-entreprise labs to the www.nuiton.org platform. Most of the
migration is complete, we invite you to use, from now on, the platform
http://www.nuiton.org (the project on libre-entreprise labs is now longer
publicly available).
The mailing-lists have been migrated and everybody should have been
automatically subscribing the new lists.
New mail address for this list: nuiton-utils-commits(a)list.nuiton.org
We are sorry for the inconvenience, and thank you for your support.
Best regards,
The development team.
1
0
[Lutinutil-commits] r1650 - in trunk/nuiton-i18n-editor/src/main: filters java/org/nuiton/i18n/editor/ui java/org/nuiton/i18n/editor/ui/project java/org/nuiton/i18n/editor/ui/project/tabs resources/i18n resources/icons
by tchemit@users.labs.libre-entreprise.org 02 Aug '09
by tchemit@users.labs.libre-entreprise.org 02 Aug '09
02 Aug '09
Author: tchemit
Date: 2009-08-02 17:27:51 +0200 (Sun, 02 Aug 2009)
New Revision: 1650
Added:
trunk/nuiton-i18n-editor/src/main/resources/icons/action-edit.png
Modified:
trunk/nuiton-i18n-editor/src/main/filters/nuiton-i18n-editor.properties
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/SelectBundlesTableModel.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties
trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties
Log:
edition de la definition du projet ouvert
Modified: trunk/nuiton-i18n-editor/src/main/filters/nuiton-i18n-editor.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/filters/nuiton-i18n-editor.properties 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/filters/nuiton-i18n-editor.properties 2009-08-02 15:27:51 UTC (rev 1650)
@@ -12,6 +12,7 @@
icon.action.cancel=action-cancel.png
icon.action.closeTab=action-closeTab.png
icon.action.config=action-config.png
+icon.action.edit=action-edit.png
icon.action.open=action-open.png
icon.action.save=action-save.png
icon.action.close=action-close.png
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css 2009-08-02 15:27:51 UTC (rev 1650)
@@ -53,6 +53,12 @@
_help:{"ui.main.menu.file.configuration"};
}
+#menuFileEditProject {
+ text:"i18neditor.action.editProject";
+ actionIcon:"edit";
+ enabled:{context.getProject() != null};
+}
+
#menuFileCreateProject {
text:"i18neditor.action.createProject";
actionIcon:"add";
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2009-08-02 15:27:51 UTC (rev 1650)
@@ -223,6 +223,7 @@
<JMenu id='menuFile'>
<JMenuItem id='menuFileConfiguration' onActionPerformed="handler.showConfig(context)"/>
<JMenuItem id="menuFileCreateProject" onActionPerformed="handler.createProject(context)"/>
+ <JMenuItem id="menuFileEditProject" onActionPerformed="handler.editProject(context)"/>
<JMenu id="menuFileOpenProject">
<JMenuItem id="menuFileOpenProjectOther"
onActionPerformed="handler.openOtherProject(context)"
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-08-02 15:27:51 UTC (rev 1650)
@@ -625,10 +625,11 @@
I18nProject project = null;
I18nProjectProvider<?> type = model.getType();
project = I18nProjectFactory.newProject(type.getType(), model);
- rootContext.getContextValue(I18nEditorConfig.class).getProjects().add(project.getName());
try {
if (project.isStoreProject()) {
- // on enregistre le projet
+ // ajout du projet dans la liste des projets connus
+ rootContext.getContextValue(I18nEditorConfig.class).getProjects().add(project.getName());
+ // on enregistre la definition du projet
project.saveDefinition();
}
project.load();
@@ -646,6 +647,52 @@
}.start();
}
+ /**
+ * Méthode pour lancer l'assistant de mise a jour de projet.
+ *
+ * @param context le context applicatif
+ */
+ public void editProject(final I18nEditorContext context) {
+ boolean canContinue = ensureModification(context);
+ if (!canContinue) {
+ return;
+ }
+
+ final I18nEditorUI mainUI = getUI(context);
+
+ new WizardUILancher<ProjectStep, ProjectUIModel, ProjectUI>(context, mainUI, ProjectUI.class, ProjectUIModel.class) {
+
+ @Override
+ protected void doAction(ProjectUI ui) {
+ log.info(ui.getName());
+ ProjectUIModel model = ui.getModel();
+ I18nProject project = null;
+ I18nProjectProvider<?> type = model.getType();
+ project = I18nProjectFactory.newProject(type.getType(), model);
+ try {
+ if (project.isStoreProject()) {
+ if (!context.getConfig().getProjects().contains(project.getName())) {
+ // ajout du projet dans la liste des projets connus
+ context.getConfig().getProjects().add(project.getName());
+ }
+ // on enregistre la definition du projet
+ project.saveDefinition();
+ }
+ project.load();
+ I18nEditorContext.PROJECT_DEF.setContextValue(context, project);
+ } catch (IOException ex) {
+ log.error(ex.getMessage(), ex);
+ }
+ }
+
+ @Override
+ protected void doCancel(ProjectUI ui) {
+ super.doCancel(ui);
+
+ }
+ }.start();
+ }
+
public void deleteProject(I18nEditorContext context) {
JComboBox box = new JComboBox();
List<String> projects = new ArrayList<String>(context.getConfig().getProjects());
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2009-08-02 15:27:51 UTC (rev 1650)
@@ -143,16 +143,12 @@
if (newStep == ProjectStep.SELECT_BUNDLES) {
// recalcule des urls disponibles
SELECT_BUNDLES.getBundlesModel().setUrls(model.detectBundles());
+ if (!model.isCreate()) {
+ // on reselectionne les urls du projet
+ SELECT_BUNDLES.getBundlesModel().setSelectedUrls(model.getProject().getUrls());
+ }
return;
- }
- //if (newStep == ProjectStep.PERSIST) {
- // positionnement de fichier de sauvegarde
- //TODO depend du statut du model (create or update)
- //if (model.getProject().isStoreProject()) {
- // model.getProject().setStoreFile(new java.io.File(config.getProjectsDirectory(), model.getProject().getName() + ".i18nproject"));
- //}
- //return;
- //}
+ }
}
@Override
@@ -200,44 +196,12 @@
void $afterCompleteSetup() {
- // on écoute les changements d'étapes
- getModel().addPropertyChangeListener(ProjectUIModel.STEP_PROPERTY_NAME, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- ProjectUIModel model = (ProjectUIModel) evt.getSource();
- ProjectStep oldStep = (ProjectStep) evt.getOldValue();
- ProjectStep newStep = (ProjectStep) evt.getNewValue();
- log.debug("step has changed <old:"+oldStep+", new:"+newStep+">");
- int oldStepIndex = oldStep == null ? -1 : model.getStepIndex(oldStep);
- int newStepIndex = model.getStepIndex(newStep);
- if (oldStepIndex + 1 == newStepIndex) {
- // creation d'un nouvel onglet
- AbstractProjectTabPanelUI c = (AbstractProjectTabPanelUI) getObjectById(newStep.name());
- String title = (String) _(newStep.getLabel());
- String tip = (String) _(newStep.getDescription());
- tabs.addTab(title, null, c, tip);
- // selection du nouvel onglet
- int index = tabs.indexOfComponent(c);
- if (index > -1) {
- tabs.setSelectedIndex(index);
- }
- } else if (oldStepIndex > newStepIndex) {
- // il s'agit d'un retour en arrière
- // on supprime tous les onglets obsoletes
- int index = newStepIndex + 1;
- while (tabs.getTabCount() > index) {
- log.trace("remove tab : " + index);
- tabs.remove(index);
- }
- } else {
- throw new IllegalStateException("can not go from " + oldStep + " to " + newStep);
- }
- }
- });
-
// installation du dispatcher de modifications du modele
WizardUtil.installWizardUIListeners(this);
+ // ajout de la politique d'affichage des onglets
+ WizardUtil.addTabsDisplayUntilStepListener(this);
+
// tableau de la synchronisation des données des references obsoletes
final JTable table = SELECT_BUNDLES.getBundles();
@@ -287,7 +251,7 @@
});
// chargement du modèle
- getModel().init(this);
+ getModel().finalizeUIInit(this);
}
]]>
</script>
@@ -296,8 +260,6 @@
<!-- les differents contenu d'onglets -->
<ChooseProjectTypePanelUI id='CHOOSE_PROJECT_TYPE' constructorParams='this'/>
<ConfigureProjectPanelUI id='CONFIGURE_PROJECT' constructorParams='this'/>
- <!--ConfigureJarProjectPanelUI id='CONFIGURE_JAR_PROJECT' constructorParams='this'/>
- <ConfigureDirectoryProjectPanelUI id='CONFIGURE_DIRECTORY_PROJECT' constructorParams='this'/-->
<SelectBundlesPanelUI id='SELECT_BUNDLES' constructorParams='this'/>
<PersistPanelUI id='PERSIST' constructorParams='this'/>
<ResumePanelUI id='RESUME' constructorParams='this'/>
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java 2009-08-02 15:27:51 UTC (rev 1650)
@@ -30,11 +30,11 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.wizard.WizardModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.i18n.editor.I18nEditorConfig;
+import org.nuiton.i18n.editor.I18nEditorContext;
import org.nuiton.i18n.editor.project.I18nProject;
import org.nuiton.i18n.editor.project.I18nProjectFactory;
import org.nuiton.i18n.editor.project.I18nProjectProvider;
@@ -51,13 +51,6 @@
static private Log log = LogFactory.getLog(ProjectUIModel.class);
public static final String TYPE_PROPERTY_NAME = "type";
public static final String PROJECT_PROPERTY_NAME = "project";
-// public static final String PROJECT_NAME_PROPERTY_NAME = "projectName";
-// public static final String JAR_SOURCE_PROPERTY_NAME = "jarSource";
-// public static final String DIRECTORY_SOURCE_PROPERTY_NAME = "directorySource";
-// public static final String SELECTED_BUNDLES_PROPERTY_NAME = "selectedBundles";
-// public static final String UNIQUE_JAR_DEFINITION_PROPERTY_NAME = "uniqueJarDefinition";
-// public static final String STORE_FILE_PROPERTY_NAME = "storeFile";
-// public static final String STORE_PROJECT_PROPERTY_NAME = "storeProject";
public static final String VALID_PROPERTY_NAME = "valid";
/** le dictionnaire des differents projects possible indexes par leur provideur */
protected Map<I18nProjectProvider<?>, I18nProject> projects;
@@ -99,28 +92,31 @@
}
/**
- * La méthode pour initialiser le modèle à partir du context applicatif.
+ * Methode pour finir l'initialisation de l'ui partir du modele.
*
- * @param context le context applicatif
+ * @param ui l'ui de l'assistant
*/
- public void init(JAXXContext context) {
+ public void finalizeUIInit(final ProjectUI ui) {
- config = context.getContextValue(I18nEditorConfig.class);
+ config = ui.getContextValue(I18nEditorConfig.class);
+ I18nEditorContext ctxt = ui.getContextValue(I18nEditorContext.class);
+
//TODO instead of seeking an ui model, must seek fro an incoming project...
- I18nProject incomingProject = context.getContextValue(I18nProject.class, "incoming");
+ I18nProject incomingProject = ctxt.getProject();
- setCreate(incomingProject==null);
-
+ setCreate(incomingProject == null);
+
if (incomingProject != null) {
+ log.info("from a incoming project " + incomingProject);
if (log.isDebugEnabled()) {
log.debug("from a incoming project " + incomingProject);
}
I18nProjectProvider<?> provider = I18nProjectFactory.getProvider(incomingProject.getClass());
setType(provider);
incomingProject.copyDefinitionTo(project);
- }
+ }
}
@Override
@@ -128,11 +124,11 @@
super.start();
firePropertyChange(TYPE_PROPERTY_NAME, null, type);
firePropertyChange(PROJECT_PROPERTY_NAME, null, project);
-// if (type != null && project != null) {
-// // ask to provider to fire every thing on the project ?
-// //TODO no! the project fire will do it in each specicialized project's ui
-// project.fireAllProperties();
-// }
+ if (!create && type != null && project != null) {
+ // ask to provider to fire every thing on the project ?
+ //TODO no! the project fire will do it in each specicialized project's ui
+ project.fireAllProperties();
+ }
}
@Override
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/SelectBundlesTableModel.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/SelectBundlesTableModel.java 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/SelectBundlesTableModel.java 2009-08-02 15:27:51 UTC (rev 1650)
@@ -63,13 +63,13 @@
public void setUrls(List<URL> entries) {
// on nettoye toujours le model lors de l'init d'une entité
this.entries = new java.util.ArrayList<URL>(entries);
- selected.clear();
+// selected.clear();
// par defaut, on selectionne toutes les references
setSelectAll(true);
//fireTableDataChanged();
}
- public List<URL> getUrls() {
+ public List<URL> getSelectedUrls() {
List<URL> result = new ArrayList<URL>();
for (Integer index : selected) {
result.add(entries.get(index));
@@ -77,6 +77,23 @@
return result;
}
+ public void setSelectedUrls(List<URL> selectedUrls) {
+ setSelectAll(false);
+
+ for (URL selectedUrl : selectedUrls) {
+ // trouver l'inder de l'url
+ String selectedUrlStr = selectedUrl.toString();
+ int index = 0;
+ for (URL u : entries) {
+ if (selectedUrlStr.equals(u.toString())) {
+ selected.add(index);
+ break;
+ }
+ index++;
+ }
+ }
+ }
+
public int[] getSelected() {
int[] result = new int[selected.size()];
int i = 0;
@@ -168,12 +185,11 @@
public void setSelectAll(boolean selectAll) {
this.selectAll = selectAll;
+ selected.clear();
if (selectAll) {
for (int i = 0, max = getRowCount(); i < max; i++) {
selected.add(i);
}
- } else {
- selected.clear();
}
fireTableDataChanged();
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx 2009-08-02 15:27:51 UTC (rev 1650)
@@ -31,7 +31,7 @@
void $afterCompleteSetup() {
- if (getStep()!=null) {
+ if (getStep() != null) {
setDescriptionText(_(getStep().getDescription()));
}
}
@@ -39,7 +39,7 @@
</script>
<SelectBundlesTableModel id='bundlesModel'
- onTableChanged='model.getProject().setUrls(bundlesModel.getUrls())'/>
+ onTableChanged='model.getProject().setUrls(bundlesModel.getSelectedUrls())'/>
<Table id='content' constraints='BorderLayout.CENTER' fill='both' weightx='1' weighty='1'>
<row>
Modified: trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties 2009-08-02 15:27:51 UTC (rev 1650)
@@ -21,6 +21,7 @@
i18neditor.action.createProject=Create project
i18neditor.action.delete.key.tip=
i18neditor.action.deleteProject=Delete project
+i18neditor.action.editProject=Modify project
i18neditor.action.exit=Exit
i18neditor.action.exit.tip=Quit
i18neditor.action.fullscreen=Full screen
Modified: trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties 2009-07-30 23:04:45 UTC (rev 1649)
+++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties 2009-08-02 15:27:51 UTC (rev 1650)
@@ -21,6 +21,7 @@
i18neditor.action.createProject=Cr\u00E9er un projet
i18neditor.action.delete.key.tip=Supprimer cette traduction
i18neditor.action.deleteProject=Supprimer un projet
+i18neditor.action.editProject=Modifier le projet
i18neditor.action.exit=Quitter
i18neditor.action.exit.tip=Quitter l'application
i18neditor.action.fullscreen=Plein \u00E9cran
Added: trunk/nuiton-i18n-editor/src/main/resources/icons/action-edit.png
===================================================================
(Binary files differ)
Property changes on: trunk/nuiton-i18n-editor/src/main/resources/icons/action-edit.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
[Lutinutil-commits] r1649 - in trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor: project project/impl ui ui/project ui/project/tabs
by tchemit@users.labs.libre-entreprise.org 30 Jul '09
by tchemit@users.labs.libre-entreprise.org 30 Jul '09
30 Jul '09
Author: tchemit
Date: 2009-07-31 01:04:45 +0200 (Fri, 31 Jul 2009)
New Revision: 1649
Modified:
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx
Log:
make ProjectUIModel neutral from project definition
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,6 +18,8 @@
*/
package org.nuiton.i18n.editor.project;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -43,113 +45,109 @@
*/
public class AbstractI18nProject implements I18nProject {
- public static final Log log = LogFactory.getLog(AbstractI18nProject.class);
+ public static final String NAME_PROPERTY_NAME = "name";
+ public static final String URLS_PROPERTY_NAME = "urls";
+ public static final String STORE_PROJECT_PROPERTY_NAME = "storeProject";
+ public static final String STORE_FILE_PROPERTY_NAME = "storeFile";
public static final Locale[] EMPTY_LOCALE_ARRAY = new Locale[0];
public static final String EMPTY_STRING = "";
public static final String[] EMPTY_STRING_ARRAY = new String[0];
- /**
- * le nom du projet
- */
- protected final String name;
- /**
- * les urls des fichiers de traduction a charger
- */
- protected URL[] urls;
- /**
- * les definitions de bundles du projet
- */
+ public static final Log log = LogFactory.getLog(AbstractI18nProject.class);
+ /** le nom du projet */
+ protected String name;
+ /** les urls des fichiers de traduction a charger */
+ protected List<URL> urls;
+ /** les definitions de bundles du projet */
protected I18nBundle[] i18nBundles;
- /**
- * le fichier où conserver le projet (si null, on ne persiste pas le projet)
- */
- protected File storeFile;
- /**
- * un drapeau pour savoir si le modele a ete charge
- */
+ /** le fichier où conserver le projet (si null, on ne persiste pas le projet) */
+ protected File storeFile = new File("");
+ /** un drapeau pour savoir si on persiste le projet */
+ protected boolean storeProject;
+ /** un drapeau pour savoir si le modele a ete charge */
boolean loaded;
- /**
- * Les locales selectionnees dans ce projet
- */
- protected final List<Locale> selectedBundles;
- /**
- * les paquetages selectionnes dans ce projet
- */
- protected final List<String> selectedPackages;
- /**
- * le dictionnaire des fichiers de traductions charges
- */
- protected final Map<String, Properties> resources;
+ /** Les locales selectionnees dans ce projet */
+ protected List<Locale> selectedBundles;
+ /** les paquetages selectionnes dans ce projet */
+ protected List<String> selectedPackages;
+ /** le dictionnaire des fichiers de traductions charges */
+ protected Map<String, Properties> resources;
+ /** pour propager les changements du modele */
+ protected PropertyChangeSupport pcs;
- protected AbstractI18nProject(String name, URL... urls) {
- this.name = name;
- this.urls = urls;
+ protected AbstractI18nProject() {
this.resources = new LinkedHashMap<String, Properties>();
this.selectedBundles = new ArrayList<Locale>();
this.selectedPackages = new ArrayList<String>();
+ this.pcs = new PropertyChangeSupport(this);
}
- /**
- * @return le nom du projet
- */
@Override
public String getName() {
return name;
}
- /**
- * @return les paquetages du projet
- */
@Override
- public String[] getPackages() {
- return I18nBundleFactory.getBundleNames(i18nBundles);
+ public List<URL> getUrls() {
+ return urls;
}
- /**
- * @return les locales du projet
- */
@Override
- public Locale[] getBundles() {
- return I18nBundleFactory.getLocales(i18nBundles);
+ public boolean isStoreProject() {
+ return storeProject;
}
- /**
- * @return les paquetages selectionnes
- */
@Override
- public List<String> getSelectedPackages() {
- return selectedPackages;
+ public File getStoreFile() {
+ return storeFile;
}
- /**
- * @return les locales selectionnees
- */
@Override
- public List<Locale> getSelectedBundles() {
- return selectedBundles;
+ public void setName(String name) {
+ String oldValue = this.name;
+ this.name = name;
+ firePropertyChange(NAME_PROPERTY_NAME, oldValue, name);
}
- /**
- * @return les urls du projet
- */
@Override
- public URL[] getURLs() {
- return urls;
+ public void setUrls(List<URL> urls) {
+ this.urls = urls;
}
@Override
- public File getStoreFile() {
- return storeFile;
+ public void setStoreProject(boolean storeProject) {
+ boolean oldValue = this.storeProject;
+ this.storeProject = storeProject;
+ firePropertyChange(STORE_PROJECT_PROPERTY_NAME, oldValue, storeProject);
}
@Override
public void setStoreFile(File storeFile) {
+ File oldValue = this.storeFile;
this.storeFile = storeFile;
+ firePropertyChange(STORE_FILE_PROPERTY_NAME, oldValue, storeFile);
}
- /**
- * @return les clefs de traductions pour les packages selectionnee et les locales selectionnes
- */
@Override
+ public String[] getPackages() {
+ return I18nBundleFactory.getBundleNames(i18nBundles);
+ }
+
+ @Override
+ public Locale[] getBundles() {
+ return I18nBundleFactory.getLocales(i18nBundles);
+ }
+
+ @Override
+ public List<String> getSelectedPackages() {
+ return selectedPackages;
+ }
+
+ @Override
+ public List<Locale> getSelectedBundles() {
+ return selectedBundles;
+ }
+
+ @Override
public String[] getKeys() {
if (!loaded) {
return EMPTY_STRING_ARRAY;
@@ -176,13 +174,6 @@
return r.toArray(new String[r.size()]);
}
- /**
- * Supprime une traduction pour une clef donnee dans une langue et un paquetage donne.
- *
- * @param packageName le paquetage ou supprimer la clef
- * @param locale la locale de la traduction
- * @param key la clef de traduction
- */
@Override
public void deleteKey(String packageName, Locale locale, String key) {
checkLoaded();
@@ -192,11 +183,6 @@
}
}
- /**
- * @param packageName
- * @param key la clef de traductions
- * @return les traductions pour les packages, locales et clef selectionnees
- */
@Override
public Map<Locale, String> getValues(String packageName, String key) {
if (!loaded) {
@@ -228,12 +214,6 @@
return r;
}
- /**
- * @param key la clef de traductions
- * @param locale la locale
- * @param packageName le nom du package
- * @return les traductions
- */
@Override
public String getValue(String packageName, Locale locale, String key) {
if (!loaded) {
@@ -248,14 +228,6 @@
}
- /**
- * Ajouter une traduction dans le projet.
- *
- * @param packageName le paquetage ou ajouter la clef
- * @param locale la locale de la traduction
- * @param key la clef de traduction
- * @param value la traduction
- */
@Override
public void addValue(String packageName, Locale locale, String key, String value) {
checkLoaded();
@@ -265,14 +237,6 @@
}
}
- /**
- * Mettre a jour une traduction dans le projet.
- *
- * @param packageName le paquetage ou ajouter la clef
- * @param locale la locale de la traduction
- * @param key la clef de traduction
- * @param value la traduction
- */
@Override
public void updateValue(String packageName, Locale locale, String key, String value) {
checkLoaded();
@@ -282,21 +246,29 @@
}
}
- /**
- * Chargement des traductions du projet.
- *
- * @throws IOException
- */
@Override
+ public void copyDefinitionTo(I18nProject project) {
+ // check we are on the same type of project
+ if (project.getClass() != getClass()) {
+ throw new IllegalArgumentException("copyDefinitionTo method must use same project type, but was not! (required : " + getClass() + ", but find " + project.getClass() + 3);
+ }
+ project.setName(name);
+ project.setUrls(urls);
+ project.setStoreProject(storeProject);
+ // always clean storeFile (could be init in project from ui, but only keep it if necessary)
+ project.setStoreFile(storeProject ? storeFile : null);
+ }
+
+ @Override
public void load() throws IOException {
try {
- synchronized (this.resources) {
+ synchronized (this) {
resources.clear();
selectedBundles.clear();
selectedPackages.clear();
// detections des bundles i18n a partir des urls donnees
- List<I18nBundle> tmp = I18nBundleFactory.detectBundles(urls);
+ List<I18nBundle> tmp = I18nBundleFactory.detectBundles(urls.toArray(new URL[urls.size()]));
i18nBundles = tmp.toArray(new I18nBundle[tmp.size()]);
selectedBundles.addAll(Arrays.asList(getBundles()));
@@ -316,26 +288,15 @@
}
}
- /**
- * Enregistrement des traductions du projet.
- *
- * @throws IOException
- */
@Override
public void store() throws IOException {
checkLoaded();
}
@Override
- public void storeDefinition() throws IOException {
+ public void saveDefinition() throws IOException {
Properties p = new Properties();
- p.setProperty("name", name);
- p.setProperty("class", getClass().getName());
- StringBuilder buffer = new StringBuilder();
- for (URL u : urls) {
- buffer.append(',').append(u.toString());
- }
- p.setProperty("urls", buffer.substring(1));
+ fillDefinition(p);
FileOutputStream stream = null;
try {
stream = new FileOutputStream(getStoreFile());
@@ -349,6 +310,69 @@
}
@Override
+ public void fillDefinition(Properties p) {
+ p.setProperty("name", name);
+ p.setProperty("class", getClass().getName());
+ StringBuilder buffer = new StringBuilder();
+ for (URL u : urls) {
+ buffer.append(',').append(u.toString());
+ }
+ p.setProperty("urls", buffer.substring(1));
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<name: " + name + ">";
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ if (log.isDebugEnabled()) {
+ log.debug(this + " / " + listener);
+ }
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ @Override
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ if (log.isDebugEnabled()) {
+ log.debug(this + " / " + propertyName + " : " + listener);
+ }
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ if (log.isDebugEnabled()) {
+ log.debug(this + " / " + listener);
+ }
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ @Override
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ if (log.isDebugEnabled()) {
+ log.debug(this + " / " + propertyName + " : " + listener);
+ }
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ @Override
+ public void removePropertyChangeListeners() {
+ for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+
+ @Override
+ public void fireAllProperties() {
+ firePropertyChange(NAME_PROPERTY_NAME, null, name);
+ firePropertyChange(URLS_PROPERTY_NAME, null, urls);
+ firePropertyChange(STORE_PROJECT_PROPERTY_NAME, null, storeProject);
+ firePropertyChange(STORE_FILE_PROPERTY_NAME, null, storeFile);
+ }
+
+ @Override
protected void finalize() throws Throwable {
super.finalize();
i18nBundles = null;
@@ -357,9 +381,8 @@
selectedPackages.clear();
}
- @Override
- public String toString() {
- return super.toString() + "<name: " + name + ">";
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
}
protected I18nBundle getI18nBundle(String packageName) {
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -26,6 +26,8 @@
import java.util.Map;
import java.util.Map.Entry;
import org.nuiton.i18n.I18n;
+import org.nuiton.i18n.editor.project.impl.DirectoryI18nProject;
+import org.nuiton.i18n.editor.ui.project.ProjectUIModel;
/**
*
@@ -36,8 +38,6 @@
public abstract class AbstractI18nProjectProvider<P extends I18nProject> implements I18nProjectProvider<P> {
public static final String CLASS_PARAMETER = "class";
- public static final String NAME_PARAMETER = "name";
- public static final String URLS_PARAMETER = "urls";
protected final Class<P> type;
protected final String label;
protected final String description;
@@ -66,7 +66,6 @@
return I18n._(description);
}
-
@Override
public Map<String, Class<?>> getAuthorizedParameters() {
if (authorizedParameters == null) {
@@ -75,7 +74,15 @@
return authorizedParameters;
}
- public <T extends Object> T getParameter(Class<T> returnType, String propertyName, Map<String, Object> parameters) {
+ @Override
+ public P newProject(ProjectUIModel model) {
+ I18nProject project = model.getProject();
+ P p = newProject();
+ project.copyDefinitionTo(p);
+ return p;
+ }
+
+ public <T extends Object> T getParameter(Class<T> returnType, String propertyName, Map<String, Object> parameters, boolean mustExist) {
Map<String, Class<?>> map = getAuthorizedParameters();
// check name
if (!map.containsKey(propertyName)) {
@@ -92,6 +99,9 @@
return (T) e.getValue();
}
}
- throw new IllegalArgumentException("could not find property " + propertyName + ".\nKnown properties in :\n" + parameters.keySet());
+ if (mustExist) {
+ throw new IllegalArgumentException("could not find property " + propertyName + ".\nKnown properties in :\n" + parameters.keySet());
+ }
+ return null;
}
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,12 +18,14 @@
*/
package org.nuiton.i18n.editor.project;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Properties;
/**
*
@@ -31,60 +33,79 @@
*/
public interface I18nProject {
+ /////////////////////////////////////////////////////////////////////
+ // definition accessor //////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
/**
* @return le nom du projet
*/
- public String getName();
+ String getName();
/**
- * @return les paquetages du projet
+ * @return les urls du projet
*/
- public String[] getPackages();
+ List<URL> getUrls();
/**
- * @return les locales du projet
+ *
+ * @return <code>true</code> si la definition du projet est persiste
*/
- public Locale[] getBundles();
+ boolean isStoreProject();
/**
- * @return les paquetages selectionnes
+ *
+ * @return le chemin du fichier ou persister la definition du projet
+ *
+ * Note : n'est pris en compte uniquement si {@link #isStoreProject()} est
+ * vrai.
*/
- public List<String> getSelectedPackages();
+ File getStoreFile();
+ /////////////////////////////////////////////////////////////////////
+ // definition mutator //////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ void setName(String name);
+
+ void setUrls(List<URL> urls);
+
+ void setStoreProject(boolean storeProject);
+
+ void setStoreFile(File storeFile);
+
+ /////////////////////////////////////////////////////////////////////
+ // runtime accessor /////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
/**
- * @return les locales selectionnees
+ * @return les paquetages du projet
*/
- public List<Locale> getSelectedBundles();
+ String[] getPackages();
/**
- * @return les urls du projet
+ * @return les locales du projet
*/
- public URL[] getURLs();
+ Locale[] getBundles();
- public File getStoreFile();
+ /**
+ * @return les paquetages selectionnes
+ */
+ List<String> getSelectedPackages();
- public void setStoreFile(File storeFile);
-
/**
- * @return les clefs de traductions pour les packages selectionnee et les locales selectionnes
+ * @return les locales selectionnees
*/
- public String[] getKeys();
+ List<Locale> getSelectedBundles();
/**
- * Supprime une traduction pour une clef donnee dans une langue et un paquetage donne.
- *
- * @param packageName le paquetage ou supprimer la clef
- * @param locale la locale de la traduction
- * @param key la clef de traduction
+ * @return les clefs de traductions pour les packages selectionnee et les locales selectionnes
*/
- public void deleteKey(String packageName, Locale locale, String key);
+ String[] getKeys();
/**
* @param packageName
* @param key la clef de traductions
* @return les traductions pour les packages, locales et clef selectionnees
*/
- public Map<Locale, String> getValues(String packageName, String key);
+ Map<Locale, String> getValues(String packageName, String key);
/**
* @param key la clef de traductions
@@ -92,9 +113,25 @@
* @param packageName le nom du package
* @return les traductions
*/
- public String getValue(String packageName, Locale locale, String key);
+ String getValue(String packageName, Locale locale, String key);
/**
+ * Copy roject definition to the given project.
+ *
+ * @param project the destination project
+ */
+ void copyDefinitionTo(I18nProject project);
+
+ /**
+ * Supprime une traduction pour une clef donnee dans une langue et un paquetage donne.
+ *
+ * @param packageName le paquetage ou supprimer la clef
+ * @param locale la locale de la traduction
+ * @param key la clef de traduction
+ */
+ void deleteKey(String packageName, Locale locale, String key);
+
+ /**
* Ajouter une traduction dans le projet.
*
* @param packageName le paquetage ou ajouter la clef
@@ -102,7 +139,7 @@
* @param key la clef de traduction
* @param value la traduction
*/
- public void addValue(String packageName, Locale locale, String key, String value);
+ void addValue(String packageName, Locale locale, String key, String value);
/**
* Mettre a jour une traduction dans le projet.
@@ -112,21 +149,50 @@
* @param key la clef de traduction
* @param value la traduction
*/
- public void updateValue(String packageName, Locale locale, String key, String value);
+ void updateValue(String packageName, Locale locale, String key, String value);
/**
* Chargement des traductions du projet.
*
* @throws IOException
*/
- public void load() throws IOException;
+ void load() throws IOException;
/**
* Enregistrement des traductions du projet.
*
* @throws IOException
*/
- public void store() throws IOException;
+ void store() throws IOException;
- public void storeDefinition() throws IOException;
+ /**
+ * Sauvegarde la definition du projet.
+ *
+ * @throws IOException pour tout pb lors de la sauvegarde
+ */
+ void saveDefinition() throws IOException;
+
+ /**
+ * Remplit un dictionnaire avec les proprietes de la definition du projet.
+ *
+ * @param p le dictionnaire des proprietes de la definition du projet
+ */
+ void fillDefinition(Properties p);
+
+ /////////////////////////////////////////////////////////////////////
+ // property change listeners ////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ void addPropertyChangeListener(PropertyChangeListener listener);
+
+ void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
+
+ void removePropertyChangeListener(PropertyChangeListener listener);
+
+ void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
+
+ void removePropertyChangeListeners();
+
+ void fireAllProperties();
+
+
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -24,13 +24,17 @@
/**
* Le contrat a respecter pour configurer un type de projet.
*
+ * @param <P> le type de projet
+ *
* @author chemit
*/
-public interface I18nProjectConfigurePanelUI extends JAXXObject {
+public interface I18nProjectConfigurePanelUI<P extends I18nProject> extends JAXXObject {
/**
*
* @return l'instance partagee du modele de creation de projet
*/
ProjectUIModel getModel();
+
+ P getProject();
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -149,7 +149,7 @@
* @return le provideur pour le le type de projet donne, ou <code>null</code>
* si aucun provideur ne prend en charge ce type de projet.
*/
- protected static <P extends I18nProject> I18nProjectProvider<P> getProvider(Class<P> projectClass) {
+ public static <P extends I18nProject> I18nProjectProvider<P> getProvider(Class<P> projectClass) {
for (I18nProjectProvider<?> p : getProviders()) {
if (p.getType() == projectClass) {
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -57,6 +57,7 @@
*/
Map<String, Class<?>> getAuthorizedParameters();
+ P newProject();
/**
*
* @param params les paramètres pour instancier le projet
@@ -93,7 +94,7 @@
*
* @return le type de l'ui pour configurer ce type de projet
*/
- Class<? extends I18nProjectConfigurePanelUI> getUIClass();
+ Class<? extends I18nProjectConfigurePanelUI<?>> getUIClass();
/**
* Valide dans l'ui de creation de projet la partie specifique a
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,8 +18,10 @@
*/
package org.nuiton.i18n.editor.project.impl;
+import java.io.File;
import org.nuiton.i18n.editor.project.AbstractI18nProject;
-import java.net.URL;
+import java.util.Properties;
+import org.nuiton.i18n.editor.project.I18nProject;
/**
*
@@ -27,7 +29,39 @@
*/
public class DirectoryI18nProject extends AbstractI18nProject {
- public DirectoryI18nProject(String name, URL[] urls) {
- super(name, urls);
+ public static final String DIRECTORY_SOURCE_PROPERTY_NAME = "directorySource";
+ /** la source pour un projet de type directory */
+ protected File directorySource = new File("");
+
+ public DirectoryI18nProject() {
+ super();
}
+
+ public File getDirectorySource() {
+ return directorySource;
+ }
+
+ public void setDirectorySource(File directorySource) {
+ File oldValue = this.directorySource;
+ this.directorySource = directorySource;
+ firePropertyChange(DIRECTORY_SOURCE_PROPERTY_NAME, oldValue, directorySource);
+ }
+
+ @Override
+ public void fillDefinition(Properties p) {
+ super.fillDefinition(p);
+ p.setProperty(DIRECTORY_SOURCE_PROPERTY_NAME, directorySource.getAbsolutePath());
+ }
+
+ @Override
+ public void copyDefinitionTo(I18nProject project) {
+ super.copyDefinitionTo(project);
+ ((DirectoryI18nProject) project).setDirectorySource(directorySource);
+ }
+
+ @Override
+ public void fireAllProperties() {
+ super.fireAllProperties();
+ firePropertyChange(DIRECTORY_SOURCE_PROPERTY_NAME, null, directorySource);
+ }
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -22,12 +22,13 @@
-->
<Table fill='both' constraints='DirectoryI18nProject.class.getName()'
- implements='org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI'>
+ implements='org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI<DirectoryI18nProject>'>
<script><![CDATA[
import jaxx.runtime.SwingUtil;
import org.nuiton.i18n.editor.*;
+import org.nuiton.i18n.editor.project.I18nProject;
import org.nuiton.i18n.editor.project.impl.*;
import org.nuiton.i18n.editor.ui.project.*;
@@ -35,18 +36,30 @@
protected ProjectUIModel model = getContextValue(ProjectUIModel.class);
+protected DirectoryI18nProject project = model.getProject(DirectoryI18nProject.class);
+
@Override
public ProjectUIModel getModel() {
return model;
}
+@Override
+public DirectoryI18nProject getProject() {
+ return project;
+ //I18nProject p = model.getProject();
+ //if (p instanceof DirectoryI18nProject) {
+ // return (DirectoryI18nProject) p;
+ //}
+ //return null;
+}
+
public void chooseDirectorySource() {
File f = model.chooseDirectory(
this,
_("i18neditor.title.choose.directory.source"),
_("i18neditor.action.choose.directory.source.description"),
- model.getJarSource());
- model.setDirectorySource(f);
+ getProject().getDirectorySource());
+ getProject().setDirectorySource(f);
}
]]>
</script>
@@ -58,8 +71,8 @@
</row>
<row>
<cell columns="2">
- <JTextField text='{SwingUtil.getStringValue(model.getProjectName())}'
- onKeyReleased='model.setProjectName(((JTextField)event.getSource()).getText())'/>
+ <JTextField text='{SwingUtil.getStringValue(getProject().getName())}'
+ onKeyReleased='getProject().setName(((JTextField)event.getSource()).getText())'/>
</cell>
</row>
<row>
@@ -70,8 +83,8 @@
<row>
<cell weightx='1' fill="both">
<JTextField id="directorySourceFile"
- text='{SwingUtil.getStringValue(model.getDirectorySource()+"")}'
- onKeyReleased='model.setDirectorySource(new File(((JTextField)event.getSource()).getText()))'/>
+ text='{SwingUtil.getStringValue(getProject().getDirectorySource()+"")}'
+ onKeyReleased='getProject().setDirectorySource(new File(((JTextField)event.getSource()).getText()))'/>
</cell>
<cell anchor="east">
<JButton actionIcon="fileChooser"
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,6 +18,7 @@
*/
package org.nuiton.i18n.editor.project.impl;
+import java.io.File;
import java.io.IOException;
import org.nuiton.i18n.editor.project.AbstractI18nProjectProvider;
import java.net.URL;
@@ -44,62 +45,80 @@
@Override
protected Map<String, Class<?>> initAuthorizedParameters() {
Map<String, Class<?>> result = new TreeMap<String, Class<?>>();
- result.put(NAME_PARAMETER, String.class);
- result.put(URLS_PARAMETER, URL[].class);
+ result.put(DirectoryI18nProject.NAME_PROPERTY_NAME, String.class);
+ result.put(DirectoryI18nProject.URLS_PROPERTY_NAME, List.class);
+ result.put(DirectoryI18nProject.DIRECTORY_SOURCE_PROPERTY_NAME, File.class);
return result;
}
@Override
- public DirectoryI18nProject newProject(Map<String, Object> params) {
- String name = getParameter(String.class, NAME_PARAMETER, params);
- URL[] urls = getParameter(URL[].class, URLS_PARAMETER, params);
- return new DirectoryI18nProject(name, urls);
+ public DirectoryI18nProject newProject() {
+ return new DirectoryI18nProject();
}
@Override
- public DirectoryI18nProject newProject(ProjectUIModel model) {
- DirectoryI18nProject p = new DirectoryI18nProject(model.getProjectName(), model.getSelectedBundles().toArray(new URL[model.getSelectedBundles().size()]));
- if (model.isStoreProject()) {
- p.setStoreFile(model.getStoreFile());
- }
+ public DirectoryI18nProject newProject(Map<String, Object> params) {
+ // mandatory parameters
+ String name = getParameter(String.class, DirectoryI18nProject.NAME_PROPERTY_NAME, params, true);
+ List<URL> urls = getParameter(List.class, DirectoryI18nProject.URLS_PROPERTY_NAME, params, true);
+
+ // optional parameters
+ File directorySource = getParameter(File.class, DirectoryI18nProject.DIRECTORY_SOURCE_PROPERTY_NAME, params, false);
+
+ DirectoryI18nProject p = new DirectoryI18nProject();
+ p.setName(name);
+ p.setUrls(urls);
+ p.setDirectorySource(directorySource);
return p;
}
@Override
public DirectoryI18nProject newProject(Properties properties) {
Map<String, Object> params = new TreeMap<String, Object>();
- params.put(NAME_PARAMETER, properties.getProperty(NAME_PARAMETER));
- String tmp = properties.getProperty(URLS_PARAMETER);
+ String tmp;
+
+ // name
+ tmp = properties.getProperty(DirectoryI18nProject.NAME_PROPERTY_NAME);
+ params.put(DirectoryI18nProject.NAME_PROPERTY_NAME, tmp);
+
+ // urls
+ tmp = properties.getProperty(DirectoryI18nProject.URLS_PROPERTY_NAME);
String[] urlsStr = tmp.split(",");
List<URL> urls = new ArrayList<URL>();
for (String u : urlsStr) {
URL url = ConverterUtil.convert(URL.class, u);
urls.add(url);
}
+ params.put(DirectoryI18nProject.URLS_PROPERTY_NAME, urls);
- params.put(URLS_PARAMETER, urls.toArray(new URL[urls.size()]));
-
+ // directorySource
+ tmp = properties.getProperty(DirectoryI18nProject.DIRECTORY_SOURCE_PROPERTY_NAME);
+ File directorySource = new File(tmp);
+ params.put(DirectoryI18nProject.DIRECTORY_SOURCE_PROPERTY_NAME, directorySource);
DirectoryI18nProject p = newProject(params);
return p;
}
@Override
public List<URL> detectBundles(ProjectUIModel model) throws IOException {
+ //TODO
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean validateUIModel(ProjectUIModel model) {
- return model.getDirectorySource() != null && model.getDirectorySource().exists() && model.getProjectName() != null && !model.getProjectName().isEmpty();
+ DirectoryI18nProject project = (DirectoryI18nProject) model.getProject();
+ return project.getDirectorySource() != null && project.getDirectorySource().exists() && project.getName() != null && !project.getName().isEmpty();
}
@Override
public boolean validateDefinition(Properties properties) {
+ //TODO
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public Class<? extends I18nProjectConfigurePanelUI> getUIClass() {
+ public Class<? extends I18nProjectConfigurePanelUI<?>> getUIClass() {
return DirectoryI18nProjectConfigurePanelUI.class;
}
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,18 +18,69 @@
*/
package org.nuiton.i18n.editor.project.impl;
+import java.io.File;
+import java.util.Properties;
import org.nuiton.i18n.editor.project.AbstractI18nProject;
-import java.net.URL;
+import org.nuiton.i18n.editor.project.I18nProject;
/**
*
* @author chemit
*/
-public class JarI18nProject extends AbstractI18nProject{
+public class JarI18nProject extends AbstractI18nProject {
- public JarI18nProject(String name, URL[] urls) {
- super(name, urls);
+ public static final String JAR_SOURCE_PROPERTY_NAME = "jarSource";
+ public static final String UNIQUE_JAR_DEFINITION_PROPERTY_NAME = "uniqueJarDefinition";
+ /** la source pour un projet de type jar */
+ protected File jarSource = new File("");
+ /**
+ * un drapeau (pour les projets de type jar) pour savoir si on utilise le
+ * système i18n avec nom unique.
+ */
+ protected boolean uniqueJarDefinition;
+
+ public JarI18nProject() {
+ super();
}
+ public File getJarSource() {
+ return jarSource;
+ }
+ public void setJarSource(File jarSource) {
+ File oldValue = this.jarSource;
+ this.jarSource = jarSource;
+ firePropertyChange(JAR_SOURCE_PROPERTY_NAME, oldValue, jarSource);
+ }
+
+ public boolean isUniqueJarDefinition() {
+ return uniqueJarDefinition;
+ }
+
+ public void setUniqueJarDefinition(boolean uniqueJarDefinition) {
+ boolean oldValue = this.uniqueJarDefinition;
+ this.uniqueJarDefinition = uniqueJarDefinition;
+ firePropertyChange(UNIQUE_JAR_DEFINITION_PROPERTY_NAME, oldValue, uniqueJarDefinition);
+ }
+
+ @Override
+ public void fillDefinition(Properties p) {
+ super.fillDefinition(p);
+ p.setProperty(JAR_SOURCE_PROPERTY_NAME, jarSource.getAbsolutePath());
+ p.setProperty(UNIQUE_JAR_DEFINITION_PROPERTY_NAME, Boolean.valueOf(uniqueJarDefinition).toString());
+ }
+
+ @Override
+ public void copyDefinitionTo(I18nProject project) {
+ super.copyDefinitionTo(project);
+ ((JarI18nProject) project).setJarSource(jarSource);
+ ((JarI18nProject) project).setUniqueJarDefinition(uniqueJarDefinition);
+ }
+
+ @Override
+ public void fireAllProperties() {
+ super.fireAllProperties();
+ firePropertyChange(JAR_SOURCE_PROPERTY_NAME, null, jarSource);
+ firePropertyChange(UNIQUE_JAR_DEFINITION_PROPERTY_NAME, null, uniqueJarDefinition);
+ }
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -22,12 +22,13 @@
-->
<Table fill='both' constraints='JarI18nProject.class.getName()'
- implements='org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI'>
+ implements='org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI<JarI18nProject>'>
<script><![CDATA[
import jaxx.runtime.SwingUtil;
import org.nuiton.i18n.editor.*;
+import org.nuiton.i18n.editor.project.I18nProject;
import org.nuiton.i18n.editor.project.impl.*;
import org.nuiton.i18n.editor.ui.project.*;
@@ -35,20 +36,32 @@
protected ProjectUIModel model = getContextValue(ProjectUIModel.class);
+protected JarI18nProject project = model.getProject(JarI18nProject.class);
+
@Override
public ProjectUIModel getModel() {
return model;
}
+@Override
+public JarI18nProject getProject() {
+ return project;
+ //I18nProject p = model.getProject();
+ //if (p instanceof JarI18nProject) {
+ // return (JarI18nProject) p;
+ //}
+ //return null;
+}
+
public void chooseJarSource() {
File f = model.chooseFile (
this,
_("i18neditor.title.choose.jar.source"),
_("i18neditor.action.choose.jar.source"),
- model.getJarSource(),
+ getProject().getJarSource(),
"^.+\\.jar$",
_("i18neditor.action.choose.jar.source.description"));
- model.setJarSource(f);
+ getProject().setJarSource(f);
}
]]>
</script>
@@ -60,8 +73,8 @@
</row>
<row>
<cell columns="2">
- <JTextField text='{SwingUtil.getStringValue(model.getProjectName())}'
- onKeyReleased='model.setProjectName(((JTextField)event.getSource()).getText())'/>
+ <JTextField text='{SwingUtil.getStringValue(getProject().getName())}'
+ onKeyReleased='getProject().setName(((JTextField)event.getSource()).getText())'/>
</cell>
</row>
<row>
@@ -72,8 +85,8 @@
<row>
<cell weightx='1' fill="both">
<JTextField id="jarSourceFile"
- text='{SwingUtil.getStringValue(model.getJarSource()+"")}'
- onKeyReleased='model.setJarSource(new File(((JTextField)event.getSource()).getText()))'/>
+ text='{SwingUtil.getStringValue(getProject().getJarSource()+"")}'
+ onKeyReleased='getProject().setJarSource(new File(((JTextField)event.getSource()).getText()))'/>
</cell>
<cell anchor="east">
<JButton actionIcon="fileChooser"
@@ -85,8 +98,8 @@
<JCheckBox id='uniqueJarDefinition'
text='i18neditor.createproject.uniqueJarDefinition'
toolTipText='i18neditor.createproject.uniqueJarDefinition.tip'
- selected='{model.isUniqueJarDefinition()}'
- onItemStateChanged='model.setUniqueJarDefinition(event.getStateChange() == ItemEvent.SELECTED)'/>
+ selected='{getProject().isUniqueJarDefinition()}'
+ onItemStateChanged='getProject().setUniqueJarDefinition(event.getStateChange() == ItemEvent.SELECTED)'/>
</cell>
</row>
</Table>
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,6 +18,7 @@
*/
package org.nuiton.i18n.editor.project.impl;
+import java.io.File;
import java.io.IOException;
import org.nuiton.i18n.editor.project.AbstractI18nProjectProvider;
import java.net.URL;
@@ -54,43 +55,65 @@
@Override
protected Map<String, Class<?>> initAuthorizedParameters() {
Map<String, Class<?>> result = new TreeMap<String, Class<?>>();
- result.put(NAME_PARAMETER, String.class);
- result.put(URLS_PARAMETER, URL[].class);
+ result.put(JarI18nProject.NAME_PROPERTY_NAME, String.class);
+ result.put(JarI18nProject.URLS_PROPERTY_NAME, List.class);
+ result.put(JarI18nProject.JAR_SOURCE_PROPERTY_NAME, File.class);
+ result.put(JarI18nProject.UNIQUE_JAR_DEFINITION_PROPERTY_NAME, Boolean.class);
return result;
}
@Override
- public JarI18nProject newProject(Map<String, Object> params) {
- String name = getParameter(String.class, NAME_PARAMETER, params);
- URL[] urls = getParameter(URL[].class, URLS_PARAMETER, params);
- JarI18nProject p = new JarI18nProject(name, urls);
- return p;
+ public JarI18nProject newProject() {
+ return new JarI18nProject();
}
@Override
- public JarI18nProject newProject(ProjectUIModel model) {
- JarI18nProject p = new JarI18nProject(model.getProjectName(),
- model.getSelectedBundles().toArray(new URL[model.getSelectedBundles().size()]));
- if (model.isStoreProject()) {
- p.setStoreFile(model.getStoreFile());
- }
+ public JarI18nProject newProject(Map<String, Object> params) {
+
+ // mandatory parameters
+ String name = getParameter(String.class, JarI18nProject.NAME_PROPERTY_NAME, params, true);
+ List<URL> urls = getParameter(List.class, JarI18nProject.URLS_PROPERTY_NAME, params, true);
+
+ // optional parameters
+ File jarSource = getParameter(File.class, JarI18nProject.JAR_SOURCE_PROPERTY_NAME, params, false);
+ Boolean uniqueJarDefinition = getParameter(Boolean.class, JarI18nProject.UNIQUE_JAR_DEFINITION_PROPERTY_NAME, params, false);
+ JarI18nProject p = new JarI18nProject();
+ p.setName(name);
+ p.setUrls(urls);
+ p.setJarSource(jarSource);
+ p.setUniqueJarDefinition(uniqueJarDefinition != null && uniqueJarDefinition);
return p;
}
@Override
public JarI18nProject newProject(Properties properties) {
Map<String, Object> params = new TreeMap<String, Object>();
- params.put(NAME_PARAMETER, properties.getProperty(NAME_PARAMETER));
- String tmp = properties.getProperty(URLS_PARAMETER);
+ String tmp;
+
+ // name
+ tmp = properties.getProperty(JarI18nProject.NAME_PROPERTY_NAME);
+ params.put(JarI18nProject.NAME_PROPERTY_NAME, tmp);
+
+ // urls
+ tmp = properties.getProperty(JarI18nProject.URLS_PROPERTY_NAME);
String[] urlsStr = tmp.split(",");
List<URL> urls = new ArrayList<URL>();
for (String u : urlsStr) {
URL url = ConverterUtil.convert(URL.class, u);
urls.add(url);
}
+ params.put(JarI18nProject.URLS_PROPERTY_NAME, urls);
- params.put(URLS_PARAMETER, urls.toArray(new URL[urls.size()]));
+ // jarSource
+ tmp = properties.getProperty(JarI18nProject.JAR_SOURCE_PROPERTY_NAME);
+ File jarSource = new File(tmp);
+ params.put(JarI18nProject.JAR_SOURCE_PROPERTY_NAME, jarSource);
+ // uniqueJarDefinition
+ tmp = properties.getProperty(JarI18nProject.UNIQUE_JAR_DEFINITION_PROPERTY_NAME, "false");
+ Boolean uniqueJarDefinition = Boolean.valueOf(tmp);
+ params.put(JarI18nProject.UNIQUE_JAR_DEFINITION_PROPERTY_NAME, uniqueJarDefinition);
+
JarI18nProject p = newProject(params);
return p;
}
@@ -98,10 +121,11 @@
@Override
public List<URL> detectBundles(ProjectUIModel model) throws IOException {
List<URL> urls = new ArrayList<URL>();
- URL source = model.getJarSource().toURI().toURL();
+ JarI18nProject project = (JarI18nProject) model.getProject();
+ URL source = project.getJarSource().toURI().toURL();
URLClassLoader loader = new URLClassLoader(new URL[]{source});
log.info("jar source : " + source);
- if (model.isUniqueJarDefinition()) {
+ if (project.isUniqueJarDefinition()) {
// on recherche l'unique bundle dans META-INF/
List<URL> defs = Resource.getURLs("META-INF/.*-i18n-definition\\.properties", loader);
log.info("detected unique bundle definition " + defs);
@@ -125,7 +149,8 @@
@Override
public boolean validateUIModel(ProjectUIModel model) {
- return model.getJarSource() != null && model.getJarSource().exists() && model.getProjectName() != null && !model.getProjectName().isEmpty();
+ JarI18nProject project = (JarI18nProject) model.getProject();
+ return project.getJarSource() != null && project.getJarSource().exists() && project.getName() != null && !project.getName().isEmpty();
}
@Override
@@ -135,14 +160,14 @@
if (!properties.containsKey(CLASS_PARAMETER)) {
throw new IllegalStateException("could not find property " + CLASS_PARAMETER);
}
- if (!properties.containsKey(NAME_PARAMETER)) {
- throw new IllegalStateException("could not find property " + NAME_PARAMETER);
+ if (!properties.containsKey(JarI18nProject.NAME_PROPERTY_NAME)) {
+ throw new IllegalStateException("could not find property " + JarI18nProject.NAME_PROPERTY_NAME);
}
- if (!properties.containsKey(URLS_PARAMETER)) {
- throw new IllegalStateException("could not find property " + URLS_PARAMETER);
+ if (!properties.containsKey(JarI18nProject.URLS_PROPERTY_NAME)) {
+ throw new IllegalStateException("could not find property " + JarI18nProject.URLS_PROPERTY_NAME);
}
// verifie que les urls existent
- String tmp = properties.getProperty(URLS_PARAMETER);
+ String tmp = properties.getProperty(JarI18nProject.URLS_PROPERTY_NAME);
String[] urlsStr = tmp.split(",");
for (String u : urlsStr) {
int lastIndex = u.lastIndexOf("/");
@@ -155,7 +180,7 @@
}
@Override
- public Class<? extends I18nProjectConfigurePanelUI> getUIClass() {
+ public Class<? extends I18nProjectConfigurePanelUI<?>> getUIClass() {
return JarI18nProjectConfigurePanelUI.class;
}
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -98,7 +98,6 @@
openProjectUI(ui, project);
}
-
return ui;
}
@@ -492,7 +491,7 @@
I18nEditorConfig.Option.CONFIG_FILE,
I18nEditorConfig.Option.PROJECTS_DIRECTORY,
I18nEditorConfig.Option.TMP_DIRECTORY);
-
+
model.addCategory(
n_("i18neditor.config.category.ui"),
n_("i18neditor.config.category.ui.description"),
@@ -624,13 +623,13 @@
ProjectUIModel model = ui.getModel();
I18nProject project = null;
- I18nProjectProvider<? extends I18nProject> type = model.getType();
+ I18nProjectProvider<?> type = model.getType();
project = I18nProjectFactory.newProject(type.getType(), model);
- rootContext.getContextValue(I18nEditorConfig.class).getProjects().add(model.getProjectName());
+ rootContext.getContextValue(I18nEditorConfig.class).getProjects().add(project.getName());
try {
- if (model.isStoreProject()) {
+ if (project.isStoreProject()) {
// on enregistre le projet
- project.storeDefinition();
+ project.saveDefinition();
}
project.load();
I18nEditorContext.PROJECT_DEF.setContextValue(rootContext, project);
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -145,13 +145,14 @@
SELECT_BUNDLES.getBundlesModel().setUrls(model.detectBundles());
return;
}
- if (newStep == ProjectStep.PERSIST) {
+ //if (newStep == ProjectStep.PERSIST) {
// positionnement de fichier de sauvegarde
- if (model.isStoreProject()) {
- model.setStoreFile(new java.io.File(config.getProjectsDirectory(), model.getProjectName() + ".i18nproject"));
- }
- return;
- }
+ //TODO depend du statut du model (create or update)
+ //if (model.getProject().isStoreProject()) {
+ // model.getProject().setStoreFile(new java.io.File(config.getProjectsDirectory(), model.getProject().getName() + ".i18nproject"));
+ //}
+ //return;
+ //}
}
@Override
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -19,18 +19,24 @@
package org.nuiton.i18n.editor.ui.project;
import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.wizard.WizardModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.i18n.editor.I18nEditorConfig;
import org.nuiton.i18n.editor.project.I18nProject;
+import org.nuiton.i18n.editor.project.I18nProjectFactory;
import org.nuiton.i18n.editor.project.I18nProjectProvider;
import org.nuiton.util.FileUtil;
@@ -43,63 +49,53 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(ProjectUIModel.class);
- public static final String PROJECT_NAME_PROPERTY_NAME = "projectName";
public static final String TYPE_PROPERTY_NAME = "type";
- public static final String JAR_SOURCE_PROPERTY_NAME = "jarSource";
- public static final String DIRECTORY_SOURCE_PROPERTY_NAME = "directorySource";
- public static final String SELECTED_BUNDLES_PROPERTY_NAME = "selectedBundles";
- public static final String UNIQUE_JAR_DEFINITION_PROPERTY_NAME = "uniqueJarDefinition";
- public static final String STORE_FILE_PROPERTY_NAME = "storeFile";
- public static final String STORE_PROJECT_PROPERTY_NAME = "storeProject";
+ public static final String PROJECT_PROPERTY_NAME = "project";
+// public static final String PROJECT_NAME_PROPERTY_NAME = "projectName";
+// public static final String JAR_SOURCE_PROPERTY_NAME = "jarSource";
+// public static final String DIRECTORY_SOURCE_PROPERTY_NAME = "directorySource";
+// public static final String SELECTED_BUNDLES_PROPERTY_NAME = "selectedBundles";
+// public static final String UNIQUE_JAR_DEFINITION_PROPERTY_NAME = "uniqueJarDefinition";
+// public static final String STORE_FILE_PROPERTY_NAME = "storeFile";
+// public static final String STORE_PROJECT_PROPERTY_NAME = "storeProject";
public static final String VALID_PROPERTY_NAME = "valid";
- /**
- * Le type de projet
- */
- protected I18nProjectProvider<? extends I18nProject> type;
- /**
- * le nom du projet
- */
- protected String projectName;
- /**
- * la source pour un projet de type jar
- */
- protected File jarSource = new File("");
- /**
- * la source pour un projet de type directory
- */
- protected File directorySource = new File("");
- /**
- * un drapeau (pour les projets de type jar) pour savoir si on utilise le
- * système i18n avec nom unique.
- */
- protected boolean uniqueJarDefinition;
- /**
- * la configuration de l'application
- */
+ /** le dictionnaire des differents projects possible indexes par leur provideur */
+ protected Map<I18nProjectProvider<?>, I18nProject> projects;
+ /** Le provideur du projet en cours d'edition */
+ protected I18nProjectProvider<?> type;
+ /** le projet en cours d'edition */
+ protected I18nProject project;
+ /** la configuration de l'application */
protected I18nEditorConfig config;
- /**
- * le fichier ou persister le projet (si null pas persiste)
- */
- protected File storeFile = new File("");
- /**
- * un drapeau pour savoir si on persiste le projet
- */
- protected boolean storeProject = true;
- /**
- * les etapes a exclure
- */
- protected List<ProjectStep> excludeSteps;
- /**
- * les bundles selectionnes
- */
- protected List<URL> selectedBundles = new ArrayList<URL>();
+ /** un drapeau pour savoir si on est en mode creation ou pas */
+ protected boolean create;
public ProjectUIModel() {
super(ProjectStep.class,
ProjectStep.CHOOSE_PROJECT_TYPE,
ProjectStep.CONFIGURE_PROJECT,
ProjectStep.SELECT_BUNDLES,
+ ProjectStep.PERSIST,
ProjectStep.RESUME);
+ this.projects = new HashMap<I18nProjectProvider<?>, I18nProject>();
+ // init map of different types of projects
+ Set<I18nProjectProvider<?>> providers = I18nProjectFactory.getProviders();
+ for (I18nProjectProvider<?> p : providers) {
+ I18nProject newProject = p.newProject();
+ this.projects.put(p, newProject);
+ // the model listens every modification of each project
+ // and at each time revalidate the model
+ newProject.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ validate();
+ }
+ });
+ }
+ if (!providers.isEmpty()) {
+ setType(providers.iterator().next());
+ }
}
/**
@@ -109,20 +105,21 @@
*/
public void init(JAXXContext context) {
- ProjectUIModel incomingModel = context.getContextValue(ProjectUIModel.class, "incoming");
-
config = context.getContextValue(I18nEditorConfig.class);
- if (incomingModel != null) {
+ //TODO instead of seeking an ui model, must seek fro an incoming project...
+ I18nProject incomingProject = context.getContextValue(I18nProject.class, "incoming");
+ setCreate(incomingProject==null);
+
+ if (incomingProject != null) {
+
if (log.isDebugEnabled()) {
- log.debug("from a incoming model " + incomingModel);
+ log.debug("from a incoming project " + incomingProject);
}
-
- // on initialie a partir d'un autre modèle
- incomingModel.copyTo(this);
-
- return;
+ I18nProjectProvider<?> provider = I18nProjectFactory.getProvider(incomingProject.getClass());
+ setType(provider);
+ incomingProject.copyDefinitionTo(project);
}
}
@@ -130,12 +127,12 @@
public void start() {
super.start();
firePropertyChange(TYPE_PROPERTY_NAME, null, type);
- firePropertyChange(PROJECT_NAME_PROPERTY_NAME, null, projectName);
- firePropertyChange(JAR_SOURCE_PROPERTY_NAME, null, jarSource);
- firePropertyChange(DIRECTORY_SOURCE_PROPERTY_NAME, null, directorySource);
- firePropertyChange(SELECTED_BUNDLES_PROPERTY_NAME, null, selectedBundles);
- firePropertyChange(STORE_PROJECT_PROPERTY_NAME, null, storeProject);
- firePropertyChange(STORE_FILE_PROPERTY_NAME, null, storeFile);
+ firePropertyChange(PROJECT_PROPERTY_NAME, null, project);
+// if (type != null && project != null) {
+// // ask to provider to fire every thing on the project ?
+// //TODO no! the project fire will do it in each specicialized project's ui
+// project.fireAllProperties();
+// }
}
@Override
@@ -169,112 +166,62 @@
validate = type.validateUIModel(this);
break;
case SELECT_BUNDLES:
- validate = !selectedBundles.isEmpty();
+ validate = !project.getUrls().isEmpty();
break;
case PERSIST:
- validate = !storeProject || (storeFile != null && !storeFile.exists());
+ boolean storeProject = project.isStoreProject();
+ if (storeProject) {
+ File storeFile = project.getStoreFile();
+ if (create) {
+ validate = storeFile != null && !storeFile.exists();
+ } else {
+ validate = storeFile != null && storeFile.exists();
+ }
+ }
break;
case RESUME:
- validate = true;
+// validate = true;
break;
}
}
return validate;
}
- public I18nProjectProvider<? extends I18nProject> getType() {
+ public I18nProjectProvider<?> getType() {
return type;
}
- public String getProjectName() {
- return projectName;
+ public I18nProject getProject() {
+ return project;
}
- public File getDirectorySource() {
- return directorySource;
+ public <T extends I18nProject> T getProject(Class<T> projectClass) {
+ I18nProjectProvider<T> projectType = I18nProjectFactory.getProvider(projectClass);
+ if (!projects.containsKey(projectType)) {
+ throw new IllegalArgumentException(projectType + " is not a registred type");
+ }
+ return (T) projects.get(projectType);
}
- public File getJarSource() {
- return jarSource;
+ public boolean isCreate() {
+ return create;
}
- public List<URL> getSelectedBundles() {
- return selectedBundles;
+ public void setCreate(boolean create) {
+ this.create = create;
}
- public boolean isUniqueJarDefinition() {
- return uniqueJarDefinition;
- }
-
- public boolean isStoreProject() {
- return storeProject;
- }
-
- public File getStoreFile() {
- return storeFile;
- }
-
- public void setType(I18nProjectProvider<? extends I18nProject> type) {
- I18nProjectProvider<?> oldValue = this.type;
+ public void setType(I18nProjectProvider<?> type) {
+ I18nProjectProvider<?> oldType = this.type;
this.type = type;
- firePropertyChange(TYPE_PROPERTY_NAME, oldValue, type);
- if (oldValue != type) {
- updateUniverse();
- }
+ firePropertyChange(TYPE_PROPERTY_NAME, oldType, type);
+ I18nProject oldProject = this.project;
+ I18nProject newProject = projects.get(type);
+ this.project = newProject;
+ firePropertyChange(PROJECT_PROPERTY_NAME, oldProject, newProject);
validate();
}
- public void setDirectorySource(File directorySource) {
- File oldValue = this.directorySource;
- this.directorySource = directorySource;
- firePropertyChange(DIRECTORY_SOURCE_PROPERTY_NAME, oldValue, directorySource);
- validate();
- }
-
- public void setJarSource(File jarSource) {
- File oldValue = this.jarSource;
- this.jarSource = jarSource;
- firePropertyChange(JAR_SOURCE_PROPERTY_NAME, oldValue, jarSource);
- validate();
- }
-
- public void setProjectName(String projectName) {
- String oldValue = this.projectName;
- this.projectName = projectName;
- firePropertyChange(PROJECT_NAME_PROPERTY_NAME, oldValue, projectName);
- validate();
- }
-
- public void setUniqueJarDefinition(boolean uniqueJarDefinition) {
- boolean oldValue = this.uniqueJarDefinition;
- this.uniqueJarDefinition = uniqueJarDefinition;
- firePropertyChange(UNIQUE_JAR_DEFINITION_PROPERTY_NAME, oldValue, uniqueJarDefinition);
- validate();
- }
-
- public void setSelectedBundles(List<URL> selectedBundles) {
-// List<URL> oldValues = this.selectedBundles;
- this.selectedBundles = selectedBundles;
- firePropertyChange(SELECTED_BUNDLES_PROPERTY_NAME, null, selectedBundles);
- validate();
- }
-
- public void setStoreProject(boolean storeProject) {
- boolean oldValue = this.storeProject;
- this.storeProject = storeProject;
- firePropertyChange(STORE_PROJECT_PROPERTY_NAME, oldValue, storeProject);
- }
-
- public void setStoreFile(File storeFile) {
- File oldValue = this.storeFile;
- this.storeFile = storeFile;
- firePropertyChange(STORE_FILE_PROPERTY_NAME, oldValue, storeFile);
- }
-
- public void setExcludeSteps(List<ProjectStep> excludeSteps) {
- this.excludeSteps = excludeSteps;
- }
-
/**
* Choisir un fichier via un sélecteur graphique de fichiers.
*
@@ -355,10 +302,4 @@
}
return urls;
}
-
- protected void copyTo(ProjectUIModel dst) {
- dst.setType(getType());
- dst.setJarSource(getJarSource());
- dst.setDirectorySource(getDirectorySource());
- }
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -27,10 +27,28 @@
import jaxx.runtime.SwingUtil;
import org.nuiton.i18n.editor.*;
+import org.nuiton.i18n.editor.project.I18nProject;
+import org.nuiton.i18n.editor.project.AbstractI18nProject;
import org.nuiton.i18n.editor.ui.project.*;
import java.io.File;
+protected final I18nEditorConfig config = getContextValue(I18nEditorConfig.class);
+
+protected final PropertyChangeListener storeProjectPropertyChangeListener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ Boolean oldValue = (Boolean) evt.getOldValue();
+ Boolean newValue = (Boolean) evt.getNewValue();
+ if (newValue != null && newValue) {
+ if (getProject().getStoreFile() == null || getProject().getStoreFile().getParentFile() == null) {
+ getProject().setStoreFile(new File(config.getProjectsDirectory(), model.getProject().getName() + ".i18nproject"));
+ }
+ }
+ }
+};
+
public void chooseProjectDirectory() {
File f = model.chooseDirectory (
this,
@@ -40,15 +58,62 @@
changeDirectory(f);
}
+public I18nProject getProject() {
+ return model.getProject();
+}
+
protected void changeDirectory(File f) {
- model.setStoreFile(new File(f, model.getProjectName() + ".i18nproject"));
+ getProject().setStoreFile(new File(f, getProject().getName() + ".i18nproject"));
}
void $afterCompleteSetup() {
if (getStep()!=null) {
setDescriptionText(_(getStep().getDescription()));
}
+ model.addPropertyChangeListener(ProjectUIModel.PROJECT_PROPERTY_NAME, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ I18nProject oldProject = (I18nProject) evt.getOldValue();
+ if (oldProject!=null) {
+ oldProject.removePropertyChangeListener(AbstractI18nProject.STORE_PROJECT_PROPERTY_NAME, storeProjectPropertyChangeListener);
+ }
+ I18nProject newProject = (I18nProject) evt.getNewValue();
+ if (newProject!=null) {
+ newProject.addPropertyChangeListener(AbstractI18nProject.STORE_PROJECT_PROPERTY_NAME, storeProjectPropertyChangeListener);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("update binding for changed project " + newProject);
+ }
+ SwingUtil.applyDataBinding(PersistPanelUI.this,
+ "storeProject.selected",
+ "storeFilePanel.visible",
+ "directoryText.text",
+ "storeFilePath.text");
+ }
+ });
}
+
+@Override
+public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ for (PropertyChangeListener l : getPropertyChangeListeners(propertyName)) {
+ if (l == listener) {
+ // already registred listener
+ if (log.isDebugEnabled()) {
+ log.debug("already registred listener for property " + propertyName + " : " + listener);
+ }
+ return;
+ }
+ }
+ super.addPropertyChangeListener(propertyName, listener);
+}
+
+protected String getStoreDirectory(File storeFile) {
+ if (storeFile == null || storeFile.getParentFile() == null) {
+ return "";
+ }
+ return storeFile.getParentFile().getAbsolutePath();
+}
]]>
</script>
@@ -57,14 +122,16 @@
<JPanel constraints='BorderLayout.NORTH'
layout='{new BorderLayout()}'
border='{BorderFactory.createTitledBorder("")}'>
- <JCheckBox constraints='BorderLayout.CENTER'
+ <JCheckBox id='storeProject'
+ constraints='BorderLayout.CENTER'
text='i18neditor.createproject.doPersist'
- selected='{model.isStoreProject()}'
- onStateChanged='getModel().setStoreProject(((JCheckBox)event.getSource()).isSelected())'/>
+ selected='{getProject().isStoreProject()}'
+ onStateChanged='getProject().setStoreProject(((JCheckBox)event.getSource()).isSelected())'/>
</JPanel>
- <Table constraints='BorderLayout.CENTER'
- visible='{model.isStoreProject()}'>
+ <Table id='storeFilePanel'
+ constraints='BorderLayout.CENTER'
+ visible='{getProject().isStoreProject()}'>
<row>
<cell weightx='1' fill="both">
<Table fill='both'>
@@ -76,26 +143,27 @@
<row>
<cell weightx='1' fill="horizontal">
<JTextField id='directoryText'
- text='{model.getStoreFile().getParent()+ ""}'
- visible='{model.isStoreProject()}'
+ text='{getStoreDirectory(getProject().getStoreFile())}'
onKeyReleased='changeDirectory(new File(((JTextField)event.getSource()).getText()))'/>
+ <!--visible='{model.getProject().isStoreProject()}'-->
</cell>
<cell anchor="east">
<JButton actionIcon='fileChooser'
- visible='{model.isStoreProject()}'
onActionPerformed="chooseProjectDirectory()"/>
+ <!--visible='{model.getProject().isStoreProject()}'-->
</cell>
</row>
<row>
<cell columns='2'>
- <JLabel text='i18neditor.createproject.storeProject.path'
- visible='{model.isStoreProject()}'/>
+ <JLabel text='i18neditor.createproject.storeProject.path'/>
+ <!--visible='{model.getProject().isStoreProject()}'/>-->
</cell>
</row>
<row>
<cell columns='2'>
- <JLabel text='{model.getStoreFile() + ""}'
- visible='{model.isStoreProject()}'/>
+ <JLabel id='storeFilePath'
+ text='{getProject().getStoreFile() + ""}'/>
+ <!--visible='{model.getProject().isStoreProject()}'/>-->
</cell>
</row>
</Table>
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -38,9 +38,8 @@
]]>
</script>
- <!-- le modèles des activités dont on a pu calculé un point gps -->
<SelectBundlesTableModel id='bundlesModel'
- onTableChanged='model.setSelectedBundles(bundlesModel.getUrls())'/>
+ onTableChanged='model.getProject().setUrls(bundlesModel.getUrls())'/>
<Table id='content' constraints='BorderLayout.CENTER' fill='both' weightx='1' weighty='1'>
<row>
1
0
[Lutinutil-commits] r1648 - in trunk/nuiton-i18n-editor: . src/main/java/org/nuiton/i18n/editor src/main/java/org/nuiton/i18n/editor/ui src/main/java/org/nuiton/i18n/editor/ui/project src/main/resources src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: tchemit
Date: 2009-07-27 22:29:29 +0200 (Mon, 27 Jul 2009)
New Revision: 1648
Modified:
trunk/nuiton-i18n-editor/pom.xml
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css
trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties
trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties
trunk/nuiton-i18n-editor/src/main/resources/log4j.properties
Log:
add config ui and configure action
Modified: trunk/nuiton-i18n-editor/pom.xml
===================================================================
--- trunk/nuiton-i18n-editor/pom.xml 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/pom.xml 2009-07-27 20:29:29 UTC (rev 1648)
@@ -73,8 +73,8 @@
<!-- main class in jar -->
<maven.jar.main.class>org.nuiton.i18n.editor.I18nEditor</maven.jar.main.class>
- <jaxx.version>1.7.0</jaxx.version>
- <lutinutil.version>1.1.0-rc-8</lutinutil.version>
+ <jaxx.version>1.7.1-SNAPSHOT</jaxx.version>
+ <lutinutil.version>1.1.0-rc-9-SNAPSHOT</lutinutil.version>
<!-- default license to use -->
<license.licenseName>gpl_v3</license.licenseName>
@@ -156,6 +156,7 @@
<artifactId>maven-i18n-plugin</artifactId>
<version>${project.version}</version>
<configuration>
+ <silent>true</silent>
<entries>
<entry>
<basedir>${maven.gen.dir}/java/</basedir>
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java 2009-07-27 20:29:29 UTC (rev 1648)
@@ -176,6 +176,17 @@
disableMainUI();
}
+ public void configure() {
+ if (log.isDebugEnabled()) {
+ log.debug(this);
+ }
+ I18nEditorContext context = I18nEditorContext.get();
+ I18nEditorConfig config = context.getConfig();
+ I18nEditorUIHandler handler = context.getContextValue(I18nEditorUIHandler.class);
+ handler.showConfig(context);
+ config.setDisplayMainUI(false);
+ }
+
/**
* Désactiver la possiblite de lancer l'ui principale.
*/
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java 2009-07-27 20:29:29 UTC (rev 1648)
@@ -261,24 +261,60 @@
//////////////////////////////////////////////////
// Toutes les options disponibles
//////////////////////////////////////////////////
- protected static enum Option {
+ public static enum Option implements OptionDef {
- CONFIG_FILE(CONFIG_FILE_NAME, _("i18neditor.config.configFileName.description"), "nuitoni18neditor-config"),
+ CONFIG_FILE(CONFIG_FILE_NAME, _("i18neditor.config.configFileName.description"), "nuitoni18neditor-config", String.class, true, true),
// directories
- TMP_DIRECTORY("tmp.directory", _("i18neditor.config.defaultTmpDirectory.description"), getUserDirectory() + File.separator + "tmp"),
- PROJECTS_DIRECTORY("projects.directory", _("i18neditor.config.defaultProjectsDirectory.description"), getUserDirectory() + File.separator + "projects"),
+ TMP_DIRECTORY("tmp.directory", _("i18neditor.config.defaultTmpDirectory.description"), getUserDirectory() + File.separator + "tmp", File.class, false, false),
+ PROJECTS_DIRECTORY("projects.directory", _("i18neditor.config.defaultProjectsDirectory.description"), getUserDirectory() + File.separator + "projects", File.class, false, false),
// ui config
- FULL_SCREEN("ui.fullscreen", _("i18neditor.config.ui.fullscreen"), "false"),
- LOCALE("ui.locale", _("i18neditor.config.ui.locale"), Locale.FRANCE.toString());
+ FULL_SCREEN("ui.fullscreen", _("i18neditor.config.ui.fullscreen"), "false", Boolean.class, false, false),
+ LOCALE("ui.locale", _("i18neditor.config.ui.locale"), Locale.FRANCE.toString(), Locale.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) {
+ 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;
+ }
}
public static enum Step {
@@ -289,6 +325,7 @@
public static enum Action {
HELP(_("i18neditor.action.commandline.help"), I18nEditor.class.getName() + "#help", "-h", "--help"),
+ CONFIGURE(_("i18neditor.action.commandline.configure"), I18nEditor.class.getName() + "#configure", "-c", "--configure"),
NO_MAIN_UI(_("i18neditor.action.commandline.disable.main.ui"), I18nEditor.class.getName() + "#disableMainUI", "-n", "--no-main");
public String description;
public String action;
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css 2009-07-27 20:29:29 UTC (rev 1648)
@@ -49,7 +49,6 @@
text:"i18neditor.action.configuration";
toolTipText:"i18neditor.action.configuration.tip";
actionIcon:"config";
- enabled:false;
mnemonic:C;
_help:{"ui.main.menu.file.configuration"};
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
@@ -221,7 +221,7 @@
</script>
<JMenuBar>
<JMenu id='menuFile'>
- <JMenuItem id='menuFileConfiguration' onActionPerformed="handler.showConfig()"/>
+ <JMenuItem id='menuFileConfiguration' onActionPerformed="handler.showConfig(context)"/>
<JMenuItem id="menuFileCreateProject" onActionPerformed="handler.createProject(context)"/>
<JMenu id="menuFileOpenProject">
<JMenuItem id="menuFileOpenProjectOther"
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-27 20:29:29 UTC (rev 1648)
@@ -46,6 +46,9 @@
import jaxx.runtime.DefaultApplicationContext.AutoLoad;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.AboutPanel;
+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.wizard.WizardUILancher;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -57,6 +60,7 @@
import org.nuiton.i18n.editor.ui.project.ProjectUI;
import org.nuiton.i18n.editor.ui.project.ProjectUIModel;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
*
@@ -478,7 +482,27 @@
// }
}
- public void showConfig() {
+ public void showConfig(I18nEditorContext context) {
+ I18nEditorUI ui = getUI(context);
+
+ ConfigUIModel model = new ConfigUIModel(context.getConfig());
+ model.addCategory(
+ n_("i18neditor.config.category.directories"),
+ n_("i18neditor.config.category.directories.description"),
+ I18nEditorConfig.Option.CONFIG_FILE,
+ I18nEditorConfig.Option.PROJECTS_DIRECTORY,
+ I18nEditorConfig.Option.TMP_DIRECTORY);
+
+ model.addCategory(
+ n_("i18neditor.config.category.ui"),
+ n_("i18neditor.config.category.ui.description"),
+ I18nEditorConfig.Option.FULL_SCREEN,
+ I18nEditorConfig.Option.LOCALE);
+
+ ConfigUI configUI = ConfigUIBuilder.newConfigUI(context, model, "i18neditor.config.category.ui");
+
+ ConfigUIBuilder.showConfigUI(configUI, ui, false);
+// configUI.showInDialog(ui, ui != null);
}
public void showHelp(JAXXContext context, String helpId) {
@@ -592,7 +616,6 @@
if (!providers.isEmpty()) {
model.setType(providers.iterator().next());
}
-// ui.setTitle(("observe.title.import.localDB"));
}
@Override
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css 2009-07-27 20:29:29 UTC (rev 1648)
@@ -18,7 +18,7 @@
*/
#mainUI {
- title:"i18neditor.title.create.project";
+ title:"i18neditor.title.noproject";
modal:true;
resizable:false;
defaultCloseOperation:"dispose_on_close";
Modified: trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties 2009-07-27 20:29:29 UTC (rev 1648)
@@ -12,6 +12,7 @@
i18neditor.action.choose.project.description=
i18neditor.action.choose.projectDir=
i18neditor.action.closeProject=Close the project
+i18neditor.action.commandline.configure=Configure the application
i18neditor.action.commandline.disable.main.ui=Do not launch main ui
i18neditor.action.commandline.help=Show this help
i18neditor.action.configuration=Preferences
@@ -45,6 +46,10 @@
i18neditor.choose.project.to.delete=
i18neditor.common.descrition=
i18neditor.common.resume=Resume
+i18neditor.config.category.directories=Directories
+i18neditor.config.category.directories.description=Directories used by the application
+i18neditor.config.category.ui=Application
+i18neditor.config.category.ui.description=Other options used by the application
i18neditor.config.configFileName.description=configuration file
i18neditor.config.defaultProjectsDirectory.description=default directory where to store project definitions (*.i18nproject)
i18neditor.config.defaultTmpDirectory.description=tempory directory used by the application
@@ -108,7 +113,6 @@
i18neditor.title.choose.jar.source=
i18neditor.title.choose.project=
i18neditor.title.choose.projectDir=
-i18neditor.title.create.project=Create a new project
i18neditor.title.noproject=Nuiton i18n editor < no project loaded >
i18neditor.title.project.info=Project's informations
i18neditor.warning.nimbus.landf=Could not find nymbus look and feel, please use at least a 1.6u10 version of sun jre
Modified: trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties 2009-07-27 20:29:29 UTC (rev 1648)
@@ -12,6 +12,7 @@
i18neditor.action.choose.project.description=Fichier de d\u00E9finition de project (*.i18nproject)
i18neditor.action.choose.projectDir=Choisir ce r\u00E9pertoire
i18neditor.action.closeProject=Fermer le projet
+i18neditor.action.commandline.configure=Configurer l'application
i18neditor.action.commandline.disable.main.ui=Ne pas lancer l'interface graphique principale
i18neditor.action.commandline.help=Voir l'aide
i18neditor.action.configuration=Pr\u00E9f\u00E9rences
@@ -41,11 +42,14 @@
i18neditor.action.showHelp.tip=Voir l'aide contextuelle
i18neditor.action.site=Site
i18neditor.action.site.tip=Acc\u00E9der au site du projet
-i18neditor.title.create.project=Cr\u00E9er un nouveau projet
i18neditor.bundle.name=Localisation \: %1$s
i18neditor.choose.project.to.delete=Choisir le projet \u00E0 supprimer
i18neditor.common.descrition=Description
i18neditor.common.resume=R\u00E9sum\u00E9
+i18neditor.config.category.directories=R\u00E9pertoires
+i18neditor.config.category.directories.description=Les r\u00E9pertoires utilis\u00E9es par l'application
+i18neditor.config.category.ui=Application
+i18neditor.config.category.ui.description=Les autres options de l'application
i18neditor.config.configFileName.description=Le nom du fichier de configuration
i18neditor.config.defaultProjectsDirectory.description=Le r\u00E9pertoire o\u00F9 sont sauvegarder les d\u00E9finitions de projets
i18neditor.config.defaultTmpDirectory.description=Le r\u00E9pertoire temporaire par d\u00E9faut
@@ -67,7 +71,7 @@
i18neditor.createproject.doPersist=Sauver la d\u00E9finition du projet
i18neditor.createproject.jar.source.label=Choisir le jar source
i18neditor.createproject.name.label=Nom du projet
-i18neditor.createproject.no.type=
+i18neditor.createproject.no.type=< Aucune type de projet s\u00E9lectionn\u00E9 >
i18neditor.createproject.storeProject.directory=R\u00E9pertoire de sauvegarde
i18neditor.createproject.storeProject.path=Fichier de sauvegarde
i18neditor.createproject.uniqueJarDefinition=Utilisation d'un bundle final
@@ -109,7 +113,6 @@
i18neditor.title.choose.jar.source=Choisir un fichier de type 'jar'
i18neditor.title.choose.project=Choisir le fichier de d\u00E9finition d'un projet
i18neditor.title.choose.projectDir=Choisir une d\u00E9finition de projet
-i18neditor.title.create.project=
i18neditor.title.noproject=Nuiton i18n editor < aucun projet charg\u00E9 >
i18neditor.title.project.info=Informations sur le projet
i18neditor.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.
Modified: trunk/nuiton-i18n-editor/src/main/resources/log4j.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/resources/log4j.properties 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/resources/log4j.properties 2009-07-27 20:29:29 UTC (rev 1648)
@@ -8,6 +8,7 @@
# package level
log4j.logger.org.nuiton=WARN
log4j.logger.org.nuiton.i18n.editor=INFO
-log4j.logger.org.nuiton.util.Resource=DEBUG
+#log4j.logger.org.nuiton.util.Resource=DEBUG
#log4j.logger.org.nuiton.i18n.editor.I18nEditorConfig=DEBUG
-#log4j.logger.jaxx.runtime.swing.I18nWidget=DEBUG
+log4j.logger.jaxx.runtime.swing.editor.config=DEBUG
+log4j.logger.jaxx.runtime.swing.editor=DEBUG
1
0
[Lutinutil-commits] r1647 - in trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin: . parser parser/impl
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: tchemit
Date: 2009-07-27 22:23:21 +0200 (Mon, 27 Jul 2009)
New Revision: 1647
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java
Log:
add silent parameter to hide all messages
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -108,6 +108,13 @@
*/
protected boolean verbose;
/**
+ * silent flag
+ *
+ * @parameter expression="${i18n.silent}" default-value="false"
+ * @since 1.0.0-rc-5
+ */
+ protected boolean silent;
+ /**
* conserve les anciens fichiers de traduction avec un suffix ~
* <p/>
* Note: par defaut, on ne l'active pas.
@@ -259,7 +266,7 @@
}
getLog().warn(buffer.toString());
} else {
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("bundle " + locale + " is valid (no empty entries).");
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -38,7 +38,6 @@
import org.apache.maven.artifact.resolver.ArtifactCollector;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
-import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.shared.dependency.tree.DependencyNode;
@@ -193,9 +192,11 @@
i18nArtifacts = detectI18nArtifacts();
- getLog().info("detected " + i18nArtifacts.length + " i18n artifact(s) : ");
- for (I18nArtifact a : i18nArtifacts) {
- getLog().info(" - " + a);
+ if (!silent) {
+ getLog().info("detected " + i18nArtifacts.length + " i18n artifact(s) : ");
+ for (I18nArtifact a : i18nArtifacts) {
+ getLog().info(" - " + a);
+ }
}
} catch (Exception ex) {
throw new RuntimeException(ex);
@@ -221,10 +222,11 @@
init();
- getLog().info("config - bundle name : " + bundleOutputName);
- getLog().info("config - baseidr : " + bundleOutputDir);
- getLog().info("config - locales : " + Arrays.toString(locales));
-
+ if (!silent) {
+ getLog().info("config - bundle name : " + bundleOutputName);
+ getLog().info("config - baseidr : " + bundleOutputDir);
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ }
// la locale par defaut est la première
Locale defaultLocale = locales[0];
@@ -238,7 +240,9 @@
File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false);
- getLog().info("generate bundle for locale " + locale);
+ if (!silent) {
+ getLog().info("generate bundle for locale " + locale);
+ }
SortedProperties propertiesOut = new SortedProperties(encoding, false);
StringBuilder buffer = new StringBuilder();
@@ -258,10 +262,12 @@
}
if (buffer.length() > 0) {
bundleDico.put(locale, buffer.substring(1));
- getLog().info("bundles for locale : " + bundleDico.get(locale));
+ if (!silent) {
+ getLog().info("bundles for locale : " + bundleDico.get(locale));
+ }
}
propertiesOut.store(bundleOut);
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")");
}
if (checkBundle) {
@@ -274,7 +280,9 @@
// charger
String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName);
File defOut = new File(bundleOutputDir, f);
- getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
+ if (!silent) {
+ getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
+ }
SortedProperties p = new SortedProperties(encoding, false);
p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles);
for (Entry<Locale, String> e : bundleDico.entrySet()) {
@@ -282,7 +290,7 @@
}
p.store(new FileOutputStream(defOut), null);
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime()));
}
} catch (IOException e) {
@@ -309,12 +317,12 @@
for (Object o : project.getArtifacts()) {
i18nArtifact = new I18nArtifact((Artifact) o);
if (i18nArtifact.detectBundles()) {
- if (getLog().isDebugEnabled()) {
+ if (!silent && getLog().isDebugEnabled()) {
getLog().debug("detected artifact " + i18nArtifact);
}
dico.put(i18nArtifact.getArtifact(), i18nArtifact);
} else {
- if (getLog().isDebugEnabled()) {
+ if (!silent && getLog().isDebugEnabled()) {
getLog().debug("reject artifact " + i18nArtifact);
}
}
@@ -336,7 +344,7 @@
i18nArtifact = new I18nArtifact(projectArtifact, src.getParentFile());
if (i18nArtifact.detectBundles()) {
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("detected artifact " + i18nArtifact);
}
artifacts.add(i18nArtifact.getArtifact());
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -64,12 +64,15 @@
return;
}
- getLog().info("config - src basedir : " + src.getAbsolutePath());
- getLog().info("config - out basedir : " + out.getAbsolutePath());
- getLog().info("config - locales : " + Arrays.toString(locales));
-
+ if (!silent) {
+ getLog().info("config - src basedir : " + src.getAbsolutePath());
+ getLog().info("config - out basedir : " + out.getAbsolutePath());
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ }
for (Locale locale : locales) {
- getLog().info("prepare bundle for locale " + locale);
+ if (!silent) {
+ getLog().info("prepare bundle for locale " + locale);
+ }
try {
// Merge
File bundleSrc = getI18nFile(src, artifactId, locale, false);
@@ -114,7 +117,9 @@
if (genSrc && keepBackup) {
backupFile(bundleSrc);
}
- getLog().info("merge bundle " + locale + " to out");
+ if (!silent) {
+ getLog().info("merge bundle " + locale + " to out");
+ }
if (checkBundle) {
checkBundle(locale, propertiesOut, showEmpty);
@@ -124,7 +129,9 @@
// Copie des fichiers dans les sources
copyFile(bundleOut, bundleSrc);
//if (verbose) {
- getLog().info("copy bundle " + locale + " to src");
+ if (!silent) {
+ getLog().info("copy bundle " + locale + " to src");
+ }
//}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -52,10 +52,11 @@
}
return;
}
+ if (!silent) {
+ getLog().info("config - basedir : " + out.getAbsolutePath());
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ }
- getLog().info("config - basedir : " + out.getAbsolutePath());
- getLog().info("config - locales : " + Arrays.toString(locales));
-
try {
File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
bundleGetters.createNewFile();
@@ -74,17 +75,19 @@
if (genSrc) {
bundleGetter.delete();
}
- getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
+ if (!silent) {
+ getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
+ }
}
// Création des bundles
for (Locale locale : locales) {
- if (getLog().isDebugEnabled()) {
+ if (!silent && getLog().isDebugEnabled()) {
getLog().debug("generate bundle for locale " + locale);
}
File bundleOut = getI18nFile(out, artifactId, locale, false);
copyFile(bundleGetters, bundleOut);
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("generate bundle " + locale);
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -107,7 +107,7 @@
addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding));
}
treadedFiles = new ArrayList<File>();
- if (verbose) {
+ if (!silent && verbose) {
showTouchedFiles = true;
}
}
@@ -126,10 +126,10 @@
return;
}
- if (safeMode) {
+ if (!silent && safeMode) {
getLog().info("config - safeMode is on (could be slower).");
}
- if (strictMode) {
+ if (!silent && strictMode) {
getLog().info("config - strictMode is on (all files will be parsed).");
}
@@ -156,9 +156,13 @@
int i = treadedFiles.size();
if (fileTreated == 0) {
- getLog().info("Nothing to generate - all files are up to date.");
+ if (!silent) {
+ getLog().info("Nothing to generate - all files are up to date.");
+ }
} else {
- getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
+ if (!silent) {
+ getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
+ }
addGetter();
}
@@ -188,7 +192,7 @@
boolean skip = entry.init(this);
if (skip) {
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("skip - " + entry.getSkipMessage());
}
continue;
@@ -196,14 +200,14 @@
long t000 = System.nanoTime();
int nbFiles = entry.getFiles().length;
- if (verbose) {
+ if (!silent && verbose) {
vLog.infoEntry("start", vLog.getLogEntry("[incoming file(s) : " + entry.getFoudFiles() + "]", 0, 0, 0));
}
// launch parser for found files
parseEntry(entry);
- if (verbose) {
+ if (!silent && verbose) {
// log skipped files
for (String skipFile : entry.getSkipFiles()) {
vLog.setFile(new File(entry.getBasedir(), skipFile));
@@ -211,7 +215,7 @@
}
}
fileTreated += nbFiles;
- if (verbose) {
+ if (!silent && verbose) {
vLog.infoEntry("end", vLog.getLogEntry("[treated file(s) : " + nbFiles + "]", nbFiles, t000, t00));
}
t00 = System.nanoTime();
@@ -258,7 +262,7 @@
touchFile = false;
int size = result.size();
- if (verbose) {
+ if (!silent && verbose) {
vLog.infoFile("parse", null);
}
parseFile(file);
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -30,7 +30,10 @@
* @author julien
* @goal parserJaxx
* @phase generate-resources
+ * @deprecated since 1.0.0, prefer use the java parser since xml parser can not
+ * be easly extendable
*/
+@Deprecated
public class ParserJaxx extends ParserXml {
/**
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -27,7 +27,9 @@
* @author julien
* @goal parserSwixat
* @phase generate-resources
+ * @deprecated since 1.0.0 : swixat is dead...
*/
+@Deprecated
public class ParserSwixat extends ParserXml {
/**
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -176,7 +176,7 @@
// load core rules
readInputStream = loadRulesFile(getCoreFileRules());
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("core rules : " + getCoreFileRules());
}
buffer.append(readInputStream);
@@ -184,7 +184,7 @@
if (!fileRules.equals(getCoreFileRules())) {
// add custom rules
readInputStream = loadRulesFile(fileRules);
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("custom rules : " + fileRules);
}
buffer.append(" | ").append(readInputStream);
1
0
[Lutinutil-commits] r1670 - trunk/src/main/java/org/nuiton/util
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: tchemit
Date: 2009-07-27 22:19:48 +0200 (Mon, 27 Jul 2009)
New Revision: 1670
Modified:
trunk/src/main/java/org/nuiton/util/ApplicationConfig.java
Log:
add OptionDef contract to have more infos in ApplicationConfg options, should add more infos (perharps via an annotation ?)
Modified: trunk/src/main/java/org/nuiton/util/ApplicationConfig.java
===================================================================
--- trunk/src/main/java/org/nuiton/util/ApplicationConfig.java 2009-07-24 14:50:39 UTC (rev 1669)
+++ trunk/src/main/java/org/nuiton/util/ApplicationConfig.java 2009-07-27 20:19:48 UTC (rev 1670)
@@ -294,6 +294,48 @@
/** suport of config modification */
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ /**
+ * Le contrat de marquage des options, on utilise cette interface pour
+ * caracteriser une option de configuration.
+ *
+ * @since 1.0.0-rc-9
+ */
+ static public interface OptionDef {
+
+ /**
+ * @return la clef identifiant l'option
+ */
+ String getKey();
+
+ /**
+ * @return le type de l'option
+ */
+ Class<?> getType();
+
+ /**
+ * @return la clef i18n de description de l'option
+ */
+ String getDescription();
+
+ /**
+ * @return la valeur par defaut de l'option sous forme de chaine de
+ * caracteres
+ */
+ String getDefaultValue();
+
+ /**
+ * @return <code>true</code> si l'option ne peut etre sauvegardee sur
+ * disque (utile par exemple pour les mots de passe, ...)
+ */
+ boolean isTransient();
+
+ /**
+ * @return <code>true</code> si l'option n'est pas modifiable (utilise
+ * par exemple pour la version de l'application, ...)
+ */
+ boolean isFinal();
+ }
+
static public class Action {
@Retention(RetentionPolicy.RUNTIME)
@@ -555,6 +597,17 @@
}
/**
+ * get option value from a option definition
+ *
+ * @param key the definition of the option
+ * @return the value for the given option
+ */
+ public Object getOption(OptionDef key) {
+ Object result = getOption(key.getType(), key.getKey());
+ return result;
+ }
+
+ /**
* get option value as typed value
*
* @param <T> type of the object wanted as return type
1
0