Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3157 discussions
[Lutinutil-commits] r932 - in trunk/commandline/commandline-ui-action: . src/main src/main/java/org/codelutin/option/ui src/main/java/org/codelutin/option/ui/actions src/main/resources/i18n src/main/uimodel src/main/uimodel/org src/main/uimodel/org/codelutin src/main/uimodel/org/codelutin/option src/main/uimodel/org/codelutin/option/ui
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
28 Jul '08
Author: tchemit
Date: 2008-07-28 12:21:47 +0000 (Mon, 28 Jul 2008)
New Revision: 932
Added:
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/AboutUI.java
trunk/commandline/commandline-ui-action/src/main/uimodel/
trunk/commandline/commandline-ui-action/src/main/uimodel/org/
trunk/commandline/commandline-ui-action/src/main/uimodel/org/codelutin/
trunk/commandline/commandline-ui-action/src/main/uimodel/org/codelutin/option/
trunk/commandline/commandline-ui-action/src/main/uimodel/org/codelutin/option/ui/
trunk/commandline/commandline-ui-action/src/main/uimodel/org/codelutin/option/ui/JAboutUI.jaxx
Modified:
trunk/commandline/commandline-ui-action/pom.xml
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/AboutAction.java
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/QuitAction.java
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/SiteAction.java
trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-en_GB.properties
trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-fr_FR.properties
Log:
mise en place action About
ajout de proprietes obligatoires supplementaires
fix bug sur l'action Quit
Modified: trunk/commandline/commandline-ui-action/pom.xml
===================================================================
--- trunk/commandline/commandline-ui-action/pom.xml 2008-07-28 12:19:43 UTC (rev 931)
+++ trunk/commandline/commandline-ui-action/pom.xml 2008-07-28 12:21:47 UTC (rev 932)
@@ -100,6 +100,8 @@
</execution>
</executions>
</plugin>
+
+ <!-- jaxx -->
<plugin>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>maven-jaxx-plugin</artifactId>
@@ -109,6 +111,14 @@
</configuration>
<executions>
<execution>
+ <id>jaxx-generate</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+
+ </execution>
+
+ <execution>
<id>jaxx-generate-actions-provider</id>
<goals>
<goal>generate-actions-provider</goal>
@@ -138,6 +148,14 @@
</configuration>
</execution>
</executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-swing</artifactId>
+ <scope>compile</scope>
+ <version>${jaxx.version}</version>
+ </dependency>
+ </dependencies>
</plugin>
</plugins>
</build>
Added: trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/AboutUI.java
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/AboutUI.java (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/AboutUI.java 2008-07-28 12:21:47 UTC (rev 932)
@@ -0,0 +1,91 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.option.ui;
+
+import org.codelutin.util.VersionNumber;
+
+import javax.swing.JEditorPane;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import javax.swing.text.html.HTMLDocument;
+import javax.swing.text.html.HTMLEditorKit;
+import javax.swing.text.html.HTMLFrameHyperlinkEvent;
+import java.awt.Desktop;
+import java.net.URL;
+
+/** @author chemit */
+public class AboutUI extends JAboutUI {
+
+ public AboutUI() {
+ super();
+ getApplicationWebsite().setEditorKit(new HTMLEditorKit());
+ getApplicationWebsite().addHyperlinkListener(createHyperLinkListener(getApplicationWebsite()));
+
+ getOrganisationWebsite().setEditorKit(new HTMLEditorKit());
+ getOrganisationWebsite().addHyperlinkListener(createHyperLinkListener(getOrganisationWebsite()));
+ }
+
+ public void init(javax.swing.JFrame frame, org.codelutin.option.Context c) {
+ if (frame != null) {
+ setLocationRelativeTo(frame);
+ }
+ org.codelutin.option.Config config = c.getMainConfig();
+ String applicationName = (String) config.getProperty("projectName");
+
+ VersionNumber applicationVersion = (VersionNumber) config.getProperty("version");
+
+ getApplicationName().setText(applicationName + " v" + applicationVersion);
+
+ URL applicationURL = (URL) config.getProperty("projectURL");
+ getApplicationWebsite().setText("<a href=\"" + applicationURL + "\">" + applicationURL + "</a>");
+
+ String organisationName = (String) config.getProperty("organisationName");
+ getOrganisationName().setText(organisationName);
+
+ URL organisationURL = (URL) config.getProperty("organisationURL");
+ getOrganisationWebsite().setText("<a href=\"" + organisationURL + "\">" + organisationURL + "</a>");
+
+ String copyright = (String) config.getProperty("copyright");
+ getCopyright().setText(copyright);
+ pack();
+
+ }
+
+ public HyperlinkListener createHyperLinkListener(final JEditorPane doc) {
+ return new HyperlinkListener() {
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ if (e instanceof HTMLFrameHyperlinkEvent) {
+ ((HTMLDocument) doc.getDocument()).processHTMLFrameHyperlinkEvent(
+ (HTMLFrameHyperlinkEvent) e);
+ } else {
+ try {
+ if (
+ Desktop.isDesktopSupported() &&
+ Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
+ Desktop.getDesktop().browse(e.getURL().toURI());
+ } else {
+ doc.setPage(e.getURL());
+ }
+ } catch (Exception eee) {
+ System.out.println("Error for : " + e.getURL());
+ eee.printStackTrace();
+ }
+ }
+ }
+ }
+ };
+ }
+}
Modified: trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/AboutAction.java
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/AboutAction.java 2008-07-28 12:19:43 UTC (rev 931)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/AboutAction.java 2008-07-28 12:21:47 UTC (rev 932)
@@ -14,6 +14,8 @@
*/
package org.codelutin.option.ui.actions;
+import org.codelutin.option.ui.AboutUI;
+
/**
* Action pour afficher la dialogue de modification de configuration
*
@@ -31,6 +33,7 @@
public class AboutAction extends CommandLineBaseAction {
private static final long serialVersionUID = 9050439968144935986L;
+ AboutUI aboutUI;
public AboutAction(String name) {
super(name);
@@ -38,12 +41,22 @@
@Override
public void doAction(java.awt.event.ActionEvent e) {
- log.info("To be done!");
+ getAboutUI().setVisible(true);
}
@Override
public void disposeUI() {
super.disposeUI();
+ if (aboutUI != null) {
+ aboutUI = null;
+ }
}
+ public AboutUI getAboutUI() {
+ if (aboutUI == null) {
+ aboutUI = new AboutUI();
+ aboutUI.init(null, getContext());
+ }
+ return aboutUI;
+ }
}
\ No newline at end of file
Modified: trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/QuitAction.java
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/QuitAction.java 2008-07-28 12:19:43 UTC (rev 931)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/QuitAction.java 2008-07-28 12:21:47 UTC (rev 932)
@@ -60,7 +60,7 @@
result = n == JOptionPane.YES_OPTION;
}
-
+ log.info("to treate ? " + result);
return result;
}
Modified: trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/SiteAction.java
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/SiteAction.java 2008-07-28 12:19:43 UTC (rev 931)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/SiteAction.java 2008-07-28 12:21:47 UTC (rev 932)
@@ -47,7 +47,7 @@
if (!super.beforeAction(e) && !Desktop.isDesktopSupported() && !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
return false;
}
- siteUrl = (URL) getContext().getMainConfig().getProperty("siteURL");
+ siteUrl = (URL) getContext().getMainConfig().getProperty("projectURL");
return siteUrl != null;
}
Modified: trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-en_GB.properties
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-en_GB.properties 2008-07-28 12:19:43 UTC (rev 931)
+++ trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-en_GB.properties 2008-07-28 12:21:47 UTC (rev 932)
@@ -20,3 +20,4 @@
commandline.no=No
commandline.question=Quit
commandline.yes=Yes
+lutinutil.about=
Modified: trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-fr_FR.properties
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-fr_FR.properties 2008-07-28 12:19:43 UTC (rev 931)
+++ trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-fr_FR.properties 2008-07-28 12:21:47 UTC (rev 932)
@@ -20,3 +20,4 @@
commandline.no=Non
commandline.question=Quitter
commandline.yes=Oui
+lutinutil.about=
Added: trunk/commandline/commandline-ui-action/src/main/uimodel/org/codelutin/option/ui/JAboutUI.jaxx
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/uimodel/org/codelutin/option/ui/JAboutUI.jaxx (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/uimodel/org/codelutin/option/ui/JAboutUI.jaxx 2008-07-28 12:21:47 UTC (rev 932)
@@ -0,0 +1,43 @@
+<JDialog title="commandline.action.about" undecorated='false' resizable='false' modal='true' locationRelativeTo="{null}"
+ defaultCloseOperation="dispose_on_close"
+ width="300" height="300">
+ <!--onMouseClicked="dispose()"-->
+
+ <Table insets='5,5,5,5'>
+ <row>
+ <cell>
+ <JLabel id="applicationName"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JEditorPane id="applicationWebsite" contentType="text/html" editable='false' opaque='false'/>
+ </cell>
+ </row>
+ <row>
+ <cell fill='horizontal'>
+ <JSeparator orientation='horizontal'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel id="organisationName"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JEditorPane id="organisationWebsite" contentType="text/html" editable='false'/>
+ </cell>
+ </row>
+ <row>
+ <cell fill='horizontal'>
+ <JSeparator orientation='horizontal'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel id="copyright"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
1
0
[Lutinutil-commits] r931 - trunk/commandline/commandline-core/src/main/java/org/codelutin/option
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
28 Jul '08
Author: tchemit
Date: 2008-07-28 12:19:43 +0000 (Mon, 28 Jul 2008)
New Revision: 931
Added:
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextKey.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextKeyImpl.java
Modified:
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/AbstractContext.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/Context.java
Log:
javadoc
mise en place d'un context dynamique
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/AbstractContext.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/AbstractContext.java 2008-07-27 10:36:26 UTC (rev 930)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/AbstractContext.java 2008-07-28 12:19:43 UTC (rev 931)
@@ -73,6 +73,9 @@
/** le timestamp de d�marrage de l'application */
protected final long startingTime;
+ /** le dictionnaire de valeurs suppl�mentaires */
+ protected final java.util.Map<String, Object> extraValues;
+
protected AbstractContext(Class<P> parserClass, Class<? extends Config>... configs) throws Exception {
startingTime = System.nanoTime();
String home = System.getProperty("user.home");
@@ -98,6 +101,9 @@
for (ConfigKey configKey : getConfigKeys()) {
this.configs[i++] = configKey.instanciateConfig();
}
+
+ extraValues = new java.util.TreeMap<String, Object>();
+
}
protected AbstractContext(Class<P> parserClass) throws Exception {
@@ -122,6 +128,7 @@
for (ConfigKey configKey : getConfigKeys()) {
this.configs[i++] = configKey.instanciateConfig();
}
+ extraValues = new java.util.TreeMap<String, Object>();
}
public void init(String[] args) throws Exception {
@@ -380,4 +387,36 @@
visitor.enterConfig(configKey);
}
}
+
+ public <T> void addContextValue(ContextKey<T> key, T value) {
+ String strKey = key.getKey();
+ if (!extraValues.containsKey(strKey)) {
+ extraValues.put(strKey, value);
+ }
+ if (log.isWarnEnabled()) {
+ log.warn("on existing value for key " + key);
+ }
+ extraValues.put(strKey, value);
+ }
+
+ public <T> void removeContextValue(ContextKey<T> key) {
+ String strKey = key.getKey();
+ if (extraValues.containsKey(strKey)) {
+ extraValues.remove(strKey);
+ }
+ }
+
+ public void removeAllContextValues() {
+ extraValues.clear();
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public <T> T getContextValue(ContextKey<T> key) {
+ String strKey = key.getKey();
+ if (!extraValues.containsKey(strKey)) {
+ //TODO Should throw an exception
+ return null;
+ }
+ return (T) extraValues.get(strKey);
+ }
}
\ No newline at end of file
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/Context.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/Context.java 2008-07-27 10:36:26 UTC (rev 930)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/Context.java 2008-07-28 12:19:43 UTC (rev 931)
@@ -18,60 +18,233 @@
import java.io.IOException;
import java.util.List;
-/** @author chemit */
+/**
+ * Contract of an application context.
+ * <p/>
+ * The context box an {@link OptionParser}, some {@link Config}.
+ * <p/>
+ * A context can also have dynamic entries (see the XXXContextValue(s) method).
+ *
+ * @author chemit
+ */
public interface Context<P extends OptionParser> extends ContextVisitable {
+ /**
+ * Init the context (says init the parser and the config)
+ *
+ * @param args arguments passed to application
+ * @throws Exception if any pb while initialisation.
+ */
void init(String[] args) throws Exception;
+ /** @return the starting time of the context (says when the context is instanciated) */
long getStartingTime();
+ /** @return the delay elasped from {@link #getStartingTime()} to now */
long getElapsedTime();
+ /** @return the delay elasped from {@link #getStartingTime()} to now as a String representation */
String getElapsedTimeAsString();
/** initialisation i18n apr�s init du parser et des configs. */
void initI18n();
- /** @return la configuration principale de l'application */
+ /**
+ * Accessor of the main configuration of context.
+ *
+ * @return la configuration principale de l'application
+ */
Config getMainConfig();
+ /** @return the boxed {@link OptionParser} */
P getParser();
+ /**
+ * @param key the given key of config
+ * @return the config registred given his key
+ */
<C extends Config> C getConfig(ConfigKey<C> key);
+ /**
+ * Accessor of the flag <code>quit</code>.
+ * <p/>
+ * The <code>quit</code> is computed while firing the options given to application.
+ *
+ * @return <ocde>true</code> if we should stop application, <code>false</code> otherwise.
+ */
boolean isQuit();
+ /**
+ * Accessor of the flag <code>useUI</code>.
+ * <p/>
+ * The <code>useUI</code> flag tells us if we can use UI in the application.
+ *
+ * @return <code>true</code> if we can use UI in the application, <code>false</code> otherwise.
+ */
boolean isUseUI();
+ /**
+ * Accessor of the flag <code>launchUI</code>.
+ * <p/>
+ * The <code>launchUI</code> flag tells us if we should launch the main UI of the application, after the init.
+ * <p/>
+ * This flag can be changed by options fired
+ *
+ * @return <code>true</code> if we should launch main UI after init, <code>false</code> otherwise.
+ */
boolean isLaunchUI();
+ /**
+ * Accessor of the flag <code>firstLaunch</code>.
+ * <p/>
+ * The <code>firstLaunch</code> determines if this is the first time the application is launched (says no
+ * configuration file was found)
+ *
+ * @return <code>true</code> if no config file was found, <code>false</code> otheriwse.
+ */
boolean isFirstLaunch();
+ /**
+ * Mutator of the flag <code>quit</code>
+ *
+ * @param quit the new value of the flag <code>quit</code>
+ */
void setQuit(boolean quit);
+ /**
+ * Mutator of the flag <code>launchUI</code>
+ *
+ * @param launchUI the new value of the flag <code>launchUI</code>
+ */
void setLaunchUI(boolean launchUI);
+ /**
+ * Mutator of the flag <code>firstLaunch</code>
+ *
+ * @param firstLaunch the new value of the flag <code>firstLaunch</code>
+ */
void setFirstLaunch(boolean firstLaunch);
+ /**
+ * Try to save the configurations boxed by context.
+ * <p/>
+ * All configuration are saved in the same file given by the method {@link #getSource()}.
+ *
+ * @throws IOException if IO pb while saving
+ * @throws IllegalStateException TODO
+ */
void save() throws IOException, IllegalStateException;
+ /**
+ * Try to save the configurations boxed by the context.
+ * <p/>
+ * If any problem appears, no exception will be trhown.
+ * <p/>
+ * <b>Note : this is a weak method, since no exception is thrown...</b>
+ */
void saveSafely();
+ /**
+ * Mutator of the configuration file
+ *
+ * @param source the new file to use to store on disk the configurations boxed by context.
+ */
void setSource(File source);
+ /**
+ * Accessor of the configuration file to store configurations
+ *
+ * @return the file where configurations boxed by context are stored.
+ */
File getSource();
+ /**
+ * Accessor of all configuration's key known by the context.
+ *
+ * @return the list of {@link org.codelutin.option.ConfigKey} known by the context.
+ */
List<ConfigKey<?>> getConfigKeys();
+ /**
+ * Accessor of all configurations boxed by the context.
+ *
+ * @return the list of all configurations boxed by the context.
+ */
Config[] getConfigs();
+ /**
+ * Accessor of a typed configuration's key given his string representation key.
+ * <p/>
+ * This method is used when we do not knwon the real implementation of a configuration key.
+ * <p/>
+ * For example, there is always a <code>main</code> config in a context, so we can access the configKey using this
+ * method in a generic code.
+ * <p/>
+ * <b>Note : Use this code as less as possible, when you don't have access to real implementation of the context.</b>
+ *
+ * @param key the string representation of a key of configuration
+ * @return the typed configuration key given his string representation
+ */
ConfigKey<?> getConfigKey(String key);
+ /**
+ * Accessor of a boxed configuration using the configuration key (as a string representation).
+ * <p/>
+ * The configuration is searched via his method {@link org.codelutin.option.Config#getCategory()}
+ * <p/>
+ * <b>Note : use this method only if you do not know the real implementation of context (for example in a
+ * generic code)</b>
+ *
+ * @param key the string representaiotn of a key configuration researched
+ * @return the configuration boxed in context, or <code>null</code> if no matching configuration is found.
+ */
Config getConfig(String key);
- @SuppressWarnings({"unchecked"})
- <C extends Config> void registerConfig(Class<? extends C> aClass);
+ /**
+ * Register in the context a new configuration, given his implementation class.
+ *
+ * @param aClass the config class implementation
+ */
+ <C extends Config> void registerConfig(Class<? extends C> aClass);
+ @Override
void accept(ContextVisitor visitor);
+ /**
+ * Dispose the context (says dispose the application), with possibility to reload it when <code>reload</code> has
+ * <code>true</code> value.
+ * <p/>
+ * For example, when we wants to change langue of an application, all uis has to be dispose then reloead, so you
+ * can use this method for the purpose.
+ *
+ * @param reload <code>true</code> if context is reload after disposing it, <ocde>false</code> otherwise.
+ */
void dispose(boolean reload);
+
+ /**
+ * Add to the context a dynamic entry given his typed key and his real value.
+ * <p/>
+ * <b>Note : if an previously entry was in context, it will be override by the new value.</b>
+ *
+ * @param key the context typed entry key
+ * @param value the context entry value
+ */
+ <T> void addContextValue(ContextKey<T> key, T value);
+
+ /**
+ * Remove ffrom the context the dynamic entry
+ *
+ * @param key the context typed entry key
+ */
+ <T> void removeContextValue(ContextKey<T> key);
+
+ /** Remove from context, all dynamic entries. */
+ void removeAllContextValues();
+
+ /**
+ * Accessor of a dynamic entry in the context given his type entry key.
+ *
+ * @param key the given typed entry key
+ * @return the value of the dynamic entry
+ */
+ <T> T getContextValue(ContextKey<T> key);
}
Added: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextKey.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextKey.java (rev 0)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextKey.java 2008-07-28 12:19:43 UTC (rev 931)
@@ -0,0 +1,34 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.option;
+
+/**
+ * Contract of a key in the context.
+ * <p/>
+ * The {@link #getKey()} returns the string value of the key.
+ * <p/>
+ * The {link #getValueType()} returns the type of the value.
+ * <p/>
+ * To obtain the real value of this key for a given context, use the method {@link Context#getContextValue(ContextKey)}
+ *
+ * @author chemit
+ */
+public interface ContextKey<T> {
+
+ String getKey();
+
+ Class<T> getValueType();
+
+}
Added: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextKeyImpl.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextKeyImpl.java (rev 0)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextKeyImpl.java 2008-07-28 12:19:43 UTC (rev 931)
@@ -0,0 +1,57 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.option;
+
+/**
+ * A simple implementation of {@link ContextKey}.
+ * <p/>
+ * This object has an invariant {@link #key} which defines the {@link #equals(Object)} methods (and of course the
+ * {@link #hashCode()} one too!).
+ *
+ * @author chemit
+ */
+public class ContextKeyImpl<T> implements ContextKey<T> {
+
+ final protected String key;
+ final protected Class<T> valueType;
+
+ public ContextKeyImpl(String key, Class<T> valueType) {
+ this.key = key;
+ this.valueType = valueType;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public Class<T> getValueType() {
+ return valueType;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<key:" + key + ", type:" + valueType + ">";
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return this == o || o instanceof ContextKeyImpl && key.equals(((ContextKeyImpl) o).key);
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode();
+ }
+}
1
0
27 Jul '08
Author: tchemit
Date: 2008-07-27 10:36:26 +0000 (Sun, 27 Jul 2008)
New Revision: 930
Modified:
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/AbstractContext.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionActionRunnable.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionParserContexts.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionChangeConfigRunnable.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionEditConfigRunnable.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpConfigRunnable.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpRunnable.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionResetConfigRunnable.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionShowConfigRunnable.java
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionUiRunnable.java
trunk/commandline/commandline-core/src/site/site_fr.xml
trunk/commandline/commandline-ui/pom.xml
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTab.jaxx
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JConfigUI.jaxx
trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JLoginUI.jaxx
trunk/commandline/commandline-ui/src/site/site_fr.xml
trunk/commandline/commandline-ui/src/test/java/org/codelutin/option/ui/UITest.java
trunk/commandline/maven-plugin/pom.xml
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/AbsractDefinitionContext.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefaultOptionAction.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefinitionParserContexts.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefinitionParserUtil.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigLoader.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigPropertyLoader.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigPropertyLoaderEntry.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/Loader.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/OptionLoader.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/OptionLoaderEntry.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorGoal.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/java/AbstractJavaGenerator.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/java/DefaultOptionActionJavaGenerator.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/util/AbstractGeneratorGoal.java
trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyParser.java
trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyParser1.java
trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/ParserTest.java
trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/ParserUtilForTest.java
trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/PropertiesLoaderTest.java
trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/generate/GenerateJavaTest.java
Log:
reformat
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/AbstractContext.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/AbstractContext.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/AbstractContext.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -375,7 +375,7 @@
}
public void accept(ContextVisitor visitor) {
- visitor.enterParser(getParser());
+ visitor.enterParser(getParser());
for (ConfigKey<?> configKey : configKeys) {
visitor.enterConfig(configKey);
}
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionActionRunnable.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionActionRunnable.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionActionRunnable.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,9 +1,10 @@
package org.codelutin.option;
/**
- * Action wrapper for OptionAction
+ * Action wrapper for OptionAction
*
- * @author chemit */
+ * @author chemit
+ */
public interface OptionActionRunnable<O extends Option, P extends OptionParser, C extends AbstractContext<P>, A extends OptionAction<O, P, C>> {
void run(A action) throws Exception;
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionParserContexts.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionParserContexts.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionParserContexts.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -276,7 +276,7 @@
// instanciate real options from safe contexts
for (OptionContext context : getContexts()) {
OptionKey key = context.getKey();
- result.registerOption(key,context.instanciate(key));
+ result.registerOption(key, context.instanciate(key));
}
// transfert unused arguments
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionChangeConfigRunnable.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionChangeConfigRunnable.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionChangeConfigRunnable.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -19,10 +19,10 @@
import org.codelutin.option.Config;
import org.codelutin.option.ConfigKey;
import org.codelutin.option.ConfigPropertyKey;
+import org.codelutin.option.Context;
import org.codelutin.option.Option;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
-import org.codelutin.option.Context;
/**
* OptionAction to change a property in a config.
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionEditConfigRunnable.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionEditConfigRunnable.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionEditConfigRunnable.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -18,9 +18,9 @@
import org.codelutin.option.AbstractContext;
import org.codelutin.option.Config;
import org.codelutin.option.ConfigKey;
+import org.codelutin.option.Context;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
-import org.codelutin.option.Context;
/** @author chemit */
public class OptionActionEditConfigRunnable implements OptionActionRunnable {
@@ -39,7 +39,7 @@
configs[i++] = context.getConfig(o);
}
javax.swing.JDialog ui = (javax.swing.JDialog) Class.forName(UI_FQN).newInstance();
- ui.getClass().getMethod("init", AbstractContext.class, Config[].class).invoke(ui, context,configs);
+ ui.getClass().getMethod("init", AbstractContext.class, Config[].class).invoke(ui, context, configs);
ui.setVisible(true);
}
}
\ No newline at end of file
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpConfigRunnable.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpConfigRunnable.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpConfigRunnable.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -18,9 +18,9 @@
import static org.codelutin.i18n.I18n._;
import org.codelutin.option.ConfigKey;
import org.codelutin.option.ConfigPropertyKey;
+import org.codelutin.option.Context;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
-import org.codelutin.option.Context;
import static org.codelutin.option.ParserUtil.addTitle;
import org.codelutin.util.ReflectUtil;
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpRunnable.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpRunnable.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpRunnable.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -18,10 +18,10 @@
import static org.codelutin.i18n.I18n._;
import org.codelutin.option.ConfigKey;
import org.codelutin.option.ConfigPropertyKey;
+import org.codelutin.option.Context;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
import org.codelutin.option.OptionKey;
-import org.codelutin.option.Context;
import static org.codelutin.option.ParserUtil.addTitle;
import org.codelutin.option.def.OptionDefinition;
import org.codelutin.util.ReflectUtil;
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionResetConfigRunnable.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionResetConfigRunnable.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionResetConfigRunnable.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -16,9 +16,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
+import org.codelutin.option.Context;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
-import org.codelutin.option.Context;
import java.io.File;
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionShowConfigRunnable.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionShowConfigRunnable.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionShowConfigRunnable.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -16,10 +16,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.option.ConfigKey;
+import org.codelutin.option.Context;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
import org.codelutin.option.ParserUtil;
-import org.codelutin.option.Context;
import java.io.StringWriter;
@@ -37,7 +37,7 @@
if (category.equals("all")) {
for (ConfigKey<?> configKey : context.getConfigKeys()) {
- ParserUtil.printConfig(writer, context.getConfig(configKey));
+ ParserUtil.printConfig(writer, context.getConfig(configKey));
}
log.info(writer);
} else {
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionUiRunnable.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionUiRunnable.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionUiRunnable.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -15,9 +15,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.option.Context;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
-import org.codelutin.option.Context;
/** @author chemit */
public class OptionActionUiRunnable implements OptionActionRunnable {
Modified: trunk/commandline/commandline-core/src/site/site_fr.xml
===================================================================
--- trunk/commandline/commandline-core/src/site/site_fr.xml 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-core/src/site/site_fr.xml 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,45 +1,47 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="LutinCommndline">
- <skin>
- <groupId>lutinlib</groupId>
- <artifactId>lutin-site-skin</artifactId>
- <version>0.1</version>
- </skin>
-
- <bannerLeft>
- <name>Lutin CommandLine</name>
- </bannerLeft>
-
- <bannerRight>
- <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
- <href>http://www.codelutin.com</href>
- </bannerRight>
+ <skin>
+ <groupId>lutinlib</groupId>
+ <artifactId>lutin-site-skin</artifactId>
+ <version>0.1</version>
+ </skin>
+ <bannerLeft>
+ <name>Lutin CommandLine</name>
+ </bannerLeft>
+
+ <bannerRight>
+ <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
+ <href>http://www.codelutin.com</href>
+ </bannerRight>
+
<poweredBy>
- <logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/>
- <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="images/jrst-logo.png"/>
- <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="images/restructuredtext-logo.png"/>
- </poweredBy>
+ <logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/>
+ <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="images/jrst-logo.png"/>
+ <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText"
+ img="images/restructuredtext-logo.png"/>
+ </poweredBy>
- <body>
- <links>
- <item name="Labs" href="http://labs.libre-entreprise.org/"/>
- <item name="Code Lutin" href="http://www.codelutin.com/"/>
- </links>
+ <body>
+ <links>
+ <item name="Labs" href="http://labs.libre-entreprise.org/"/>
+ <item name="Code Lutin" href="http://www.codelutin.com/"/>
+ </links>
- <menu name="Utilisateur">
- <item name="Accueil" href="index.html"/>
- <item name="R�aliser sa premi�re application" href="firstusage.html"/>
- <item href="http://lutinbuilder.labs.libre-entreprise.org/maven2/lutinlib/lutincommandl…" name="T�l�chargement"/>
- </menu>
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ <item name="R�aliser sa premi�re application" href="firstusage.html"/>
+ <item href="http://lutinbuilder.labs.libre-entreprise.org/maven2/lutinlib/lutincommandl…"
+ name="T�l�chargement"/>
+ </menu>
- <menu name="D�veloppeur">
- <item name="Implantation" href="devel/implementation.html"/>
- <item name="A faire" href="Todo.html"/>
- </menu>
+ <menu name="D�veloppeur">
+ <item name="Implantation" href="devel/implementation.html"/>
+ <item name="A faire" href="Todo.html"/>
+ </menu>
- ${reports}
+ ${reports}
- </body>
+ </body>
</project>
Modified: trunk/commandline/commandline-ui/pom.xml
===================================================================
--- trunk/commandline/commandline-ui/pom.xml 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/pom.xml 2008-07-27 10:36:26 UTC (rev 930)
@@ -48,7 +48,7 @@
<packaging>jar</packaging>
<build>
-
+
<plugins>
<!-- jaxx -->
Modified: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ClassCellEditor.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -62,9 +62,9 @@
if (converter != null) {
return converter.convert(Class.class, o);
}
- o =Class.forName(o+"");
+ o = Class.forName(o + "");
} catch (Exception e) {
- o=null;
+ o = null;
}
return o;
}
Modified: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableModel.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -212,7 +212,7 @@
ConfigPropertyKey<?> key = getKey(row);
Object val;
- if (aValue==null || key.getType() ==aValue.getClass()) {
+ if (aValue == null || key.getType() == aValue.getClass()) {
// we have directly the value, no conversion need
val = aValue;
} else {
@@ -227,7 +227,7 @@
} catch (Exception e) {
val = null;
}
- }
+ }
props.put(key, val);
fireTableRowsUpdated(row, row);
}
Modified: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigTableRenderer.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -69,7 +69,7 @@
}
if (cellRenderer == null) {
throw new IllegalStateException("no renderer find for column " + column);
- }
+ }
cellRenderer.setEnabled(!isFinal);
cellRenderer.setFont(isModified ? font2 : font);
return cellRenderer;
Modified: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -21,7 +21,7 @@
import org.codelutin.option.Config;
import org.codelutin.option.Context;
-import javax.swing.*;
+import javax.swing.JTable;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
Modified: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTab.jaxx
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTab.jaxx 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/ConfigTab.jaxx 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,44 +1,50 @@
<Table weightx="1">
<script>
-protected ConfigUIHandler handler;
+ protected ConfigUIHandler handler;
-public ConfigUIHandler getHandler() {
- if (handler == null) handler = new ConfigUIHandler(this);
- return handler;
-}
+ public ConfigUIHandler getHandler() {
+ if (handler == null) handler = new ConfigUIHandler(this);
+ return handler;
+ }
-public void dispose() {
- getHandler().dispose();
-}
+ public void dispose() {
+ getHandler().dispose();
+ }
-protected void doSave() { getHandler().doSave(); }
-protected void doReset() { getHandler().doReset(); }
-protected void doSelectNormal() { if (normal.isSelected()) getHandler().getTableModel().setType(ConfigTableModel.TypeModel.nontech); }
-protected void doSelectAll() { if (all.isSelected()) getHandler().getTableModel().setType(ConfigTableModel.TypeModel.all); }
-protected void doSelectTechnical() { if (onlytech.isSelected()) getHandler().getTableModel().setType(ConfigTableModel.TypeModel.tech); }
+ protected void doSave() { getHandler().doSave(); }
+ protected void doReset() { getHandler().doReset(); }
+ protected void doSelectNormal() { if (normal.isSelected())
+ getHandler().getTableModel().setType(ConfigTableModel.TypeModel.nontech); }
+ protected void doSelectAll() { if (all.isSelected())
+ getHandler().getTableModel().setType(ConfigTableModel.TypeModel.all); }
+ protected void doSelectTechnical() { if (onlytech.isSelected())
+ getHandler().getTableModel().setType(ConfigTableModel.TypeModel.tech); }
</script>
- <row>
- <cell weighty="1" weightx='1' fill='both'>
- <JScrollPane id='scroll' verticalScrollBarPolicy='20' horizontalScrollBarPolicy='31' >
- <JTable id="main" rowSelectionAllowed="false" autoResizeMode='auto_resize_last_column'/>
- </JScrollPane>
- </cell>
- </row>
<row>
+ <cell weighty="1" weightx='1' fill='both'>
+ <JScrollPane id='scroll' verticalScrollBarPolicy='20' horizontalScrollBarPolicy='31'>
+ <JTable id="main" rowSelectionAllowed="false" autoResizeMode='auto_resize_last_column'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row>
<cell columns='2' fill='both'>
<JPanel layout='{new GridLayout(0, 3, 2, 2)}'>
- <JRadioButton id='normal' selected='true' buttonGroup='type' text='lutinutil.common.toggle.normal' onActionPerformed='doSelectNormal()'/>
- <JRadioButton id='onlytech' selected='false' buttonGroup='type' text='lutinutil.common.toggle.technical' onActionPerformed='doSelectTechnical()'/>
- <JRadioButton id='all' selected='false' buttonGroup='type' text='lutinutil.common.toggle.all' onActionPerformed='doSelectAll()'/>
+ <JRadioButton id='normal' selected='true' buttonGroup='type' text='lutinutil.common.toggle.normal'
+ onActionPerformed='doSelectNormal()'/>
+ <JRadioButton id='onlytech' selected='false' buttonGroup='type' text='lutinutil.common.toggle.technical'
+ onActionPerformed='doSelectTechnical()'/>
+ <JRadioButton id='all' selected='false' buttonGroup='type' text='lutinutil.common.toggle.all'
+ onActionPerformed='doSelectAll()'/>
</JPanel>
</cell>
</row>
- <row fill='horizontal'>
- <cell>
- <JPanel layout='{new GridLayout(0, 2, 2, 2)}'>
- <JButton id='save' text='lutinutil.common.save' onActionPerformed='doSave()'/>
- <JButton id='reset' text='lutinutil.common.reset' onActionPerformed='doReset()'/>
- </JPanel>
- </cell>
- </row>
- </Table>
+ <row fill='horizontal'>
+ <cell>
+ <JPanel layout='{new GridLayout(0, 2, 2, 2)}'>
+ <JButton id='save' text='lutinutil.common.save' onActionPerformed='doSave()'/>
+ <JButton id='reset' text='lutinutil.common.reset' onActionPerformed='doReset()'/>
+ </JPanel>
+ </cell>
+ </row>
+</Table>
Modified: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JConfigUI.jaxx
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JConfigUI.jaxx 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JConfigUI.jaxx 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,22 +1,22 @@
<JDialog title='lutinutil.config.title' modal='true'
defaultCloseOperation='DISPOSE_ON_CLOSE' width='500' height='300'>
<script>
-public ListCellRenderer getListener() { return null; }
+ public ListCellRenderer getListener() { return null; }
-public void onValueChanged() {}
+ public void onValueChanged() {}
-Action quitAction ;
+ Action quitAction ;
-JRootPane rootPane = getRootPane();
-rootPane.setDefaultButton(quit);
-quitAction = new AbstractAction(quit.getText()) {
- private static final long serialVersionUID = -869095664995763057L;
- public void actionPerformed(ActionEvent e) {
+ JRootPane rootPane = getRootPane();
+ rootPane.setDefaultButton(quit);
+ quitAction = new AbstractAction(quit.getText()) {
+ private static final long serialVersionUID = -869095664995763057L;
+ public void actionPerformed(ActionEvent e) {
dispose();
- }
-};
-rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),"quit");
-rootPane.getActionMap().put("quit", quitAction);
+ }
+ };
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"),"quit");
+ rootPane.getActionMap().put("quit", quitAction);
</script>
<DefaultListModel id='listModel'/>
<java.awt.CardLayout id='cardLayout'/>
@@ -27,7 +27,8 @@
<row>
<cell weighty='1' fill='both' weightx='1'>
<JScrollPane>
- <JList id='list' onValueChanged='onValueChanged()' cellRenderer='{getListener()}' model='{listModel}'/>
+ <JList id='list' onValueChanged='onValueChanged()' cellRenderer='{getListener()}'
+ model='{listModel}'/>
</JScrollPane>
</cell>
</row>
Modified: trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JLoginUI.jaxx
===================================================================
--- trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JLoginUI.jaxx 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/src/main/uimodel/org/codelutin/option/ui/JLoginUI.jaxx 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,20 +1,20 @@
<JDialog title="lutinutil.connexion" modal='true' locationRelativeTo="{null}" defaultCloseOperation="dispose_on_close">
- <script>
- protected LoginUIHandler handler;
+ <script>
+ protected LoginUIHandler handler;
- public boolean launch(String login,String password) {
+ public boolean launch(String login,String password) {
if (login != null) {
- this.getLogin().setText(login);
+ this.getLogin().setText(login);
}
if (password!=null) {
- this.getPassword().setText(password);
+ this.getPassword().setText(password);
}
check();
setVisible(true);
return !handler.cancel;
- }
+ }
- public JLoginUI(JFrame instance, LoginUIHandler handler) {
+ public JLoginUI(JFrame instance, LoginUIHandler handler) {
super(instance);
this.handler = handler;
this.handler.setUi(this);
@@ -22,23 +22,23 @@
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
JRootPane rootPane = getRootPane();
rootPane.setDefaultButton(ok);
- }
+ }
- protected void doConnect() {
+ protected void doConnect() {
handler.doConnect();
if (handler.isCancel()) {
- doCancel();
+ doCancel();
}
- }
+ }
- protected void doCancel() {
+ protected void doCancel() {
handler.doCancel();
dispose();
- }
+ }
- protected void check() {
+ protected void check() {
ok.setEnabled(login.getText().trim().length()>0 && password.getPassword().length>0);
- }
+ }
</script>
Modified: trunk/commandline/commandline-ui/src/site/site_fr.xml
===================================================================
--- trunk/commandline/commandline-ui/src/site/site_fr.xml 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/src/site/site_fr.xml 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,45 +1,47 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="LutinCommndline">
- <skin>
- <groupId>lutinlib</groupId>
- <artifactId>lutin-site-skin</artifactId>
- <version>0.1</version>
- </skin>
-
- <bannerLeft>
- <name>Lutin CommandLine</name>
- </bannerLeft>
-
- <bannerRight>
- <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
- <href>http://www.codelutin.com</href>
- </bannerRight>
+ <skin>
+ <groupId>lutinlib</groupId>
+ <artifactId>lutin-site-skin</artifactId>
+ <version>0.1</version>
+ </skin>
+ <bannerLeft>
+ <name>Lutin CommandLine</name>
+ </bannerLeft>
+
+ <bannerRight>
+ <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
+ <href>http://www.codelutin.com</href>
+ </bannerRight>
+
<poweredBy>
- <logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/>
- <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="images/jrst-logo.png"/>
- <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="images/restructuredtext-logo.png"/>
- </poweredBy>
+ <logo href="http://maven.apache.org" name="Maven" img="images/logos/maven-feather.png"/>
+ <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="images/jrst-logo.png"/>
+ <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText"
+ img="images/restructuredtext-logo.png"/>
+ </poweredBy>
- <body>
- <links>
- <item name="Labs" href="http://labs.libre-entreprise.org/"/>
- <item name="Code Lutin" href="http://www.codelutin.com/"/>
- </links>
+ <body>
+ <links>
+ <item name="Labs" href="http://labs.libre-entreprise.org/"/>
+ <item name="Code Lutin" href="http://www.codelutin.com/"/>
+ </links>
- <menu name="Utilisateur">
- <item name="Accueil" href="index.html"/>
- <item name="R�aliser sa premi�re application" href="firstusage.html"/>
- <item href="http://lutinbuilder.labs.libre-entreprise.org/maven2/lutinlib/lutincommandl…" name="T�l�chargement"/>
- </menu>
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ <item name="R�aliser sa premi�re application" href="firstusage.html"/>
+ <item href="http://lutinbuilder.labs.libre-entreprise.org/maven2/lutinlib/lutincommandl…"
+ name="T�l�chargement"/>
+ </menu>
- <menu name="D�veloppeur">
- <item name="Implantation" href="devel/implementation.html"/>
- <item name="A faire" href="Todo.html"/>
- </menu>
+ <menu name="D�veloppeur">
+ <item name="Implantation" href="devel/implementation.html"/>
+ <item name="A faire" href="Todo.html"/>
+ </menu>
- ${reports}
+ ${reports}
- </body>
+ </body>
</project>
Modified: trunk/commandline/commandline-ui/src/test/java/org/codelutin/option/ui/UITest.java
===================================================================
--- trunk/commandline/commandline-ui/src/test/java/org/codelutin/option/ui/UITest.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/commandline-ui/src/test/java/org/codelutin/option/ui/UITest.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -21,16 +21,15 @@
import org.codelutin.i18n.LanguageEnum;
import org.codelutin.option.Config;
import org.codelutin.option.ConfigPropertyKey;
+import static org.codelutin.option.ConfigPropertyKey.newConfigPropertyKey;
import org.codelutin.option.OptionKey;
-import static org.codelutin.option.ConfigPropertyKey.newConfigPropertyKey;
import static org.codelutin.option.def.ConfigPropertyModifier.MANDATORY;
+import org.codelutin.util.SimplePaginationEnum;
import java.io.File;
import java.net.URL;
import java.util.Locale;
-import org.codelutin.util.SimplePaginationEnum;
-
/**
* TODO javadoc
*
@@ -63,6 +62,7 @@
super("main", "main description");
init();
}
+
protected void init() throws Exception {
loadFromDefaultValue();
clearModified();
@@ -94,6 +94,7 @@
super("local", "local description");
init();
}
+
protected void init() throws Exception {
loadFromDefaultValue();
clearModified();
@@ -124,6 +125,7 @@
super("remote", "remote description");
init();
}
+
protected void init() throws Exception {
loadFromDefaultValue();
clearModified();
Modified: trunk/commandline/maven-plugin/pom.xml
===================================================================
--- trunk/commandline/maven-plugin/pom.xml 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/pom.xml 2008-07-27 10:36:26 UTC (rev 930)
@@ -24,7 +24,7 @@
<artifactId>commandline-core</artifactId>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
@@ -37,7 +37,7 @@
<artifactId>maven-plugin-api</artifactId>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
@@ -53,9 +53,9 @@
<version>0.7-SNAPSHOT</version>
<description>
- Plugin maven 2 pour la generation du parser d'options, des
- configurations et du context d'application en se basant sur
- la librairie commandline.
+ Plugin maven 2 pour la generation du parser d'options, des
+ configurations et du context d'application en se basant sur
+ la librairie commandline.
</description>
<inceptionYear>2008</inceptionYear>
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/AbsractDefinitionContext.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/AbsractDefinitionContext.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/AbsractDefinitionContext.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -17,7 +17,7 @@
import org.codelutin.option.ParserUtil;
/**
- * Classe abstraite d�finissant un context de parser de d�finitions.
+ * Classe abstraite d�finissant un context de parser de d�finitions.
*
* @author tony
*/
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefaultOptionAction.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefaultOptionAction.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefaultOptionAction.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -35,11 +35,11 @@
changeConfig("--config * <key:String> <value:String> [@categories@] "),
help("--help|-h"),
-
+
helpConfig("--help-config * <all|@categories@>"),
resetConfig("--reset-config"),
-
+
ui("--ui <flag:Boolean>");
private final String def;
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefinitionParserContexts.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefinitionParserContexts.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefinitionParserContexts.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -578,7 +578,7 @@
public static class ConfigsContext extends AbsractDefinitionContext<ParserContext, ConfigContext> {
protected final List<ConfigLoaderEntry> source;
-
+
protected List<String> safeCategories;
public ConfigsContext(ParserContext parent, List<ConfigLoaderEntry> configs) {
@@ -674,9 +674,9 @@
String value = sourceP.getModifiers().trim();
String[] mods = value.split(",");
- if (value.length()==0 || mods.length == 0) {
+ if (value.length() == 0 || mods.length == 0) {
_mods.put(key, 0);
- mods =new String[0];
+ mods = new String[0];
}
List<Integer> modifiers = new ArrayList<Integer>();
for (String mod : mods) {
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefinitionParserUtil.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefinitionParserUtil.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/DefinitionParserUtil.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -44,7 +44,7 @@
final static String ODEFINITION_KEY_SUFFIX = ".option.definition";
final static String CDEFINITION_KEY_FACTOR = ".config.definition.";
final static String CMODIFIERS_KEY_FACTOR = ".config.modifiers.";
-
+
static class ConfigDefEntry extends AbstractMap.SimpleEntry<String, String> {
private static final long serialVersionUID = -5430904379928407190L;
String def;
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigLoader.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigLoader.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigLoader.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -39,7 +39,7 @@
public ConfigLoader(Map<String, String> injects) {
super(CONFIG_DEFINITION_PATTERN, ConfigLoaderEntry.class);
- this.injects=injects;
+ this.injects = injects;
this.defaultProperties = MandatoryConfigProperty.getConfigPropertyKeys();
}
@@ -55,7 +55,7 @@
configs.add(detectMainConfig);
}
- if (detectMainConfig!=null) {
+ if (detectMainConfig != null) {
for (MandatoryConfigProperty configProperty : MandatoryConfigProperty.values()) {
ConfigPropertyLoaderEntry loaderEntry = new ConfigPropertyLoaderEntry(configProperty.getEntryKey(), configProperty.name());
loaderEntry.setModifiers(configProperty.getModifiers());
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigPropertyLoader.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigPropertyLoader.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigPropertyLoader.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -37,7 +37,7 @@
log.warn("detected generic config property key " + key + ", will use the generic one...");
// clean source
source.remove(key);
- source.remove("main.config.modifiers."+value);
+ source.remove("main.config.modifiers." + value);
return false;
}
return true;
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigPropertyLoaderEntry.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigPropertyLoaderEntry.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/ConfigPropertyLoaderEntry.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -32,7 +32,7 @@
}
public void load(Properties source, List<ConfigPropertyLoaderEntry> result) {
- definition = source.get(getFullKey())+"";
+ definition = source.get(getFullKey()) + "";
source.remove(getFullKey());
String modifiersKey = getModifierFullKey();
Object cv = source.get(modifiersKey);
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/Loader.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/Loader.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/Loader.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -58,7 +58,7 @@
for (Map.Entry<String, String> entry : keys.entrySet()) {
String key = entry.getKey();
- if (needLoad(key, entry.getValue(), result,source)) {
+ if (needLoad(key, entry.getValue(), result, source)) {
// found a entry to treate
E e = eConstructor.newInstance(key, entry.getValue());
e.load(source, result);
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/OptionLoader.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/OptionLoader.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/OptionLoader.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -30,9 +30,9 @@
public OptionLoader() {
super(OPTION_PATTERN, OptionLoaderEntry.class);
- this.defaultOptions = DefaultOptionAction.getConfigKeys();
+ this.defaultOptions = DefaultOptionAction.getConfigKeys();
}
-
+
public OptionLoader(String categoriesStr) {
super(OPTION_PATTERN, OptionLoaderEntry.class);
this.defaultOptions = DefaultOptionAction.getConfigKeys();
@@ -72,7 +72,7 @@
boolean need = true;
if (defaultOptions.contains(key)) {
// do not add this, this is a generated option
- log.warn("generic option detected '" + value+ "', will use generic version instead...");
+ log.warn("generic option detected '" + value + "', will use generic version instead...");
need = false;
source.remove(key);
}
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/OptionLoaderEntry.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/OptionLoaderEntry.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/def/loader/OptionLoaderEntry.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -27,7 +27,7 @@
}
public void load(Properties source, List<OptionLoaderEntry> result) {
- this.definition = source.get(getFullKey())+"";
+ this.definition = source.get(getFullKey()) + "";
source.remove(getFullKey());
}
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorGoal.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorGoal.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorGoal.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -66,7 +66,7 @@
* @parameter expression="${jaxx.copyToCP}" default-value="true"
*/
protected boolean copyToCP;
-
+
/**
* @description Chemin du fichier de propriétés contenant les définitions d'options à utiliser pour générer la factory de définitions d'options.
* @parameter expression="${commandline.source}"
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/java/AbstractJavaGenerator.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/java/AbstractJavaGenerator.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/java/AbstractJavaGenerator.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -21,9 +21,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.option.generate.JavaGeneratorContext;
import org.codelutin.util.FileUtil;
import org.codelutin.util.StringUtil;
-import org.codelutin.option.generate.JavaGeneratorContext;
import java.io.File;
import java.io.IOException;
@@ -137,20 +137,20 @@
this.userName = System.getProperty("user.name", getClass().getSimpleName());
}
- protected AbstractJavaGenerator(JavaGeneratorContext context,int modifiers, String pack, String simpleName, String superClass, String... interfaceClass) {
+ protected AbstractJavaGenerator(JavaGeneratorContext context, int modifiers, String pack, String simpleName, String superClass, String... interfaceClass) {
this.context = context;
this.out = context.getOut();
- this.timestamp = context.getTimestamp();
- this.i18nPrefix = context.getI18nPrefix();
- this.pack = pack;
- this.simpleName = simpleName;
- this.simpleNameWithNoType = getNameWithNoType(simpleName);
- this.superClass = superClass;
- this.superClassWithNoType = getNameWithNoType(superClass);
- this.interfaceClass = interfaceClass;
- this.modifiers = modifiers;
- this.userName = System.getProperty("user.name", getClass().getSimpleName());
- }
+ this.timestamp = context.getTimestamp();
+ this.i18nPrefix = context.getI18nPrefix();
+ this.pack = pack;
+ this.simpleName = simpleName;
+ this.simpleNameWithNoType = getNameWithNoType(simpleName);
+ this.superClass = superClass;
+ this.superClassWithNoType = getNameWithNoType(superClass);
+ this.interfaceClass = interfaceClass;
+ this.modifiers = modifiers;
+ this.userName = System.getProperty("user.name", getClass().getSimpleName());
+ }
protected String getNameWithNoType(String simpleName) {
int pos = simpleName.indexOf('<');
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/java/DefaultOptionActionJavaGenerator.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/java/DefaultOptionActionJavaGenerator.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/java/DefaultOptionActionJavaGenerator.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,9 +1,9 @@
package org.codelutin.option.generate.java;
+import org.apache.commons.lang.StringUtils;
import org.codelutin.option.def.DefaultOptionAction;
import org.codelutin.option.def.DefinitionParserContexts.OptionContext;
import org.codelutin.option.generate.JavaGeneratorContext;
-import org.apache.commons.lang.StringUtils;
import java.lang.reflect.Modifier;
@@ -20,7 +20,7 @@
String runnable;
if (option == null) {
runnable = getFQN();
- } else {
+ } else {
runnable = "org.codelutin.option.actions.OptionAction" + StringUtils.capitalize(context.getKey());
}
addConstructor(null, Modifier.PUBLIC, "super(\"" + runnable + "Runnable\");", new String[]{Exception.class.getSimpleName()});
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/util/AbstractGeneratorGoal.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/util/AbstractGeneratorGoal.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/util/AbstractGeneratorGoal.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -22,8 +22,8 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
+import org.codelutin.i18n.I18n;
import org.codelutin.util.StringUtil;
-import org.codelutin.i18n.I18n;
import java.io.File;
@@ -110,7 +110,7 @@
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
} finally {
- getLog().info(getClass().getSimpleName()+" - total time " + StringUtil.convertTime(timestamp,System.nanoTime()));
+ getLog().info(getClass().getSimpleName() + " - total time " + StringUtil.convertTime(timestamp, System.nanoTime()));
}
}
@@ -175,6 +175,7 @@
/**
* permet d'ajout le r�pertoire de g�n�ration des fichiers java dans les r�pertoires
* de compilation du projet Maven.
+ *
* @param dirGen le repertoire de generation des fichiers java
*/
public void fixCompileSourceRoots(File dirGen) {
Modified: trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyParser.java
===================================================================
--- trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyParser.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyParser.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,11 +1,9 @@
package org.codelutin.option;
-import org.codelutin.option.def.ParserTest.AbstractHelpAction;
-import org.codelutin.option.def.ParserTest.OptionHelp;
import org.codelutin.option.def.OptionDefinition;
import org.codelutin.option.def.OptionDefinitionBuilder;
-import org.codelutin.option.OptionParser;
-import org.codelutin.option.OptionKey;
+import org.codelutin.option.def.ParserTest.AbstractHelpAction;
+import org.codelutin.option.def.ParserTest.OptionHelp;
/** @author chemit */
public class MyParser extends OptionParser {
Modified: trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyParser1.java
===================================================================
--- trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyParser1.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyParser1.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,17 +1,14 @@
package org.codelutin.option;
+import org.codelutin.option.def.ArgumentType;
+import org.codelutin.option.def.OptionDefinition;
+import org.codelutin.option.def.OptionDefinitionBuilder;
import org.codelutin.option.def.ParserTest.AbstractHelp1Action;
import org.codelutin.option.def.ParserTest.AbstractMandatory1Action;
import org.codelutin.option.def.ParserTest.AbstractMandatory2Action;
import org.codelutin.option.def.ParserTest.AbstractOptional1Action;
import org.codelutin.option.def.ParserTest.AbstractOptional2Action;
import org.codelutin.option.def.ParserTest.OptionHelp1;
-import org.codelutin.option.def.OptionDefinition;
-import org.codelutin.option.def.OptionDefinitionBuilder;
-import org.codelutin.option.def.ArgumentType;
-import org.codelutin.option.OptionParser;
-import org.codelutin.option.OptionKey;
-import org.codelutin.option.Option;
/** @author chemit */
public class MyParser1 extends OptionParser {
Modified: trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/ParserTest.java
===================================================================
--- trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/ParserTest.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/ParserTest.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -1,21 +1,20 @@
package org.codelutin.option.def;
import junit.framework.TestCase;
-
-import java.io.IOException;
-import java.util.Arrays;
-
import org.codelutin.i18n.I18n;
import org.codelutin.log.LutinLogFactory;
-import org.codelutin.option.Option;
import org.codelutin.option.Argument;
-import org.codelutin.option.OptionAction;
-import org.codelutin.option.OptionParser;
import org.codelutin.option.MyContext;
import org.codelutin.option.MyContext1;
import org.codelutin.option.MyParser;
import org.codelutin.option.MyParser1;
+import org.codelutin.option.Option;
+import org.codelutin.option.OptionAction;
+import org.codelutin.option.OptionParser;
+import java.io.IOException;
+import java.util.Arrays;
+
/**
* OptionParser Tester.
*
@@ -26,14 +25,14 @@
public class ParserTest extends TestCase {
static boolean first;
-
+
static {
if (!first) {
I18n.init();
System.setProperty("org.apache.commons.logging.LogFactory", LutinLogFactory.class.getName());
first = true;
- }
+ }
}
static int counter = 0;
Modified: trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/ParserUtilForTest.java
===================================================================
--- trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/ParserUtilForTest.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/ParserUtilForTest.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -15,7 +15,6 @@
import junit.framework.Assert;
import org.codelutin.i18n.I18n;
import org.codelutin.log.LutinLogFactory;
-import org.codelutin.option.def.DefinitionParser;
import org.codelutin.option.OptionParser;
import org.codelutin.option.OptionParserResult;
import org.codelutin.option.ParserFailedException;
@@ -76,7 +75,7 @@
assertEquals(nbOptions, result.size());
assertEquals(nbErrors, e == null ? 0 : e.getNbErrors());
- assertEquals(nbUnused, result.getNbUnsued());
+ assertEquals(nbUnused, result.getNbUnsued());
}
Modified: trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/PropertiesLoaderTest.java
===================================================================
--- trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/PropertiesLoaderTest.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/def/PropertiesLoaderTest.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -25,10 +25,10 @@
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
-import java.util.Map;
-import java.util.HashMap;
/** @author chemit */
public class PropertiesLoaderTest extends TestCase {
@@ -48,10 +48,10 @@
}
public void testConfigCategory() throws Exception {
- Map<String, String> injects =new HashMap<String, String>();
+ Map<String, String> injects = new HashMap<String, String>();
- injects.put(MandatoryConfigProperty.encoding.name(),"UTF-8");
-
+ injects.put(MandatoryConfigProperty.encoding.name(), "UTF-8");
+
ConfigLoader configLoader = new ConfigLoader(injects);
File f;
@@ -84,9 +84,9 @@
currentSize = currentSize - result2.size() * 2;
}
// we have 2 mandatories value,
- int nbMandatories = MandatoryConfigProperty.values().length-2;
- currentSize+= nbMandatories*2;
-
+ int nbMandatories = MandatoryConfigProperty.values().length - 2;
+ currentSize += nbMandatories * 2;
+
assertEquals(currentSize, p.size());
OptionLoader optionLoader = new OptionLoader(configLoader.getCategoriesStr());
Modified: trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/generate/GenerateJavaTest.java
===================================================================
--- trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/generate/GenerateJavaTest.java 2008-07-27 10:35:17 UTC (rev 929)
+++ trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/generate/GenerateJavaTest.java 2008-07-27 10:36:26 UTC (rev 930)
@@ -18,6 +18,8 @@
package org.codelutin.option.generate;
import junit.framework.TestCase;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.codelutin.i18n.I18n;
import org.codelutin.option.Config;
import org.codelutin.option.Option;
@@ -25,8 +27,6 @@
import org.codelutin.option.OptionParser;
import org.codelutin.option.def.DefaultOptionAction;
import org.codelutin.option.def.DefinitionParserFromProperties;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import java.io.File;
@@ -57,7 +57,7 @@
goal.setPrefix("Test");
goal.setVerbose(false);
goal.setSource(new File(HERE + "/src/test/testOptions.properties"));
-
+
goal.setPackageName("org.codelutin.option.test1");
goal._version = "0.0.1";
goal.setParserSuperClass(OptionParser.class.getName());
1
0
[Lutinutil-commits] r929 - in trunk/commandline/commandline-ui-action: . src/main/java/org/codelutin/option/ui/actions
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
27 Jul '08
Author: tchemit
Date: 2008-07-27 10:35:17 +0000 (Sun, 27 Jul 2008)
New Revision: 929
Modified:
trunk/commandline/commandline-ui-action/pom.xml
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ChangeLocaleAction.java
Log:
reformat
Modified: trunk/commandline/commandline-ui-action/pom.xml
===================================================================
--- trunk/commandline/commandline-ui-action/pom.xml 2008-07-27 10:03:21 UTC (rev 928)
+++ trunk/commandline/commandline-ui-action/pom.xml 2008-07-27 10:35:17 UTC (rev 929)
@@ -45,7 +45,7 @@
<packaging>jar</packaging>
<build>
-
+
<resources>
<resource>
<directory>src/main/resources</directory>
@@ -56,7 +56,7 @@
</resources>
<plugins>
-
+
<!-- Compile phase -->
<plugin>
<groupId>lutinplugin</groupId>
Modified: trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ChangeLocaleAction.java
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ChangeLocaleAction.java 2008-07-27 10:03:21 UTC (rev 928)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ChangeLocaleAction.java 2008-07-27 10:35:17 UTC (rev 929)
@@ -92,7 +92,7 @@
// save config
getContext().saveSafely();
// dispose then reload application
- getContext().dispose(true);
+ getContext().dispose(true);
}
@Override
1
0
[Lutinutil-commits] r928 - in trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo: . ui
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
27 Jul '08
Author: tchemit
Date: 2008-07-27 10:03:21 +0000 (Sun, 27 Jul 2008)
New Revision: 928
Modified:
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/DemoMain.java
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/DemoMainUI.java
Log:
use ContextProvider + ActionHelper
Modified: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/DemoMain.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/DemoMain.java 2008-07-27 10:02:45 UTC (rev 927)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/DemoMain.java 2008-07-27 10:03:21 UTC (rev 928)
@@ -16,9 +16,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.option.ContextProvider;
import org.codelutin.option.OptionParserResult;
import org.codelutin.option.ParserFailedException;
-import org.codelutin.option.ContextProvider;
import java.io.IOException;
@@ -27,18 +27,15 @@
private static final Log log = LogFactory.getLog(DemoMain.class);
- /** le context principal de l'application */
- protected static DemoContext context;
-
+ /** @return le context applicatif. */
public static DemoContext getContext() {
- checkInitContext();
- return context;
+ return (DemoContext) ContextProvider.get();
}
/**
* initialisation de l'application :
* <p/>
- * chargement du context
+ * chargement du context applicatif
*
* @param args les arguments pass�s � l'application
*/
@@ -46,7 +43,7 @@
try {
// instanciate context, parser and configs
- context = (DemoContext) ContextProvider.getContext();
+ DemoContext context = (DemoContext) ContextProvider.init();
// init context
context.init(args);
@@ -100,10 +97,4 @@
}
- public static void checkInitContext() {
- if (context == null) {
- throw new RuntimeException("context is null, you must init first the " + DemoContext.class.getName() + " class via init method");
- }
- }
-
}
Modified: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/DemoMainUI.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/DemoMainUI.java 2008-07-27 10:02:45 UTC (rev 927)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/DemoMainUI.java 2008-07-27 10:03:21 UTC (rev 928)
@@ -14,32 +14,22 @@
*/
package org.codelutin.commandline.demo.ui;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.codelutin.commandline.demo.DemoContext;
import org.codelutin.commandline.demo.DemoMain;
-import org.codelutin.commandline.demo.ui.actions.CommandLineDemoBaseAction;
-import static org.codelutin.i18n.I18n._;
+import org.codelutin.option.ui.actions.ActionHelper;
-import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
-import java.util.Locale;
-import java.util.regex.Matcher;
/** @author chemit */
public class DemoMainUI extends JDemoMainUI {
- /** log */
- private static final Log log = LogFactory.getLog(DemoMainUI.class);
-
public DemoMainUI() {
+
super();
- DemoMain.checkInitContext();
-
finalizeInit(DemoMain.getContext());
}
@@ -53,55 +43,7 @@
getRootPane().getActionMap().put("quit", context.getActionFactory().newAction("quit", null));
// repaint i18n actions
- refreshI18nActions(context);
-
+ ActionHelper.refreshI18nActions(context, context.getActionFactory(), this);
}
- /**
- * Rafraichit les actions i18n dans le menu en fonction de la locale
- * actuellement utilis�e.
- *
- * @param context application context
- */
- public void refreshI18nActions(DemoContext context) {
-
- Locale locale = context.getMainConfig().getLocale();
- //CountryEnum country = context.getConfig().getUserCountry();
- String[] actions = context.getActionFactory().getActionNames();
- for (String actionName : actions) {
- Matcher matcher = org.codelutin.option.ui.actions.ChangeLocaleAction.PATTERN_NAME.matcher(actionName);
- if (!matcher.matches()) {
- continue;
- }
- AbstractButton button = (AbstractButton) getObjectById(actionName);
- CommandLineDemoBaseAction action1 = (CommandLineDemoBaseAction) button.getAction();
- org.codelutin.option.ui.actions.ChangeLocaleAction action = (org.codelutin.option.ui.actions.ChangeLocaleAction) action1.getDelegate();
- boolean enable = !action.equalsLocale(locale);
- log.debug("incoming locale : " + locale);
- log.debug("load i18n action " + action + " is enable ? " + enable);
- UpdateButton(button, enable, enable ? action.getLocale() : null);
- button.setEnabled(enable);
- }
- }
-
- public static void DisableButton(AbstractButton... buttons) {
- for (AbstractButton button : buttons) {
- UpdateButton(button, false);
- }
- }
-
- public static void EnableButton(AbstractButton button, Object... params) {
- UpdateButton(button, true, params);
- }
-
- public static void UpdateButton(AbstractButton button, boolean enabled, Object... params) {
- button.setEnabled(enabled);
- if (!enabled) {
- button.setToolTipText(null);
- } else {
- CommandLineDemoBaseAction action = (CommandLineDemoBaseAction) button.getAction();
- String t = _(action.getI18nToolTipText(), params);
- button.setToolTipText(t);
- }
- }
}
1
0
[Lutinutil-commits] r927 - trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
27 Jul '08
Author: tchemit
Date: 2008-07-27 10:02:45 +0000 (Sun, 27 Jul 2008)
New Revision: 927
Modified:
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/CommandLineBaseAction.java
Log:
use ContextProvider
Modified: trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/CommandLineBaseAction.java
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/CommandLineBaseAction.java 2008-07-27 10:02:12 UTC (rev 926)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/CommandLineBaseAction.java 2008-07-27 10:02:45 UTC (rev 927)
@@ -38,11 +38,11 @@
}
protected String getPrefix() {
- return "jaxx";
+ return "commandline";
}
- protected Context getContext() {
- return ContextProvider.getContext();
+ protected Context getContext() throws IllegalStateException {
+ return ContextProvider.get();
}
}
1
0
[Lutinutil-commits] r926 - trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
27 Jul '08
Author: tchemit
Date: 2008-07-27 10:02:12 +0000 (Sun, 27 Jul 2008)
New Revision: 926
Added:
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ActionHelper.java
Log:
introduce ActionHelper class to manage action enable state + logic of refreshing i18n actions from an ui
Added: trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ActionHelper.java
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ActionHelper.java (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ActionHelper.java 2008-07-27 10:02:12 UTC (rev 926)
@@ -0,0 +1,132 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.option.ui.actions;
+
+import jaxx.runtime.JAXXObject;
+import static org.codelutin.i18n.I18n._;
+import org.codelutin.jaxx.action.MyAbstractAction;
+import org.codelutin.jaxx.action.factory.ActionFactory;
+import org.codelutin.option.Context;
+
+import javax.swing.AbstractButton;
+import javax.swing.JComboBox;
+import java.util.Locale;
+import java.util.regex.Matcher;
+
+/**
+ * Usefull methods for action on ui
+ *
+ * @author chemit
+ */
+public class ActionHelper {
+
+ /**
+ * Disable the given buttons
+ *
+ * @param buttons the buttons to disable
+ */
+ public static void DisableButton(AbstractButton... buttons) {
+ for (AbstractButton button : buttons) {
+ UpdateButton(button, false);
+ }
+ }
+
+ /**
+ * Enable an action and add to it a libelle
+ *
+ * @param button the button to enable
+ * @param params extra params to compute action libelle
+ */
+ public static void EnableButton(AbstractButton button, Object... params) {
+ UpdateButton(button, true, params);
+ }
+
+ /**
+ * Update the enabled state of a button action.
+ * <p/>
+ * If action is to be enabled, compute also a libelle on it, otherwise remove libelle.
+ *
+ * @param button the button to treate
+ * @param enabled <code>true</code> if to enable, <code>false</code> otherwise
+ * @param params extra params to compute action libelle (only use when action is to be enabled)
+ */
+ public static void UpdateButton(AbstractButton button, boolean enabled, Object... params) {
+ button.setEnabled(enabled);
+ if (!enabled) {
+ button.setToolTipText(null);
+ } else {
+ MyAbstractAction action = (MyAbstractAction) button.getAction();
+ String t = org.codelutin.i18n.I18n._(action.getI18nToolTipText(), params);
+ button.setToolTipText(t);
+ }
+ }
+
+ /**
+ * Update the enabled state of a combo box action.
+ * <p/>
+ * If action is to be enabled, compute also a libelle on it, otherwise remove libelle.
+ *
+ * @param comboBox the button to treate
+ * @param enabled <code>true</code> if to enable, <code>false</code> otherwise
+ * @param params extra params to compute action libelle (only use when action is to be enabled)
+ */
+ public static void UpdateCombo(JComboBox comboBox, boolean enabled, Object... params) {
+ comboBox.setEnabled(enabled);
+ if (!enabled) {
+ comboBox.setToolTipText(null);
+ } else {
+ MyAbstractAction action = (MyAbstractAction) comboBox.getAction();
+ if (action != null) {
+ String t = _(action.getI18nToolTipText(), params);
+ comboBox.setToolTipText(t);
+ }
+ }
+ }
+
+ /**
+ * Update the i18n actions found in <code>factory</code> (diable the i18n action of the current locale found in
+ * context, and enabled all the others).
+ *
+ * @param context application context
+ * @param actionFactory factory of actions
+ * @param mainUI main ui
+ */
+ public static void refreshI18nActions(Context context, ActionFactory actionFactory, JAXXObject mainUI) {
+
+ Locale locale = (Locale) context.getMainConfig().getProperty("locale");
+ String[] actions = actionFactory.getActionNames();
+ for (String actionName : actions) {
+ Matcher matcher = ChangeLocaleAction.PATTERN_NAME.matcher(actionName);
+ if (!matcher.matches()) {
+ continue;
+ }
+ AbstractButton button = (AbstractButton) mainUI.getObjectById(actionName);
+ MyAbstractAction myAbstractAction = (MyAbstractAction) button.getAction();
+ ChangeLocaleAction action;
+ if (myAbstractAction.hasDelegate()) {
+ action = (ChangeLocaleAction) myAbstractAction.getDelegate();
+ } else {
+ action = (ChangeLocaleAction) myAbstractAction;
+ }
+ boolean enable = !action.equalsLocale(locale);
+ UpdateButton(button, enable, enable ? action.getLocale() : null);
+ button.setEnabled(enable);
+ }
+ }
+
+ protected ActionHelper() {
+ // no instance
+ }
+}
1
0
[Lutinutil-commits] r925 - in trunk/commandline/commandline-core/src/main: java/org/codelutin/option resources/i18n
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
by tchemit@users.labs.libre-entreprise.org 27 Jul '08
27 Jul '08
Author: tchemit
Date: 2008-07-27 09:05:50 +0000 (Sun, 27 Jul 2008)
New Revision: 925
Modified:
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextProvider.java
trunk/commandline/commandline-core/src/main/resources/i18n/commandline-core-en_GB.properties
trunk/commandline/commandline-core/src/main/resources/i18n/commandline-core-fr_FR.properties
Log:
improve context loading
add javadoc
i18n
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextProvider.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextProvider.java 2008-07-25 23:20:28 UTC (rev 924)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextProvider.java 2008-07-27 09:05:50 UTC (rev 925)
@@ -14,15 +14,20 @@
*/
package org.codelutin.option;
+import static org.codelutin.i18n.I18n._;
+
import java.util.Iterator;
import java.util.ServiceLoader;
/**
* Cette classe permet de trouver dynamiquement le contexte Commandline en utilisant le
- * m�canisme java de {@link java.util.ServiceLoader}.
+ * m�canisme java de {@link ServiceLoader}.
* <p/>
- * Le contexte trouv� lors du premier appel � la m�thode {@link #getContext()} est cach�� dans le champ {@link #context}.
+ * Avant tout utilisation du context, il faut lancer la m�thode {@link #init()} qui charge le context dans la
+ * variable statique {@link #context}.
* <p/>
+ * Ensuite on peut r�cupere le context, via l'accesseur {@link #get()}.
+ * <p/>
* Il est possible de supprimer un context charg� via la m�thode {@link #reset()}.
* <p/>
* <b>Note : Attention, un seul contexte commandline peut �tre d�fini.</b>
@@ -30,29 +35,76 @@
* @author chemit
*/
public class ContextProvider {
+
+ /** share instance of the context */
+ protected static Context context;
+
/**
- * share instance of the context
+ * Init the shared instance of the context.
+ * <p/>
+ * An {@link IllegalStateException} will be be thrown in theses cases :
+ * <ul>
+ * <li>context was previously init (says the shared instance is not null)</li>
+ * <li>no context was found by the {@link ServiceLoader}</li>
+ * <li>more than one context was found by the {@link ServiceLoader}</li>
+ * </ul>
+ *
+ * @return the shared instanciated context
+ * @throws IllegalStateException if the context waspreviously init, or not found or if more than one context was found.
*/
- private static Context context;
+ public static synchronized Context init() throws IllegalStateException {
+ if (context != null) {
+ throw new IllegalStateException(_("commandline.context.error.alredyinit"));
+ }
+ ServiceLoader<Context> loader = ServiceLoader.load(Context.class);
+ Iterator<Context> iterator = loader.iterator();
+ if (!iterator.hasNext()) {
+ throw new IllegalStateException(_("commandline.context.error.unfound"));
+ }
+ context = iterator.next();
+ if (iterator.hasNext()) {
+ // not authorized!
+ reset();
+ throw new IllegalStateException(_("commandline.context.error.multicontextfound"));
+ }
- public static synchronized Context getContext() {
+ return context;
+ }
+
+ /**
+ * Obtain the shared instance of the context.
+ * <p/>
+ * An {@link IllegalStateException} will be thrown if the shared instances was not previously init via method {@link #init()}
+ *
+ * @return the shared instance of the context
+ * @throws IllegalStateException if shared instance was not init
+ */
+ public static synchronized Context get() throws IllegalStateException {
+ checkContextInit();
+ return context;
+ }
+
+ /**
+ * Check if shared instance was previously init via method {@link #init()}
+ *
+ * @throws IllegalStateException if shared instance is null.
+ */
+ public static void checkContextInit() throws IllegalStateException {
if (context == null) {
- ServiceLoader<Context> loader = ServiceLoader.load(Context.class);
- Iterator<Context> iterator = loader.iterator();
- if (!iterator.hasNext()) {
- throw new IllegalStateException("could not find a " + Context.class + " service");
- }
- context = iterator.next();
- if (iterator.hasNext()) {
- // not authorized!
- reset();
- throw new IllegalStateException("only one " + Context.class + " service can be defined in classpath");
- }
+ throw new IllegalStateException(_("commandline.context.error.noinit"));
}
- return context;
}
+ /**
+ * Remove the reference of the shared instance of context.
+ * <p/>
+ * This method must be used before to be able to reload a context via method {@link #init()}
+ */
public static void reset() {
context = null;
}
+
+ protected ContextProvider() {
+ // no instance of this class
+ }
}
Modified: trunk/commandline/commandline-core/src/main/resources/i18n/commandline-core-en_GB.properties
===================================================================
--- trunk/commandline/commandline-core/src/main/resources/i18n/commandline-core-en_GB.properties 2008-07-25 23:20:28 UTC (rev 924)
+++ trunk/commandline/commandline-core/src/main/resources/i18n/commandline-core-en_GB.properties 2008-07-27 09:05:50 UTC (rev 925)
@@ -1,3 +1,7 @@
+commandline.context.error.alredyinit=Context was previously initialized, use the method ContextProvider\#reset() to delete it
+commandline.context.error.multicontextfound=More than one Context was found in classpath, this is forbidden
+commandline.context.error.noinit=The context was not init (use before all ContextProvider\#init() method
+commandline.context.error.unfound=Could not find a Context in the classpath
lutinutil.change.config.property=changed for configuration {0} property {1} <old\: {2}, new\: {3}>
lutinutil.error.config.unauthorized.key=The given key {0} is not autohrized, list of authorized keys {1}
lutinutil.error.final.property=In configuration [{0}], can not modify the final property {1}
Modified: trunk/commandline/commandline-core/src/main/resources/i18n/commandline-core-fr_FR.properties
===================================================================
--- trunk/commandline/commandline-core/src/main/resources/i18n/commandline-core-fr_FR.properties 2008-07-25 23:20:28 UTC (rev 924)
+++ trunk/commandline/commandline-core/src/main/resources/i18n/commandline-core-fr_FR.properties 2008-07-27 09:05:50 UTC (rev 925)
@@ -1,3 +1,7 @@
+commandline.context.error.alredyinit=Le context a d\u00E9j\u00E0 \u00E9t\u00E9 initialis\u00E9, utiliser la m\u00E9thode ContextProvider\#reset() pour le supprimer
+commandline.context.error.multicontextfound=Plusieurs context ont \u00E9t\u00E9 trouv\u00E9s dans le classpath, ce qui est interdit
+commandline.context.error.noinit=Le context n'a pas \u00E9t\u00E9 initialis\u00E9, il faut utiliser la m\u00E9thode ContextProvier\#init() avant
+commandline.context.error.unfound=Aucun Context n'a \u00E9t\u00E9 trouv\u00E9 dans le classpath
lutinutil.change.config.property=modification pour la configuration {0} propri\u00E9t\u00E9 {1} <old\: {2}, new\: {3}>
lutinutil.error.config.unauthorized.key=La clef {0} n''est pas autoris\u00E9, liste des clefs possibles {1}
lutinutil.error.final.property=Dans la configuration [{0}], impossible de modifier la propri\u00E9t\u00E9 finale {1}
1
0
[Lutinutil-commits] r924 - trunk/commandline/commandline-demo
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 23:20:28 +0000 (Fri, 25 Jul 2008)
New Revision: 924
Modified:
trunk/commandline/commandline-demo/pom.xml
Log:
use commons actions from commandline-ui-action
Modified: trunk/commandline/commandline-demo/pom.xml
===================================================================
--- trunk/commandline/commandline-demo/pom.xml 2008-07-25 23:07:27 UTC (rev 923)
+++ trunk/commandline/commandline-demo/pom.xml 2008-07-25 23:20:28 UTC (rev 924)
@@ -177,7 +177,7 @@
<goal>generate-actions-provider</goal>
</goals>
<configuration>
- <fqn>org.codelutin.commandline.demo.ui.MyActionProvider</fqn>
+ <fqn>org.codelutin.commandline.demo.ui.CommandLineDemoActionProvider</fqn>
<fqnAction>org.codelutin.commandline.demo.ui.actions.CommandLineDemoBaseAction</fqnAction>
<providerName>commandlinedemo</providerName>
</configuration>
1
0
[Lutinutil-commits] r923 - trunk/commandline/commandline-demo
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 23:07:27 +0000 (Fri, 25 Jul 2008)
New Revision: 923
Modified:
trunk/commandline/commandline-demo/pom.xml
Log:
use commons actions from commandline-ui-action
Modified: trunk/commandline/commandline-demo/pom.xml
===================================================================
--- trunk/commandline/commandline-demo/pom.xml 2008-07-25 23:07:10 UTC (rev 922)
+++ trunk/commandline/commandline-demo/pom.xml 2008-07-25 23:07:27 UTC (rev 923)
@@ -24,13 +24,20 @@
<groupId>org.codelutin.commandline</groupId>
<artifactId>commandline-core</artifactId>
</dependency>
+
<dependency>
<groupId>org.codelutin.commandline</groupId>
<artifactId>commandline-ui</artifactId>
</dependency>
+
<dependency>
+ <groupId>org.codelutin.commandline</groupId>
+ <artifactId>commandline-ui-action</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-swing-action</artifactId>
+ <artifactId>jaxx-swing-action</artifactId>
</dependency>
<dependency>
@@ -68,7 +75,7 @@
<groupId>lutinplugin</groupId>
<artifactId>maven-i18n-plugin</artifactId>
<executions>
- <execution>
+ <!--execution>
<id>javaActionConfig</id>
<phase>compile</phase>
<goals>
@@ -90,7 +97,7 @@
</entry>
</entries>
</configuration>
- </execution>
+ </execution-->
<execution>
<id>java</id>
<phase>compile</phase>
@@ -130,6 +137,7 @@
<source>${maven.src.dir}/main/resources/commandline.properties</source>
<out>${maven.gen.dir}/java</out>
<concreteConfig>true</concreteConfig>
+ <concreteContextFQN>org.codelutin.commandline.demo.DemoContext</concreteContextFQN>
<_projectName>CommandlineDemo</_projectName>
<_configFileName>.commandlineDemo-1</_configFileName>
<_version>${current.version}</_version>
1
0