Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
July 2009
- 2 participants
- 9 discussions
[Lutinutil-commits] r1649 - in trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor: project project/impl ui ui/project ui/project/tabs
by tchemit@users.labs.libre-entreprise.org 30 Jul '09
by tchemit@users.labs.libre-entreprise.org 30 Jul '09
30 Jul '09
Author: tchemit
Date: 2009-07-31 01:04:45 +0200 (Fri, 31 Jul 2009)
New Revision: 1649
Modified:
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx
Log:
make ProjectUIModel neutral from project definition
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProject.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,6 +18,8 @@
*/
package org.nuiton.i18n.editor.project;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -43,113 +45,109 @@
*/
public class AbstractI18nProject implements I18nProject {
- public static final Log log = LogFactory.getLog(AbstractI18nProject.class);
+ public static final String NAME_PROPERTY_NAME = "name";
+ public static final String URLS_PROPERTY_NAME = "urls";
+ public static final String STORE_PROJECT_PROPERTY_NAME = "storeProject";
+ public static final String STORE_FILE_PROPERTY_NAME = "storeFile";
public static final Locale[] EMPTY_LOCALE_ARRAY = new Locale[0];
public static final String EMPTY_STRING = "";
public static final String[] EMPTY_STRING_ARRAY = new String[0];
- /**
- * le nom du projet
- */
- protected final String name;
- /**
- * les urls des fichiers de traduction a charger
- */
- protected URL[] urls;
- /**
- * les definitions de bundles du projet
- */
+ public static final Log log = LogFactory.getLog(AbstractI18nProject.class);
+ /** le nom du projet */
+ protected String name;
+ /** les urls des fichiers de traduction a charger */
+ protected List<URL> urls;
+ /** les definitions de bundles du projet */
protected I18nBundle[] i18nBundles;
- /**
- * le fichier où conserver le projet (si null, on ne persiste pas le projet)
- */
- protected File storeFile;
- /**
- * un drapeau pour savoir si le modele a ete charge
- */
+ /** le fichier où conserver le projet (si null, on ne persiste pas le projet) */
+ protected File storeFile = new File("");
+ /** un drapeau pour savoir si on persiste le projet */
+ protected boolean storeProject;
+ /** un drapeau pour savoir si le modele a ete charge */
boolean loaded;
- /**
- * Les locales selectionnees dans ce projet
- */
- protected final List<Locale> selectedBundles;
- /**
- * les paquetages selectionnes dans ce projet
- */
- protected final List<String> selectedPackages;
- /**
- * le dictionnaire des fichiers de traductions charges
- */
- protected final Map<String, Properties> resources;
+ /** Les locales selectionnees dans ce projet */
+ protected List<Locale> selectedBundles;
+ /** les paquetages selectionnes dans ce projet */
+ protected List<String> selectedPackages;
+ /** le dictionnaire des fichiers de traductions charges */
+ protected Map<String, Properties> resources;
+ /** pour propager les changements du modele */
+ protected PropertyChangeSupport pcs;
- protected AbstractI18nProject(String name, URL... urls) {
- this.name = name;
- this.urls = urls;
+ protected AbstractI18nProject() {
this.resources = new LinkedHashMap<String, Properties>();
this.selectedBundles = new ArrayList<Locale>();
this.selectedPackages = new ArrayList<String>();
+ this.pcs = new PropertyChangeSupport(this);
}
- /**
- * @return le nom du projet
- */
@Override
public String getName() {
return name;
}
- /**
- * @return les paquetages du projet
- */
@Override
- public String[] getPackages() {
- return I18nBundleFactory.getBundleNames(i18nBundles);
+ public List<URL> getUrls() {
+ return urls;
}
- /**
- * @return les locales du projet
- */
@Override
- public Locale[] getBundles() {
- return I18nBundleFactory.getLocales(i18nBundles);
+ public boolean isStoreProject() {
+ return storeProject;
}
- /**
- * @return les paquetages selectionnes
- */
@Override
- public List<String> getSelectedPackages() {
- return selectedPackages;
+ public File getStoreFile() {
+ return storeFile;
}
- /**
- * @return les locales selectionnees
- */
@Override
- public List<Locale> getSelectedBundles() {
- return selectedBundles;
+ public void setName(String name) {
+ String oldValue = this.name;
+ this.name = name;
+ firePropertyChange(NAME_PROPERTY_NAME, oldValue, name);
}
- /**
- * @return les urls du projet
- */
@Override
- public URL[] getURLs() {
- return urls;
+ public void setUrls(List<URL> urls) {
+ this.urls = urls;
}
@Override
- public File getStoreFile() {
- return storeFile;
+ public void setStoreProject(boolean storeProject) {
+ boolean oldValue = this.storeProject;
+ this.storeProject = storeProject;
+ firePropertyChange(STORE_PROJECT_PROPERTY_NAME, oldValue, storeProject);
}
@Override
public void setStoreFile(File storeFile) {
+ File oldValue = this.storeFile;
this.storeFile = storeFile;
+ firePropertyChange(STORE_FILE_PROPERTY_NAME, oldValue, storeFile);
}
- /**
- * @return les clefs de traductions pour les packages selectionnee et les locales selectionnes
- */
@Override
+ public String[] getPackages() {
+ return I18nBundleFactory.getBundleNames(i18nBundles);
+ }
+
+ @Override
+ public Locale[] getBundles() {
+ return I18nBundleFactory.getLocales(i18nBundles);
+ }
+
+ @Override
+ public List<String> getSelectedPackages() {
+ return selectedPackages;
+ }
+
+ @Override
+ public List<Locale> getSelectedBundles() {
+ return selectedBundles;
+ }
+
+ @Override
public String[] getKeys() {
if (!loaded) {
return EMPTY_STRING_ARRAY;
@@ -176,13 +174,6 @@
return r.toArray(new String[r.size()]);
}
- /**
- * Supprime une traduction pour une clef donnee dans une langue et un paquetage donne.
- *
- * @param packageName le paquetage ou supprimer la clef
- * @param locale la locale de la traduction
- * @param key la clef de traduction
- */
@Override
public void deleteKey(String packageName, Locale locale, String key) {
checkLoaded();
@@ -192,11 +183,6 @@
}
}
- /**
- * @param packageName
- * @param key la clef de traductions
- * @return les traductions pour les packages, locales et clef selectionnees
- */
@Override
public Map<Locale, String> getValues(String packageName, String key) {
if (!loaded) {
@@ -228,12 +214,6 @@
return r;
}
- /**
- * @param key la clef de traductions
- * @param locale la locale
- * @param packageName le nom du package
- * @return les traductions
- */
@Override
public String getValue(String packageName, Locale locale, String key) {
if (!loaded) {
@@ -248,14 +228,6 @@
}
- /**
- * Ajouter une traduction dans le projet.
- *
- * @param packageName le paquetage ou ajouter la clef
- * @param locale la locale de la traduction
- * @param key la clef de traduction
- * @param value la traduction
- */
@Override
public void addValue(String packageName, Locale locale, String key, String value) {
checkLoaded();
@@ -265,14 +237,6 @@
}
}
- /**
- * Mettre a jour une traduction dans le projet.
- *
- * @param packageName le paquetage ou ajouter la clef
- * @param locale la locale de la traduction
- * @param key la clef de traduction
- * @param value la traduction
- */
@Override
public void updateValue(String packageName, Locale locale, String key, String value) {
checkLoaded();
@@ -282,21 +246,29 @@
}
}
- /**
- * Chargement des traductions du projet.
- *
- * @throws IOException
- */
@Override
+ public void copyDefinitionTo(I18nProject project) {
+ // check we are on the same type of project
+ if (project.getClass() != getClass()) {
+ throw new IllegalArgumentException("copyDefinitionTo method must use same project type, but was not! (required : " + getClass() + ", but find " + project.getClass() + 3);
+ }
+ project.setName(name);
+ project.setUrls(urls);
+ project.setStoreProject(storeProject);
+ // always clean storeFile (could be init in project from ui, but only keep it if necessary)
+ project.setStoreFile(storeProject ? storeFile : null);
+ }
+
+ @Override
public void load() throws IOException {
try {
- synchronized (this.resources) {
+ synchronized (this) {
resources.clear();
selectedBundles.clear();
selectedPackages.clear();
// detections des bundles i18n a partir des urls donnees
- List<I18nBundle> tmp = I18nBundleFactory.detectBundles(urls);
+ List<I18nBundle> tmp = I18nBundleFactory.detectBundles(urls.toArray(new URL[urls.size()]));
i18nBundles = tmp.toArray(new I18nBundle[tmp.size()]);
selectedBundles.addAll(Arrays.asList(getBundles()));
@@ -316,26 +288,15 @@
}
}
- /**
- * Enregistrement des traductions du projet.
- *
- * @throws IOException
- */
@Override
public void store() throws IOException {
checkLoaded();
}
@Override
- public void storeDefinition() throws IOException {
+ public void saveDefinition() throws IOException {
Properties p = new Properties();
- p.setProperty("name", name);
- p.setProperty("class", getClass().getName());
- StringBuilder buffer = new StringBuilder();
- for (URL u : urls) {
- buffer.append(',').append(u.toString());
- }
- p.setProperty("urls", buffer.substring(1));
+ fillDefinition(p);
FileOutputStream stream = null;
try {
stream = new FileOutputStream(getStoreFile());
@@ -349,6 +310,69 @@
}
@Override
+ public void fillDefinition(Properties p) {
+ p.setProperty("name", name);
+ p.setProperty("class", getClass().getName());
+ StringBuilder buffer = new StringBuilder();
+ for (URL u : urls) {
+ buffer.append(',').append(u.toString());
+ }
+ p.setProperty("urls", buffer.substring(1));
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<name: " + name + ">";
+ }
+
+ @Override
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ if (log.isDebugEnabled()) {
+ log.debug(this + " / " + listener);
+ }
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ @Override
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ if (log.isDebugEnabled()) {
+ log.debug(this + " / " + propertyName + " : " + listener);
+ }
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ @Override
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ if (log.isDebugEnabled()) {
+ log.debug(this + " / " + listener);
+ }
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ @Override
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ if (log.isDebugEnabled()) {
+ log.debug(this + " / " + propertyName + " : " + listener);
+ }
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ @Override
+ public void removePropertyChangeListeners() {
+ for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+
+ @Override
+ public void fireAllProperties() {
+ firePropertyChange(NAME_PROPERTY_NAME, null, name);
+ firePropertyChange(URLS_PROPERTY_NAME, null, urls);
+ firePropertyChange(STORE_PROJECT_PROPERTY_NAME, null, storeProject);
+ firePropertyChange(STORE_FILE_PROPERTY_NAME, null, storeFile);
+ }
+
+ @Override
protected void finalize() throws Throwable {
super.finalize();
i18nBundles = null;
@@ -357,9 +381,8 @@
selectedPackages.clear();
}
- @Override
- public String toString() {
- return super.toString() + "<name: " + name + ">";
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
}
protected I18nBundle getI18nBundle(String packageName) {
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/AbstractI18nProjectProvider.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -26,6 +26,8 @@
import java.util.Map;
import java.util.Map.Entry;
import org.nuiton.i18n.I18n;
+import org.nuiton.i18n.editor.project.impl.DirectoryI18nProject;
+import org.nuiton.i18n.editor.ui.project.ProjectUIModel;
/**
*
@@ -36,8 +38,6 @@
public abstract class AbstractI18nProjectProvider<P extends I18nProject> implements I18nProjectProvider<P> {
public static final String CLASS_PARAMETER = "class";
- public static final String NAME_PARAMETER = "name";
- public static final String URLS_PARAMETER = "urls";
protected final Class<P> type;
protected final String label;
protected final String description;
@@ -66,7 +66,6 @@
return I18n._(description);
}
-
@Override
public Map<String, Class<?>> getAuthorizedParameters() {
if (authorizedParameters == null) {
@@ -75,7 +74,15 @@
return authorizedParameters;
}
- public <T extends Object> T getParameter(Class<T> returnType, String propertyName, Map<String, Object> parameters) {
+ @Override
+ public P newProject(ProjectUIModel model) {
+ I18nProject project = model.getProject();
+ P p = newProject();
+ project.copyDefinitionTo(p);
+ return p;
+ }
+
+ public <T extends Object> T getParameter(Class<T> returnType, String propertyName, Map<String, Object> parameters, boolean mustExist) {
Map<String, Class<?>> map = getAuthorizedParameters();
// check name
if (!map.containsKey(propertyName)) {
@@ -92,6 +99,9 @@
return (T) e.getValue();
}
}
- throw new IllegalArgumentException("could not find property " + propertyName + ".\nKnown properties in :\n" + parameters.keySet());
+ if (mustExist) {
+ throw new IllegalArgumentException("could not find property " + propertyName + ".\nKnown properties in :\n" + parameters.keySet());
+ }
+ return null;
}
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProject.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,12 +18,14 @@
*/
package org.nuiton.i18n.editor.project;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Properties;
/**
*
@@ -31,60 +33,79 @@
*/
public interface I18nProject {
+ /////////////////////////////////////////////////////////////////////
+ // definition accessor //////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
/**
* @return le nom du projet
*/
- public String getName();
+ String getName();
/**
- * @return les paquetages du projet
+ * @return les urls du projet
*/
- public String[] getPackages();
+ List<URL> getUrls();
/**
- * @return les locales du projet
+ *
+ * @return <code>true</code> si la definition du projet est persiste
*/
- public Locale[] getBundles();
+ boolean isStoreProject();
/**
- * @return les paquetages selectionnes
+ *
+ * @return le chemin du fichier ou persister la definition du projet
+ *
+ * Note : n'est pris en compte uniquement si {@link #isStoreProject()} est
+ * vrai.
*/
- public List<String> getSelectedPackages();
+ File getStoreFile();
+ /////////////////////////////////////////////////////////////////////
+ // definition mutator //////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ void setName(String name);
+
+ void setUrls(List<URL> urls);
+
+ void setStoreProject(boolean storeProject);
+
+ void setStoreFile(File storeFile);
+
+ /////////////////////////////////////////////////////////////////////
+ // runtime accessor /////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
/**
- * @return les locales selectionnees
+ * @return les paquetages du projet
*/
- public List<Locale> getSelectedBundles();
+ String[] getPackages();
/**
- * @return les urls du projet
+ * @return les locales du projet
*/
- public URL[] getURLs();
+ Locale[] getBundles();
- public File getStoreFile();
+ /**
+ * @return les paquetages selectionnes
+ */
+ List<String> getSelectedPackages();
- public void setStoreFile(File storeFile);
-
/**
- * @return les clefs de traductions pour les packages selectionnee et les locales selectionnes
+ * @return les locales selectionnees
*/
- public String[] getKeys();
+ List<Locale> getSelectedBundles();
/**
- * Supprime une traduction pour une clef donnee dans une langue et un paquetage donne.
- *
- * @param packageName le paquetage ou supprimer la clef
- * @param locale la locale de la traduction
- * @param key la clef de traduction
+ * @return les clefs de traductions pour les packages selectionnee et les locales selectionnes
*/
- public void deleteKey(String packageName, Locale locale, String key);
+ String[] getKeys();
/**
* @param packageName
* @param key la clef de traductions
* @return les traductions pour les packages, locales et clef selectionnees
*/
- public Map<Locale, String> getValues(String packageName, String key);
+ Map<Locale, String> getValues(String packageName, String key);
/**
* @param key la clef de traductions
@@ -92,9 +113,25 @@
* @param packageName le nom du package
* @return les traductions
*/
- public String getValue(String packageName, Locale locale, String key);
+ String getValue(String packageName, Locale locale, String key);
/**
+ * Copy roject definition to the given project.
+ *
+ * @param project the destination project
+ */
+ void copyDefinitionTo(I18nProject project);
+
+ /**
+ * Supprime une traduction pour une clef donnee dans une langue et un paquetage donne.
+ *
+ * @param packageName le paquetage ou supprimer la clef
+ * @param locale la locale de la traduction
+ * @param key la clef de traduction
+ */
+ void deleteKey(String packageName, Locale locale, String key);
+
+ /**
* Ajouter une traduction dans le projet.
*
* @param packageName le paquetage ou ajouter la clef
@@ -102,7 +139,7 @@
* @param key la clef de traduction
* @param value la traduction
*/
- public void addValue(String packageName, Locale locale, String key, String value);
+ void addValue(String packageName, Locale locale, String key, String value);
/**
* Mettre a jour une traduction dans le projet.
@@ -112,21 +149,50 @@
* @param key la clef de traduction
* @param value la traduction
*/
- public void updateValue(String packageName, Locale locale, String key, String value);
+ void updateValue(String packageName, Locale locale, String key, String value);
/**
* Chargement des traductions du projet.
*
* @throws IOException
*/
- public void load() throws IOException;
+ void load() throws IOException;
/**
* Enregistrement des traductions du projet.
*
* @throws IOException
*/
- public void store() throws IOException;
+ void store() throws IOException;
- public void storeDefinition() throws IOException;
+ /**
+ * Sauvegarde la definition du projet.
+ *
+ * @throws IOException pour tout pb lors de la sauvegarde
+ */
+ void saveDefinition() throws IOException;
+
+ /**
+ * Remplit un dictionnaire avec les proprietes de la definition du projet.
+ *
+ * @param p le dictionnaire des proprietes de la definition du projet
+ */
+ void fillDefinition(Properties p);
+
+ /////////////////////////////////////////////////////////////////////
+ // property change listeners ////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ void addPropertyChangeListener(PropertyChangeListener listener);
+
+ void addPropertyChangeListener(String propertyName, PropertyChangeListener listener);
+
+ void removePropertyChangeListener(PropertyChangeListener listener);
+
+ void removePropertyChangeListener(String propertyName, PropertyChangeListener listener);
+
+ void removePropertyChangeListeners();
+
+ void fireAllProperties();
+
+
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -24,13 +24,17 @@
/**
* Le contrat a respecter pour configurer un type de projet.
*
+ * @param <P> le type de projet
+ *
* @author chemit
*/
-public interface I18nProjectConfigurePanelUI extends JAXXObject {
+public interface I18nProjectConfigurePanelUI<P extends I18nProject> extends JAXXObject {
/**
*
* @return l'instance partagee du modele de creation de projet
*/
ProjectUIModel getModel();
+
+ P getProject();
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectFactory.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -149,7 +149,7 @@
* @return le provideur pour le le type de projet donne, ou <code>null</code>
* si aucun provideur ne prend en charge ce type de projet.
*/
- protected static <P extends I18nProject> I18nProjectProvider<P> getProvider(Class<P> projectClass) {
+ public static <P extends I18nProject> I18nProjectProvider<P> getProvider(Class<P> projectClass) {
for (I18nProjectProvider<?> p : getProviders()) {
if (p.getType() == projectClass) {
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -57,6 +57,7 @@
*/
Map<String, Class<?>> getAuthorizedParameters();
+ P newProject();
/**
*
* @param params les paramètres pour instancier le projet
@@ -93,7 +94,7 @@
*
* @return le type de l'ui pour configurer ce type de projet
*/
- Class<? extends I18nProjectConfigurePanelUI> getUIClass();
+ Class<? extends I18nProjectConfigurePanelUI<?>> getUIClass();
/**
* Valide dans l'ui de creation de projet la partie specifique a
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProject.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,8 +18,10 @@
*/
package org.nuiton.i18n.editor.project.impl;
+import java.io.File;
import org.nuiton.i18n.editor.project.AbstractI18nProject;
-import java.net.URL;
+import java.util.Properties;
+import org.nuiton.i18n.editor.project.I18nProject;
/**
*
@@ -27,7 +29,39 @@
*/
public class DirectoryI18nProject extends AbstractI18nProject {
- public DirectoryI18nProject(String name, URL[] urls) {
- super(name, urls);
+ public static final String DIRECTORY_SOURCE_PROPERTY_NAME = "directorySource";
+ /** la source pour un projet de type directory */
+ protected File directorySource = new File("");
+
+ public DirectoryI18nProject() {
+ super();
}
+
+ public File getDirectorySource() {
+ return directorySource;
+ }
+
+ public void setDirectorySource(File directorySource) {
+ File oldValue = this.directorySource;
+ this.directorySource = directorySource;
+ firePropertyChange(DIRECTORY_SOURCE_PROPERTY_NAME, oldValue, directorySource);
+ }
+
+ @Override
+ public void fillDefinition(Properties p) {
+ super.fillDefinition(p);
+ p.setProperty(DIRECTORY_SOURCE_PROPERTY_NAME, directorySource.getAbsolutePath());
+ }
+
+ @Override
+ public void copyDefinitionTo(I18nProject project) {
+ super.copyDefinitionTo(project);
+ ((DirectoryI18nProject) project).setDirectorySource(directorySource);
+ }
+
+ @Override
+ public void fireAllProperties() {
+ super.fireAllProperties();
+ firePropertyChange(DIRECTORY_SOURCE_PROPERTY_NAME, null, directorySource);
+ }
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -22,12 +22,13 @@
-->
<Table fill='both' constraints='DirectoryI18nProject.class.getName()'
- implements='org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI'>
+ implements='org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI<DirectoryI18nProject>'>
<script><![CDATA[
import jaxx.runtime.SwingUtil;
import org.nuiton.i18n.editor.*;
+import org.nuiton.i18n.editor.project.I18nProject;
import org.nuiton.i18n.editor.project.impl.*;
import org.nuiton.i18n.editor.ui.project.*;
@@ -35,18 +36,30 @@
protected ProjectUIModel model = getContextValue(ProjectUIModel.class);
+protected DirectoryI18nProject project = model.getProject(DirectoryI18nProject.class);
+
@Override
public ProjectUIModel getModel() {
return model;
}
+@Override
+public DirectoryI18nProject getProject() {
+ return project;
+ //I18nProject p = model.getProject();
+ //if (p instanceof DirectoryI18nProject) {
+ // return (DirectoryI18nProject) p;
+ //}
+ //return null;
+}
+
public void chooseDirectorySource() {
File f = model.chooseDirectory(
this,
_("i18neditor.title.choose.directory.source"),
_("i18neditor.action.choose.directory.source.description"),
- model.getJarSource());
- model.setDirectorySource(f);
+ getProject().getDirectorySource());
+ getProject().setDirectorySource(f);
}
]]>
</script>
@@ -58,8 +71,8 @@
</row>
<row>
<cell columns="2">
- <JTextField text='{SwingUtil.getStringValue(model.getProjectName())}'
- onKeyReleased='model.setProjectName(((JTextField)event.getSource()).getText())'/>
+ <JTextField text='{SwingUtil.getStringValue(getProject().getName())}'
+ onKeyReleased='getProject().setName(((JTextField)event.getSource()).getText())'/>
</cell>
</row>
<row>
@@ -70,8 +83,8 @@
<row>
<cell weightx='1' fill="both">
<JTextField id="directorySourceFile"
- text='{SwingUtil.getStringValue(model.getDirectorySource()+"")}'
- onKeyReleased='model.setDirectorySource(new File(((JTextField)event.getSource()).getText()))'/>
+ text='{SwingUtil.getStringValue(getProject().getDirectorySource()+"")}'
+ onKeyReleased='getProject().setDirectorySource(new File(((JTextField)event.getSource()).getText()))'/>
</cell>
<cell anchor="east">
<JButton actionIcon="fileChooser"
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,6 +18,7 @@
*/
package org.nuiton.i18n.editor.project.impl;
+import java.io.File;
import java.io.IOException;
import org.nuiton.i18n.editor.project.AbstractI18nProjectProvider;
import java.net.URL;
@@ -44,62 +45,80 @@
@Override
protected Map<String, Class<?>> initAuthorizedParameters() {
Map<String, Class<?>> result = new TreeMap<String, Class<?>>();
- result.put(NAME_PARAMETER, String.class);
- result.put(URLS_PARAMETER, URL[].class);
+ result.put(DirectoryI18nProject.NAME_PROPERTY_NAME, String.class);
+ result.put(DirectoryI18nProject.URLS_PROPERTY_NAME, List.class);
+ result.put(DirectoryI18nProject.DIRECTORY_SOURCE_PROPERTY_NAME, File.class);
return result;
}
@Override
- public DirectoryI18nProject newProject(Map<String, Object> params) {
- String name = getParameter(String.class, NAME_PARAMETER, params);
- URL[] urls = getParameter(URL[].class, URLS_PARAMETER, params);
- return new DirectoryI18nProject(name, urls);
+ public DirectoryI18nProject newProject() {
+ return new DirectoryI18nProject();
}
@Override
- public DirectoryI18nProject newProject(ProjectUIModel model) {
- DirectoryI18nProject p = new DirectoryI18nProject(model.getProjectName(), model.getSelectedBundles().toArray(new URL[model.getSelectedBundles().size()]));
- if (model.isStoreProject()) {
- p.setStoreFile(model.getStoreFile());
- }
+ public DirectoryI18nProject newProject(Map<String, Object> params) {
+ // mandatory parameters
+ String name = getParameter(String.class, DirectoryI18nProject.NAME_PROPERTY_NAME, params, true);
+ List<URL> urls = getParameter(List.class, DirectoryI18nProject.URLS_PROPERTY_NAME, params, true);
+
+ // optional parameters
+ File directorySource = getParameter(File.class, DirectoryI18nProject.DIRECTORY_SOURCE_PROPERTY_NAME, params, false);
+
+ DirectoryI18nProject p = new DirectoryI18nProject();
+ p.setName(name);
+ p.setUrls(urls);
+ p.setDirectorySource(directorySource);
return p;
}
@Override
public DirectoryI18nProject newProject(Properties properties) {
Map<String, Object> params = new TreeMap<String, Object>();
- params.put(NAME_PARAMETER, properties.getProperty(NAME_PARAMETER));
- String tmp = properties.getProperty(URLS_PARAMETER);
+ String tmp;
+
+ // name
+ tmp = properties.getProperty(DirectoryI18nProject.NAME_PROPERTY_NAME);
+ params.put(DirectoryI18nProject.NAME_PROPERTY_NAME, tmp);
+
+ // urls
+ tmp = properties.getProperty(DirectoryI18nProject.URLS_PROPERTY_NAME);
String[] urlsStr = tmp.split(",");
List<URL> urls = new ArrayList<URL>();
for (String u : urlsStr) {
URL url = ConverterUtil.convert(URL.class, u);
urls.add(url);
}
+ params.put(DirectoryI18nProject.URLS_PROPERTY_NAME, urls);
- params.put(URLS_PARAMETER, urls.toArray(new URL[urls.size()]));
-
+ // directorySource
+ tmp = properties.getProperty(DirectoryI18nProject.DIRECTORY_SOURCE_PROPERTY_NAME);
+ File directorySource = new File(tmp);
+ params.put(DirectoryI18nProject.DIRECTORY_SOURCE_PROPERTY_NAME, directorySource);
DirectoryI18nProject p = newProject(params);
return p;
}
@Override
public List<URL> detectBundles(ProjectUIModel model) throws IOException {
+ //TODO
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean validateUIModel(ProjectUIModel model) {
- return model.getDirectorySource() != null && model.getDirectorySource().exists() && model.getProjectName() != null && !model.getProjectName().isEmpty();
+ DirectoryI18nProject project = (DirectoryI18nProject) model.getProject();
+ return project.getDirectorySource() != null && project.getDirectorySource().exists() && project.getName() != null && !project.getName().isEmpty();
}
@Override
public boolean validateDefinition(Properties properties) {
+ //TODO
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public Class<? extends I18nProjectConfigurePanelUI> getUIClass() {
+ public Class<? extends I18nProjectConfigurePanelUI<?>> getUIClass() {
return DirectoryI18nProjectConfigurePanelUI.class;
}
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProject.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,18 +18,69 @@
*/
package org.nuiton.i18n.editor.project.impl;
+import java.io.File;
+import java.util.Properties;
import org.nuiton.i18n.editor.project.AbstractI18nProject;
-import java.net.URL;
+import org.nuiton.i18n.editor.project.I18nProject;
/**
*
* @author chemit
*/
-public class JarI18nProject extends AbstractI18nProject{
+public class JarI18nProject extends AbstractI18nProject {
- public JarI18nProject(String name, URL[] urls) {
- super(name, urls);
+ public static final String JAR_SOURCE_PROPERTY_NAME = "jarSource";
+ public static final String UNIQUE_JAR_DEFINITION_PROPERTY_NAME = "uniqueJarDefinition";
+ /** la source pour un projet de type jar */
+ protected File jarSource = new File("");
+ /**
+ * un drapeau (pour les projets de type jar) pour savoir si on utilise le
+ * système i18n avec nom unique.
+ */
+ protected boolean uniqueJarDefinition;
+
+ public JarI18nProject() {
+ super();
}
+ public File getJarSource() {
+ return jarSource;
+ }
+ public void setJarSource(File jarSource) {
+ File oldValue = this.jarSource;
+ this.jarSource = jarSource;
+ firePropertyChange(JAR_SOURCE_PROPERTY_NAME, oldValue, jarSource);
+ }
+
+ public boolean isUniqueJarDefinition() {
+ return uniqueJarDefinition;
+ }
+
+ public void setUniqueJarDefinition(boolean uniqueJarDefinition) {
+ boolean oldValue = this.uniqueJarDefinition;
+ this.uniqueJarDefinition = uniqueJarDefinition;
+ firePropertyChange(UNIQUE_JAR_DEFINITION_PROPERTY_NAME, oldValue, uniqueJarDefinition);
+ }
+
+ @Override
+ public void fillDefinition(Properties p) {
+ super.fillDefinition(p);
+ p.setProperty(JAR_SOURCE_PROPERTY_NAME, jarSource.getAbsolutePath());
+ p.setProperty(UNIQUE_JAR_DEFINITION_PROPERTY_NAME, Boolean.valueOf(uniqueJarDefinition).toString());
+ }
+
+ @Override
+ public void copyDefinitionTo(I18nProject project) {
+ super.copyDefinitionTo(project);
+ ((JarI18nProject) project).setJarSource(jarSource);
+ ((JarI18nProject) project).setUniqueJarDefinition(uniqueJarDefinition);
+ }
+
+ @Override
+ public void fireAllProperties() {
+ super.fireAllProperties();
+ firePropertyChange(JAR_SOURCE_PROPERTY_NAME, null, jarSource);
+ firePropertyChange(UNIQUE_JAR_DEFINITION_PROPERTY_NAME, null, uniqueJarDefinition);
+ }
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -22,12 +22,13 @@
-->
<Table fill='both' constraints='JarI18nProject.class.getName()'
- implements='org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI'>
+ implements='org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI<JarI18nProject>'>
<script><![CDATA[
import jaxx.runtime.SwingUtil;
import org.nuiton.i18n.editor.*;
+import org.nuiton.i18n.editor.project.I18nProject;
import org.nuiton.i18n.editor.project.impl.*;
import org.nuiton.i18n.editor.ui.project.*;
@@ -35,20 +36,32 @@
protected ProjectUIModel model = getContextValue(ProjectUIModel.class);
+protected JarI18nProject project = model.getProject(JarI18nProject.class);
+
@Override
public ProjectUIModel getModel() {
return model;
}
+@Override
+public JarI18nProject getProject() {
+ return project;
+ //I18nProject p = model.getProject();
+ //if (p instanceof JarI18nProject) {
+ // return (JarI18nProject) p;
+ //}
+ //return null;
+}
+
public void chooseJarSource() {
File f = model.chooseFile (
this,
_("i18neditor.title.choose.jar.source"),
_("i18neditor.action.choose.jar.source"),
- model.getJarSource(),
+ getProject().getJarSource(),
"^.+\\.jar$",
_("i18neditor.action.choose.jar.source.description"));
- model.setJarSource(f);
+ getProject().setJarSource(f);
}
]]>
</script>
@@ -60,8 +73,8 @@
</row>
<row>
<cell columns="2">
- <JTextField text='{SwingUtil.getStringValue(model.getProjectName())}'
- onKeyReleased='model.setProjectName(((JTextField)event.getSource()).getText())'/>
+ <JTextField text='{SwingUtil.getStringValue(getProject().getName())}'
+ onKeyReleased='getProject().setName(((JTextField)event.getSource()).getText())'/>
</cell>
</row>
<row>
@@ -72,8 +85,8 @@
<row>
<cell weightx='1' fill="both">
<JTextField id="jarSourceFile"
- text='{SwingUtil.getStringValue(model.getJarSource()+"")}'
- onKeyReleased='model.setJarSource(new File(((JTextField)event.getSource()).getText()))'/>
+ text='{SwingUtil.getStringValue(getProject().getJarSource()+"")}'
+ onKeyReleased='getProject().setJarSource(new File(((JTextField)event.getSource()).getText()))'/>
</cell>
<cell anchor="east">
<JButton actionIcon="fileChooser"
@@ -85,8 +98,8 @@
<JCheckBox id='uniqueJarDefinition'
text='i18neditor.createproject.uniqueJarDefinition'
toolTipText='i18neditor.createproject.uniqueJarDefinition.tip'
- selected='{model.isUniqueJarDefinition()}'
- onItemStateChanged='model.setUniqueJarDefinition(event.getStateChange() == ItemEvent.SELECTED)'/>
+ selected='{getProject().isUniqueJarDefinition()}'
+ onItemStateChanged='getProject().setUniqueJarDefinition(event.getStateChange() == ItemEvent.SELECTED)'/>
</cell>
</row>
</Table>
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -18,6 +18,7 @@
*/
package org.nuiton.i18n.editor.project.impl;
+import java.io.File;
import java.io.IOException;
import org.nuiton.i18n.editor.project.AbstractI18nProjectProvider;
import java.net.URL;
@@ -54,43 +55,65 @@
@Override
protected Map<String, Class<?>> initAuthorizedParameters() {
Map<String, Class<?>> result = new TreeMap<String, Class<?>>();
- result.put(NAME_PARAMETER, String.class);
- result.put(URLS_PARAMETER, URL[].class);
+ result.put(JarI18nProject.NAME_PROPERTY_NAME, String.class);
+ result.put(JarI18nProject.URLS_PROPERTY_NAME, List.class);
+ result.put(JarI18nProject.JAR_SOURCE_PROPERTY_NAME, File.class);
+ result.put(JarI18nProject.UNIQUE_JAR_DEFINITION_PROPERTY_NAME, Boolean.class);
return result;
}
@Override
- public JarI18nProject newProject(Map<String, Object> params) {
- String name = getParameter(String.class, NAME_PARAMETER, params);
- URL[] urls = getParameter(URL[].class, URLS_PARAMETER, params);
- JarI18nProject p = new JarI18nProject(name, urls);
- return p;
+ public JarI18nProject newProject() {
+ return new JarI18nProject();
}
@Override
- public JarI18nProject newProject(ProjectUIModel model) {
- JarI18nProject p = new JarI18nProject(model.getProjectName(),
- model.getSelectedBundles().toArray(new URL[model.getSelectedBundles().size()]));
- if (model.isStoreProject()) {
- p.setStoreFile(model.getStoreFile());
- }
+ public JarI18nProject newProject(Map<String, Object> params) {
+
+ // mandatory parameters
+ String name = getParameter(String.class, JarI18nProject.NAME_PROPERTY_NAME, params, true);
+ List<URL> urls = getParameter(List.class, JarI18nProject.URLS_PROPERTY_NAME, params, true);
+
+ // optional parameters
+ File jarSource = getParameter(File.class, JarI18nProject.JAR_SOURCE_PROPERTY_NAME, params, false);
+ Boolean uniqueJarDefinition = getParameter(Boolean.class, JarI18nProject.UNIQUE_JAR_DEFINITION_PROPERTY_NAME, params, false);
+ JarI18nProject p = new JarI18nProject();
+ p.setName(name);
+ p.setUrls(urls);
+ p.setJarSource(jarSource);
+ p.setUniqueJarDefinition(uniqueJarDefinition != null && uniqueJarDefinition);
return p;
}
@Override
public JarI18nProject newProject(Properties properties) {
Map<String, Object> params = new TreeMap<String, Object>();
- params.put(NAME_PARAMETER, properties.getProperty(NAME_PARAMETER));
- String tmp = properties.getProperty(URLS_PARAMETER);
+ String tmp;
+
+ // name
+ tmp = properties.getProperty(JarI18nProject.NAME_PROPERTY_NAME);
+ params.put(JarI18nProject.NAME_PROPERTY_NAME, tmp);
+
+ // urls
+ tmp = properties.getProperty(JarI18nProject.URLS_PROPERTY_NAME);
String[] urlsStr = tmp.split(",");
List<URL> urls = new ArrayList<URL>();
for (String u : urlsStr) {
URL url = ConverterUtil.convert(URL.class, u);
urls.add(url);
}
+ params.put(JarI18nProject.URLS_PROPERTY_NAME, urls);
- params.put(URLS_PARAMETER, urls.toArray(new URL[urls.size()]));
+ // jarSource
+ tmp = properties.getProperty(JarI18nProject.JAR_SOURCE_PROPERTY_NAME);
+ File jarSource = new File(tmp);
+ params.put(JarI18nProject.JAR_SOURCE_PROPERTY_NAME, jarSource);
+ // uniqueJarDefinition
+ tmp = properties.getProperty(JarI18nProject.UNIQUE_JAR_DEFINITION_PROPERTY_NAME, "false");
+ Boolean uniqueJarDefinition = Boolean.valueOf(tmp);
+ params.put(JarI18nProject.UNIQUE_JAR_DEFINITION_PROPERTY_NAME, uniqueJarDefinition);
+
JarI18nProject p = newProject(params);
return p;
}
@@ -98,10 +121,11 @@
@Override
public List<URL> detectBundles(ProjectUIModel model) throws IOException {
List<URL> urls = new ArrayList<URL>();
- URL source = model.getJarSource().toURI().toURL();
+ JarI18nProject project = (JarI18nProject) model.getProject();
+ URL source = project.getJarSource().toURI().toURL();
URLClassLoader loader = new URLClassLoader(new URL[]{source});
log.info("jar source : " + source);
- if (model.isUniqueJarDefinition()) {
+ if (project.isUniqueJarDefinition()) {
// on recherche l'unique bundle dans META-INF/
List<URL> defs = Resource.getURLs("META-INF/.*-i18n-definition\\.properties", loader);
log.info("detected unique bundle definition " + defs);
@@ -125,7 +149,8 @@
@Override
public boolean validateUIModel(ProjectUIModel model) {
- return model.getJarSource() != null && model.getJarSource().exists() && model.getProjectName() != null && !model.getProjectName().isEmpty();
+ JarI18nProject project = (JarI18nProject) model.getProject();
+ return project.getJarSource() != null && project.getJarSource().exists() && project.getName() != null && !project.getName().isEmpty();
}
@Override
@@ -135,14 +160,14 @@
if (!properties.containsKey(CLASS_PARAMETER)) {
throw new IllegalStateException("could not find property " + CLASS_PARAMETER);
}
- if (!properties.containsKey(NAME_PARAMETER)) {
- throw new IllegalStateException("could not find property " + NAME_PARAMETER);
+ if (!properties.containsKey(JarI18nProject.NAME_PROPERTY_NAME)) {
+ throw new IllegalStateException("could not find property " + JarI18nProject.NAME_PROPERTY_NAME);
}
- if (!properties.containsKey(URLS_PARAMETER)) {
- throw new IllegalStateException("could not find property " + URLS_PARAMETER);
+ if (!properties.containsKey(JarI18nProject.URLS_PROPERTY_NAME)) {
+ throw new IllegalStateException("could not find property " + JarI18nProject.URLS_PROPERTY_NAME);
}
// verifie que les urls existent
- String tmp = properties.getProperty(URLS_PARAMETER);
+ String tmp = properties.getProperty(JarI18nProject.URLS_PROPERTY_NAME);
String[] urlsStr = tmp.split(",");
for (String u : urlsStr) {
int lastIndex = u.lastIndexOf("/");
@@ -155,7 +180,7 @@
}
@Override
- public Class<? extends I18nProjectConfigurePanelUI> getUIClass() {
+ public Class<? extends I18nProjectConfigurePanelUI<?>> getUIClass() {
return JarI18nProjectConfigurePanelUI.class;
}
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -98,7 +98,6 @@
openProjectUI(ui, project);
}
-
return ui;
}
@@ -492,7 +491,7 @@
I18nEditorConfig.Option.CONFIG_FILE,
I18nEditorConfig.Option.PROJECTS_DIRECTORY,
I18nEditorConfig.Option.TMP_DIRECTORY);
-
+
model.addCategory(
n_("i18neditor.config.category.ui"),
n_("i18neditor.config.category.ui.description"),
@@ -624,13 +623,13 @@
ProjectUIModel model = ui.getModel();
I18nProject project = null;
- I18nProjectProvider<? extends I18nProject> type = model.getType();
+ I18nProjectProvider<?> type = model.getType();
project = I18nProjectFactory.newProject(type.getType(), model);
- rootContext.getContextValue(I18nEditorConfig.class).getProjects().add(model.getProjectName());
+ rootContext.getContextValue(I18nEditorConfig.class).getProjects().add(project.getName());
try {
- if (model.isStoreProject()) {
+ if (project.isStoreProject()) {
// on enregistre le projet
- project.storeDefinition();
+ project.saveDefinition();
}
project.load();
I18nEditorContext.PROJECT_DEF.setContextValue(rootContext, project);
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -145,13 +145,14 @@
SELECT_BUNDLES.getBundlesModel().setUrls(model.detectBundles());
return;
}
- if (newStep == ProjectStep.PERSIST) {
+ //if (newStep == ProjectStep.PERSIST) {
// positionnement de fichier de sauvegarde
- if (model.isStoreProject()) {
- model.setStoreFile(new java.io.File(config.getProjectsDirectory(), model.getProjectName() + ".i18nproject"));
- }
- return;
- }
+ //TODO depend du statut du model (create or update)
+ //if (model.getProject().isStoreProject()) {
+ // model.getProject().setStoreFile(new java.io.File(config.getProjectsDirectory(), model.getProject().getName() + ".i18nproject"));
+ //}
+ //return;
+ //}
}
@Override
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUIModel.java 2009-07-30 23:04:45 UTC (rev 1649)
@@ -19,18 +19,24 @@
package org.nuiton.i18n.editor.ui.project;
import java.awt.Component;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.wizard.WizardModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.i18n.editor.I18nEditorConfig;
import org.nuiton.i18n.editor.project.I18nProject;
+import org.nuiton.i18n.editor.project.I18nProjectFactory;
import org.nuiton.i18n.editor.project.I18nProjectProvider;
import org.nuiton.util.FileUtil;
@@ -43,63 +49,53 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(ProjectUIModel.class);
- public static final String PROJECT_NAME_PROPERTY_NAME = "projectName";
public static final String TYPE_PROPERTY_NAME = "type";
- public static final String JAR_SOURCE_PROPERTY_NAME = "jarSource";
- public static final String DIRECTORY_SOURCE_PROPERTY_NAME = "directorySource";
- public static final String SELECTED_BUNDLES_PROPERTY_NAME = "selectedBundles";
- public static final String UNIQUE_JAR_DEFINITION_PROPERTY_NAME = "uniqueJarDefinition";
- public static final String STORE_FILE_PROPERTY_NAME = "storeFile";
- public static final String STORE_PROJECT_PROPERTY_NAME = "storeProject";
+ public static final String PROJECT_PROPERTY_NAME = "project";
+// public static final String PROJECT_NAME_PROPERTY_NAME = "projectName";
+// public static final String JAR_SOURCE_PROPERTY_NAME = "jarSource";
+// public static final String DIRECTORY_SOURCE_PROPERTY_NAME = "directorySource";
+// public static final String SELECTED_BUNDLES_PROPERTY_NAME = "selectedBundles";
+// public static final String UNIQUE_JAR_DEFINITION_PROPERTY_NAME = "uniqueJarDefinition";
+// public static final String STORE_FILE_PROPERTY_NAME = "storeFile";
+// public static final String STORE_PROJECT_PROPERTY_NAME = "storeProject";
public static final String VALID_PROPERTY_NAME = "valid";
- /**
- * Le type de projet
- */
- protected I18nProjectProvider<? extends I18nProject> type;
- /**
- * le nom du projet
- */
- protected String projectName;
- /**
- * la source pour un projet de type jar
- */
- protected File jarSource = new File("");
- /**
- * la source pour un projet de type directory
- */
- protected File directorySource = new File("");
- /**
- * un drapeau (pour les projets de type jar) pour savoir si on utilise le
- * système i18n avec nom unique.
- */
- protected boolean uniqueJarDefinition;
- /**
- * la configuration de l'application
- */
+ /** le dictionnaire des differents projects possible indexes par leur provideur */
+ protected Map<I18nProjectProvider<?>, I18nProject> projects;
+ /** Le provideur du projet en cours d'edition */
+ protected I18nProjectProvider<?> type;
+ /** le projet en cours d'edition */
+ protected I18nProject project;
+ /** la configuration de l'application */
protected I18nEditorConfig config;
- /**
- * le fichier ou persister le projet (si null pas persiste)
- */
- protected File storeFile = new File("");
- /**
- * un drapeau pour savoir si on persiste le projet
- */
- protected boolean storeProject = true;
- /**
- * les etapes a exclure
- */
- protected List<ProjectStep> excludeSteps;
- /**
- * les bundles selectionnes
- */
- protected List<URL> selectedBundles = new ArrayList<URL>();
+ /** un drapeau pour savoir si on est en mode creation ou pas */
+ protected boolean create;
public ProjectUIModel() {
super(ProjectStep.class,
ProjectStep.CHOOSE_PROJECT_TYPE,
ProjectStep.CONFIGURE_PROJECT,
ProjectStep.SELECT_BUNDLES,
+ ProjectStep.PERSIST,
ProjectStep.RESUME);
+ this.projects = new HashMap<I18nProjectProvider<?>, I18nProject>();
+ // init map of different types of projects
+ Set<I18nProjectProvider<?>> providers = I18nProjectFactory.getProviders();
+ for (I18nProjectProvider<?> p : providers) {
+ I18nProject newProject = p.newProject();
+ this.projects.put(p, newProject);
+ // the model listens every modification of each project
+ // and at each time revalidate the model
+ newProject.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ validate();
+ }
+ });
+ }
+ if (!providers.isEmpty()) {
+ setType(providers.iterator().next());
+ }
}
/**
@@ -109,20 +105,21 @@
*/
public void init(JAXXContext context) {
- ProjectUIModel incomingModel = context.getContextValue(ProjectUIModel.class, "incoming");
-
config = context.getContextValue(I18nEditorConfig.class);
- if (incomingModel != null) {
+ //TODO instead of seeking an ui model, must seek fro an incoming project...
+ I18nProject incomingProject = context.getContextValue(I18nProject.class, "incoming");
+ setCreate(incomingProject==null);
+
+ if (incomingProject != null) {
+
if (log.isDebugEnabled()) {
- log.debug("from a incoming model " + incomingModel);
+ log.debug("from a incoming project " + incomingProject);
}
-
- // on initialie a partir d'un autre modèle
- incomingModel.copyTo(this);
-
- return;
+ I18nProjectProvider<?> provider = I18nProjectFactory.getProvider(incomingProject.getClass());
+ setType(provider);
+ incomingProject.copyDefinitionTo(project);
}
}
@@ -130,12 +127,12 @@
public void start() {
super.start();
firePropertyChange(TYPE_PROPERTY_NAME, null, type);
- firePropertyChange(PROJECT_NAME_PROPERTY_NAME, null, projectName);
- firePropertyChange(JAR_SOURCE_PROPERTY_NAME, null, jarSource);
- firePropertyChange(DIRECTORY_SOURCE_PROPERTY_NAME, null, directorySource);
- firePropertyChange(SELECTED_BUNDLES_PROPERTY_NAME, null, selectedBundles);
- firePropertyChange(STORE_PROJECT_PROPERTY_NAME, null, storeProject);
- firePropertyChange(STORE_FILE_PROPERTY_NAME, null, storeFile);
+ firePropertyChange(PROJECT_PROPERTY_NAME, null, project);
+// if (type != null && project != null) {
+// // ask to provider to fire every thing on the project ?
+// //TODO no! the project fire will do it in each specicialized project's ui
+// project.fireAllProperties();
+// }
}
@Override
@@ -169,112 +166,62 @@
validate = type.validateUIModel(this);
break;
case SELECT_BUNDLES:
- validate = !selectedBundles.isEmpty();
+ validate = !project.getUrls().isEmpty();
break;
case PERSIST:
- validate = !storeProject || (storeFile != null && !storeFile.exists());
+ boolean storeProject = project.isStoreProject();
+ if (storeProject) {
+ File storeFile = project.getStoreFile();
+ if (create) {
+ validate = storeFile != null && !storeFile.exists();
+ } else {
+ validate = storeFile != null && storeFile.exists();
+ }
+ }
break;
case RESUME:
- validate = true;
+// validate = true;
break;
}
}
return validate;
}
- public I18nProjectProvider<? extends I18nProject> getType() {
+ public I18nProjectProvider<?> getType() {
return type;
}
- public String getProjectName() {
- return projectName;
+ public I18nProject getProject() {
+ return project;
}
- public File getDirectorySource() {
- return directorySource;
+ public <T extends I18nProject> T getProject(Class<T> projectClass) {
+ I18nProjectProvider<T> projectType = I18nProjectFactory.getProvider(projectClass);
+ if (!projects.containsKey(projectType)) {
+ throw new IllegalArgumentException(projectType + " is not a registred type");
+ }
+ return (T) projects.get(projectType);
}
- public File getJarSource() {
- return jarSource;
+ public boolean isCreate() {
+ return create;
}
- public List<URL> getSelectedBundles() {
- return selectedBundles;
+ public void setCreate(boolean create) {
+ this.create = create;
}
- public boolean isUniqueJarDefinition() {
- return uniqueJarDefinition;
- }
-
- public boolean isStoreProject() {
- return storeProject;
- }
-
- public File getStoreFile() {
- return storeFile;
- }
-
- public void setType(I18nProjectProvider<? extends I18nProject> type) {
- I18nProjectProvider<?> oldValue = this.type;
+ public void setType(I18nProjectProvider<?> type) {
+ I18nProjectProvider<?> oldType = this.type;
this.type = type;
- firePropertyChange(TYPE_PROPERTY_NAME, oldValue, type);
- if (oldValue != type) {
- updateUniverse();
- }
+ firePropertyChange(TYPE_PROPERTY_NAME, oldType, type);
+ I18nProject oldProject = this.project;
+ I18nProject newProject = projects.get(type);
+ this.project = newProject;
+ firePropertyChange(PROJECT_PROPERTY_NAME, oldProject, newProject);
validate();
}
- public void setDirectorySource(File directorySource) {
- File oldValue = this.directorySource;
- this.directorySource = directorySource;
- firePropertyChange(DIRECTORY_SOURCE_PROPERTY_NAME, oldValue, directorySource);
- validate();
- }
-
- public void setJarSource(File jarSource) {
- File oldValue = this.jarSource;
- this.jarSource = jarSource;
- firePropertyChange(JAR_SOURCE_PROPERTY_NAME, oldValue, jarSource);
- validate();
- }
-
- public void setProjectName(String projectName) {
- String oldValue = this.projectName;
- this.projectName = projectName;
- firePropertyChange(PROJECT_NAME_PROPERTY_NAME, oldValue, projectName);
- validate();
- }
-
- public void setUniqueJarDefinition(boolean uniqueJarDefinition) {
- boolean oldValue = this.uniqueJarDefinition;
- this.uniqueJarDefinition = uniqueJarDefinition;
- firePropertyChange(UNIQUE_JAR_DEFINITION_PROPERTY_NAME, oldValue, uniqueJarDefinition);
- validate();
- }
-
- public void setSelectedBundles(List<URL> selectedBundles) {
-// List<URL> oldValues = this.selectedBundles;
- this.selectedBundles = selectedBundles;
- firePropertyChange(SELECTED_BUNDLES_PROPERTY_NAME, null, selectedBundles);
- validate();
- }
-
- public void setStoreProject(boolean storeProject) {
- boolean oldValue = this.storeProject;
- this.storeProject = storeProject;
- firePropertyChange(STORE_PROJECT_PROPERTY_NAME, oldValue, storeProject);
- }
-
- public void setStoreFile(File storeFile) {
- File oldValue = this.storeFile;
- this.storeFile = storeFile;
- firePropertyChange(STORE_FILE_PROPERTY_NAME, oldValue, storeFile);
- }
-
- public void setExcludeSteps(List<ProjectStep> excludeSteps) {
- this.excludeSteps = excludeSteps;
- }
-
/**
* Choisir un fichier via un sélecteur graphique de fichiers.
*
@@ -355,10 +302,4 @@
}
return urls;
}
-
- protected void copyTo(ProjectUIModel dst) {
- dst.setType(getType());
- dst.setJarSource(getJarSource());
- dst.setDirectorySource(getDirectorySource());
- }
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/PersistPanelUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -27,10 +27,28 @@
import jaxx.runtime.SwingUtil;
import org.nuiton.i18n.editor.*;
+import org.nuiton.i18n.editor.project.I18nProject;
+import org.nuiton.i18n.editor.project.AbstractI18nProject;
import org.nuiton.i18n.editor.ui.project.*;
import java.io.File;
+protected final I18nEditorConfig config = getContextValue(I18nEditorConfig.class);
+
+protected final PropertyChangeListener storeProjectPropertyChangeListener = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ Boolean oldValue = (Boolean) evt.getOldValue();
+ Boolean newValue = (Boolean) evt.getNewValue();
+ if (newValue != null && newValue) {
+ if (getProject().getStoreFile() == null || getProject().getStoreFile().getParentFile() == null) {
+ getProject().setStoreFile(new File(config.getProjectsDirectory(), model.getProject().getName() + ".i18nproject"));
+ }
+ }
+ }
+};
+
public void chooseProjectDirectory() {
File f = model.chooseDirectory (
this,
@@ -40,15 +58,62 @@
changeDirectory(f);
}
+public I18nProject getProject() {
+ return model.getProject();
+}
+
protected void changeDirectory(File f) {
- model.setStoreFile(new File(f, model.getProjectName() + ".i18nproject"));
+ getProject().setStoreFile(new File(f, getProject().getName() + ".i18nproject"));
}
void $afterCompleteSetup() {
if (getStep()!=null) {
setDescriptionText(_(getStep().getDescription()));
}
+ model.addPropertyChangeListener(ProjectUIModel.PROJECT_PROPERTY_NAME, new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ I18nProject oldProject = (I18nProject) evt.getOldValue();
+ if (oldProject!=null) {
+ oldProject.removePropertyChangeListener(AbstractI18nProject.STORE_PROJECT_PROPERTY_NAME, storeProjectPropertyChangeListener);
+ }
+ I18nProject newProject = (I18nProject) evt.getNewValue();
+ if (newProject!=null) {
+ newProject.addPropertyChangeListener(AbstractI18nProject.STORE_PROJECT_PROPERTY_NAME, storeProjectPropertyChangeListener);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("update binding for changed project " + newProject);
+ }
+ SwingUtil.applyDataBinding(PersistPanelUI.this,
+ "storeProject.selected",
+ "storeFilePanel.visible",
+ "directoryText.text",
+ "storeFilePath.text");
+ }
+ });
}
+
+@Override
+public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ for (PropertyChangeListener l : getPropertyChangeListeners(propertyName)) {
+ if (l == listener) {
+ // already registred listener
+ if (log.isDebugEnabled()) {
+ log.debug("already registred listener for property " + propertyName + " : " + listener);
+ }
+ return;
+ }
+ }
+ super.addPropertyChangeListener(propertyName, listener);
+}
+
+protected String getStoreDirectory(File storeFile) {
+ if (storeFile == null || storeFile.getParentFile() == null) {
+ return "";
+ }
+ return storeFile.getParentFile().getAbsolutePath();
+}
]]>
</script>
@@ -57,14 +122,16 @@
<JPanel constraints='BorderLayout.NORTH'
layout='{new BorderLayout()}'
border='{BorderFactory.createTitledBorder("")}'>
- <JCheckBox constraints='BorderLayout.CENTER'
+ <JCheckBox id='storeProject'
+ constraints='BorderLayout.CENTER'
text='i18neditor.createproject.doPersist'
- selected='{model.isStoreProject()}'
- onStateChanged='getModel().setStoreProject(((JCheckBox)event.getSource()).isSelected())'/>
+ selected='{getProject().isStoreProject()}'
+ onStateChanged='getProject().setStoreProject(((JCheckBox)event.getSource()).isSelected())'/>
</JPanel>
- <Table constraints='BorderLayout.CENTER'
- visible='{model.isStoreProject()}'>
+ <Table id='storeFilePanel'
+ constraints='BorderLayout.CENTER'
+ visible='{getProject().isStoreProject()}'>
<row>
<cell weightx='1' fill="both">
<Table fill='both'>
@@ -76,26 +143,27 @@
<row>
<cell weightx='1' fill="horizontal">
<JTextField id='directoryText'
- text='{model.getStoreFile().getParent()+ ""}'
- visible='{model.isStoreProject()}'
+ text='{getStoreDirectory(getProject().getStoreFile())}'
onKeyReleased='changeDirectory(new File(((JTextField)event.getSource()).getText()))'/>
+ <!--visible='{model.getProject().isStoreProject()}'-->
</cell>
<cell anchor="east">
<JButton actionIcon='fileChooser'
- visible='{model.isStoreProject()}'
onActionPerformed="chooseProjectDirectory()"/>
+ <!--visible='{model.getProject().isStoreProject()}'-->
</cell>
</row>
<row>
<cell columns='2'>
- <JLabel text='i18neditor.createproject.storeProject.path'
- visible='{model.isStoreProject()}'/>
+ <JLabel text='i18neditor.createproject.storeProject.path'/>
+ <!--visible='{model.getProject().isStoreProject()}'/>-->
</cell>
</row>
<row>
<cell columns='2'>
- <JLabel text='{model.getStoreFile() + ""}'
- visible='{model.isStoreProject()}'/>
+ <JLabel id='storeFilePath'
+ text='{getProject().getStoreFile() + ""}'/>
+ <!--visible='{model.getProject().isStoreProject()}'/>-->
</cell>
</row>
</Table>
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/SelectBundlesPanelUI.jaxx 2009-07-30 23:04:45 UTC (rev 1649)
@@ -38,9 +38,8 @@
]]>
</script>
- <!-- le modèles des activités dont on a pu calculé un point gps -->
<SelectBundlesTableModel id='bundlesModel'
- onTableChanged='model.setSelectedBundles(bundlesModel.getUrls())'/>
+ onTableChanged='model.getProject().setUrls(bundlesModel.getUrls())'/>
<Table id='content' constraints='BorderLayout.CENTER' fill='both' weightx='1' weighty='1'>
<row>
1
0
[Lutinutil-commits] r1648 - in trunk/nuiton-i18n-editor: . src/main/java/org/nuiton/i18n/editor src/main/java/org/nuiton/i18n/editor/ui src/main/java/org/nuiton/i18n/editor/ui/project src/main/resources src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: tchemit
Date: 2009-07-27 22:29:29 +0200 (Mon, 27 Jul 2009)
New Revision: 1648
Modified:
trunk/nuiton-i18n-editor/pom.xml
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css
trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties
trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties
trunk/nuiton-i18n-editor/src/main/resources/log4j.properties
Log:
add config ui and configure action
Modified: trunk/nuiton-i18n-editor/pom.xml
===================================================================
--- trunk/nuiton-i18n-editor/pom.xml 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/pom.xml 2009-07-27 20:29:29 UTC (rev 1648)
@@ -73,8 +73,8 @@
<!-- main class in jar -->
<maven.jar.main.class>org.nuiton.i18n.editor.I18nEditor</maven.jar.main.class>
- <jaxx.version>1.7.0</jaxx.version>
- <lutinutil.version>1.1.0-rc-8</lutinutil.version>
+ <jaxx.version>1.7.1-SNAPSHOT</jaxx.version>
+ <lutinutil.version>1.1.0-rc-9-SNAPSHOT</lutinutil.version>
<!-- default license to use -->
<license.licenseName>gpl_v3</license.licenseName>
@@ -156,6 +156,7 @@
<artifactId>maven-i18n-plugin</artifactId>
<version>${project.version}</version>
<configuration>
+ <silent>true</silent>
<entries>
<entry>
<basedir>${maven.gen.dir}/java/</basedir>
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditor.java 2009-07-27 20:29:29 UTC (rev 1648)
@@ -176,6 +176,17 @@
disableMainUI();
}
+ public void configure() {
+ if (log.isDebugEnabled()) {
+ log.debug(this);
+ }
+ I18nEditorContext context = I18nEditorContext.get();
+ I18nEditorConfig config = context.getConfig();
+ I18nEditorUIHandler handler = context.getContextValue(I18nEditorUIHandler.class);
+ handler.showConfig(context);
+ config.setDisplayMainUI(false);
+ }
+
/**
* Désactiver la possiblite de lancer l'ui principale.
*/
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/I18nEditorConfig.java 2009-07-27 20:29:29 UTC (rev 1648)
@@ -261,24 +261,60 @@
//////////////////////////////////////////////////
// Toutes les options disponibles
//////////////////////////////////////////////////
- protected static enum Option {
+ public static enum Option implements OptionDef {
- CONFIG_FILE(CONFIG_FILE_NAME, _("i18neditor.config.configFileName.description"), "nuitoni18neditor-config"),
+ CONFIG_FILE(CONFIG_FILE_NAME, _("i18neditor.config.configFileName.description"), "nuitoni18neditor-config", String.class, true, true),
// directories
- TMP_DIRECTORY("tmp.directory", _("i18neditor.config.defaultTmpDirectory.description"), getUserDirectory() + File.separator + "tmp"),
- PROJECTS_DIRECTORY("projects.directory", _("i18neditor.config.defaultProjectsDirectory.description"), getUserDirectory() + File.separator + "projects"),
+ TMP_DIRECTORY("tmp.directory", _("i18neditor.config.defaultTmpDirectory.description"), getUserDirectory() + File.separator + "tmp", File.class, false, false),
+ PROJECTS_DIRECTORY("projects.directory", _("i18neditor.config.defaultProjectsDirectory.description"), getUserDirectory() + File.separator + "projects", File.class, false, false),
// ui config
- FULL_SCREEN("ui.fullscreen", _("i18neditor.config.ui.fullscreen"), "false"),
- LOCALE("ui.locale", _("i18neditor.config.ui.locale"), Locale.FRANCE.toString());
+ FULL_SCREEN("ui.fullscreen", _("i18neditor.config.ui.fullscreen"), "false", Boolean.class, false, false),
+ LOCALE("ui.locale", _("i18neditor.config.ui.locale"), Locale.FRANCE.toString(), Locale.class, false, false);
public final String key;
public final String description;
public final String defaultValue;
+ public final Class<?> type;
+ public final boolean _transient;
+ public final boolean _final;
- private Option(String key, String description, String defaultValue) {
+ private Option(String key, String description, String defaultValue, Class<?> type, boolean _transient, boolean _final) {
this.key = key;
this.description = description;
this.defaultValue = defaultValue;
+ this.type = type;
+ this._final = _final;
+ this._transient = _transient;
}
+
+ @Override
+ public boolean isFinal() {
+ return _final;
+ }
+
+ @Override
+ public boolean isTransient() {
+ return _transient;
+ }
+
+ @Override
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public String getKey() {
+ return key;
+ }
+
+ @Override
+ public Class<?> getType() {
+ return type;
+ }
}
public static enum Step {
@@ -289,6 +325,7 @@
public static enum Action {
HELP(_("i18neditor.action.commandline.help"), I18nEditor.class.getName() + "#help", "-h", "--help"),
+ CONFIGURE(_("i18neditor.action.commandline.configure"), I18nEditor.class.getName() + "#configure", "-c", "--configure"),
NO_MAIN_UI(_("i18neditor.action.commandline.disable.main.ui"), I18nEditor.class.getName() + "#disableMainUI", "-n", "--no-main");
public String description;
public String action;
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css 2009-07-27 20:29:29 UTC (rev 1648)
@@ -49,7 +49,6 @@
text:"i18neditor.action.configuration";
toolTipText:"i18neditor.action.configuration.tip";
actionIcon:"config";
- enabled:false;
mnemonic:C;
_help:{"ui.main.menu.file.configuration"};
}
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2009-07-27 20:29:29 UTC (rev 1648)
@@ -221,7 +221,7 @@
</script>
<JMenuBar>
<JMenu id='menuFile'>
- <JMenuItem id='menuFileConfiguration' onActionPerformed="handler.showConfig()"/>
+ <JMenuItem id='menuFileConfiguration' onActionPerformed="handler.showConfig(context)"/>
<JMenuItem id="menuFileCreateProject" onActionPerformed="handler.createProject(context)"/>
<JMenu id="menuFileOpenProject">
<JMenuItem id="menuFileOpenProjectOther"
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-27 20:29:29 UTC (rev 1648)
@@ -46,6 +46,9 @@
import jaxx.runtime.DefaultApplicationContext.AutoLoad;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.AboutPanel;
+import jaxx.runtime.swing.editor.config.ConfigUI;
+import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
+import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
import jaxx.runtime.swing.wizard.WizardUILancher;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -57,6 +60,7 @@
import org.nuiton.i18n.editor.ui.project.ProjectUI;
import org.nuiton.i18n.editor.ui.project.ProjectUIModel;
import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
/**
*
@@ -478,7 +482,27 @@
// }
}
- public void showConfig() {
+ public void showConfig(I18nEditorContext context) {
+ I18nEditorUI ui = getUI(context);
+
+ ConfigUIModel model = new ConfigUIModel(context.getConfig());
+ model.addCategory(
+ n_("i18neditor.config.category.directories"),
+ n_("i18neditor.config.category.directories.description"),
+ I18nEditorConfig.Option.CONFIG_FILE,
+ I18nEditorConfig.Option.PROJECTS_DIRECTORY,
+ I18nEditorConfig.Option.TMP_DIRECTORY);
+
+ model.addCategory(
+ n_("i18neditor.config.category.ui"),
+ n_("i18neditor.config.category.ui.description"),
+ I18nEditorConfig.Option.FULL_SCREEN,
+ I18nEditorConfig.Option.LOCALE);
+
+ ConfigUI configUI = ConfigUIBuilder.newConfigUI(context, model, "i18neditor.config.category.ui");
+
+ ConfigUIBuilder.showConfigUI(configUI, ui, false);
+// configUI.showInDialog(ui, ui != null);
}
public void showHelp(JAXXContext context, String helpId) {
@@ -592,7 +616,6 @@
if (!providers.isEmpty()) {
model.setType(providers.iterator().next());
}
-// ui.setTitle(("observe.title.import.localDB"));
}
@Override
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css 2009-07-27 20:29:29 UTC (rev 1648)
@@ -18,7 +18,7 @@
*/
#mainUI {
- title:"i18neditor.title.create.project";
+ title:"i18neditor.title.noproject";
modal:true;
resizable:false;
defaultCloseOperation:"dispose_on_close";
Modified: trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties 2009-07-27 20:29:29 UTC (rev 1648)
@@ -12,6 +12,7 @@
i18neditor.action.choose.project.description=
i18neditor.action.choose.projectDir=
i18neditor.action.closeProject=Close the project
+i18neditor.action.commandline.configure=Configure the application
i18neditor.action.commandline.disable.main.ui=Do not launch main ui
i18neditor.action.commandline.help=Show this help
i18neditor.action.configuration=Preferences
@@ -45,6 +46,10 @@
i18neditor.choose.project.to.delete=
i18neditor.common.descrition=
i18neditor.common.resume=Resume
+i18neditor.config.category.directories=Directories
+i18neditor.config.category.directories.description=Directories used by the application
+i18neditor.config.category.ui=Application
+i18neditor.config.category.ui.description=Other options used by the application
i18neditor.config.configFileName.description=configuration file
i18neditor.config.defaultProjectsDirectory.description=default directory where to store project definitions (*.i18nproject)
i18neditor.config.defaultTmpDirectory.description=tempory directory used by the application
@@ -108,7 +113,6 @@
i18neditor.title.choose.jar.source=
i18neditor.title.choose.project=
i18neditor.title.choose.projectDir=
-i18neditor.title.create.project=Create a new project
i18neditor.title.noproject=Nuiton i18n editor < no project loaded >
i18neditor.title.project.info=Project's informations
i18neditor.warning.nimbus.landf=Could not find nymbus look and feel, please use at least a 1.6u10 version of sun jre
Modified: trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties 2009-07-27 20:29:29 UTC (rev 1648)
@@ -12,6 +12,7 @@
i18neditor.action.choose.project.description=Fichier de d\u00E9finition de project (*.i18nproject)
i18neditor.action.choose.projectDir=Choisir ce r\u00E9pertoire
i18neditor.action.closeProject=Fermer le projet
+i18neditor.action.commandline.configure=Configurer l'application
i18neditor.action.commandline.disable.main.ui=Ne pas lancer l'interface graphique principale
i18neditor.action.commandline.help=Voir l'aide
i18neditor.action.configuration=Pr\u00E9f\u00E9rences
@@ -41,11 +42,14 @@
i18neditor.action.showHelp.tip=Voir l'aide contextuelle
i18neditor.action.site=Site
i18neditor.action.site.tip=Acc\u00E9der au site du projet
-i18neditor.title.create.project=Cr\u00E9er un nouveau projet
i18neditor.bundle.name=Localisation \: %1$s
i18neditor.choose.project.to.delete=Choisir le projet \u00E0 supprimer
i18neditor.common.descrition=Description
i18neditor.common.resume=R\u00E9sum\u00E9
+i18neditor.config.category.directories=R\u00E9pertoires
+i18neditor.config.category.directories.description=Les r\u00E9pertoires utilis\u00E9es par l'application
+i18neditor.config.category.ui=Application
+i18neditor.config.category.ui.description=Les autres options de l'application
i18neditor.config.configFileName.description=Le nom du fichier de configuration
i18neditor.config.defaultProjectsDirectory.description=Le r\u00E9pertoire o\u00F9 sont sauvegarder les d\u00E9finitions de projets
i18neditor.config.defaultTmpDirectory.description=Le r\u00E9pertoire temporaire par d\u00E9faut
@@ -67,7 +71,7 @@
i18neditor.createproject.doPersist=Sauver la d\u00E9finition du projet
i18neditor.createproject.jar.source.label=Choisir le jar source
i18neditor.createproject.name.label=Nom du projet
-i18neditor.createproject.no.type=
+i18neditor.createproject.no.type=< Aucune type de projet s\u00E9lectionn\u00E9 >
i18neditor.createproject.storeProject.directory=R\u00E9pertoire de sauvegarde
i18neditor.createproject.storeProject.path=Fichier de sauvegarde
i18neditor.createproject.uniqueJarDefinition=Utilisation d'un bundle final
@@ -109,7 +113,6 @@
i18neditor.title.choose.jar.source=Choisir un fichier de type 'jar'
i18neditor.title.choose.project=Choisir le fichier de d\u00E9finition d'un projet
i18neditor.title.choose.projectDir=Choisir une d\u00E9finition de projet
-i18neditor.title.create.project=
i18neditor.title.noproject=Nuiton i18n editor < aucun projet charg\u00E9 >
i18neditor.title.project.info=Informations sur le projet
i18neditor.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java.
Modified: trunk/nuiton-i18n-editor/src/main/resources/log4j.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/resources/log4j.properties 2009-07-27 20:23:21 UTC (rev 1647)
+++ trunk/nuiton-i18n-editor/src/main/resources/log4j.properties 2009-07-27 20:29:29 UTC (rev 1648)
@@ -8,6 +8,7 @@
# package level
log4j.logger.org.nuiton=WARN
log4j.logger.org.nuiton.i18n.editor=INFO
-log4j.logger.org.nuiton.util.Resource=DEBUG
+#log4j.logger.org.nuiton.util.Resource=DEBUG
#log4j.logger.org.nuiton.i18n.editor.I18nEditorConfig=DEBUG
-#log4j.logger.jaxx.runtime.swing.I18nWidget=DEBUG
+log4j.logger.jaxx.runtime.swing.editor.config=DEBUG
+log4j.logger.jaxx.runtime.swing.editor=DEBUG
1
0
[Lutinutil-commits] r1647 - in trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin: . parser parser/impl
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: tchemit
Date: 2009-07-27 22:23:21 +0200 (Mon, 27 Jul 2009)
New Revision: 1647
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java
Log:
add silent parameter to hide all messages
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -108,6 +108,13 @@
*/
protected boolean verbose;
/**
+ * silent flag
+ *
+ * @parameter expression="${i18n.silent}" default-value="false"
+ * @since 1.0.0-rc-5
+ */
+ protected boolean silent;
+ /**
* conserve les anciens fichiers de traduction avec un suffix ~
* <p/>
* Note: par defaut, on ne l'active pas.
@@ -259,7 +266,7 @@
}
getLog().warn(buffer.toString());
} else {
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("bundle " + locale + " is valid (no empty entries).");
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -38,7 +38,6 @@
import org.apache.maven.artifact.resolver.ArtifactCollector;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
-import org.apache.maven.model.Resource;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.shared.dependency.tree.DependencyNode;
@@ -193,9 +192,11 @@
i18nArtifacts = detectI18nArtifacts();
- getLog().info("detected " + i18nArtifacts.length + " i18n artifact(s) : ");
- for (I18nArtifact a : i18nArtifacts) {
- getLog().info(" - " + a);
+ if (!silent) {
+ getLog().info("detected " + i18nArtifacts.length + " i18n artifact(s) : ");
+ for (I18nArtifact a : i18nArtifacts) {
+ getLog().info(" - " + a);
+ }
}
} catch (Exception ex) {
throw new RuntimeException(ex);
@@ -221,10 +222,11 @@
init();
- getLog().info("config - bundle name : " + bundleOutputName);
- getLog().info("config - baseidr : " + bundleOutputDir);
- getLog().info("config - locales : " + Arrays.toString(locales));
-
+ if (!silent) {
+ getLog().info("config - bundle name : " + bundleOutputName);
+ getLog().info("config - baseidr : " + bundleOutputDir);
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ }
// la locale par defaut est la première
Locale defaultLocale = locales[0];
@@ -238,7 +240,9 @@
File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false);
- getLog().info("generate bundle for locale " + locale);
+ if (!silent) {
+ getLog().info("generate bundle for locale " + locale);
+ }
SortedProperties propertiesOut = new SortedProperties(encoding, false);
StringBuilder buffer = new StringBuilder();
@@ -258,10 +262,12 @@
}
if (buffer.length() > 0) {
bundleDico.put(locale, buffer.substring(1));
- getLog().info("bundles for locale : " + bundleDico.get(locale));
+ if (!silent) {
+ getLog().info("bundles for locale : " + bundleDico.get(locale));
+ }
}
propertiesOut.store(bundleOut);
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")");
}
if (checkBundle) {
@@ -274,7 +280,9 @@
// charger
String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName);
File defOut = new File(bundleOutputDir, f);
- getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
+ if (!silent) {
+ getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
+ }
SortedProperties p = new SortedProperties(encoding, false);
p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles);
for (Entry<Locale, String> e : bundleDico.entrySet()) {
@@ -282,7 +290,7 @@
}
p.store(new FileOutputStream(defOut), null);
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime()));
}
} catch (IOException e) {
@@ -309,12 +317,12 @@
for (Object o : project.getArtifacts()) {
i18nArtifact = new I18nArtifact((Artifact) o);
if (i18nArtifact.detectBundles()) {
- if (getLog().isDebugEnabled()) {
+ if (!silent && getLog().isDebugEnabled()) {
getLog().debug("detected artifact " + i18nArtifact);
}
dico.put(i18nArtifact.getArtifact(), i18nArtifact);
} else {
- if (getLog().isDebugEnabled()) {
+ if (!silent && getLog().isDebugEnabled()) {
getLog().debug("reject artifact " + i18nArtifact);
}
}
@@ -336,7 +344,7 @@
i18nArtifact = new I18nArtifact(projectArtifact, src.getParentFile());
if (i18nArtifact.detectBundles()) {
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("detected artifact " + i18nArtifact);
}
artifacts.add(i18nArtifact.getArtifact());
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -64,12 +64,15 @@
return;
}
- getLog().info("config - src basedir : " + src.getAbsolutePath());
- getLog().info("config - out basedir : " + out.getAbsolutePath());
- getLog().info("config - locales : " + Arrays.toString(locales));
-
+ if (!silent) {
+ getLog().info("config - src basedir : " + src.getAbsolutePath());
+ getLog().info("config - out basedir : " + out.getAbsolutePath());
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ }
for (Locale locale : locales) {
- getLog().info("prepare bundle for locale " + locale);
+ if (!silent) {
+ getLog().info("prepare bundle for locale " + locale);
+ }
try {
// Merge
File bundleSrc = getI18nFile(src, artifactId, locale, false);
@@ -114,7 +117,9 @@
if (genSrc && keepBackup) {
backupFile(bundleSrc);
}
- getLog().info("merge bundle " + locale + " to out");
+ if (!silent) {
+ getLog().info("merge bundle " + locale + " to out");
+ }
if (checkBundle) {
checkBundle(locale, propertiesOut, showEmpty);
@@ -124,7 +129,9 @@
// Copie des fichiers dans les sources
copyFile(bundleOut, bundleSrc);
//if (verbose) {
- getLog().info("copy bundle " + locale + " to src");
+ if (!silent) {
+ getLog().info("copy bundle " + locale + " to src");
+ }
//}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -52,10 +52,11 @@
}
return;
}
+ if (!silent) {
+ getLog().info("config - basedir : " + out.getAbsolutePath());
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ }
- getLog().info("config - basedir : " + out.getAbsolutePath());
- getLog().info("config - locales : " + Arrays.toString(locales));
-
try {
File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
bundleGetters.createNewFile();
@@ -74,17 +75,19 @@
if (genSrc) {
bundleGetter.delete();
}
- getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
+ if (!silent) {
+ getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
+ }
}
// Création des bundles
for (Locale locale : locales) {
- if (getLog().isDebugEnabled()) {
+ if (!silent && getLog().isDebugEnabled()) {
getLog().debug("generate bundle for locale " + locale);
}
File bundleOut = getI18nFile(out, artifactId, locale, false);
copyFile(bundleGetters, bundleOut);
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("generate bundle " + locale);
}
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -107,7 +107,7 @@
addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding));
}
treadedFiles = new ArrayList<File>();
- if (verbose) {
+ if (!silent && verbose) {
showTouchedFiles = true;
}
}
@@ -126,10 +126,10 @@
return;
}
- if (safeMode) {
+ if (!silent && safeMode) {
getLog().info("config - safeMode is on (could be slower).");
}
- if (strictMode) {
+ if (!silent && strictMode) {
getLog().info("config - strictMode is on (all files will be parsed).");
}
@@ -156,9 +156,13 @@
int i = treadedFiles.size();
if (fileTreated == 0) {
- getLog().info("Nothing to generate - all files are up to date.");
+ if (!silent) {
+ getLog().info("Nothing to generate - all files are up to date.");
+ }
} else {
- getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
+ if (!silent) {
+ getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
+ }
addGetter();
}
@@ -188,7 +192,7 @@
boolean skip = entry.init(this);
if (skip) {
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("skip - " + entry.getSkipMessage());
}
continue;
@@ -196,14 +200,14 @@
long t000 = System.nanoTime();
int nbFiles = entry.getFiles().length;
- if (verbose) {
+ if (!silent && verbose) {
vLog.infoEntry("start", vLog.getLogEntry("[incoming file(s) : " + entry.getFoudFiles() + "]", 0, 0, 0));
}
// launch parser for found files
parseEntry(entry);
- if (verbose) {
+ if (!silent && verbose) {
// log skipped files
for (String skipFile : entry.getSkipFiles()) {
vLog.setFile(new File(entry.getBasedir(), skipFile));
@@ -211,7 +215,7 @@
}
}
fileTreated += nbFiles;
- if (verbose) {
+ if (!silent && verbose) {
vLog.infoEntry("end", vLog.getLogEntry("[treated file(s) : " + nbFiles + "]", nbFiles, t000, t00));
}
t00 = System.nanoTime();
@@ -258,7 +262,7 @@
touchFile = false;
int size = result.size();
- if (verbose) {
+ if (!silent && verbose) {
vLog.infoFile("parse", null);
}
parseFile(file);
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -30,7 +30,10 @@
* @author julien
* @goal parserJaxx
* @phase generate-resources
+ * @deprecated since 1.0.0, prefer use the java parser since xml parser can not
+ * be easly extendable
*/
+@Deprecated
public class ParserJaxx extends ParserXml {
/**
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -27,7 +27,9 @@
* @author julien
* @goal parserSwixat
* @phase generate-resources
+ * @deprecated since 1.0.0 : swixat is dead...
*/
+@Deprecated
public class ParserSwixat extends ParserXml {
/**
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java 2009-07-23 20:14:25 UTC (rev 1646)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java 2009-07-27 20:23:21 UTC (rev 1647)
@@ -176,7 +176,7 @@
// load core rules
readInputStream = loadRulesFile(getCoreFileRules());
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("core rules : " + getCoreFileRules());
}
buffer.append(readInputStream);
@@ -184,7 +184,7 @@
if (!fileRules.equals(getCoreFileRules())) {
// add custom rules
readInputStream = loadRulesFile(fileRules);
- if (verbose) {
+ if (!silent && verbose) {
getLog().info("custom rules : " + fileRules);
}
buffer.append(" | ").append(readInputStream);
1
0
[Lutinutil-commits] r1670 - trunk/src/main/java/org/nuiton/util
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
by tchemit@users.labs.libre-entreprise.org 27 Jul '09
27 Jul '09
Author: tchemit
Date: 2009-07-27 22:19:48 +0200 (Mon, 27 Jul 2009)
New Revision: 1670
Modified:
trunk/src/main/java/org/nuiton/util/ApplicationConfig.java
Log:
add OptionDef contract to have more infos in ApplicationConfg options, should add more infos (perharps via an annotation ?)
Modified: trunk/src/main/java/org/nuiton/util/ApplicationConfig.java
===================================================================
--- trunk/src/main/java/org/nuiton/util/ApplicationConfig.java 2009-07-24 14:50:39 UTC (rev 1669)
+++ trunk/src/main/java/org/nuiton/util/ApplicationConfig.java 2009-07-27 20:19:48 UTC (rev 1670)
@@ -294,6 +294,48 @@
/** suport of config modification */
protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ /**
+ * Le contrat de marquage des options, on utilise cette interface pour
+ * caracteriser une option de configuration.
+ *
+ * @since 1.0.0-rc-9
+ */
+ static public interface OptionDef {
+
+ /**
+ * @return la clef identifiant l'option
+ */
+ String getKey();
+
+ /**
+ * @return le type de l'option
+ */
+ Class<?> getType();
+
+ /**
+ * @return la clef i18n de description de l'option
+ */
+ String getDescription();
+
+ /**
+ * @return la valeur par defaut de l'option sous forme de chaine de
+ * caracteres
+ */
+ String getDefaultValue();
+
+ /**
+ * @return <code>true</code> si l'option ne peut etre sauvegardee sur
+ * disque (utile par exemple pour les mots de passe, ...)
+ */
+ boolean isTransient();
+
+ /**
+ * @return <code>true</code> si l'option n'est pas modifiable (utilise
+ * par exemple pour la version de l'application, ...)
+ */
+ boolean isFinal();
+ }
+
static public class Action {
@Retention(RetentionPolicy.RUNTIME)
@@ -555,6 +597,17 @@
}
/**
+ * get option value from a option definition
+ *
+ * @param key the definition of the option
+ * @return the value for the given option
+ */
+ public Object getOption(OptionDef key) {
+ Object result = getOption(key.getType(), key.getKey());
+ return result;
+ }
+
+ /**
* get option value as typed value
*
* @param <T> type of the object wanted as return type
1
0
[Lutinutil-commits] r1669 - trunk/src/main/java/org/nuiton/util
by echatellier@users.labs.libre-entreprise.org 24 Jul '09
by echatellier@users.labs.libre-entreprise.org 24 Jul '09
24 Jul '09
Author: echatellier
Date: 2009-07-24 16:50:39 +0200 (Fri, 24 Jul 2009)
New Revision: 1669
Modified:
trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java
Log:
Remove ununed ungeneric code, add comment.
Modified: trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java
===================================================================
--- trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java 2009-07-24 14:50:12 UTC (rev 1668)
+++ trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java 2009-07-24 14:50:39 UTC (rev 1669)
@@ -106,7 +106,7 @@
* @deprecated unused same as {@code CategorisedListenerSet(boolean)}
*/
@Deprecated
- public CategorisedListenerSet(Class listenerClass, boolean isClassCategory) {
+ public CategorisedListenerSet(Class<?> listenerClass, boolean isClassCategory) {
this(isClassCategory);
}
1
0
[Lutinutil-commits] r1668 - trunk/src/main/java/org/nuiton/util
by echatellier@users.labs.libre-entreprise.org 24 Jul '09
by echatellier@users.labs.libre-entreprise.org 24 Jul '09
24 Jul '09
Author: echatellier
Date: 2009-07-24 16:50:12 +0200 (Fri, 24 Jul 2009)
New Revision: 1668
Modified:
trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java
trunk/src/main/java/org/nuiton/util/ListenerSet.java
Log:
Remove ununed ungeneric code, add comment.
Modified: trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java
===================================================================
--- trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java 2009-07-11 12:07:21 UTC (rev 1667)
+++ trunk/src/main/java/org/nuiton/util/CategorisedListenerSet.java 2009-07-24 14:50:12 UTC (rev 1668)
@@ -51,14 +51,16 @@
* leur derniers referencements
* <p/>
* <p> Si les categories sont representees par des Class, alors vous pouvez
- * utiliser la hierachie de classe pour creer de facon automatique les pere
+ * utiliser la hierachie de classe pour creer de facon automatique les peres.
+ *
+ * @param <L> listener type
*
* @see org.nuiton.util.ListenerSet
*/
-public class CategorisedListenerSet<Listener> { // CategorisedListenerSet
+public class CategorisedListenerSet<L> { // CategorisedListenerSet
/** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(CategorisedListenerSet.class);
+ private static Log log = LogFactory.getLog(CategorisedListenerSet.class);
/**
* permet de remplacer toutes les categories.
@@ -71,26 +73,28 @@
* HashMap de ListenerSet, en cle l'objet qui caracterise la categorie
* en valeur un ListenerSet
*/
- protected WeakHashMap<Object, ListenerSet<Listener>> listeners = new WeakHashMap<Object, ListenerSet<Listener>>();
+ protected WeakHashMap<Object, ListenerSet<L>> listeners = new WeakHashMap<Object, ListenerSet<L>>();
protected WeakHashMap<Object, Object> categoryParent = new WeakHashMap<Object, Object>();
protected boolean isClassCategory = true;
-// protected Class listenerClass = null;
/**
- * Construit un CategorisedListenerSet qui accepte n'importe quel type
- * de listener et dont le isClassCategory est activé
+ * Empty constructor.
*/
public CategorisedListenerSet() {
+
}
+
+ /**
+ * @param isClassCategory si vrai et que les categorie passé en arguement
+ * lors de l'ajout sont de type Class alors lors du fire on recherche aussi
+ * les peres dans la hierarchie d'heritage de la classe (Super class et
+ * interfaces)
+ */
+ public CategorisedListenerSet(boolean isClassCategory) {
+ this();
+ this.isClassCategory = isClassCategory;
+ }
-// /**
-// * Construit un CategorisedListenerSet qui accepte les listeners
-// * dont le type est passé en parametre et dont le isClassCategory est activé
-// */
-// public CategorisedListenerSet(Class listenerClass){
-// this.listenerClass = listenerClass;
-// }
-
/**
* @param listenerClass la classe dont doit heriter les listeners pour
* etre accepté lors de l'ajout
@@ -98,16 +102,18 @@
* lors de l'ajout sont de type Class alors lors du fire on recherche aussi
* les peres dans la hierarchie d'heritage de la classe (Super class et
* interfaces)
+ *
+ * @deprecated unused same as {@code CategorisedListenerSet(boolean)}
*/
+ @Deprecated
public CategorisedListenerSet(Class listenerClass, boolean isClassCategory) {
-// this(listenerClass);
- this.isClassCategory = isClassCategory;
+ this(isClassCategory);
}
-
protected void checkCategory(Object category) {
if (category == ALL) {
- throw new IllegalArgumentException("ALL category can't be use to add listener or add Category");
+ throw new IllegalArgumentException(
+ "ALL category can't be use to add listener or add Category");
}
}
@@ -132,9 +138,9 @@
* @param category la categorie dans lequel il faut ajouter le listener
* @param l le listener a ajouter
*/
- public void add(Object category, Listener l) {
+ public void add(Object category, L l) {
checkCategory(category);
- ListenerSet<Listener> listeners = getListeners(category);
+ ListenerSet<L> listeners = getListeners(category);
listeners.add(l);
}
@@ -145,8 +151,8 @@
* @param category la categorie dans lequel il faut supprimer le listener
* @param l le listener a supprimer
*/
- public void remove(Object category, Listener l) {
- ListenerSet<Listener> listeners = getListeners(category);
+ public void remove(Object category, L l) {
+ ListenerSet<L> listeners = getListeners(category);
listeners.remove(l);
}
@@ -158,21 +164,15 @@
* @param methodName le nom de la méthode de la classe listener
* @param event l'objet event a passer en paramètre de la methode du
* listener
+ * @throws Exception if event can't be fired
*/
public void fire(Object category, String methodName, Object event)
throws Exception {
- if (log != null && log.isTraceEnabled()) {
+ if (log.isTraceEnabled()) {
log.trace("fire category: " + category + " method: " + methodName);
}
- ListenerSet<Listener> ls = getAllListeners(category);
+ ListenerSet<L> ls = getAllListeners(category);
ls.fire(methodName, event);
-/* for(Iterator i=iterator(category); i.hasNext();){
- Object o = i.next();
- Log.logDevFinest("org.nuiton.util.CategorisedListenerSet.fire", "fire on: " + o);
- Statement stm = new Statement(o, methodName, new Object[]{event});
- stm.execute();
- }
-*/
}
/**
@@ -182,9 +182,11 @@
*
* @param category la categorie a partir duquel il faut lancer l'evenement
* @param methodName le nom de la méthode de la classe listener
+ *
+ * @throws Exception if event can't be fired
*/
public void fire(Object category, String methodName) throws Exception {
- for (Listener l : getAllListeners(category)) {
+ for (L l : getAllListeners(category)) {
Statement stm = new Statement(l, methodName, null);
stm.execute();
}
@@ -194,8 +196,11 @@
* Retourne un Iterator sur tous les listeners qu'il faut prevenir si on
* souhaite prevenir une certaine categorie. Ceci inclue les ancetre de la
* categorie
+ *
+ * @param category category to get iterator on
+ * @return iterator
*/
- public Iterator<Listener> iterator(Object category) {
+ public Iterator<L> iterator(Object category) {
return getAllListeners(category).iterator();
}
@@ -203,10 +208,10 @@
* Retourne un ListenerSet contenant tous les listeners c'est à dire les
* listener de la categorie demandé mais aussi les listeners des ancetres
*/
- protected ListenerSet<Listener> getAllListeners(Object category) {
- ListenerSet<Listener> result = new ListenerSet<Listener>();
+ protected ListenerSet<L> getAllListeners(Object category) {
+ ListenerSet<L> result = new ListenerSet<L>();
if (category == ALL) {
- for (ListenerSet<Listener> ls : listeners.values()) {
+ for (ListenerSet<L> ls : listeners.values()) {
result.addAll(ls);
}
} else {
@@ -214,24 +219,25 @@
while (parentCategory != null) {
result.addAll(getListeners(parentCategory));
if (isClassCategory && parentCategory instanceof Class) {
- result.addAll(getListenersClass((Class) parentCategory));
+ result.addAll(getListenersClass((Class<?>) parentCategory));
}
parentCategory = categoryParent.get(parentCategory);
}
}
- if (log != null && log.isTraceEnabled()) {
- log.trace("getAllListeners category: " + category + " result: " + result);
+ if (log.isTraceEnabled()) {
+ log.trace("getAllListeners category: " + category + " result: "
+ + result);
}
return result;
}
- protected ListenerSet<Listener> getListenersClass(Class category) {
- ListenerSet<Listener> result = new ListenerSet<Listener>();
- Class superClass = category.getSuperclass();
+ protected ListenerSet<L> getListenersClass(Class<?> category) {
+ ListenerSet<L> result = new ListenerSet<L>();
+ Class<?> superClass = category.getSuperclass();
if (superClass != null) {
result.addAll(getAllListeners(superClass));
}
- for (Class c : category.getInterfaces()) {
+ for (Class<?> c : category.getInterfaces()) {
result.addAll(getAllListeners(c));
}
return result;
@@ -241,19 +247,21 @@
* Retourne un ListenerSet contenant seulement les listener de la categorie
* demandé. Si la categorie n'existe pas alors elle est créé.
*/
- protected ListenerSet<Listener> getListeners(Object category) {
- ListenerSet<Listener> result = listeners.get(category);
+ protected ListenerSet<L> getListeners(Object category) {
+ ListenerSet<L> result = listeners.get(category);
if (result == null) {
- listeners.put(category, result = new ListenerSet<Listener>());
+ listeners.put(category, result = new ListenerSet<L>());
}
if (log != null && log.isTraceEnabled()) {
- log.trace("getListeners category: " + category + " result: " + result);
+ log.trace("getListeners category: " + category + " result: "
+ + result);
}
return result;
}
public String toString() {
- return "Listeners Category: " + categoryParent + "\nListener: " + listeners;
+ return "Listeners Category: " + categoryParent + "\nListener: "
+ + listeners;
}
} // CategorisedListenerSet
Modified: trunk/src/main/java/org/nuiton/util/ListenerSet.java
===================================================================
--- trunk/src/main/java/org/nuiton/util/ListenerSet.java 2009-07-11 12:07:21 UTC (rev 1667)
+++ trunk/src/main/java/org/nuiton/util/ListenerSet.java 2009-07-24 14:50:12 UTC (rev 1668)
@@ -62,30 +62,16 @@
* Cette deuxième façon de faire est plus sûr car elle n'utilise pas
* l'introspection et donc une vérification est faite sur le nom de la méthode
* à appeler à la compilation, mais elle est plus verbeuse à écrire.
+ *
+ * @param <L> listeners type
*
* @see org.nuiton.util.CategorisedListenerSet
*/
-public class ListenerSet<Listener> implements Iterable<Listener> { // ListenerSet
+public class ListenerSet<L> implements Iterable<L> { // ListenerSet
- /** DOCUMENTME Description of the Field DOCUMENTME Description of the Field DOCUMENTME Description of the Field */
-// protected Class<T> listenerClass = null;
- /** DOCUMENTME Description of the Field */
- protected HashSet<Reference<Listener>> listeners = new HashSet<Reference<Listener>>();
+ /** Listeners reference set. */
+ protected HashSet<Reference<L>> listeners = new HashSet<Reference<L>>();
- /** DOCUMENTME Constructor for the ListenerSet object */
- public ListenerSet() {
- }
-
-// /**
-// * Constructeur permettant de passer une classe que devra s'attisfaire les
-// * listener que l'on souhaite ajouter
-// *
-// * @param listenerClass DOCUMENTME Description of the Parameter
-// */
-// public ListenerSet(Class<T> listenerClass) {
-// this.listenerClass = listenerClass;
-// }
-
public int size() {
return listeners.size();
}
@@ -97,18 +83,13 @@
* si l'objet n'est pas du type passé en argument du constructeur
* une IllegalArgumentException est levée.
*/
- public void add(Listener l) {
+ public void add(L l) {
if (l == null) {
return;
}
-// if (listenerClass == null || listenerClass.isInstance(l)) {
- TransparenteWeakReference<Listener> ref = new TransparenteWeakReference<Listener>(l);
+
+ TransparenteWeakReference<L> ref = new TransparenteWeakReference<L>(l);
listeners.add(ref);
-// } else {
-// throw new IllegalArgumentException("Listener object ("
-// + l.getClass().getName() + ") is not compatible with class: "
-// + listenerClass.getName());
-// }
}
/**
@@ -116,15 +97,8 @@
*
* @param ls The feature to be added to the All attribute
*/
- public void addAll(ListenerSet<Listener> ls) {
-// if (listenerClass == null || (ls.listenerClass != null &&
-// listenerClass.isAssignableFrom(ls.listenDOCUMENTME Description of the ExceptionerClass))) {
+ public void addAll(ListenerSet<L> ls) {
listeners.addAll(ls.listeners);
-// } else {
-// throw new IllegalArgumentException("Listener object ("
-// + ls.listenerClass + ") is not compatible with : "
-// + listenerClass);
-// }
}
/**
@@ -137,55 +111,52 @@
* @throws Exception si un des listeners leve une exception lors de l'appel
*/
public void fire(String methodName, Object event) throws Exception {
- for (Iterator i = iterator(); i.hasNext();) {
- Object o = i.next();
- Statement stm = new Statement(o, methodName, new Object[]{event});
+ for (Iterator<L> i = iterator(); i.hasNext();) {
+ L o = i.next();
+ Statement stm = new Statement(o, methodName, new Object[] { event });
stm.execute();
}
}
/**
- * Appel la méthode du listener sans argument
+ * Appele la méthode du listener sans argument.
+ *
* Cette méthode echoue si la methode ou l'objet contenant la methode a
- * appeler n'est pas public
+ * appeler n'est pas public.
*
* @param methodName le nom de la methode a appeler
* @throws Exception si un des listeners leve une exception lors de l'appel
*/
public void fire(String methodName) throws Exception {
- for (Iterator i = iterator(); i.hasNext();) {
- Object o = i.next();
+ for (Iterator<L> i = iterator(); i.hasNext();) {
+ L o = i.next();
Statement stm = new Statement(o, methodName, null);
stm.execute();
}
}
/**
- * DOCUMENTME Method
+ * Get iterator on listener list.
*
- * @return DOCUMENTME Description of the Return Value
+ * @return iterator on listener list.
*/
- public Iterator<Listener> iterator() {
- return new ReferenceIterator<Listener>(listeners.iterator());
+ public Iterator<L> iterator() {
+ return new ReferenceIterator<L>(listeners.iterator());
}
/**
- * DOCUMENTME Method
+ * Remove listener.
*
- * @param l DOCUMENTME Description of the Parameter
+ * @param l listener to remove
*/
- public void remove(Listener l) {
- TransparenteWeakReference<Listener> ref = new TransparenteWeakReference<Listener>(l);
+ public void remove(L l) {
+ TransparenteWeakReference<L> ref = new TransparenteWeakReference<L>(l);
listeners.remove(ref);
}
- /**
- * DOCUMENTME Method
- *
- * @return DOCUMENTME Description of the Return Value
- */
+ @Override
public String toString() {
- return "" + listeners;
+ return listeners.toString();
}
/** Iterator qui supprime les references vides lors du parcours */
@@ -246,4 +217,3 @@
}
} // ListenerSet
-
1
0
[Lutinutil-commits] r1646 - in trunk/nuiton-i18n-editor/src/main: java/org/nuiton/i18n/editor/project java/org/nuiton/i18n/editor/project/impl java/org/nuiton/i18n/editor/ui java/org/nuiton/i18n/editor/ui/project java/org/nuiton/i18n/editor/ui/project/tabs resources/i18n
by tchemit@users.labs.libre-entreprise.org 23 Jul '09
by tchemit@users.labs.libre-entreprise.org 23 Jul '09
23 Jul '09
Author: tchemit
Date: 2009-07-23 22:14:25 +0200 (Thu, 23 Jul 2009)
New Revision: 1646
Added:
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx
Removed:
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/DirectoryI18nProjectConfigurePanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/JarI18nProjectConfigurePanelUI.jaxx
Modified:
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.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/I18nEditorUI.css
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx
trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureProjectPanelUI.jaxx
trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties
trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties
Log:
improve package and css
Copied: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java (from rev 1645, 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/project/I18nProjectConfigurePanelUI.java (rev 0)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java 2009-07-23 20:14:25 UTC (rev 1646)
@@ -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.project;
+
+import 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();
+}
Property changes on: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectConfigurePanelUI.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java 2009-07-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/I18nProjectProvider.java 2009-07-23 20:14:25 UTC (rev 1646)
@@ -24,7 +24,6 @@
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.
Copied: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx (from rev 1645, 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/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx (rev 0)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx 2009-07-23 20:14:25 UTC (rev 1646)
@@ -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.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>
Property changes on: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectConfigurePanelUI.jaxx
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java 2009-07-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/DirectoryI18nProjectProvider.java 2009-07-23 20:14:25 UTC (rev 1646)
@@ -27,9 +27,8 @@
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.project.I18nProjectConfigurePanelUI;
import org.nuiton.i18n.editor.ui.project.ProjectUIModel;
-import org.nuiton.i18n.editor.ui.project.tabs.DirectoryI18nProjectConfigurePanelUI;
import org.nuiton.util.ConverterUtil;
/**
Copied: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx (from rev 1645, 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/project/impl/JarI18nProjectConfigurePanelUI.jaxx (rev 0)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx 2009-07-23 20:14:25 UTC (rev 1646)
@@ -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.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>
+
Property changes on: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectConfigurePanelUI.jaxx
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java 2009-07-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/project/impl/JarI18nProjectProvider.java 2009-07-23 20:14:25 UTC (rev 1646)
@@ -31,9 +31,8 @@
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.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;
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-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.css 2009-07-23 20:14:25 UTC (rev 1646)
@@ -175,6 +175,13 @@
visible:true;
}
+#showProjectInfo {
+ actionIcon:"information";
+ toolTipText:"i18neditor.project.info.tip";
+ borderPainted:false;
+ rolloverEnabled:false;
+}
+
#closeTab{
actionIcon:"closeTab";
borderPainted:false;
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-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUI.jaxx 2009-07-23 20:14:25 UTC (rev 1646)
@@ -227,7 +227,7 @@
<JMenuItem id="menuFileOpenProjectOther"
onActionPerformed="handler.openOtherProject(context)"
_doNotRemove='Boolean.TRUE'/>
- <JMenuItem id="menuFileDeleteProject"
+ <JMenuItem id="menuFileDeleteProject"
onActionPerformed="handler.deleteProject(context)"
_doNotRemove='Boolean.TRUE'/>
<JSeparator/>
@@ -259,6 +259,9 @@
<JButton id='showHelp'/>
<javax.swing.Box.Filler constructorParams='SwingUtil.newMinDimension(), SwingUtil.newMinDimension(), SwingUtil.newMaxXDimension()'/>
+ <JSeparator orientation='vertical'/>
+ <JButton id='showProjectInfo' onActionPerformed='handler.showStorageInfo(context)'/>
+
<jaxx.runtime.swing.editor.I18nEditor id='changeI18n'
opaque='false'
showText='false'
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-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/I18nEditorUIHandler.java 2009-07-23 20:14:25 UTC (rev 1646)
@@ -553,6 +553,23 @@
about.showInDialog(ui, true);
}
+ public void showStorageInfo(I18nEditorContext context) {
+
+ I18nEditorUI ui = getUI(context);
+
+ String text = null;
+ if (context.getProject() == null) {
+ text = _("i18neditor.message.no.project.loaded");
+ } else {
+ text = context.getProject().toString();
+ }
+ JOptionPane.showMessageDialog(
+ ui,
+ text,
+ _("i18neditor.title.project.info"),
+ JOptionPane.INFORMATION_MESSAGE);
+ }
+
/**
* Méthode pour lancer l'assistant de creation de projet.
*
Deleted: 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 2009-07-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/I18nProjectConfigurePanelUI.java 2009-07-23 20:14:25 UTC (rev 1646)
@@ -1,35 +0,0 @@
-/**
- * *##% 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/ProjectUI.css
===================================================================
--- trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css 2009-07-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.css 2009-07-23 20:14:25 UTC (rev 1646)
@@ -17,8 +17,8 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>. ##%*
*/
-#storageMain {
- title:"i18neditor.title.change.storage";
+#mainUI {
+ title:"i18neditor.title.create.project";
modal:true;
resizable:false;
defaultCloseOperation:"dispose_on_close";
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-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/ProjectUI.jaxx 2009-07-23 20:14:25 UTC (rev 1646)
@@ -21,7 +21,7 @@
-->
-<JDialog id="storageMain"
+<JDialog id="mainUI"
implements='jaxx.runtime.swing.wizard.WizardUI<ProjectStep, ProjectUIModel>'
width='550' height='560' defaultCloseOperation='dispose_on_close'>
Modified: 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 2009-07-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/ConfigureProjectPanelUI.jaxx 2009-07-23 20:14:25 UTC (rev 1646)
@@ -30,6 +30,7 @@
import org.nuiton.i18n.editor.*;
import org.nuiton.i18n.editor.project.I18nProjectProvider;
import org.nuiton.i18n.editor.project.I18nProjectFactory;
+import org.nuiton.i18n.editor.project.I18nProjectConfigurePanelUI;
import org.nuiton.i18n.editor.ui.project.*;
protected String updateContentLayout(I18nProjectProvider<?> projectType) {
Deleted: 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 2009-07-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/DirectoryI18nProjectConfigurePanelUI.jaxx 2009-07-23 20:14:25 UTC (rev 1646)
@@ -1,81 +0,0 @@
-<!--
-
-/**
- * *##% 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>
Deleted: 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 2009-07-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/java/org/nuiton/i18n/editor/ui/project/tabs/JarI18nProjectConfigurePanelUI.jaxx 2009-07-23 20:14:25 UTC (rev 1646)
@@ -1,93 +0,0 @@
-<!--
-
-/**
- * *##% 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/resources/i18n/nuiton-i18n-editor-en_GB.properties
===================================================================
--- trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties 2009-07-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-en_GB.properties 2009-07-23 20:14:25 UTC (rev 1646)
@@ -4,7 +4,7 @@
i18neditor.action.apply=Apply
i18neditor.action.apply.tip=
i18neditor.action.cancel=Cancel
-i18neditor.action.cancel.tip=
+i18neditor.action.cancel.tip=Cancel
i18neditor.action.choose.directory.source.description=
i18neditor.action.choose.jar.source=
i18neditor.action.choose.jar.source.description=
@@ -19,7 +19,7 @@
i18neditor.action.create=Create
i18neditor.action.createProject=Create project
i18neditor.action.delete.key.tip=
-i18neditor.action.deleteProject=
+i18neditor.action.deleteProject=Delete project
i18neditor.action.exit=Exit
i18neditor.action.exit.tip=Quit
i18neditor.action.fullscreen=Full screen
@@ -82,14 +82,12 @@
i18neditor.menu.storeall=Save all
i18neditor.message.config.loaded=Config of nuiton-i18n-editor v %1$s was loaded.
i18neditor.message.help.usage=Help of nuiton-i18n-editor v %1$s
+i18neditor.message.no.project.loaded=< No project loaded >
i18neditor.no.keys=< No defined key >
i18neditor.package.name=Package \: %1$s
+i18neditor.project.info.tip=Click here to display project's informations
i18neditor.project.step.chooseProjectType=
i18neditor.project.step.chooseProjectType.description=
-i18neditor.project.step.configureDirectoryProject=
-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=
@@ -104,13 +102,14 @@
i18neditor.project.type.jar=
i18neditor.project.type.jar.description=
i18neditor.resource.name=Resource \: %1$s
-i18neditor.title=
+i18neditor.title=Nuiton i18n editor < Project %1$s >
i18neditor.title.about=About Nuiton i18n editor
-i18neditor.title.change.storage=
i18neditor.title.choose.directory.source=
i18neditor.title.choose.jar.source=
i18neditor.title.choose.project=
i18neditor.title.choose.projectDir=
-i18neditor.title.noproject=
+i18neditor.title.create.project=Create a new project
+i18neditor.title.noproject=Nuiton i18n editor < no project loaded >
+i18neditor.title.project.info=Project's informations
i18neditor.warning.nimbus.landf=Could not find nymbus look and feel, please use at least a 1.6u10 version of sun jre
i18neditor.warning.no.ui=No ui environment detected\!
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-22 17:50:16 UTC (rev 1645)
+++ trunk/nuiton-i18n-editor/src/main/resources/i18n/nuiton-i18n-editor-fr_FR.properties 2009-07-23 20:14:25 UTC (rev 1646)
@@ -41,6 +41,7 @@
i18neditor.action.showHelp.tip=Voir l'aide contextuelle
i18neditor.action.site=Site
i18neditor.action.site.tip=Acc\u00E9der au site du projet
+i18neditor.title.create.project=Cr\u00E9er un nouveau projet
i18neditor.bundle.name=Localisation \: %1$s
i18neditor.choose.project.to.delete=Choisir le projet \u00E0 supprimer
i18neditor.common.descrition=Description
@@ -82,14 +83,12 @@
i18neditor.menu.storeall=Sauvegarder
i18neditor.message.config.loaded=Configuration de nuiton-i18n-editor v. %1$s charg\u00E9e.
i18neditor.message.help.usage=Aide de nuiton-i18n-editor v %1$s
+i18neditor.message.no.project.loaded=< Aucun projet charg\u00E9 >
i18neditor.no.keys=< Aucune clef definie >
i18neditor.package.name=Paquetage \: %1$s
+i18neditor.project.info.tip=Cliquer ici pour obtenir des informations sur le projet charg\u00E9
i18neditor.project.step.chooseProjectType=Type de projet
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=
-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
@@ -106,11 +105,12 @@
i18neditor.resource.name=Resource \: %1$s
i18neditor.title=Nuiton i18n editor < Projet %1$s >
i18neditor.title.about=A propos de nuiton-i18n-editor...
-i18neditor.title.change.storage=Ouvrir un projet
i18neditor.title.choose.directory.source=Choisir le r\u00E9pertoire
i18neditor.title.choose.jar.source=Choisir un fichier de type 'jar'
i18neditor.title.choose.project=Choisir le fichier de d\u00E9finition d'un projet
i18neditor.title.choose.projectDir=Choisir une d\u00E9finition de projet
+i18neditor.title.create.project=
i18neditor.title.noproject=Nuiton i18n editor < aucun projet charg\u00E9 >
+i18neditor.title.project.info=Informations sur le projet
i18neditor.warning.nimbus.landf=Le look and Feel Nimbus n'a pas \u00E9t\u00E9 trouv\u00E9, il faut au moins la version 1.6u10 de java.
i18neditor.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9
1
0
[Lutinutil-commits] r1645 - in trunk/nuiton-i18n-editor: . src/main/java/org/nuiton/i18n/editor src/main/java/org/nuiton/i18n/editor/project src/main/java/org/nuiton/i18n/editor/project/impl src/main/java/org/nuiton/i18n/editor/ui src/main/java/org/nuiton/i18n/editor/ui/project src/main/java/org/nuiton/i18n/editor/ui/project/tabs src/main/resources src/main/resources/META-INF src/main/resources/META-INF/services src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org 22 Jul '09
by tchemit@users.labs.libre-entreprise.org 22 Jul '09
22 Jul '09
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
1
0
[Lutinutil-commits] r1667 - trunk/src/main/java/org/nuiton/util
by tchemit@users.labs.libre-entreprise.org 11 Jul '09
by tchemit@users.labs.libre-entreprise.org 11 Jul '09
11 Jul '09
Author: tchemit
Date: 2009-07-11 14:07:21 +0200 (Sat, 11 Jul 2009)
New Revision: 1667
Modified:
trunk/src/main/java/org/nuiton/util/MD5InputStream.java
Log:
push back some missing codes
Modified: trunk/src/main/java/org/nuiton/util/MD5InputStream.java
===================================================================
--- trunk/src/main/java/org/nuiton/util/MD5InputStream.java 2009-07-06 20:42:06 UTC (rev 1666)
+++ trunk/src/main/java/org/nuiton/util/MD5InputStream.java 2009-07-11 12:07:21 UTC (rev 1667)
@@ -53,135 +53,140 @@
* @author Santeri Paavolainen <santtu(a)cs.hut.fi>
* @author Timothy W Macinta (twm(a)alum.mit.edu) (added main() method)
**/
-
-
public class MD5InputStream extends FilterInputStream {
- /**
- * MD5 context
- */
- private MD5 md5;
-
- /**
- * Creates a MD5InputStream
- * @param in The input stream
- */
- public MD5InputStream (InputStream in) {
- super(in);
+ /** Class logger. */
+ private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(MD5InputStream.class);
+ /**
+ * MD5 context
+ */
+ protected MD5 md5;
+ protected long streamLength;
- md5 = new MD5();
- }
+ /**
+ * Creates a MD5InputStream
+ * @param in The input stream
+ */
+ public MD5InputStream(InputStream in) {
+ super(in);
- /**
- * Read a byte of data.
- * @see java.io.FilterInputStream
- */
- public int read() throws IOException {
- int c = in.read();
-
- if (c == -1)
- return -1;
-
- if ((c & ~0xff) != 0) {
- System.out.println("MD5InputStream.read() got character with (c & ~0xff) != 0)!");
- } else {
- md5.Update(c);
+ md5 = new MD5();
}
- return c;
- }
+ @Override
+ public int read() throws IOException {
+ int c = in.read();
- /**
- * Reads into an array of bytes.
- *
- * @see java.io.FilterInputStream
- */
- public int read (byte bytes[], int offset, int length) throws IOException {
- int r;
-
- if ((r = in.read(bytes, offset, length)) == -1)
- return r;
+ if (c == -1) {
+ return -1;
+ }
- md5.Update(bytes, offset, r);
+ if ((c & ~0xff) != 0) {
+ log.warn("MD5InputStream.read() got character with (c & ~0xff) != 0)!");
+ } else {
+ streamLength++;
+ md5.Update(c);
+ }
- return r;
- }
+ return c;
+ }
- /**
- * Returns array of bytes representing hash of the stream as
- * finalized for the current state.
- * @see MD5#Final
- */
- public byte[] hash () {
- return md5.Final();
- }
+ @Override
+ public int read(byte bytes[], int offset, int length) throws IOException {
+ int r;
- public MD5 getMD5() {
- return md5;
- }
+ if ((r = in.read(bytes, offset, length)) == -1) {
+ return r;
+ }
+ streamLength += r;
- /**
- * This method is here for testing purposes only - do not rely
- * on it being here.
- **/
- public static void main(String[] arg) {
- try {
+ md5.Update(bytes, offset, r);
- ////////////////////////////////////////////////////////////////
- //
- // usage: java com.twmacinta.util.MD5InputStream [--use-default-md5] [--no-native-lib] filename
- //
- /////////
+ return r;
+ }
- // determine the filename to use and the MD5 impelementation to use
+ /**
+ * Returns array of bytes representing hash of the stream as
+ * finalized for the current state.
+ * @return
+ * @see MD5#Final
+ */
+ public byte[] hash() {
+ return md5.Final();
+ }
- String filename = arg[arg.length-1];
- boolean use_default_md5 = false;
- boolean use_native_lib = true;
- for (int i = 0; i < arg.length-1; i++) {
- if (arg[i].equals("--use-default-md5")) {
- use_default_md5 = true;
- } else if (arg[i].equals("--no-native-lib")) {
- use_native_lib = false;
- }
- }
+ public MD5 getMD5() {
+ return md5;
+ }
- // initialize common variables
-
- byte[] buf = new byte[65536];
- int num_read;
-
- // Use the default MD5 implementation that comes with Java
-
- if (use_default_md5) {
- InputStream in = new BufferedInputStream(new FileInputStream(filename));
- java.security.MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
- while ((num_read = in.read(buf)) != -1) {
- digest.update(buf, 0, num_read);
- }
- System.out.println(MD5.asHex(digest.digest())+" "+filename);
- in.close();
-
- // Use the optimized MD5 implementation
-
- } else {
-
- // disable the native library search, if requested
-
- if (!use_native_lib) {
- MD5.initNativeLibrary(true);
- }
-
- // calculate the checksum
-
- MD5InputStream in = new MD5InputStream(new BufferedInputStream(new FileInputStream(filename)));
- while ((num_read = in.read(buf)) != -1);
- System.out.println(MD5.asHex(in.hash())+" "+filename);
- in.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
+ public long getStreamLength() {
+ return streamLength;
}
- }
+ //TODO TC-20090711 : do a unit test instead of this main !
+// /**
+// * This method is here for testing purposes only - do not rely
+// * on it being here.
+// *
+// * @param arg
+// */
+// public static void main(String[] arg) {
+// try {
+//
+// ////////////////////////////////////////////////////////////////
+// //
+// // usage: java com.twmacinta.util.MD5InputStream [--use-default-md5] [--no-native-lib] filename
+// //
+// /////////
+//
+// // determine the filename to use and the MD5 impelementation to use
+//
+// String filename = arg[arg.length - 1];
+// boolean use_default_md5 = false;
+// boolean use_native_lib = true;
+// for (int i = 0; i < arg.length - 1; i++) {
+// if (arg[i].equals("--use-default-md5")) {
+// use_default_md5 = true;
+// } else if (arg[i].equals("--no-native-lib")) {
+// use_native_lib = false;
+// }
+// }
+//
+// // initialize common variables
+//
+// byte[] buf = new byte[65536];
+// int num_read;
+//
+// // Use the default MD5 implementation that comes with Java
+//
+// if (use_default_md5) {
+// InputStream in = new BufferedInputStream(new FileInputStream(filename));
+// java.security.MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
+// while ((num_read = in.read(buf)) != -1) {
+// digest.update(buf, 0, num_read);
+// }
+// System.out.println(MD5.asHex(digest.digest()) + " " + filename);
+// in.close();
+//
+// // Use the optimized MD5 implementation
+//
+// } else {
+//
+// // disable the native library search, if requested
+//
+// if (!use_native_lib) {
+// MD5.initNativeLibrary(true);
+// }
+//
+// // calculate the checksum
+//
+// MD5InputStream in = new MD5InputStream(new BufferedInputStream(new FileInputStream(filename)));
+// while ((num_read = in.read(buf)) != -1);
+// System.out.println(MD5.asHex(in.hash()) + " " + filename);
+// in.close();
+// }
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
}
1
0