Author: tchemit Date: 2009-07-22 19:50:16 +0200 (Wed, 22 Jul 2009) New Revision: 1645 Added: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/ 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/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/ 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/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/JarI18nProjectProvider.java trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertieNode.java trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertiesTreeModel.java trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/TreeModelMode.java trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/I18nProjectConfigurePanelUI.java trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureProjectPanelUI.jaxx trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/DirectoryI18nProjectConfigurePanelUI.jaxx trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/JarI18nProjectConfigurePanelUI.jaxx trunk/nuiton-i18n-editor/src/main/resources/META-INF/ trunk/nuiton-i18n-editor/src/main/resources/META-INF/services/ trunk/nuiton-i18n-editor/src/main/resources/META-INF/services/org.nuiton.i18n.editor.project.I18nProjectProvider Removed: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/model/ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectType.java trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureDirectoryProjectPanelUI.jaxx trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureJarProjectPanelUI.jaxx 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/I18nEditorContext.java trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleCheckBoxMenuUI.jaxx trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValueUI.css trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValueUI.jaxx trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValuesUI.jaxx trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreateBundleUI.css trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreateBundleUI.jaxx trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreatePackageUI.css trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreatePackageUI.jaxx 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/PackageCheckBoxMenuUI.jaxx trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectStep.java 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.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/AbstractProjectTabPanelUI.css trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.jaxx trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ChooseProjectTypePanelUI.jaxx 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/ResumePanelUI.jaxx 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 trunk/nuiton-i18n-editor/src/main/resources/log4j.properties Log: ca avance Modified: trunk/nuiton-i18n-editor/pom.xml =================================================================== --- trunk/nuiton-i18n-editor/pom.xml 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/pom.xml 2009-07-22 17:50:16 UTC (rev 1645) @@ -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-SNAPSHOT</jaxx.version> - <lutinutil.version>1.1.0-rc-8-SNAPSHOT</lutinutil.version> + <jaxx.version>1.7.0</jaxx.version> + <lutinutil.version>1.1.0-rc-8</lutinutil.version> <!-- default license to use --> <license.licenseName>gpl_v3</license.licenseName> @@ -175,6 +175,9 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> + <configuration> + <silent>true</silent> + </configuration> <executions> <execution> <id>copy-dependencies</id> 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,9 +1,9 @@ /** - * *##% Lutin I18n Editor - * Copyright (C) 2008 CodeLutin + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as + * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * @@ -12,9 +12,9 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. * - * You should have received a copy of the GNU General Lesser Public + * You should have received a copy of the GNU General Public * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* */ package org.nuiton.i18n.editor; 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,6 +1,6 @@ /** - * *##% observe-swing - * Copyright (C) 2008 - 2009 IRD + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorContext.java =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorContext.java 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorContext.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,6 +1,6 @@ /** - * *##% observe-swing - * Copyright (C) 2008 - 2009 IRD + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -24,8 +24,8 @@ import jaxx.runtime.JAXXContextEntryDef; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.i18n.editor.model.I18nProject; -import org.nuiton.i18n.editor.model.TreeModelMode; +import org.nuiton.i18n.editor.project.I18nProject; +import org.nuiton.i18n.editor.ui.TreeModelMode; import org.nuiton.i18n.editor.ui.I18nEditorUI; /** Added: 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 (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,402 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.project; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.i18n.bundle.I18nBundle; +import org.nuiton.i18n.bundle.I18nBundleEntry; +import org.nuiton.i18n.bundle.I18nBundleFactory; + +/** + * + * @author chemit + */ +public class AbstractI18nProject implements I18nProject { + + public static final Log log = LogFactory.getLog(AbstractI18nProject.class); + 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 + */ + 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 + */ + 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; + + protected AbstractI18nProject(String name, URL... urls) { + this.name = name; + this.urls = urls; + this.resources = new LinkedHashMap<String, Properties>(); + this.selectedBundles = new ArrayList<Locale>(); + this.selectedPackages = new ArrayList<String>(); + } + + /** + * @return le nom du projet + */ + @Override + public String getName() { + return name; + } + + /** + * @return les paquetages du projet + */ + @Override + public String[] getPackages() { + return I18nBundleFactory.getBundleNames(i18nBundles); + } + + /** + * @return les locales du projet + */ + @Override + public Locale[] getBundles() { + return I18nBundleFactory.getLocales(i18nBundles); + } + + /** + * @return les paquetages selectionnes + */ + @Override + public List<String> getSelectedPackages() { + return selectedPackages; + } + + /** + * @return les locales selectionnees + */ + @Override + public List<Locale> getSelectedBundles() { + return selectedBundles; + } + + /** + * @return les urls du projet + */ + @Override + public URL[] getURLs() { + return urls; + } + + @Override + public File getStoreFile() { + return storeFile; + } + + @Override + public void setStoreFile(File storeFile) { + this.storeFile = storeFile; + } + + /** + * @return les clefs de traductions pour les packages selectionnee et les locales selectionnes + */ + @Override + public String[] getKeys() { + if (!loaded) { + return EMPTY_STRING_ARRAY; + } + + List<String> paquetages = getSelectedPackages(); + List<Locale> locales = getSelectedBundles(); + Set<String> keys = new HashSet<String>(); + + for (I18nBundle bundle : i18nBundles) { + if (paquetages.contains(bundle.getBundlePrefix())) { + for (I18nBundleEntry entry : bundle) { + if (!locales.contains(entry.getLocale())) { + continue; + } + Set<Object> keySet = resources.get(entry.getPath().toString()).keySet(); + for (Object object : keySet) { + keys.add(object.toString()); + } + } + } + } + List<String> r = new ArrayList<String>(keys); + 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(); + Properties resource = getResource(packageName, locale); + if (resource != null) { + resource.remove(key); + } + } + + /** + * @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) { + return null; + } + + List<String> paquetages = getSelectedPackages(); + + if (!paquetages.contains(packageName)) { + return null; + } + + Map<Locale, String> r = new LinkedHashMap<Locale, String>(); + + List<Locale> locales = getSelectedBundles(); + + I18nBundle bundle = getI18nBundle(packageName); + + for (I18nBundleEntry entry : bundle) { + Locale locale = entry.getLocale(); + if (!locales.contains(locale)) { + continue; + } + Properties resource = resources.get(entry.getPath().toString()); + if (resource.containsKey(key)) { + r.put(locale, resource.getProperty(key).toString()); + } + } + 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) { + return EMPTY_STRING; + } + Properties resource = getResource(packageName, locale); + if (resource != null) { + Object object = resource.get(key); + return object.toString(); + } + return null; + + } + + /** + * 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(); + Properties resource = getResource(packageName, locale); + if (resource != null) { + resource.put(key, value); + } + } + + /** + * 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(); + Properties resource = getResource(packageName, locale); + if (resource != null) { + resource.put(key, value); + } + } + + /** + * Chargement des traductions du projet. + * + * @throws IOException + */ + @Override + public void load() throws IOException { + try { + synchronized (this.resources) { + resources.clear(); + selectedBundles.clear(); + selectedPackages.clear(); + + // detections des bundles i18n a partir des urls donnees + List<I18nBundle> tmp = I18nBundleFactory.detectBundles(urls); + i18nBundles = tmp.toArray(new I18nBundle[tmp.size()]); + + selectedBundles.addAll(Arrays.asList(getBundles())); + selectedPackages.addAll(Arrays.asList(getPackages())); + + for (I18nBundle bundle : i18nBundles) { + for (I18nBundleEntry entry : bundle) { + URL path = entry.getPath(); + Properties properties = new Properties(); + entry.load(properties); + resources.put(path.toString(), properties); + } + } + } + } finally { + loaded = true; + } + } + + /** + * Enregistrement des traductions du projet. + * + * @throws IOException + */ + @Override + public void store() throws IOException { + checkLoaded(); + } + + @Override + public void storeDefinition() 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)); + FileOutputStream stream = null; + try { + stream = new FileOutputStream(getStoreFile()); + p.store(stream, "generated by " + getClass().getName()); + } finally { + if (stream != null) { + stream.close(); + } + } + + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + i18nBundles = null; + resources.clear(); + selectedBundles.clear(); + selectedPackages.clear(); + } + + @Override + public String toString() { + return super.toString() + "<name: " + name + ">"; + } + + protected I18nBundle getI18nBundle(String packageName) { + if (i18nBundles != null) { + for (I18nBundle b : i18nBundles) { + if (b.getBundlePrefix().equals(packageName)) { + return b; + } + } + } + return null; + } + + protected I18nBundleEntry getI18nBundleEntry(String packageName, Locale locale) { + I18nBundle bundle = getI18nBundle(packageName); + if (bundle != null) { + for (I18nBundleEntry entry : bundle) { + if (locale.equals(entry.getLocale())) { + return entry; + } + } + } + return null; + } + + protected Properties getResource(String packageName, Locale locale) { + I18nBundleEntry entry = getI18nBundleEntry(packageName, locale); + if (entry != null) { + Properties resource = resources.get(entry.getPath().toString()); + return resource; + } + return null; + } + + protected void checkLoaded() throws IllegalStateException { + if (!loaded) { + throw new IllegalStateException("project was not loaded"); + } + } +} Added: 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 (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,97 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.nuiton.i18n.editor.project; + +import java.util.Collections; +import java.util.Map; +import java.util.Map.Entry; +import org.nuiton.i18n.I18n; + +/** + * + * @param <P> le type de projet supporte. + * + * @author chemit + */ +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; + protected Map<String, Class<?>> authorizedParameters; + + protected abstract Map<String, Class<?>> initAuthorizedParameters(); + + public AbstractI18nProjectProvider(Class<P> type, String label, String description) { + this.type = type; + this.label = label; + this.description = description; + } + + @Override + public Class<P> getType() { + return type; + } + + @Override + public String getLabel() { + return label; + } + + @Override + public String getDescription() { + return I18n._(description); + } + + + @Override + public Map<String, Class<?>> getAuthorizedParameters() { + if (authorizedParameters == null) { + this.authorizedParameters = Collections.unmodifiableMap(initAuthorizedParameters()); + } + return authorizedParameters; + } + + public <T extends Object> T getParameter(Class<T> returnType, String propertyName, Map<String, Object> parameters) { + Map<String, Class<?>> map = getAuthorizedParameters(); + // check name + if (!map.containsKey(propertyName)) { + throw new IllegalArgumentException("the property " + propertyName + " is unknown for this project.\nKnown parameters :" + map.keySet()); + } + // check type + Class<?> requiredType = map.get(propertyName); + if (returnType != requiredType && !returnType.isAssignableFrom(requiredType)) { + throw new IllegalArgumentException("the property " + propertyName + " must be of the type " + requiredType + ", but was : " + requiredType); + } + + for (Entry<String, Object> e : parameters.entrySet()) { + if (propertyName.equals(e.getKey())) { + return (T) e.getValue(); + } + } + throw new IllegalArgumentException("could not find property " + propertyName + ".\nKnown properties in :\n" + parameters.keySet()); + } +} Copied: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java (from rev 1644, trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/model/I18nProject.java) =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,132 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.project; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * + * @author chemit + */ +public interface I18nProject { + + /** + * @return le nom du projet + */ + public String getName(); + + /** + * @return les paquetages du projet + */ + public String[] getPackages(); + + /** + * @return les locales du projet + */ + public Locale[] getBundles(); + + /** + * @return les paquetages selectionnes + */ + public List<String> getSelectedPackages(); + + /** + * @return les locales selectionnees + */ + public List<Locale> getSelectedBundles(); + + /** + * @return les urls du projet + */ + public URL[] getURLs(); + + public File getStoreFile(); + + public void setStoreFile(File storeFile); + + /** + * @return les clefs de traductions pour les packages selectionnee et les locales selectionnes + */ + public String[] getKeys(); + + /** + * 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 + */ + public void deleteKey(String packageName, Locale locale, String key); + + /** + * @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); + + /** + * @param key la clef de traductions + * @param locale la locale + * @param packageName le nom du package + * @return les traductions + */ + public String getValue(String packageName, Locale locale, String key); + + /** + * 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 + */ + public void addValue(String packageName, Locale locale, String key, String value); + + /** + * 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 + */ + public void updateValue(String packageName, Locale locale, String key, String value); + + /** + * Chargement des traductions du projet. + * + * @throws IOException + */ + public void load() throws IOException; + + /** + * Enregistrement des traductions du projet. + * + * @throws IOException + */ + public void store() throws IOException; + + public void storeDefinition() throws IOException; +} Property changes on: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java ___________________________________________________________________ Added: svn:mergeinfo + Added: 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 (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,177 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.project; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.ServiceLoader; +import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.i18n.editor.ui.project.ProjectUIModel; + +/** + * L'usine de projets. + * + * @author chemit + * @see I18nProject + * @see I18nProjectProvider + */ +public class I18nProjectFactory { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + private static final Log log = LogFactory.getLog(I18nProjectFactory.class); + /** le cache des provideurs de projet. */ + protected static Set<I18nProjectProvider<?>> providers; + + /** + * Creer un projet a partir d'un dictionnaire de parametres. + * + * @param <P> le type de projet + * @param projectClass le type de la classe + * @param params le dictionnaire des paramètres pour créer le projet + * @return le projet instancie mais non ouvert. + */ + public static <P extends I18nProject> P newProject(Class<P> projectClass, Map<String, Object> params) { + I18nProjectProvider<P> provider = getProvider(projectClass); + if (provider == null) { + throw new IllegalArgumentException("could not provider for " + projectClass); + } + P result = provider.newProject(params); + return result; + } + + /** + * Creer un projet a partir de l'ui de creation de projet. + * + * @param <P> le type du projet + * @param projectClass le type du projet + * @param model le model de l'ui de creation de projet + * @return le projet instantie mais non ouvert + */ + public static <P extends I18nProject> P newProject(Class<P> projectClass, ProjectUIModel model) { + + I18nProjectProvider<P> provider = getProvider(projectClass); + if (provider == null) { + throw new IllegalArgumentException("could not provider for " + projectClass); + } + P result = provider.newProject(model); + return result; + } + + /** + * Creer un projet a partir d'un fichier de definition de projet. + * + * @param <P> le type du projet + * @param projectFile le fichier contenant la definition du projet + * @return le projet instantie mais non ouvert. + */ + public static <P extends I18nProject> P newProject(File projectFile) { + + FileInputStream stream = null; + try { + Properties p = new Properties(); + stream = new FileInputStream(projectFile); + p.load(stream); + + String tmp = p.getProperty(AbstractI18nProjectProvider.CLASS_PARAMETER); + Class<? extends I18nProject> projectClass = (Class<? extends I18nProject>) Class.forName(tmp); + + I18nProjectProvider<P> provider = (I18nProjectProvider<P>) getProvider(projectClass); + if (provider == null) { + throw new IllegalArgumentException("could not provider for " + projectClass); + } + // validate definition + provider.validateDefinition(p); + // instanciate safe project + P result = provider.newProject(p); + result.setStoreFile(projectFile); + return result; + + } catch (Exception ex) { + throw new RuntimeException("could not load project for reason " + ex.getMessage(), ex); + } finally { + if (stream != null) { + try { + stream.close(); + } catch (IOException ex) { + throw new RuntimeException("could not close project for reason " + ex.getMessage(), ex); + } + } + } + + + } + + /** + * Recupere l'ensemble des provideurs de projet connus par le systeme. + * + * Note: pour ajouter de nouveaux types de projet, on utilise la mecanique + * de chargement de service de la jdk {@link ServiceLoader}. + * + * @return l'ensemble des provideurs de projet connus par le systeme. + * + */ + public static Set<I18nProjectProvider<?>> getProviders() { + if (providers == null) { + synchronized (I18nProjectProvider.class) { + discoverProviders(); + } + } + return providers; + } + + /** + * Recupere le provideur d'un type de projet donne. + * + * @param <P> le type de projet + * @param projectClass le type de projet + * @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) { + + for (I18nProjectProvider<?> p : getProviders()) { + if (p.getType() == projectClass) { + return (I18nProjectProvider<P>) p; + } + } + return null; + } + + /** + * Decouvrer les provideurs de projet via la mecanique {@link ServiceLoader} + * de la jdk + */ + protected static void discoverProviders() { + if (providers == null) { + providers = new HashSet<I18nProjectProvider<?>>(); + } else { + providers.clear(); + } + for (I18nProjectProvider<?> p : ServiceLoader.load(I18nProjectProvider.class)) { + log.info("loaded " + p); + providers.add(p); + } + } +} Added: 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 (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,120 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.project; + +import java.io.IOException; +import java.net.URL; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import org.nuiton.i18n.editor.ui.project.ProjectUIModel; +import org.nuiton.i18n.editor.ui.project.I18nProjectConfigurePanelUI; + +/** + * Le contrat d'un provider du projet. + * + * @param <P> le type de projet connu par le provider. + * @author chemit + */ +public interface I18nProjectProvider<P extends I18nProject> { + + /** + * + * @return le type du projet + */ + Class<P> getType(); + + /** + * + * @return le label du type de projet + */ + String getLabel(); + + /** + * + * @return la description de ce type de projet + */ + String getDescription(); + + /** + * + * @return le dictionnaire des paramètres autorisés pour ce type de projet + */ + Map<String, Class<?>> getAuthorizedParameters(); + + /** + * + * @param params les paramètres pour instancier le projet + * @return le projet instancié (mais non chargé?) + */ + P newProject(Map<String, Object> params); + + /** + * + * @param model le model d'ui + * @return le projet instancié (mais non chargé?) + */ + P newProject(ProjectUIModel model); + + /** + * + * @param properties le model d'ui + * @return le projet instancié (mais non chargé?) + */ + P newProject(Properties properties); + + /** + * Decouvre et retourne tous les fichiers de traductions disponibles a + * partir du modele de cration de projet. + * + * @param model le modele a utiliser + * @return la liste des urls des fichiers de traductions trouves a partir + * du modele. + * @throws IOException pour toute erreur + */ + List<URL> detectBundles(ProjectUIModel model) throws IOException; + + /** + * + * @return le type de l'ui pour configurer ce type de projet + */ + Class<? extends I18nProjectConfigurePanelUI> getUIClass(); + + /** + * Valide dans l'ui de creation de projet la partie specifique a + * ce type de projet. + * + * @param model le model a valider + * @return <code>true</code> si la partie specifique a ce type de projet + * est valide, <code>false</code> autrement. + */ + boolean validateUIModel(ProjectUIModel model); + + /** + * Valide un projet a partir de sa definition contenue dans un fichier de + * proprietes. + * + * Cette methode est appellee avant tout chargement de projet en memoire, + * afin de verifier la coherence du projet. + * + * @param properties les proprietes de la definition du projet + * @return <code>true</code> si le projet est valide. + */ + boolean validateDefinition(Properties properties); +} Added: 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 (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,33 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.project.impl; + +import org.nuiton.i18n.editor.project.AbstractI18nProject; +import java.net.URL; + +/** + * + * @author chemit + */ +public class DirectoryI18nProject extends AbstractI18nProject { + + public DirectoryI18nProject(String name, URL[] urls) { + super(name, urls); + } +} Added: 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 (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,106 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.project.impl; + +import java.io.IOException; +import org.nuiton.i18n.editor.project.AbstractI18nProjectProvider; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.TreeMap; +import org.nuiton.i18n.I18n; +import org.nuiton.i18n.editor.ui.project.I18nProjectConfigurePanelUI; +import org.nuiton.i18n.editor.ui.project.ProjectUIModel; +import org.nuiton.i18n.editor.ui.project.tabs.DirectoryI18nProjectConfigurePanelUI; +import org.nuiton.util.ConverterUtil; + +/** + * + * @author chemit + */ +public class DirectoryI18nProjectProvider extends AbstractI18nProjectProvider<DirectoryI18nProject> { + + public DirectoryI18nProjectProvider() { + super(DirectoryI18nProject.class, I18n.n_("i18neditor.project.type.directory"), I18n.n_("i18neditor.project.type.directory.description")); + } + + @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); + 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); + } + + @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()); + } + 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[] 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(URLS_PARAMETER, urls.toArray(new URL[urls.size()])); + + DirectoryI18nProject p = newProject(params); + return p; + } + + @Override + public List<URL> detectBundles(ProjectUIModel model) throws IOException { + 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(); + } + + @Override + public boolean validateDefinition(Properties properties) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Class<? extends I18nProjectConfigurePanelUI> getUIClass() { + return DirectoryI18nProjectConfigurePanelUI.class; + } +} Added: 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 (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,35 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.project.impl; + +import org.nuiton.i18n.editor.project.AbstractI18nProject; +import java.net.URL; + +/** + * + * @author chemit + */ +public class JarI18nProject extends AbstractI18nProject{ + + public JarI18nProject(String name, URL[] urls) { + super(name, urls); + } + + +} Added: 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 (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,162 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.project.impl; + +import java.io.IOException; +import org.nuiton.i18n.editor.project.AbstractI18nProjectProvider; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.TreeMap; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.i18n.I18n; +import org.nuiton.i18n.bundle.I18nBundleFactory; +import org.nuiton.i18n.editor.ui.project.I18nProjectConfigurePanelUI; +import org.nuiton.i18n.editor.ui.project.ProjectUIModel; +import org.nuiton.i18n.editor.ui.project.tabs.JarI18nProjectConfigurePanelUI; +import org.nuiton.util.ConverterUtil; +import org.nuiton.util.Resource; + +/** + * + * @author chemit + */ +public class JarI18nProjectProvider extends AbstractI18nProjectProvider<JarI18nProject> { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(JarI18nProjectProvider.class); + + public JarI18nProjectProvider() { + super(JarI18nProject.class, + I18n.n_("i18neditor.project.type.jar"), + I18n.n_("i18neditor.project.type.jar.description")); + } + + @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); + 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; + } + + @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()); + } + 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[] 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(URLS_PARAMETER, urls.toArray(new URL[urls.size()])); + + JarI18nProject p = newProject(params); + return p; + } + + @Override + public List<URL> detectBundles(ProjectUIModel model) throws IOException { + List<URL> urls = new ArrayList<URL>(); + URL source = model.getJarSource().toURI().toURL(); + URLClassLoader loader = new URLClassLoader(new URL[]{source}); + log.info("jar source : " + source); + if (model.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); + if (!defs.isEmpty()) { + // on ne traite que le premier ??? + URL u = defs.get(0); + String path = u.toString(); + int index = path.lastIndexOf("/"); + path = path.substring(index + 1); + String bundleName = path.substring(0, path.length() - "-i18n-definition.properties".length()); + log.info("bundleName : " + bundleName); + urls = Resource.getURLs("META-INF/" + bundleName + "-.*\\.properties", loader); + urls.remove(u); + } + } else { + urls = Resource.getURLs(I18nBundleFactory.SEARCH_BUNDLE_PATTERN, loader); + log.info("detected bundles : " + urls); + } + return urls; + } + + @Override + public boolean validateUIModel(ProjectUIModel model) { + return model.getJarSource() != null && model.getJarSource().exists() && model.getProjectName() != null && !model.getProjectName().isEmpty(); + } + + @Override + public boolean validateDefinition(Properties properties) { + + // verifie que les proprietes sont presentes : + 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(URLS_PARAMETER)) { + throw new IllegalStateException("could not find property " + URLS_PARAMETER); + } + // verifie que les urls existent + String tmp = properties.getProperty(URLS_PARAMETER); + String[] urlsStr = tmp.split(","); + for (String u : urlsStr) { + int lastIndex = u.lastIndexOf("/"); + u = u.substring(0, lastIndex); + URL url = ConverterUtil.convert(URL.class, u); + // check if url is an existing file + log.info(url + " to check"); + } + return false; + } + + @Override + public Class<? extends I18nProjectConfigurePanelUI> getUIClass() { + return JarI18nProjectConfigurePanelUI.class; + } +} Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleCheckBoxMenuUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleCheckBoxMenuUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleCheckBoxMenuUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,4 +1,26 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <JCheckBoxMenuItem id='content' text='{getBundle().getDisplayName()}' toolTipText='{_("i18neditor.bundle.name", getBundle().getDisplayName())}' onItemStateChanged='updateState(event)'> <!-- le nom du bundle --> Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValueUI.css =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValueUI.css 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValueUI.css 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,3 +1,21 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ JToolBar { borderPainted:false; floatable:false; Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValueUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValueUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValueUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,4 +1,26 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <JPanel layout='{new BorderLayout()}'> <style source='BundleValueUI.css'/> Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValuesUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValuesUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/BundleValuesUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,4 +1,26 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <org.jdesktop.swingx.JXTitledPanel id='content' title='{updateTitle(getPackageName())}'> Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreateBundleUI.css =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreateBundleUI.css 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreateBundleUI.css 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,4 +1,21 @@ - +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ #countryLabel { text:"i18neditor.createbundle.newlocale"; labelFor:{country}; Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreateBundleUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreateBundleUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreateBundleUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,4 +1,26 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <JDialog id='main'> <style source='CreateBundleUI.css'/> Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreatePackageUI.css =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreatePackageUI.css 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreatePackageUI.css 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,3 +1,21 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ #packageLabel { text:"i18neditor.createpackage.newpackage"; Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreatePackageUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreatePackageUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/CreatePackageUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,4 +1,26 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <JDialog id='main'> <style source='CreatePackageUI.css'/> 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,3 +1,22 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* +*/ + JToolBar { borderPainted:false; floatable:false; @@ -179,3 +198,51 @@ /*resizeWeight:1.0;*/ } +#toolbar{ + _help:{"ui.main.toolbar"}; +} + +#treeToolBar{ + enabled:{context.getProject() != null}; +} + +#toTreeMode { + + buttonGroup:"treeModelMode"; + text:{TreeModelMode.TREE.toString()}; +enabled:{context.getProject() != null}; +selected:{context.getTreeModelMode() == TreeModelMode.TREE}; +value:{TreeModelMode.TREE}; +} + +#toFlatMode { + buttonGroup:"treeModelMode"; + text:{TreeModelMode.FLAT.toString()}; +enabled:{context.getProject() != null}; +selected:{context.getTreeModelMode() == TreeModelMode.FLAT}; +value:{TreeModelMode.FLAT}; +} + +#collapseAll { + actionIcon:"collapseAll"; + enabled:{context.getProject() != null && context.getSelectedKey() != null}; +} + +#expandAll{ + actionIcon:"expandAll"; + enabled:{context.getProject() != null && context.getSelectedKey() != null}; +} + +#keysView { + columnHeaderView:{treeToolBar}; +} + +#tree{ + showsRootHandles:false; + rootVisible:false; + selectionModel:{treeSelectionModel}; +} + +#valuesView { + horizontalScrollBarPolicy:horizontal_scrollbar_never; +} 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,4 +1,26 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <JFrame id='mainFrame' implements='PropertyChangeListener' width='800' height='800' @@ -12,7 +34,7 @@ import javax.swing.tree.*; import java.util.Locale; import org.nuiton.i18n.editor.*; -import org.nuiton.i18n.editor.model.*; +import org.nuiton.i18n.editor.project.I18nProject; protected I18nEditorUIHandler handler = getContextValue(I18nEditorUIHandler.class); protected I18nEditorConfig config = getContextValue(I18nEditorConfig.class); @@ -202,9 +224,12 @@ <JMenuItem id='menuFileConfiguration' onActionPerformed="handler.showConfig()"/> <JMenuItem id="menuFileCreateProject" onActionPerformed="handler.createProject(context)"/> <JMenu id="menuFileOpenProject"> - <JMenuItem id="menuFileOpenProjectOther" onActionPerformed="handler.openOtherProject(context)" + <JMenuItem id="menuFileOpenProjectOther" + onActionPerformed="handler.openOtherProject(context)" _doNotRemove='Boolean.TRUE'/> - <JMenuItem id="menuFileDeleteProject" onActionPerformed="handler.deleteProject(context)" _doNotRemove='Boolean.TRUE'/> + <JMenuItem id="menuFileDeleteProject" + onActionPerformed="handler.deleteProject(context)" + _doNotRemove='Boolean.TRUE'/> <JSeparator/> </JMenu> @@ -245,16 +270,16 @@ <ButtonGroup id='treeModelMode' onStateChanged='handler.changeTreeModelMode(context, (TreeModelMode) treeModelMode.getSelectedValue())'/> - <JToolBar id='treeToolBar' enabled='{context.getProject() != null}'> - <JToggleButton id='toTreeMode' buttonGroup="treeModelMode" text='{TreeModelMode.TREE.toString()}' selected='{context.getTreeModelMode() == TreeModelMode.TREE}' value='{TreeModelMode.TREE}'/> - <JToggleButton id='toFlatMode' buttonGroup="treeModelMode" text='{TreeModelMode.FLAT.toString()}' selected='{context.getTreeModelMode() == TreeModelMode.FLAT}' value='{TreeModelMode.FLAT}'/> - + <JToolBar id='treeToolBar'> + <JToggleButton id='toTreeMode'/> + <JToggleButton id='toFlatMode'/> + <JSeparator orientation='vertical'/> <javax.swing.Box.Filler constructorParams='SwingUtil.newMinDimension(), SwingUtil.newMinDimension(), SwingUtil.newMaxXDimension()'/> - <JButton id='collapseAll' actionIcon='collapseAll' enabled='{context.getSelectedKey() != null}' onActionPerformed='collapseAll((PropertieNode)tree.getSelectionValue())'/> - <JButton id='expandAll' actionIcon='expandAll' enabled='{context.getSelectedKey() != null}' onActionPerformed='expandAll((PropertieNode)tree.getSelectionValue())'/> + <JButton id='collapseAll' onActionPerformed='collapseAll((PropertieNode)tree.getSelectionValue())'/> + <JButton id='expandAll' onActionPerformed='expandAll((PropertieNode)tree.getSelectionValue())'/> </JToolBar> - <org.nuiton.i18n.editor.model.PropertiesTreeModel id='treeModel' mode='{context.getTreeModelMode()}'/> + <PropertiesTreeModel id='treeModel' mode='{context.getTreeModelMode()}'/> <javax.swing.tree.DefaultTreeSelectionModel id='treeSelectionModel'/> <!--onValueChanged='updateSelectedKey((PropertieNode) tree.getSelectionValue())'/--> @@ -263,11 +288,10 @@ <!-- left : bundles keys --> - <JScrollPane id='keysView' columnHeaderView='{treeToolBar}'> + <!--JScrollPane id='keysView' columnHeaderView='{treeToolBar}'--> + <JScrollPane id='keysView'> <JTree id="tree" constructorParams='treeModel' - showsRootHandles='false' - rootVisible='false' - selectionModel='{treeSelectionModel}' + onKeyReleased='updateSelectedKey((PropertieNode) tree.getSelectionValue())' onMouseClicked='updateSelectedKey((PropertieNode) tree.getSelectionValue())' cellRenderer='{ new DefaultTreeCellRenderer() { @@ -300,7 +324,8 @@ <!-- right : bundles values (for the selected key) --> - <JScrollPane id='valuesView' horizontalScrollBarPolicy="horizontal_scrollbar_never"> + <!--JScrollPane id='valuesView' horizontalScrollBarPolicy="horizontal_scrollbar_never"--> + <JScrollPane id='valuesView'> <JPanel id="values" layout='{new GridLayout(0,1)}'/> </JScrollPane> 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,3 +1,21 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ package org.nuiton.i18n.editor.ui; import java.awt.Component; @@ -5,6 +23,7 @@ import java.awt.event.ActionEvent; import java.io.IOException; import java.util.Map; +import java.util.Set; import javax.swing.JMenu; import org.nuiton.i18n.editor.*; import java.awt.Desktop; @@ -15,7 +34,6 @@ import java.util.Collections; import java.util.List; import java.util.Locale; -import java.util.Properties; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JCheckBoxMenuItem; @@ -32,14 +50,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.i18n.I18n; -import org.nuiton.i18n.editor.model.I18nProject; -import org.nuiton.i18n.editor.model.PropertiesTreeModel; -import org.nuiton.i18n.editor.model.TreeModelMode; +import org.nuiton.i18n.editor.project.I18nProject; +import org.nuiton.i18n.editor.project.I18nProjectFactory; +import org.nuiton.i18n.editor.project.I18nProjectProvider; import org.nuiton.i18n.editor.ui.project.ProjectStep; -import org.nuiton.i18n.editor.ui.project.ProjectType; import org.nuiton.i18n.editor.ui.project.ProjectUI; import org.nuiton.i18n.editor.ui.project.ProjectUIModel; -import org.nuiton.util.ConverterUtil; import static org.nuiton.i18n.I18n._; /** @@ -357,6 +373,7 @@ item.setText(name); menu.add(item); } + ui.getMenuFileDeleteProject().setEnabled(!projects.isEmpty()); } @@ -554,7 +571,10 @@ @Override protected void init(ProjectUI ui) { ProjectUIModel model = ui.getModel(); - model.setProjectType(ProjectType.JAR); + Set<I18nProjectProvider<?>> providers = I18nProjectFactory.getProviders(); + if (!providers.isEmpty()) { + model.setType(providers.iterator().next()); + } // ui.setTitle(("observe.title.import.localDB")); } @@ -562,7 +582,10 @@ protected void doAction(ProjectUI ui) { log.info(ui.getName()); ProjectUIModel model = ui.getModel(); - I18nProject project = model.toProject(); + + I18nProject project = null; + I18nProjectProvider<? extends I18nProject> type = model.getType(); + project = I18nProjectFactory.newProject(type.getType(), model); rootContext.getContextValue(I18nEditorConfig.class).getProjects().add(model.getProjectName()); try { if (model.isStoreProject()) { @@ -613,19 +636,8 @@ public void loadProject(I18nEditorContext context, File projectFile) { FileInputStream stream = null; try { - Properties p = new Properties(); - stream = new FileInputStream(projectFile); - p.load(stream); + I18nProject project = I18nProjectFactory.newProject(projectFile); - String name = p.getProperty("name"); - String tmp = p.getProperty("urls"); - String[] urlsStr = tmp.split(","); - List<URL> urls = new ArrayList<URL>(); - for (String u : urlsStr) { - URL url = ConverterUtil.convert(URL.class, u); - urls.add(url); - } - I18nProject project = new I18nProject(name, urls.toArray(new URL[urls.size()])); project.setStoreFile(projectFile); project.load(); I18nEditorContext.PROJECT_DEF.setContextValue(context, project); Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PackageCheckBoxMenuUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PackageCheckBoxMenuUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PackageCheckBoxMenuUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,6 +1,31 @@ +<!-- -<JCheckBoxMenuItem id='content' text='{updateText(getUrl())}' toolTipText='{_("i18neditor.resource.name", getUrl())}' onItemStateChanged='updateState(event)'> +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +--> + +<JCheckBoxMenuItem id='content' + text='{updateText(getUrl())}' + toolTipText='{_("i18neditor.resource.name", getUrl())}' + onItemStateChanged='updateState(event)'> + <!-- le nom du bundle --> <String id='url' javaBean='""'/> @@ -29,8 +54,7 @@ // pas encore de context (ui en construction) return; } - boolean selected = e.getStateChange() == ItemEvent.SELECTED; - if (selected) { + if (e.getStateChange() == ItemEvent.SELECTED) { context.addSelectedPackage(url); } else { context.removeSelectedPackage(url); Copied: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertieNode.java (from rev 1642, trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/model/PropertieNode.java) =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertieNode.java (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertieNode.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,122 @@ +/* + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* */ +package org.nuiton.i18n.editor.ui; + +import javax.swing.tree.DefaultMutableTreeNode; +import java.io.Serializable; +import javax.swing.tree.MutableTreeNode; + +/** + * Représente un noeud de l'ardre des propriétés affichées. Le noeud contient + * le chemin de la propriétés, par exemple tutu.toto.tata va être représenté avec + * 3 noeuds avec comme chemin tutu, tutu.toto, tutu.toto.tata + * + * @author julien + */ +public class PropertieNode extends DefaultMutableTreeNode implements Comparable<PropertieNode> { + + /** @see Serializable */ + private static final long serialVersionUID = 1L; + + /** + * Constructeur avec l'objet contenu dans le noeud + * + * @param userObject chemin de la propriété + */ + public PropertieNode(Object userObject) { + super(userObject); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof PropertieNode) { + // Comparaison du chemin + PropertieNode node = (PropertieNode) obj; + return getUserObject().equals(node.getUserObject()); + } + return false; + } + + public PropertieNode getChildAt(String path) { + if (!isLeaf()) { + for (Object o : children) { + PropertieNode n = (PropertieNode) o; + if (path.equals(n.getUserObject())) { + return n; + } + } + } + return null; + } + + /** + * Ajoute le noeud fils a la bonne position (on conserve l'ordre alphabetique des path) + * + * Note : si le path existe deja, alors on ne fait rien. + * + * @param newChild le fils a ajouter + */ + @Override + public void add(MutableTreeNode newChild) { + int index = 0; + if (!isLeaf()) { + // on recherche la position ou ajouter la clef + for (Object o : children) { + PropertieNode n = (PropertieNode) o; + int compareTo = n.compareTo((PropertieNode) newChild); + if (compareTo == 0) { + // le noeud existe deja + return; + } + if (compareTo > 0) { + // le noeud courant doit etre apres le noeud a ajouter + break; + } + index++; + } + } + insert(newChild, index); + } + +// @Override +// public String toString() { +// String result = getUserObject().toString(); +// if (isRoot()) { +// // Si c'est la racine +// return result; +// } else { +// // Si c'est un chemin +// int lastSeparator = result.lastIndexOf("."); +// return result.substring(lastSeparator + 1); +// } +// } + + @Override + public int hashCode() { + return getUserObject().hashCode(); + } + + @Override + public int compareTo(PropertieNode node) { + // Compare les chemins + return getUserObject().toString().compareTo(node.getUserObject().toString()); + } +} Property changes on: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertieNode.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertiesTreeModel.java (from rev 1644, trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/model/PropertiesTreeModel.java) =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertiesTreeModel.java (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertiesTreeModel.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,199 @@ +/* + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* */ +package org.nuiton.i18n.editor.ui; + +import javax.swing.tree.DefaultTreeModel; +import java.io.Serializable; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.i18n.editor.I18nEditorContext; +import static org.nuiton.i18n.I18n._; + +/** + * Modèle de l'arbre des propriétés. Le modèle permet de sructurer les propriétés + * (ex: tutu.toto.tata) en un des noeuds de l'arbre. + * + * @author julien + */ +public class PropertiesTreeModel extends DefaultTreeModel { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(PropertiesTreeModel.class); + /** @see Serializable */ + private static final long serialVersionUID = 1L; + protected TreeModelMode mode; + protected String[] keys; + + /** + * Constructeur avec un liste de proprétés + * + * @param list liste de propriétés + */ + public PropertiesTreeModel(String... list) { + this(TreeModelMode.TREE, list); + } + + /** + * Constructeur avec un liste de proprétés + * + * @param mode le mode de modele a construire + * @param list liste de propriétés + */ + public PropertiesTreeModel(TreeModelMode mode, String... list) { + super(null); + this.keys = list; + + // Création de la racine (qui n'est jamais affichee) + PropertieNode r = new PropertieNode(""); +// PropertieNode r = new PropertieNode(list.length == 0 ? _("i18neditor.no.keys") : I18nEditorContext.ROOT_NAME); + setRoot(r); + setMode(mode); + } + + @Override + public PropertieNode getRoot() { + return (PropertieNode) super.getRoot(); + } + + public String[] getKeys() { + return keys; + } + + public void setKeys(String[] keys) { + this.keys = keys; + // on reconstruit le model + TreeModelMode theMode = mode; + mode = null; + setMode(theMode); + } + + public boolean containsKey(String selectedKey) { + if (keys != null) { + switch (mode) { + case TREE: + for (String k : keys) { + if (k.equals(selectedKey) || k.startsWith(selectedKey + ".")) { + return true; + } + } + break; + case FLAT: + + for (String k : keys) { + if (k.equals(selectedKey)) { + return true; + } + } + break; + } + } + return false; + } + + public PropertieNode getNode(String path) { + PropertieNode result = null; + switch (mode) { + case TREE: + String[] names = path.split("\\" + I18nEditorContext.SEPARATOR); + result = getRoot(); + String currentPath = ""; + for (String name : names) { + if (!currentPath.isEmpty()) { + currentPath += I18nEditorContext.SEPARATOR; + } + currentPath += name; + result = result.getChildAt(currentPath); + } + break; + case FLAT: + result = getRoot().getChildAt(path); + break; + } + return result; + } + + public TreeModelMode getMode() { + return mode; + } + + public void setMode(TreeModelMode mode) { + this.mode = mode; + + if (root == null) { + return; + } + PropertieNode r = (PropertieNode) root; + if (!r.isLeaf()) { + // on supprime tous les fils + r.removeAllChildren(); + } + if (keys == null || keys.length == 0) { + // pas de clef a reconstruire + PropertieNode r2 = new PropertieNode(_("i18neditor.no.keys")); + r.add(r2); + // on notifie que le modele a ete reconstruit + nodeStructureChanged(root); + return; + } + + // on reconstruit le modele + + switch (mode) { + case TREE: + buildTreeModel(r, keys); + break; + + case FLAT: + buildFlatModel(r, keys); + break; + } + // on notifie que le modele a ete reconstruit + nodeStructureChanged(root); + } + + private void buildTreeModel(PropertieNode r, String[] list) { + for (String property : list) { + String path = ""; + PropertieNode parent = r; + + String[] names = property.split("\\" + I18nEditorContext.SEPARATOR); + for (String name : names) { + if (!path.isEmpty()) { + + path += I18nEditorContext.SEPARATOR; + } + path += name; + + PropertieNode node = parent.getChildAt(path); + if (node == null) { + node = new PropertieNode(path); + parent.add(node); + } + parent = node; + } + } + } + + private void buildFlatModel(PropertieNode r, String[] list) { + + for (String property : list) { + PropertieNode node = new PropertieNode(property); + r.add(node); + } + } +} Property changes on: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/PropertiesTreeModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/TreeModelMode.java (from rev 1642, trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/model/TreeModelMode.java) =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/TreeModelMode.java (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/TreeModelMode.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,36 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.ui; + +/** + * Pour caracteriser le mode a utiliser dans le modele de navigation. + * + * @author chemit + */ +public enum TreeModelMode { + + /** + * pour afficher les clefs sous forme d'arbre + */ + TREE, + /** + * pour afficher les clefs a plat + */ + FLAT +} Property changes on: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/TreeModelMode.java ___________________________________________________________________ Added: svn:mergeinfo + Added: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/I18nProjectConfigurePanelUI.java =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/I18nProjectConfigurePanelUI.java (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/I18nProjectConfigurePanelUI.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,35 @@ +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ +package org.nuiton.i18n.editor.ui.project; + +import jaxx.runtime.JAXXObject; + +/** + * Le contrat a respecter pour configurer un type de projet. + * + * @author chemit + */ +public interface I18nProjectConfigurePanelUI extends JAXXObject { + + /** + * + * @return l'instance partagee du modele de creation de projet + */ + ProjectUIModel getModel(); +} Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectStep.java =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectStep.java 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectStep.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,6 +1,6 @@ /** - * *##% observe-swing - * Copyright (C) 2008 - 2009 IRD + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -21,7 +21,7 @@ import static org.nuiton.i18n.I18n.n_; /** - * Pour caractériser les étapes lors du wiazrd de création de projet + * Pour caracteriser les étapes lors du wizard de creation de projet * * @author tchemit */ @@ -32,14 +32,10 @@ */ CHOOSE_PROJECT_TYPE(n_("i18neditor.project.step.chooseProjectType"), n_("i18neditor.project.step.chooseProjectType.description")), /** - * pour configurer un projet de type jar + * pour configurer un projet */ - CONFIGURE_JAR_PROJECT(n_("i18neditor.project.step.configureJarProject"), n_("i18neditor.project.step.configureJarProject.description")), + CONFIGURE_PROJECT(n_("i18neditor.project.step.configureProject"), n_("i18neditor.project.step.configureProject.description")), /** - * pour configurer un projet de type directory - */ - CONFIGURE_DIRECTORY_PROJECT(n_("i18neditor.project.step.configureDirectoryProject"), n_("i18neditor.project.step.configureDirectoryProject.description")), - /** * pour choisir les bundles parmis ceux trouvés */ SELECT_BUNDLES(n_("i18neditor.project.step.selecteBundles"), n_("i18neditor.project.step.selecteBundles.description")), Deleted: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectType.java =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectType.java 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectType.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,53 +0,0 @@ -/** - * *##% observe-swing - * Copyright (C) 2008 - 2009 IRD - * - * 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 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* - */ -package org.nuiton.i18n.editor.ui.project; - -import static org.nuiton.i18n.I18n.n_; - -/** - * Pour caractériser les différents types de projet - * - * @author tchemit - */ -public enum ProjectType { - - /** - * charger un projet a partir d'un jar (ou zip) - */ - JAR(n_("i18neditor.project.type.jar"), n_("i18neditor.project.type.jar.description")), - /** - * charger un projet a partir d'un repertoire - */ - DIRECTORY(n_("i18neditor.project.type.directory"), n_("i18neditor.project.type.directory.description")); - private final String label; - private final String description; - - private ProjectType(String label, String description) { - this.label = label; - this.description = description; - } - - public String getLabel() { - return label; - } - - public String getDescription() { - return description; - } -} 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,6 +1,6 @@ /** - * *##% observe-swing - * Copyright (C) 2008 - 2009 IRD + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -16,13 +16,6 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* */ -/* - Document : SynchroPanelUI - Created on : 21 avr. 2009, 23:58:39 - Author : chemit - Description: - Purpose of the stylesheet follows. -*/ #storageMain { title:"i18neditor.title.change.storage"; 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,4 +1,26 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <JDialog id="storageMain" implements='jaxx.runtime.swing.wizard.WizardUI<ProjectStep, ProjectUIModel>' width='550' height='560' defaultCloseOperation='dispose_on_close'> @@ -272,8 +294,9 @@ <CardLayout> <!-- les differents contenu d'onglets --> <ChooseProjectTypePanelUI id='CHOOSE_PROJECT_TYPE' constructorParams='this'/> - <ConfigureJarProjectPanelUI id='CONFIGURE_JAR_PROJECT' constructorParams='this'/> - <ConfigureDirectoryProjectPanelUI id='CONFIGURE_DIRECTORY_PROJECT' 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,6 +1,6 @@ /** - * *##% observe-swing - * Copyright (C) 2008 - 2009 IRD + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -20,21 +20,19 @@ import java.awt.Component; import java.io.File; +import java.io.IOException; import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import java.util.regex.Pattern; 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.bundle.I18nBundleFactory; import org.nuiton.i18n.editor.I18nEditorConfig; -import org.nuiton.i18n.editor.model.I18nProject; +import org.nuiton.i18n.editor.project.I18nProject; +import org.nuiton.i18n.editor.project.I18nProjectProvider; import org.nuiton.util.FileUtil; -import org.nuiton.util.Resource; /** * Le modele de l'ui pour creer un projet via un assistant @@ -46,7 +44,7 @@ /** 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 PROJECT_TYPE_PROPERTY_NAME = "projectType"; + 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"; @@ -57,7 +55,7 @@ /** * Le type de projet */ - protected ProjectType projectType; + protected I18nProjectProvider<? extends I18nProject> type; /** * le nom du projet */ @@ -99,8 +97,7 @@ public ProjectUIModel() { super(ProjectStep.class, ProjectStep.CHOOSE_PROJECT_TYPE, - ProjectStep.CONFIGURE_JAR_PROJECT, - ProjectStep.CONFIGURE_DIRECTORY_PROJECT, + ProjectStep.CONFIGURE_PROJECT, ProjectStep.SELECT_BUNDLES, ProjectStep.RESUME); } @@ -132,7 +129,7 @@ @Override public void start() { super.start(); - firePropertyChange(PROJECT_TYPE_PROPERTY_NAME, null, projectType); + 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); @@ -143,22 +140,14 @@ @Override public void updateUniverse() { - if (projectType == null) { + if (type == null) { // pas de mode choisi donc l'univers ne change pas return; } List<ProjectStep> universe = new ArrayList<ProjectStep>(); universe.add(ProjectStep.CHOOSE_PROJECT_TYPE); + universe.add(ProjectStep.CONFIGURE_PROJECT); - switch (projectType) { - case JAR: - universe.add(ProjectStep.CONFIGURE_JAR_PROJECT); - break; - case DIRECTORY: - universe.add(ProjectStep.CONFIGURE_DIRECTORY_PROJECT); - break; - } - universe.add(ProjectStep.SELECT_BUNDLES); universe.add(ProjectStep.PERSIST); universe.add(ProjectStep.RESUME); @@ -174,14 +163,11 @@ if (validate) { switch (s) { case CHOOSE_PROJECT_TYPE: - validate = projectType != null; + validate = type != null; break; - case CONFIGURE_JAR_PROJECT: - validate = jarSource != null && jarSource.exists() && projectName != null && !projectName.isEmpty(); + case CONFIGURE_PROJECT: + validate = type.validateUIModel(this); break; - case CONFIGURE_DIRECTORY_PROJECT: - validate = directorySource != null && directorySource.exists() && projectName != null && !projectName.isEmpty(); - break; case SELECT_BUNDLES: validate = !selectedBundles.isEmpty(); break; @@ -196,8 +182,8 @@ return validate; } - public ProjectType getProjectType() { - return projectType; + public I18nProjectProvider<? extends I18nProject> getType() { + return type; } public String getProjectName() { @@ -228,11 +214,11 @@ return storeFile; } - public void setProjectType(ProjectType projectType) { - ProjectType oldValue = this.projectType; - this.projectType = projectType; - firePropertyChange(PROJECT_TYPE_PROPERTY_NAME, oldValue, projectType); - if (oldValue != projectType) { + public void setType(I18nProjectProvider<? extends I18nProject> type) { + I18nProjectProvider<?> oldValue = this.type; + this.type = type; + firePropertyChange(TYPE_PROPERTY_NAME, oldValue, type); + if (oldValue != type) { updateUniverse(); } validate(); @@ -352,44 +338,13 @@ } public List<URL> detectBundles() { - List<URL> urls = new ArrayList<URL>(); - switch (projectType) { - case JAR: - if (uniqueJarDefinition) { - // on recherche l'unique bundle dans META-INF/ - try { - URLClassLoader loader = new URLClassLoader(new URL[]{jarSource.toURI().toURL()}); - List<URL> defs = Resource.getURLs("META-INF/.*-i18n-definition\\.properties", loader); - log.info("detected unique bundle definition " + defs); - if (!defs.isEmpty()) { - // on ne traite que le premier ??? - URL u = defs.get(0); - String path = u.toString(); - int index = path.lastIndexOf("/"); - path = path.substring(index + 1); - String bundleName = path.substring(0, path.length() - "-i18n-definition.properties".length()); - log.info("bundleName : " + bundleName); - urls = Resource.getURLs("META-INF/" + bundleName + "-.*\\.properties", loader); - urls.remove(u); - } - } catch (Exception ex) { - throw new RuntimeException(ex.getMessage(), ex); - } - - } else { - try { - URLClassLoader loader = new URLClassLoader(new URL[]{jarSource.toURI().toURL()}); - urls = Resource.getURLs(I18nBundleFactory.SEARCH_BUNDLE_PATTERN, loader); - log.info("detected bundles : " + urls); - } catch (Exception ex) { - throw new RuntimeException(ex.getMessage(), ex); - } - } - break; - case DIRECTORY: - break; + List<URL> urls; + try { + urls = type.detectBundles(this); + } catch (IOException ex) { + throw new RuntimeException(ex); } - Pattern p = Pattern.compile("(\\.+)-"); + // suppression du fichier pom.properties... for (Iterator<URL> it = urls.iterator(); it.hasNext();) { String path = it.next().toString(); int index = path.lastIndexOf("/"); @@ -402,16 +357,8 @@ } protected void copyTo(ProjectUIModel dst) { - dst.setProjectType(getProjectType()); + dst.setType(getType()); dst.setJarSource(getJarSource()); dst.setDirectorySource(getDirectorySource()); } - - public I18nProject toProject() { - I18nProject p = new I18nProject(projectName, selectedBundles.toArray(new URL[selectedBundles.size()])); - if (storeProject) { - p.setStoreFile(storeFile); - } - return p; - } } 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/SelectBundlesTableModel.java 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,6 +1,6 @@ /** - * *##% observe-swing - * Copyright (C) 2008 - 2009 IRD + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.css =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.css 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.css 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,6 +1,6 @@ /** - * *##% observe-swing - * Copyright (C) 2008 - 2009 IRD + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -16,6 +16,7 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* */ + #tabPanel { layout:{new BorderLayout()}; border:{new LineBorder(Color.BLACK,1,true)}; @@ -37,4 +38,4 @@ rows:3; editable:false; focusable:false; -} \ No newline at end of file +} Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/AbstractProjectTabPanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,4 +1,26 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <JPanel id="tabPanel" abstract='true' implements='jaxx.runtime.swing.wizard.WizardStepUI<ProjectStep, ProjectUIModel>'> @@ -43,7 +65,13 @@ return txt; } ]]></script> - + + <!-- layout pour la configuration specifique de chaque type de projet + on expose ici le layout sinon cela ne fonctionne pas (layout cree + apres 'content' : a fixer dans JAXX) --> + <jaxx.runtime.swing.CardLayout2Ext id='contentLayout' + constructorParams='this, "content"'/> + <!-- titre --> <JPanel layout='{new BorderLayout()}' constraints='BorderLayout.NORTH'> <JProgressBar id='progress' constraints='BorderLayout.CENTER'/> Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ChooseProjectTypePanelUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ChooseProjectTypePanelUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ChooseProjectTypePanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,8 +1,8 @@ <!-- /** - * *##% observe-swing - * Copyright (C) 2008 - 2009 IRD + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -24,47 +24,49 @@ <!-- L'écran de sélection de type de connexion --> <!-- ***************************************** --> <AbstractProjectTabPanelUI _step='{ProjectStep.CHOOSE_PROJECT_TYPE}'> - - <style> -JRadioButton { - buttonGroup:"mode"; -} - </style> <script><![CDATA[ import org.nuiton.i18n.editor.*; -import org.nuiton.i18n.editor.model.*; +import org.nuiton.i18n.editor.project.*; import org.nuiton.i18n.editor.ui.project.*; void $afterCompleteSetup() { - model.addPropertyChangeListener(ProjectUIModel.PROJECT_TYPE_PROPERTY_NAME, new PropertyChangeListener() { + // ajout des types de projets connus a partir des providers connus + int index = 0; + for (I18nProjectProvider<?> p : I18nProjectFactory.getProviders()) { + JRadioButton b = new JRadioButton(); + String name = "$JRadioButton" + index; + $objectMap.put( name, b); + b.setName(name); + b.putClientProperty("$buttonGroup", mode); + mode.add(b); + b.setText(_(p.getLabel())); + b.setToolTipText(_(p.getDescription())); + b.putClientProperty("$value", p); + mode.updateSelectedValue(); + content.add(b, new GridBagConstraints(0, index++, 1, 1, 1.0, 0.0, 10, 1, new Insets(3, 3, 3, 3), 0, 0)); + } + // on ecoute les changement de type de projet + model.addPropertyChangeListener(ProjectUIModel.TYPE_PROPERTY_NAME, new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { - ProjectType newMode = (ProjectType) evt.getNewValue(); - log.debug("new project type : " + newMode); - AbstractButton c = mode.getButton(newMode); - c.setSelected(true); - setDescriptionText(_(newMode.getDescription())); + I18nProjectProvider<?> newMode = (I18nProjectProvider<?>) evt.getNewValue(); + if (newMode != null) { + log.info("new project type : " + newMode); + AbstractButton c = mode.getButton(newMode); + c.setSelected(true); + setDescriptionText(_(newMode.getDescription())); + } } }); } ]]> </script> - <ButtonGroup id='mode' - onStateChanged='model.setProjectType((ProjectType) mode.getSelectedValue())'/> + <ButtonGroup id='mode' + onStateChanged='model.setType((I18nProjectProvider) mode.getSelectedValue())'/> - <Table id='content' fill='both' weightx='1' constraints='BorderLayout.CENTER'> - <row> - <cell> - <JRadioButton value='{ProjectType.JAR}' text='{ProjectType.JAR.getLabel()}' /> - </cell> - </row> - <row> - <cell> - <JRadioButton value='{ProjectType.DIRECTORY}' text='{ProjectType.DIRECTORY.getLabel()}' /> - </cell> - </row> - </Table> + <Table id='content' fill='both' weightx='1' constraints='BorderLayout.CENTER'/> </AbstractProjectTabPanelUI> Deleted: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureDirectoryProjectPanelUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureDirectoryProjectPanelUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureDirectoryProjectPanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,62 +0,0 @@ - -<AbstractProjectTabPanelUI _step='{ProjectStep.CONFIGURE_DIRECTORY_PROJECT}'> - - <script><![CDATA[ -import jaxx.runtime.SwingUtil; - -import org.nuiton.i18n.editor.*; -import org.nuiton.i18n.editor.model.*; -import org.nuiton.i18n.editor.ui.project.*; - -import java.io.File; - -public void chooseDirectorySource() { - File f = model.chooseDirectory( - this, - _("i18neditor.title.choose.directory.source"), - _("i18neditor.action.choose.directory.source.description"), - model.getJarSource()); - model.setDirectorySource(f); -} - -void $afterCompleteSetup() { - if (getStep()!=null) { - setDescriptionText(_(getStep().getDescription())); - } -} -]]> - </script> - - <Table id='content' fill='both' constraints='BorderLayout.CENTER'> - <row> - <cell columns="2"> - <JLabel text='i18neditor.createproject.name.label'/> - </cell> - </row> - <row> - <cell columns="2"> - <JTextField id='projectName' - text='{SwingUtil.getStringValue(model.getProjectName())}' - onKeyReleased='model.setProjectName(((JTextField)event.getSource()).getText())'/> - </cell> - </row> - <row> - <cell columns="2"> - <JLabel text='i18neditor.createproject.directory.source.label'/> - </cell> - </row> - <row> - <cell weightx='1' fill="both"> - <JTextField id="directorySourceFile" - text='{SwingUtil.getStringValue(model.getDirectorySource()+"")}' - onKeyReleased='model.setDirectorySource(new File(((JTextField)event.getSource()).getText()))'/> - </cell> - <cell anchor="east"> - <JButton id="fileChooserAction" - actionIcon="fileChooser" - onActionPerformed="chooseDirectorySource()"/> - </cell> - </row> - </Table> - -</AbstractProjectTabPanelUI> Deleted: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureJarProjectPanelUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureJarProjectPanelUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureJarProjectPanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,73 +0,0 @@ - -<AbstractProjectTabPanelUI _step='{ProjectStep.CONFIGURE_JAR_PROJECT}'> - - <script><![CDATA[ -import jaxx.runtime.SwingUtil; - -import org.nuiton.i18n.editor.*; -import org.nuiton.i18n.editor.model.*; -import org.nuiton.i18n.editor.ui.project.*; - -import java.io.File; - -public void chooseJarSource() { - File f = model.chooseFile ( - this, - _("i18neditor.title.choose.jar.source"), - _("i18neditor.action.choose.jar.source"), - model.getJarSource(), - "^.+\\.jar$", - _("i18neditor.action.choose.jar.source.description")); - model.setJarSource(f); -} - -void $afterCompleteSetup() { - if (getStep()!=null) { - setDescriptionText(_(getStep().getDescription())); - } -} -]]> - </script> - - <Table id='content' fill='both' constraints='BorderLayout.CENTER'> - <row> - <cell columns="2"> - <JLabel text='i18neditor.createproject.name.label'/> - </cell> - </row> - <row> - <cell columns="2"> - <JTextField id='projectName' - text='{SwingUtil.getStringValue(model.getProjectName())}' - onKeyReleased='model.setProjectName(((JTextField)event.getSource()).getText())'/> - </cell> - </row> - <row> - <cell columns="2"> - <JLabel text='i18neditor.createproject.jar.source.label'/> - </cell> - </row> - <row> - <cell weightx='1' fill="both"> - <JTextField id="jarSourceFile" - text='{SwingUtil.getStringValue(model.getJarSource()+"")}' - onKeyReleased='model.setJarSource(new File(((JTextField)event.getSource()).getText()))'/> - </cell> - <cell anchor="east"> - <JButton id="fileChooserAction" - actionIcon="fileChooser" - onActionPerformed="chooseJarSource()"/> - </cell> - </row> - <row> - <cell columns="2"> - <JCheckBox id='uniqueJarDefinition' - text='i18neditor.createproject.uniqueJarDefinition' - toolTipText='i18neditor.createproject.uniqueJarDefinition.tip' - selected='{model.isUniqueJarDefinition()}' - onItemStateChanged='model.setUniqueJarDefinition(event.getStateChange() == ItemEvent.SELECTED)'/> - </cell> - </row> - </Table> - -</AbstractProjectTabPanelUI> Added: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureProjectPanelUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureProjectPanelUI.jaxx (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureProjectPanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,69 @@ +<!-- + +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + +<AbstractProjectTabPanelUI _step='{ProjectStep.CONFIGURE_PROJECT}'> + + <script><![CDATA[ + +import java.lang.reflect.Constructor; + +import org.nuiton.i18n.editor.*; +import org.nuiton.i18n.editor.project.I18nProjectProvider; +import org.nuiton.i18n.editor.project.I18nProjectFactory; +import org.nuiton.i18n.editor.ui.project.*; + +protected String updateContentLayout(I18nProjectProvider<?> projectType) { + if (projectType == null) { + return "null"; + } + return projectType.getType().getName(); +} + +void $afterCompleteSetup() { + if (getStep()!=null) { + setDescriptionText(_(getStep().getDescription())); + } + for (I18nProjectProvider<?> p : I18nProjectFactory.getProviders()) { + try { + Class<? extends I18nProjectConfigurePanelUI> c = p.getUIClass(); + Constructor<? extends I18nProjectConfigurePanelUI> constructor = c.getConstructor(jaxx.runtime.JAXXContext.class); + I18nProjectConfigurePanelUI ui = constructor.newInstance(this); + getContent().add((java.awt.Component) ui, p.getType().getName()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} +]]> + </script> + + <jaxx.runtime.swing.CardLayout2Ext id='contentLayout' + selected='{updateContentLayout(model.getType())}'/> + + <JPanel id='content' layout='{contentLayout}'> + + <JLabel text='i18neditor.createproject.no.type' constraints='"null"'/> + + </JPanel> + +</AbstractProjectTabPanelUI> Added: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/DirectoryI18nProjectConfigurePanelUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/DirectoryI18nProjectConfigurePanelUI.jaxx (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/DirectoryI18nProjectConfigurePanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,81 @@ +<!-- + +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + +<Table fill='both' constraints='DirectoryI18nProject.class.getName()' + implements='org.nuiton.i18n.editor.ui.project.I18nProjectConfigurePanelUI'> + + <script><![CDATA[ +import jaxx.runtime.SwingUtil; + +import org.nuiton.i18n.editor.*; +import org.nuiton.i18n.editor.project.impl.*; +import org.nuiton.i18n.editor.ui.project.*; + +import java.io.File; + +protected ProjectUIModel model = getContextValue(ProjectUIModel.class); + +@Override +public ProjectUIModel getModel() { + return model; +} + +public void chooseDirectorySource() { + File f = model.chooseDirectory( + this, + _("i18neditor.title.choose.directory.source"), + _("i18neditor.action.choose.directory.source.description"), + model.getJarSource()); + model.setDirectorySource(f); +} +]]> + </script> + + <row> + <cell columns="2"> + <JLabel text='i18neditor.createproject.name.label'/> + </cell> + </row> + <row> + <cell columns="2"> + <JTextField text='{SwingUtil.getStringValue(model.getProjectName())}' + onKeyReleased='model.setProjectName(((JTextField)event.getSource()).getText())'/> + </cell> + </row> + <row> + <cell columns="2"> + <JLabel text='i18neditor.createproject.directory.source.label'/> + </cell> + </row> + <row> + <cell weightx='1' fill="both"> + <JTextField id="directorySourceFile" + text='{SwingUtil.getStringValue(model.getDirectorySource()+"")}' + onKeyReleased='model.setDirectorySource(new File(((JTextField)event.getSource()).getText()))'/> + </cell> + <cell anchor="east"> + <JButton actionIcon="fileChooser" + onActionPerformed="chooseDirectorySource()"/> + </cell> + </row> +</Table> Added: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/JarI18nProjectConfigurePanelUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/JarI18nProjectConfigurePanelUI.jaxx (rev 0) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/JarI18nProjectConfigurePanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,93 @@ +<!-- + +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + +<Table fill='both' constraints='JarI18nProject.class.getName()' + implements='org.nuiton.i18n.editor.ui.project.I18nProjectConfigurePanelUI'> + + <script><![CDATA[ +import jaxx.runtime.SwingUtil; + +import org.nuiton.i18n.editor.*; +import org.nuiton.i18n.editor.project.impl.*; +import org.nuiton.i18n.editor.ui.project.*; + +import java.io.File; + +protected ProjectUIModel model = getContextValue(ProjectUIModel.class); + +@Override +public ProjectUIModel getModel() { + return model; +} + +public void chooseJarSource() { + File f = model.chooseFile ( + this, + _("i18neditor.title.choose.jar.source"), + _("i18neditor.action.choose.jar.source"), + model.getJarSource(), + "^.+\\.jar$", + _("i18neditor.action.choose.jar.source.description")); + model.setJarSource(f); +} +]]> + </script> + + <row> + <cell columns="2"> + <JLabel text='i18neditor.createproject.name.label'/> + </cell> + </row> + <row> + <cell columns="2"> + <JTextField text='{SwingUtil.getStringValue(model.getProjectName())}' + onKeyReleased='model.setProjectName(((JTextField)event.getSource()).getText())'/> + </cell> + </row> + <row> + <cell columns="2"> + <JLabel text='i18neditor.createproject.jar.source.label'/> + </cell> + </row> + <row> + <cell weightx='1' fill="both"> + <JTextField id="jarSourceFile" + text='{SwingUtil.getStringValue(model.getJarSource()+"")}' + onKeyReleased='model.setJarSource(new File(((JTextField)event.getSource()).getText()))'/> + </cell> + <cell anchor="east"> + <JButton actionIcon="fileChooser" + onActionPerformed="chooseJarSource()"/> + </cell> + </row> + <row> + <cell columns="2"> + <JCheckBox id='uniqueJarDefinition' + text='i18neditor.createproject.uniqueJarDefinition' + toolTipText='i18neditor.createproject.uniqueJarDefinition.tip' + selected='{model.isUniqueJarDefinition()}' + onItemStateChanged='model.setUniqueJarDefinition(event.getStateChange() == ItemEvent.SELECTED)'/> + </cell> + </row> +</Table> + 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,11 +1,32 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <AbstractProjectTabPanelUI _step='{ProjectStep.PERSIST}'> <script><![CDATA[ import jaxx.runtime.SwingUtil; import org.nuiton.i18n.editor.*; -import org.nuiton.i18n.editor.model.*; import org.nuiton.i18n.editor.ui.project.*; import java.io.File; Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ResumePanelUI.jaxx =================================================================== --- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ResumePanelUI.jaxx 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ResumePanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,10 +1,31 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <AbstractProjectTabPanelUI _step='{ProjectStep.RESUME}'> <script><![CDATA[ import org.nuiton.i18n.editor.*; -import org.nuiton.i18n.editor.model.*; import org.nuiton.i18n.editor.ui.project.*; void $afterCompleteSetup() { 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx 2009-07-22 17:50:16 UTC (rev 1645) @@ -1,11 +1,32 @@ +<!-- +/** + * *##% Nuiton I18n Editor + * Copyright (C) 2008 - 2009 CodeLutin + * + * 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. ##%* + */ + +--> + <AbstractProjectTabPanelUI _step='{ProjectStep.SELECT_BUNDLES}'> <script><![CDATA[ import jaxx.runtime.SwingUtil; import org.nuiton.i18n.editor.*; -import org.nuiton.i18n.editor.model.*; import org.nuiton.i18n.editor.ui.project.*; Added: trunk/nuiton-i18n-editor/src/main/resources/META-INF/services/org.nuiton.i18n.editor.project.I18nProjectProvider =================================================================== --- trunk/nuiton-i18n-editor/src/main/resources/META-INF/services/org.nuiton.i18n.editor.project.I18nProjectProvider (rev 0) +++ trunk/nuiton-i18n-editor/src/main/resources/META-INF/services/org.nuiton.i18n.editor.project.I18nProjectProvider 2009-07-22 17:50:16 UTC (rev 1645) @@ -0,0 +1,2 @@ +org.nuiton.i18n.editor.project.impl.JarI18nProjectProvider +org.nuiton.i18n.editor.project.impl.DirectoryI18nProjectProvider 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties 2009-07-22 17:50:16 UTC (rev 1645) @@ -66,6 +66,7 @@ i18neditor.createproject.doPersist= i18neditor.createproject.jar.source.label= i18neditor.createproject.name.label= +i18neditor.createproject.no.type= i18neditor.createproject.storeProject.directory= i18neditor.createproject.storeProject.path= i18neditor.createproject.uniqueJarDefinition= @@ -89,6 +90,8 @@ i18neditor.project.step.configureDirectoryProject.description= i18neditor.project.step.configureJarProject= i18neditor.project.step.configureJarProject.description= +i18neditor.project.step.configureProject= +i18neditor.project.step.configureProject.description= i18neditor.project.step.label= i18neditor.project.step.persist= i18neditor.project.step.persist.description= 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-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties 2009-07-22 17:50:16 UTC (rev 1645) @@ -66,6 +66,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.storeProject.directory=R\u00E9pertoire de sauvegarde i18neditor.createproject.storeProject.path=Fichier de sauvegarde i18neditor.createproject.uniqueJarDefinition=Utilisation d'un bundle final @@ -87,8 +88,10 @@ i18neditor.project.step.chooseProjectType.description=Choisir le type de projet \u00E0 ouvrir i18neditor.project.step.configureDirectoryProject=Configuration i18neditor.project.step.configureDirectoryProject.description=Configurer le projet de type 'r\u00E9pertoire' -i18neditor.project.step.configureJarProject=Configuration -i18neditor.project.step.configureJarProject.description=Configurer le projet de type 'jar' +i18neditor.project.step.configureJarProject= +i18neditor.project.step.configureJarProject.description= +i18neditor.project.step.configureProject=Configuration +i18neditor.project.step.configureProject.description=Configurer le projet i18neditor.project.step.label=Etape %1$d/%2$d \: %3$s i18neditor.project.step.persist=Sauvegarde i18neditor.project.step.persist.description=Permet de sauvegarder la d\u00E9finition du projet Modified: trunk/nuiton-i18n-editor/src/main/resources/log4j.properties =================================================================== --- trunk/nuiton-i18n-editor/src/main/resources/log4j.properties 2009-07-06 12:04:17 UTC (rev 1644) +++ trunk/nuiton-i18n-editor/src/main/resources/log4j.properties 2009-07-22 17:50:16 UTC (rev 1645) @@ -8,6 +8,6 @@ # package level log4j.logger.org.nuiton=WARN log4j.logger.org.nuiton.i18n.editor=INFO -#log4j.logger.org.nuiton.i18n=INFO +log4j.logger.org.nuiton.util.Resource=DEBUG #log4j.logger.org.nuiton.i18n.editor.I18nEditorConfig=DEBUG #log4j.logger.jaxx.runtime.swing.I18nWidget=DEBUG