Author: tchemit Date: 2008-08-15 13:21:23 +0000 (Fri, 15 Aug 2008) New Revision: 1022 Added: trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/I18nEditor.java Modified: trunk/lutini18neditor/pom.xml trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/ManagerI18n.java trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/ui/I18nPrincipalImpl.java Log: creation d'une classe Main + creation du jar executable. fix bug si pas de bundle trouve utilisation I18nBundleManager pour recuperer les bundles trouves possibilite d'ajouter un jar a traiter Modified: trunk/lutini18neditor/pom.xml =================================================================== --- trunk/lutini18neditor/pom.xml 2008-08-15 13:14:01 UTC (rev 1021) +++ trunk/lutini18neditor/pom.xml 2008-08-15 13:21:23 UTC (rev 1022) @@ -66,7 +66,7 @@ <!-- BE WARE, this value must rewritten here since it will be otherwise suffixed by inheritance --> <maven.scm.url>https://${labs.host}/plugins/scmsvn/viewcvs.php/trunk/${pom.artifactId}?root=${labs.project} </maven.scm.url> - + <maven.jar.main.class>org.codelutin.i18n.editor.I18nEditor</maven.jar.main.class> </properties> <build> @@ -105,6 +105,26 @@ </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <mainClass>${maven.jar.main.class}</mainClass> + <addClasspath>true</addClasspath> + <addExtensions/> + <classpathPrefix>./dependency/</classpathPrefix> + </manifest> + </archive> + </configuration> + </plugin> + </plugins> </build> Added: trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/I18nEditor.java =================================================================== --- trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/I18nEditor.java (rev 0) +++ trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/I18nEditor.java 2008-08-15 13:21:23 UTC (rev 1022) @@ -0,0 +1,51 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.i18n.editor; + +import org.codelutin.i18n.I18n; +import org.codelutin.i18n.editor.ui.I18nPrincipalImpl; +import org.codelutin.util.Resource; + +import java.io.File; +import java.io.IOException; +import java.net.URL; + +/** + * L'application. + * + * @author chemit + */ +public class I18nEditor { + + /** + * Lancement de l'interface + * + * @param args path to manage + * @throws java.io.IOException if any IO exception + */ + public static void main(String[] args) throws IOException { + + for (String arg : args) { + File file = new File(arg); + URL url = new URL(("" + file.toURI().toURL())); + //urls.add(url); + Resource.addClassLoader(I18nEditor.class.getClassLoader(), url); + } + + I18n.init(); // Par défaut pour tester + + new I18nPrincipalImpl().setVisible(true); + } +} Modified: trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/ManagerI18n.java =================================================================== --- trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/ManagerI18n.java 2008-08-15 13:14:01 UTC (rev 1021) +++ trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/ManagerI18n.java 2008-08-15 13:21:23 UTC (rev 1022) @@ -18,8 +18,8 @@ package org.codelutin.i18n.editor; +import org.codelutin.i18n.I18n; import org.codelutin.i18n.I18nFileReader; -import org.codelutin.util.Resource; import java.io.FileWriter; import java.io.IOException; @@ -68,7 +68,11 @@ /** Ensemble des bundles modifiés ou créés par l'utilisateur */ protected Map<String, I18nFileReader> userBundles; - /** Singleton */ + /** + * Singleton + * + * @return the shared instance of manager + */ public static ManagerI18n getInstance() { if (manager == null) { try { @@ -80,14 +84,26 @@ return manager; } - /** Constucteur pour initialiser les bundles disponibles */ + /** + * Constucteur pour initialiser les bundles disponibles + * + * @throws java.io.IOException if any IO problems + */ protected ManagerI18n() throws IOException { bundles = new HashMap<String, I18nFileReader>(); userBundles = new HashMap<String, I18nFileReader>(); // Récupération des fichiers - List<URL> files = Resource.getURLs(".*i18n/.+\\.properties"); + URL[] files = I18n.getBundleManager().getUrls(); + if (files.length==0) { + //fixme : + PROJECT_NAME="unknown ?"; + return; + } + + //List<URL> files = Resource.getURLs(".*i18n/.+\\.properties"); + for (URL file : files) { String path = file.getPath(); I18nFileReader property = new I18nFileReader(); @@ -96,8 +112,10 @@ } // Détermination du nom du projet - List<URL> projects = Resource.getURLs(".*/i18n/.+\\.properties"); - String project = projects.get(0).getPath(); + //URL[] projects = files; + //List<URL> projects = Resource.getURLs(".*/i18n/.+\\.properties"); + //fixme : si pas de project, alors NullPointerException + String project = files[0].getPath(); Matcher matcher = PATTERN_FILE_NAME.matcher(project); matcher.matches(); Modified: trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/ui/I18nPrincipalImpl.java =================================================================== --- trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/ui/I18nPrincipalImpl.java 2008-08-15 13:14:01 UTC (rev 1021) +++ trunk/lutini18neditor/src/main/java/org/codelutin/i18n/editor/ui/I18nPrincipalImpl.java 2008-08-15 13:21:23 UTC (rev 1022) @@ -18,7 +18,6 @@ package org.codelutin.i18n.editor.ui; -import org.codelutin.i18n.I18n; import org.codelutin.i18n.editor.ManagerI18n; import org.codelutin.i18n.editor.model.PropertieNode; import org.codelutin.i18n.editor.model.PropertiesTreeModel; @@ -37,10 +36,8 @@ import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.io.FileNotFoundException; -import java.io.IOException; import java.io.Serializable; import java.util.List; @@ -89,22 +86,11 @@ // A chaque accès à l'arbre, réaffichage des valeurs des bundles pour // la clé sélectionnée - tree.addMouseListener(new MouseListener() { + tree.addMouseListener(new MouseAdapter() { + @Override public void mouseClicked(MouseEvent e) { reloadValues(); } - - public void mouseEntered(MouseEvent e) { - } - - public void mouseExited(MouseEvent e) { - } - - public void mousePressed(MouseEvent e) { - } - - public void mouseReleased(MouseEvent e) { - } }); // Action de fermeture par le menu @@ -272,9 +258,4 @@ values.add(panel, new GBC(0, index).setFill(GBC.HORIZONTAL).setWeight(1, 1).setInsets(10)); } - /** Lancement de l'interface */ - public static void main(String[] args) throws FileNotFoundException, IOException { - I18n.init(); // Par défaut pour tester - new I18nPrincipalImpl().setVisible(true); - } }