Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
July 2008
- 3 participants
- 152 discussions
[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
[Lutinutil-commits] r922 - in trunk/commandline/commandline-demo/src/main: java/org/codelutin/commandline/demo java/org/codelutin/commandline/demo/ui resources/i18n
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:10 +0000 (Fri, 25 Jul 2008)
New Revision: 922
Modified:
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/DemoContext.java
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
trunk/commandline/commandline-demo/src/main/resources/i18n/commandline-demo-en_GB.properties
trunk/commandline/commandline-demo/src/main/resources/i18n/commandline-demo-fr_FR.properties
Log:
use commons actions from commandline-ui-action
Modified: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/DemoContext.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/DemoContext.java 2008-07-25 23:04:26 UTC (rev 921)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/DemoContext.java 2008-07-25 23:07:10 UTC (rev 922)
@@ -45,6 +45,20 @@
I18n.init(getMainConfig().getLocale(), getMainConfig().getEncoding());
}
+ public void dispose(boolean reload) {
+
+ getActionFactory().dispose();
+
+ disposeUI();
+
+ //ErrorDialog.disposeUI();
+
+ if (reload) {
+ DemoMain.launch();
+ }
+
+ }
+
public JDemoMainUI getMainUI() {
if (mainUI == null) {
mainUI = new DemoMainUI();
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-25 23:04:26 UTC (rev 921)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/DemoMain.java 2008-07-25 23:07:10 UTC (rev 922)
@@ -18,6 +18,7 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.option.OptionParserResult;
import org.codelutin.option.ParserFailedException;
+import org.codelutin.option.ContextProvider;
import java.io.IOException;
@@ -45,7 +46,7 @@
try {
// instanciate context, parser and configs
- context = new DemoContext();
+ context = (DemoContext) ContextProvider.getContext();
// init context
context.init(args);
@@ -105,17 +106,4 @@
}
}
- public static void dispose(boolean reload) {
-
- getContext().getActionFactory().dispose();
-
- getContext().disposeUI();
-
- //ErrorDialog.disposeUI();
-
- if (reload) {
- launch();
- }
- }
-
}
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-25 23:04:26 UTC (rev 921)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/DemoMainUI.java 2008-07-25 23:07:10 UTC (rev 922)
@@ -18,7 +18,6 @@
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.ChangeLocaleAction;
import org.codelutin.commandline.demo.ui.actions.CommandLineDemoBaseAction;
import static org.codelutin.i18n.I18n._;
@@ -70,12 +69,13 @@
//CountryEnum country = context.getConfig().getUserCountry();
String[] actions = context.getActionFactory().getActionNames();
for (String actionName : actions) {
- Matcher matcher = ChangeLocaleAction.PATTERN_NAME.matcher(actionName);
+ Matcher matcher = org.codelutin.option.ui.actions.ChangeLocaleAction.PATTERN_NAME.matcher(actionName);
if (!matcher.matches()) {
continue;
}
AbstractButton button = (AbstractButton) getObjectById(actionName);
- ChangeLocaleAction action = (ChangeLocaleAction) button.getAction();
+ 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);
Modified: trunk/commandline/commandline-demo/src/main/resources/i18n/commandline-demo-en_GB.properties
===================================================================
--- trunk/commandline/commandline-demo/src/main/resources/i18n/commandline-demo-en_GB.properties 2008-07-25 23:04:26 UTC (rev 921)
+++ trunk/commandline/commandline-demo/src/main/resources/i18n/commandline-demo-en_GB.properties 2008-07-25 23:07:10 UTC (rev 922)
@@ -1,21 +1,3 @@
-commandlinedemo.action.about=About
-commandlinedemo.action.about.help=
-commandlinedemo.action.about.tooltip=
-commandlinedemo.action.changeLocale.help=
-commandlinedemo.action.changeLocale.tooltip=
-commandlinedemo.action.config=Preferences
-commandlinedemo.action.config.help=
-commandlinedemo.action.config.tooltip=
-commandlinedemo.action.help=Help
-commandlinedemo.action.help.help=
-commandlinedemo.action.help.tooltip=
-commandlinedemo.action.quit=Quite
-commandlinedemo.action.quit.help=
-commandlinedemo.action.quit.tooltip=
-commandlinedemo.action.site=Site
-commandlinedemo.action.site.help=
-commandlinedemo.action.site.tooltip=
-commandlinedemo.close_question=Really quit ?
commandlinedemo.config.main.configFileName.description=
commandlinedemo.config.main.debugMode.description=
commandlinedemo.config.main.description=
@@ -34,8 +16,6 @@
commandlinedemo.config.remote.proxyLogin.description=
commandlinedemo.config.remote.proxyPassword.description=
commandlinedemo.config.remote.useProxy.description=
-commandlinedemo.confirm.changeLanguage=
-commandlinedemo.no=No
commandlinedemo.option.description.changeConfig=
commandlinedemo.option.description.changeFileConfig=
commandlinedemo.option.description.editConfig=
@@ -44,8 +24,6 @@
commandlinedemo.option.description.resetConfig=
commandlinedemo.option.description.showConfig=
commandlinedemo.option.description.ui=
-commandlinedemo.question=Quit
-commandlinedemo.yes=Yes
mainui.menu.edit=Edit
mainui.menu.file=File
mainui.menu.help=Help
Modified: trunk/commandline/commandline-demo/src/main/resources/i18n/commandline-demo-fr_FR.properties
===================================================================
--- trunk/commandline/commandline-demo/src/main/resources/i18n/commandline-demo-fr_FR.properties 2008-07-25 23:04:26 UTC (rev 921)
+++ trunk/commandline/commandline-demo/src/main/resources/i18n/commandline-demo-fr_FR.properties 2008-07-25 23:07:10 UTC (rev 922)
@@ -1,21 +1,3 @@
-commandlinedemo.action.about=A propos
-commandlinedemo.action.about.help=
-commandlinedemo.action.about.tooltip=
-commandlinedemo.action.changeLocale.help=
-commandlinedemo.action.changeLocale.tooltip=
-commandlinedemo.action.config=Pr\u00E9f\u00E9rences
-commandlinedemo.action.config.help=
-commandlinedemo.action.config.tooltip=
-commandlinedemo.action.help=Aide
-commandlinedemo.action.help.help=
-commandlinedemo.action.help.tooltip=
-commandlinedemo.action.quit=Quitter
-commandlinedemo.action.quit.help=
-commandlinedemo.action.quit.tooltip=
-commandlinedemo.action.site=Site
-commandlinedemo.action.site.help=
-commandlinedemo.action.site.tooltip=
-commandlinedemo.close_question=Voulez-vous quitter ?
commandlinedemo.config.main.configFileName.description=
commandlinedemo.config.main.debugMode.description=
commandlinedemo.config.main.description=
@@ -34,8 +16,6 @@
commandlinedemo.config.remote.proxyLogin.description=
commandlinedemo.config.remote.proxyPassword.description=
commandlinedemo.config.remote.useProxy.description=
-commandlinedemo.confirm.changeLanguage=
-commandlinedemo.no=Non
commandlinedemo.option.description.changeConfig=
commandlinedemo.option.description.changeFileConfig=
commandlinedemo.option.description.editConfig=
@@ -44,8 +24,6 @@
commandlinedemo.option.description.resetConfig=
commandlinedemo.option.description.showConfig=
commandlinedemo.option.description.ui=
-commandlinedemo.question=Quitter
-commandlinedemo.yes=Oui
mainui.menu.edit=Edit
mainui.menu.file=Fichier
mainui.menu.help=Aide
1
0
[Lutinutil-commits] r921 - trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions
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:04:26 +0000 (Fri, 25 Jul 2008)
New Revision: 921
Added:
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineDemoBaseAction.java
Log:
add commandline-ui-action module with default actions (no need anyl onger :))
let at least a BaseAction class since we need it for commons actions
Added: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineDemoBaseAction.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineDemoBaseAction.java (rev 0)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineDemoBaseAction.java 2008-07-25 23:04:26 UTC (rev 921)
@@ -0,0 +1,52 @@
+/**
+ * # #% 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.commandline.demo.ui.actions;
+
+import org.codelutin.commandline.demo.DemoContext;
+import org.codelutin.commandline.demo.DemoMain;
+import org.codelutin.jaxx.action.MyAbstractAction;
+
+import java.awt.event.ActionEvent;
+
+/** @author chemit */
+public class CommandLineDemoBaseAction extends MyAbstractAction {
+
+ private static final long serialVersionUID = -810023044364620841L;
+
+ protected ActionEvent e;
+
+ protected String getPrefix() {
+ return "commandlinedemo";
+ }
+
+ protected CommandLineDemoBaseAction(String name) {
+ super(name);
+ if (log.isTraceEnabled()) {
+ log.trace("> " + this);
+ }
+ }
+
+ public CommandLineDemoBaseAction(MyAbstractAction delegate) {
+ super(delegate);
+ if (log.isTraceEnabled()) {
+ log.trace("> " + this);
+ }
+ }
+
+ protected DemoContext getContext() {
+ return DemoMain.getContext();
+ }
+
+}
1
0
[Lutinutil-commits] r920 - trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions
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 22:34:41 +0000 (Fri, 25 Jul 2008)
New Revision: 920
Removed:
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/AboutAction.java
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/ChangeLocaleAction.java
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineDemoBaseAction.java
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/ConfigAction.java
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/HelpAction.java
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/QuitAction.java
trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/SiteAction.java
Log:
add commandline-ui-action module with default actions (no need anyl onger :))
Deleted: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/AboutAction.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/AboutAction.java 2008-07-25 22:32:24 UTC (rev 919)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/AboutAction.java 2008-07-25 22:34:41 UTC (rev 920)
@@ -1,49 +0,0 @@
-/**
- * # #% 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.commandline.demo.ui.actions;
-
-/**
- * Action pour afficher la dialogue de modification de configuration
- *
- * @author Code Lutin, Chemit Tony
- */
-(a)org.codelutin.jaxx.action.ActionConfig(
- actionCommand = "about",
- name = "commandlinedemo.action.about",
- shortDescription = "commandlinedemo.action.about.tooltip",
- longDescription = "commandlinedemo.action.about.help",
- smallIcon = "action/about.png",
- mnemonic = 'a',
- hideActionText = false
-)
-public class AboutAction extends CommandLineDemoBaseAction {
- private static final long serialVersionUID = 9050439968144935986L;
-
-
- public AboutAction(String name) {
- super(name);
- }
-
- @Override
- public void doAction(java.awt.event.ActionEvent e) {
- log.info("To be done!");
- }
-
- @Override
- public void disposeUI() {
- super.disposeUI();
- }
-
-}
\ No newline at end of file
Deleted: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/ChangeLocaleAction.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/ChangeLocaleAction.java 2008-07-25 22:32:24 UTC (rev 919)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/ChangeLocaleAction.java 2008-07-25 22:34:41 UTC (rev 920)
@@ -1,111 +0,0 @@
-/**
- * # #% 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.commandline.demo.ui.actions;
-
-/** @author chemit */
-
-import org.codelutin.commandline.demo.DemoMain;
-import static org.codelutin.i18n.I18n._;
-
-import javax.swing.Action;
-import java.awt.event.ActionEvent;
-import java.util.Locale;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Une action pour recharger la locale.
- * <p/>
- * Le nom de l'action doit etre de la forme i18n_XX_YY o� XX est la langue
- * et YY le pays de la locale � charger.
- *
- * @author Code Lutin, Chemit Tony
- */
-(a)org.codelutin.jaxx.action.ActionConfig(
- actionCommand = "changeLocale",
- shortDescription = "commandlinedemo.action.changeLocale.tooltip",
- longDescription = "commandlinedemo.action.changeLocale.help",
- hideActionText = false,
- multiNames = {"i18n_fr", "i18n_en"}
-)
-(a)org.codelutin.i18n.I18nable
-public class ChangeLocaleAction extends CommandLineDemoBaseAction {
-
- public static final Pattern PATTERN_NAME = Pattern.compile("i18n_(\\w\\w)");
-
- protected Locale locale;
-
- private static final long serialVersionUID = 4180668477670765253L;
-
- public ChangeLocaleAction(String name) {
- super(name);
- Matcher matcher = PATTERN_NAME.matcher(name);
- if (!matcher.matches()) {
- throw new IllegalArgumentException(_(getClass().getName() + " should have a name like this 'i18n_XX', but was {0}", name));
- }
-
- locale = org.codelutin.i18n.I18n.newLocale(matcher.group(1));
-
- //putValue(Action.NAME, _(locale.getLibelle()));
- //TODO Make it works again :)
- putValue(Action.NAME, _(locale.getDisplayLanguage()));
- putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(getIcon()));
- }
-
- @Override
- public String getI18nToolTipText() {
- return "commandlinedemo.action.changeLocale.tooltip";
- }
-
- public String getIcon() {
- return "action/i18n-" + locale.getLanguage() + ".png";
- }
-
- @Override
- protected boolean beforeAction(ActionEvent e) throws Exception {
- return true;
- //TODO Faut-il proposer une confirmation ?
- //String s = _(locale.getLibelle());
- //int result = JOptionPane.showConfirmDialog(null, _("commandlinedemo.confirm.changeLanguage", s), "changeLanguage", JOptionPane.YES_NO_OPTION);
- //return result == JOptionPane.OK_OPTION;
- }
-
- @Override
- public void doAction(ActionEvent e) {
-
- getContext().getMainConfig().setLocale(locale);
- // on doit initialiser la nouvelle locale avant de decharger les ui
- // au cas ou un appel � une ui surviendrait et dans quel cas la locale
- // serait toujours sur l'ancienne valeur ...
- getContext().initI18n();
- // save config
- getContext().saveSafely();
- // dispose then reload main ui
- DemoMain.dispose(true);
- }
-
- @Override
- public String toString() {
- return super.toString() + " Locale " + locale;
- }
-
- public boolean equalsLocale(Locale locale) {
- return this.locale.equals(locale) || this.locale.getLanguage().equals(locale.getLanguage());
- }
-
- public Locale getLocale() {
- return locale;
- }
-}
\ No newline at end of file
Deleted: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineDemoBaseAction.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineDemoBaseAction.java 2008-07-25 22:32:24 UTC (rev 919)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineDemoBaseAction.java 2008-07-25 22:34:41 UTC (rev 920)
@@ -1,53 +0,0 @@
-/**
- * # #% 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.commandline.demo.ui.actions;
-
-import org.codelutin.commandline.demo.DemoContext;
-import org.codelutin.commandline.demo.DemoMain;
-import org.codelutin.jaxx.action.MyAbstractAction;
-
-import java.awt.event.ActionEvent;
-
-/** @author chemit */
-public class CommandLineDemoBaseAction extends MyAbstractAction {
-
- private static final long serialVersionUID = -810023044364620841L;
-
- protected ActionEvent e;
-
- protected String getPrefix() {
- return "commandlinedemo";
- }
-
- protected CommandLineDemoBaseAction(String name) {
- super(name);
- if (log.isTraceEnabled()) {
- log.trace("> " + this);
- }
- }
-
- public CommandLineDemoBaseAction(MyAbstractAction delegate) {
- super(delegate);
- if (log.isTraceEnabled()) {
- log.trace("> " + this);
- }
- }
-
- protected DemoContext getContext() {
- return DemoMain.getContext();
- }
-
-
-}
Deleted: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/ConfigAction.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/ConfigAction.java 2008-07-25 22:32:24 UTC (rev 919)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/ConfigAction.java 2008-07-25 22:34:41 UTC (rev 920)
@@ -1,64 +0,0 @@
-/**
- * # #% 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.commandline.demo.ui.actions;
-
-import org.codelutin.option.ui.ConfigUI;
-
-
-/**
- * Action pour afficher la dialogue de modification de configuration
- *
- * @author Code Lutin, Chemit Tony
- */
-(a)org.codelutin.jaxx.action.ActionConfig(
- actionCommand = "config",
- name = "commandlinedemo.action.config",
- shortDescription = "commandlinedemo.action.config.tooltip",
- longDescription = "commandlinedemo.action.config.help",
- smallIcon = "action/config.png",
- mnemonic = 'P',
- hideActionText = false
-)
-public class ConfigAction extends CommandLineDemoBaseAction {
-
- ConfigUI ui;
-
- private static final long serialVersionUID = 1449553547444065616L;
-
- public ConfigAction(String name) {
- super(name);
- }
-
- @Override
- public void doAction(java.awt.event.ActionEvent e) {
- getUi().setVisible(true);
- }
-
- @Override
- public void disposeUI() {
- super.disposeUI();
- if (ui != null) {
- ui.dispose();
- ui = null;
- }
- }
-
- public ConfigUI getUi() {
- if (ui == null) {
- ui = new ConfigUI().init(getContext(), getContext().getMainConfig(), getContext().getRemoteConfig());
- }
- return ui;
- }
-}
\ No newline at end of file
Deleted: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/HelpAction.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/HelpAction.java 2008-07-25 22:32:24 UTC (rev 919)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/HelpAction.java 2008-07-25 22:34:41 UTC (rev 920)
@@ -1,50 +0,0 @@
-/**
- * # #% 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.commandline.demo.ui.actions;
-
-/**
- * Action pour afficher la dialogue de modification de configuration
- *
- * @author Code Lutin, Chemit Tony
- */
-(a)org.codelutin.jaxx.action.ActionConfig(
- actionCommand = "help",
- name = "commandlinedemo.action.help",
- shortDescription = "commandlinedemo.action.help.tooltip",
- longDescription = "commandlinedemo.action.help.help",
- smallIcon = "action/help.png",
- mnemonic = 'h',
- hideActionText = false
-)
-public class HelpAction extends CommandLineDemoBaseAction {
- private static final long serialVersionUID = 9050439968144935986L;
-
-
- public HelpAction(String name) {
- super(name);
- }
-
- @Override
- public void doAction(java.awt.event.ActionEvent e) {
- log.info("To be done!");
- }
-
- @Override
- public void disposeUI() {
- super.disposeUI();
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/QuitAction.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/QuitAction.java 2008-07-25 22:32:24 UTC (rev 919)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/QuitAction.java 2008-07-25 22:34:41 UTC (rev 920)
@@ -1,82 +0,0 @@
-/**
- * # #% 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.commandline.demo.ui.actions;
-
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.commandline.demo.DemoMain;
-
-import javax.swing.JOptionPane;
-import java.awt.event.ActionEvent;
-
-
-/**
- * Action pour afficher la dialogue de modification de configuration
- *
- * @author Code Lutin, Chemit Tony
- */
-(a)org.codelutin.jaxx.action.ActionConfig(
- actionCommand = "quit",
- name = "commandlinedemo.action.quit",
- shortDescription = "commandlinedemo.action.quit.tooltip",
- longDescription = "commandlinedemo.action.quit.help",
- smallIcon = "action/quit.png",
- mnemonic = 'q',
- hideActionText = false
-)
-public class QuitAction extends CommandLineDemoBaseAction {
- private static final long serialVersionUID = 9050439968144935986L;
-
-
- public QuitAction(String name) {
- super(name);
- }
-
- @Override
- protected boolean beforeAction(ActionEvent e) throws Exception {
-
- boolean result = super.beforeAction(e);
-
- if (result) {
- String[] response = {_("commandlinedemo.yes"), _("commandlinedemo.no")};
- int n = JOptionPane.showOptionDialog(null,
- _("commandlinedemo.close_question"),
- _("commandlinedemo.question"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null, //do not use a custom Icon
- response, //the titles of buttons
- response[1]); //default button title
-
- result = n == JOptionPane.YES_OPTION;
-
- }
-
- return result;
-
-
- }
-
- @Override
- public void doAction(java.awt.event.ActionEvent e) {
- DemoMain.dispose(false);
- }
-
- @Override
- public void disposeUI() {
- super.disposeUI();
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/SiteAction.java
===================================================================
--- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/SiteAction.java 2008-07-25 22:32:24 UTC (rev 919)
+++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/SiteAction.java 2008-07-25 22:34:41 UTC (rev 920)
@@ -1,60 +0,0 @@
-/**
- * # #% 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.commandline.demo.ui.actions;
-
-import java.awt.Desktop;
-import java.awt.event.ActionEvent;
-import java.net.URL;
-
-
-/**
- * Action pour afficher la dialogue de modification de configuration
- *
- * @author Code Lutin, Chemit Tony
- */
-(a)org.codelutin.jaxx.action.ActionConfig(
- actionCommand = "site",
- name = "commandlinedemo.action.site",
- shortDescription = "commandlinedemo.action.site.tooltip",
- longDescription = "commandlinedemo.action.site.help",
- smallIcon = "action/site.png",
- mnemonic = 's',
- hideActionText = false
-)
-public class SiteAction extends CommandLineDemoBaseAction {
- private static final long serialVersionUID = 9050439968144935986L;
-
- protected URL siteUrl;
-
- public SiteAction(String name) {
- super(name);
- }
-
- @Override
- protected boolean beforeAction(ActionEvent e) throws Exception {
- if (!super.beforeAction(e) && !Desktop.isDesktopSupported() && !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
- return false;
- }
- siteUrl = getContext().getMainConfig().getSiteURL();
- return siteUrl != null;
- }
-
- @Override
- public void doAction(java.awt.event.ActionEvent e) throws Exception {
- super.doAction(e);
- Desktop.getDesktop().browse(siteUrl.toURI());
- }
-
-}
\ No newline at end of file
1
0
25 Jul '08
Author: tchemit
Date: 2008-07-25 22:32:24 +0000 (Fri, 25 Jul 2008)
New Revision: 919
Added:
trunk/commandline/commandline-ui-action/
trunk/commandline/commandline-ui-action/pom.xml
trunk/commandline/commandline-ui-action/src/
trunk/commandline/commandline-ui-action/src/main/
trunk/commandline/commandline-ui-action/src/main/java/
trunk/commandline/commandline-ui-action/src/main/java/org/
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/
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/ChangeLocaleAction.java
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/ConfigAction.java
trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/HelpAction.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/
trunk/commandline/commandline-ui-action/src/main/resources/i18n/
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
trunk/commandline/commandline-ui-action/src/site/
trunk/commandline/commandline-ui-action/src/test/
trunk/commandline/commandline-ui-action/src/test/java/
trunk/commandline/commandline-ui-action/src/test/resources/
Modified:
trunk/commandline/pom.xml
Log:
add commandline-ui-action module with default actions
Property changes on: trunk/commandline/commandline-ui-action
___________________________________________________________________
Name: svn:ignore
+ target
Added: trunk/commandline/commandline-ui-action/pom.xml
===================================================================
--- trunk/commandline/commandline-ui-action/pom.xml (rev 0)
+++ trunk/commandline/commandline-ui-action/pom.xml 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin.commandline</groupId>
+ <artifactId>commandline-pom</artifactId>
+ <version>0.7-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>commandline-ui-action</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.codelutin.commandline</groupId>
+ <artifactId>commandline-ui</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-swing-action</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>commandine-ui-action</name>
+ <version>0.7-SNAPSHOT</version>
+ <description>basic actions implemented using jaxx-swing-action framework</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <build>
+
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ <resource>
+ <directory>${maven.gen.dir}/resources</directory>
+ </resource>
+ </resources>
+
+ <plugins>
+
+ <!-- Compile phase -->
+ <plugin>
+ <groupId>lutinplugin</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>javaActionConfig</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>parserJavaActionConfig</goal>
+ </goals>
+ <configuration>
+ <treateDefaultEntry>false</treateDefaultEntry>
+ <entries>
+ <entry>
+ <basedir>${maven.src.dir}/main/java</basedir>
+ <includes>
+ <param>org\/codelutin\/option\/ui\/actions\/**\/*Action.java</param>
+ </includes>
+ <excludes>
+ <param>org\/codelutin\/option\/ui\/actions\/**\/*AbstractAction.java</param>
+ </excludes>
+ </entry>
+ </entries>
+ </configuration>
+ </execution>
+ <execution>
+ <id>java</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ <configuration>
+ <entries>
+ <entry>
+ <basedir>${maven.gen.dir}/java</basedir>
+ </entry>
+ </entries>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <configuration>
+ <copyToCP>true</copyToCP>
+ <actionsFile>/jaxx/commandline-jaxx-actions.properties</actionsFile>
+ </configuration>
+ <executions>
+ <execution>
+ <id>jaxx-generate-actions-provider</id>
+ <goals>
+ <goal>generate-actions-provider</goal>
+ </goals>
+ <configuration>
+ <fqn>org.codelutin.option.ui.CommandlineActionProvider</fqn>
+ <fqnAction>org.codelutin.option.ui.actions.CommandLineBaseAction</fqnAction>
+ <providerName>commandline</providerName>
+ </configuration>
+ </execution>
+ <execution>
+ <id>jaxx-generate-actions</id>
+ <goals>
+ <goal>generate-actions-properties</goal>
+ </goals>
+ <configuration>
+ <includes>
+ <param>
+ org\/codelutin\/option/ui\/actions\/**\/*Action.java
+ </param>
+ </includes>
+ <excludes>
+ <param>
+ org\/codelutin\/option\/jaxx\/actions\/**\/*AbstractAction.java
+ </param>
+ </excludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: 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 (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/AboutAction.java 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,49 @@
+/**
+ * # #% 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;
+
+/**
+ * Action pour afficher la dialogue de modification de configuration
+ *
+ * @author Code Lutin, Chemit Tony
+ */
+(a)org.codelutin.jaxx.action.ActionConfig(
+ actionCommand = "about",
+ name = "commandline.action.about",
+ shortDescription = "commandline.action.about.tooltip",
+ longDescription = "commandline.action.about.help",
+ smallIcon = "action/about.png",
+ mnemonic = 'a',
+ hideActionText = false
+)
+public class AboutAction extends CommandLineBaseAction {
+ private static final long serialVersionUID = 9050439968144935986L;
+
+
+ public AboutAction(String name) {
+ super(name);
+ }
+
+ @Override
+ public void doAction(java.awt.event.ActionEvent e) {
+ log.info("To be done!");
+ }
+
+ @Override
+ public void disposeUI() {
+ super.disposeUI();
+ }
+
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ChangeLocaleAction.java 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,110 @@
+/**
+ * # #% 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;
+
+/** @author chemit */
+
+import static org.codelutin.i18n.I18n._;
+
+import javax.swing.Action;
+import java.awt.event.ActionEvent;
+import java.util.Locale;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Une action pour recharger la locale.
+ * <p/>
+ * Le nom de l'action doit etre de la forme i18n_XX_YY o� XX est la langue
+ * et YY le pays de la locale � charger.
+ *
+ * @author Code Lutin, Chemit Tony
+ */
+(a)org.codelutin.jaxx.action.ActionConfig(
+ actionCommand = "changeLocale",
+ shortDescription = "commandline.action.changeLocale.tooltip",
+ longDescription = "commandline.action.changeLocale.help",
+ hideActionText = false,
+ multiNames = {"i18n_fr", "i18n_en"}
+)
+(a)org.codelutin.i18n.I18nable
+public class ChangeLocaleAction extends CommandLineBaseAction {
+
+ public static final Pattern PATTERN_NAME = Pattern.compile("i18n_(\\w\\w)");
+
+ protected Locale locale;
+
+ private static final long serialVersionUID = 4180668477670765253L;
+
+ public ChangeLocaleAction(String name) {
+ super(name);
+ Matcher matcher = PATTERN_NAME.matcher(name);
+ if (!matcher.matches()) {
+ throw new IllegalArgumentException(_(getClass().getName() + " should have a name like this 'i18n_XX', but was {0}", name));
+ }
+
+ locale = org.codelutin.i18n.I18n.newLocale(matcher.group(1));
+
+ //putValue(Action.NAME, _(locale.getLibelle()));
+ //TODO Make it works again :)
+ putValue(Action.NAME, _(locale.getDisplayLanguage()));
+ putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(getIcon()));
+ }
+
+ @Override
+ public String getI18nToolTipText() {
+ return "commandline.action.changeLocale.tooltip";
+ }
+
+ public String getIcon() {
+ return "action/i18n-" + locale.getLanguage() + ".png";
+ }
+
+ @Override
+ protected boolean beforeAction(ActionEvent e) throws Exception {
+ return true;
+ //TODO Faut-il proposer une confirmation ?
+ //String s = _(locale.getLibelle());
+ //int result = JOptionPane.showConfirmDialog(null, _("commandline.confirm.changeLanguage", s), "changeLanguage", JOptionPane.YES_NO_OPTION);
+ //return result == JOptionPane.OK_OPTION;
+ }
+
+ @Override
+ public void doAction(ActionEvent e) {
+
+ getContext().getMainConfig().setProperty("locale", locale);
+ // on doit initialiser la nouvelle locale avant de decharger les ui
+ // au cas ou un appel � une ui surviendrait et dans quel cas la locale
+ // serait toujours sur l'ancienne valeur ...
+ getContext().initI18n();
+ // save config
+ getContext().saveSafely();
+ // dispose then reload application
+ getContext().dispose(true);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " Locale " + locale;
+ }
+
+ public boolean equalsLocale(Locale locale) {
+ return this.locale.equals(locale) || this.locale.getLanguage().equals(locale.getLanguage());
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/CommandLineBaseAction.java 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,48 @@
+/**
+ * ##% 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 org.codelutin.jaxx.action.MyAbstractAction;
+import org.codelutin.option.Context;
+import org.codelutin.option.ContextProvider;
+
+/** @author chemit */
+public class CommandLineBaseAction extends MyAbstractAction {
+
+ private static final long serialVersionUID = -810023044364620841L;
+
+ protected CommandLineBaseAction(String name) {
+ super(name);
+ if (log.isTraceEnabled()) {
+ log.trace("> " + this);
+ }
+ }
+
+ public CommandLineBaseAction(MyAbstractAction delegate) {
+ super(delegate);
+ if (log.isTraceEnabled()) {
+ log.trace("> " + this);
+ }
+ }
+
+ protected String getPrefix() {
+ return "jaxx";
+ }
+
+ protected Context getContext() {
+ return ContextProvider.getContext();
+ }
+
+}
Added: trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ConfigAction.java
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ConfigAction.java (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/ConfigAction.java 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,64 @@
+/**
+ * # #% 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 org.codelutin.option.ui.ConfigUI;
+
+
+/**
+ * Action pour afficher la dialogue de modification de configuration
+ *
+ * @author Code Lutin, Chemit Tony
+ */
+(a)org.codelutin.jaxx.action.ActionConfig(
+ actionCommand = "config",
+ name = "commandline.action.config",
+ shortDescription = "commandline.action.config.tooltip",
+ longDescription = "commandline.action.config.help",
+ smallIcon = "action/config.png",
+ mnemonic = 'P',
+ hideActionText = false
+)
+public class ConfigAction extends CommandLineBaseAction {
+
+ ConfigUI ui;
+
+ private static final long serialVersionUID = 1449553547444065616L;
+
+ public ConfigAction(String name) {
+ super(name);
+ }
+
+ @Override
+ public void doAction(java.awt.event.ActionEvent e) {
+ getUi().setVisible(true);
+ }
+
+ @Override
+ public void disposeUI() {
+ super.disposeUI();
+ if (ui != null) {
+ ui.dispose();
+ ui = null;
+ }
+ }
+
+ public ConfigUI getUi() {
+ if (ui == null) {
+ ui = new ConfigUI().init(getContext(), getContext().getConfigs());
+ }
+ return ui;
+ }
+}
\ No newline at end of file
Added: trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/HelpAction.java
===================================================================
--- trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/HelpAction.java (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/HelpAction.java 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,50 @@
+/**
+ * # #% 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;
+
+/**
+ * Action pour afficher la dialogue de modification de configuration
+ *
+ * @author Code Lutin, Chemit Tony
+ */
+(a)org.codelutin.jaxx.action.ActionConfig(
+ actionCommand = "help",
+ name = "commandline.action.help",
+ shortDescription = "commandline.action.help.tooltip",
+ longDescription = "commandline.action.help.help",
+ smallIcon = "action/help.png",
+ mnemonic = 'h',
+ hideActionText = false
+)
+public class HelpAction extends CommandLineBaseAction {
+ private static final long serialVersionUID = 9050439968144935986L;
+
+
+ public HelpAction(String name) {
+ super(name);
+ }
+
+ @Override
+ public void doAction(java.awt.event.ActionEvent e) {
+ log.info("To be done!");
+ }
+
+ @Override
+ public void disposeUI() {
+ super.disposeUI();
+ }
+
+
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/QuitAction.java 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,78 @@
+/**
+ * # #% 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 static org.codelutin.i18n.I18n._;
+
+import javax.swing.JOptionPane;
+import java.awt.event.ActionEvent;
+
+/**
+ * Action pour quitter l'aaplication
+ *
+ * @author Code Lutin, Chemit Tony
+ */
+(a)org.codelutin.jaxx.action.ActionConfig(
+ actionCommand = "quit",
+ name = "commandline.action.quit",
+ shortDescription = "commandline.action.quit.tooltip",
+ longDescription = "commandline.action.quit.help",
+ smallIcon = "action/quit.png",
+ mnemonic = 'q',
+ hideActionText = false
+)
+public class QuitAction extends CommandLineBaseAction {
+
+ private static final long serialVersionUID = 9050439968144935986L;
+
+ public QuitAction(String name) {
+ super(name);
+ }
+
+ @Override
+ protected boolean beforeAction(ActionEvent e) throws Exception {
+
+ boolean result = super.beforeAction(e);
+
+ if (result) {
+ String[] response = {_("commandline.yes"), _("commandline.no")};
+ int n = JOptionPane.showOptionDialog(null,
+ _("commandline.close_question"),
+ _("commandline.question"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE,
+ null, //do not use a custom Icon
+ response, //the titles of buttons
+ response[1]); //default button title
+
+ result = n == JOptionPane.YES_OPTION;
+
+ }
+
+ return result;
+ }
+
+ @Override
+ public void doAction(java.awt.event.ActionEvent e) {
+ // ask context to dispose application
+ getContext().dispose(false);
+ }
+
+ @Override
+ public void disposeUI() {
+ super.disposeUI();
+ }
+
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/java/org/codelutin/option/ui/actions/SiteAction.java 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,60 @@
+/**
+ * # #% 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 java.awt.Desktop;
+import java.awt.event.ActionEvent;
+import java.net.URL;
+
+
+/**
+ * Action pour afficher la dialogue de modification de configuration
+ *
+ * @author Code Lutin, Chemit Tony
+ */
+(a)org.codelutin.jaxx.action.ActionConfig(
+ actionCommand = "site",
+ name = "commandline.action.site",
+ shortDescription = "commandline.action.site.tooltip",
+ longDescription = "commandline.action.site.help",
+ smallIcon = "action/site.png",
+ mnemonic = 's',
+ hideActionText = false
+)
+public class SiteAction extends CommandLineBaseAction {
+ private static final long serialVersionUID = 9050439968144935986L;
+
+ protected URL siteUrl;
+
+ public SiteAction(String name) {
+ super(name);
+ }
+
+ @Override
+ protected boolean beforeAction(ActionEvent e) throws Exception {
+ if (!super.beforeAction(e) && !Desktop.isDesktopSupported() && !Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
+ return false;
+ }
+ siteUrl = (URL) getContext().getMainConfig().getProperty("siteURL");
+ return siteUrl != null;
+ }
+
+ @Override
+ public void doAction(java.awt.event.ActionEvent e) throws Exception {
+ super.doAction(e);
+ Desktop.getDesktop().browse(siteUrl.toURI());
+ }
+
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-en_GB.properties 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,22 @@
+commandline.action.about=About
+commandline.action.about.help=
+commandline.action.about.tooltip=
+commandline.action.changeLocale.help=
+commandline.action.changeLocale.tooltip=
+commandline.action.config=Preferences
+commandline.action.config.help=
+commandline.action.config.tooltip=
+commandline.action.help=Help
+commandline.action.help.help=
+commandline.action.help.tooltip=
+commandline.action.quit=Quit
+commandline.action.quit.help=
+commandline.action.quit.tooltip=
+commandline.action.site=Site
+commandline.action.site.help=
+commandline.action.site.tooltip=
+commandline.close_question=Really quit ?
+commandline.confirm.changeLanguage=
+commandline.no=No
+commandline.question=Quit
+commandline.yes=Yes
Added: 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 (rev 0)
+++ trunk/commandline/commandline-ui-action/src/main/resources/i18n/commandline-ui-action-fr_FR.properties 2008-07-25 22:32:24 UTC (rev 919)
@@ -0,0 +1,22 @@
+commandline.action.about=A propos
+commandline.action.about.help=
+commandline.action.about.tooltip=
+commandline.action.changeLocale.help=
+commandline.action.changeLocale.tooltip=
+commandline.action.config=Pr\u00E9f\u00E9rences
+commandline.action.config.help=
+commandline.action.config.tooltip=
+commandline.action.help=Aide
+commandline.action.help.help=
+commandline.action.help.tooltip=
+commandline.action.quit=Quitter
+commandline.action.quit.help=
+commandline.action.quit.tooltip=
+commandline.action.site=Site
+commandline.action.site.help=
+commandline.action.site.tooltip=
+commandline.close_question=Voulez-vous quitter ?
+commandline.confirm.changeLanguage=
+commandline.no=Non
+commandline.question=Quitter
+commandline.yes=Oui
Modified: trunk/commandline/pom.xml
===================================================================
--- trunk/commandline/pom.xml 2008-07-25 22:30:53 UTC (rev 918)
+++ trunk/commandline/pom.xml 2008-07-25 22:32:24 UTC (rev 919)
@@ -21,6 +21,7 @@
<modules>
<module>commandline-core</module>
<module>commandline-ui</module>
+ <module>commandline-ui-action</module>
<module>maven-plugin</module>
<module>commandline-demo</module>
</modules>
@@ -269,8 +270,13 @@
<artifactId>commandline-ui</artifactId>
<version>${current.version}</version>
</dependency>
-
<dependency>
+ <groupId>org.codelutin.commandline</groupId>
+ <artifactId>commandline-ui-action</artifactId>
+ <version>${current.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0.4</version>
1
0
[Lutinutil-commits] r918 - trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate
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 22:30:53 +0000 (Fri, 25 Jul 2008)
New Revision: 918
Modified:
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorContext.java
trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorGoal.java
Log:
add ContextProvider service declaration generation in commandline plugin :
need parameter : concreteContextFQN
Modified: trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorContext.java
===================================================================
--- trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorContext.java 2008-07-25 22:28:50 UTC (rev 917)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorContext.java 2008-07-25 22:30:53 UTC (rev 918)
@@ -19,9 +19,9 @@
import org.codelutin.option.Option;
import org.codelutin.option.OptionParser;
import org.codelutin.option.def.DefinitionParser;
-import org.codelutin.option.def.MandatoryConfigProperty;
import org.codelutin.option.def.DefinitionParserContexts.ConfigContext;
import org.codelutin.option.def.DefinitionParserContexts.OptionContext;
+import org.codelutin.option.def.MandatoryConfigProperty;
import org.codelutin.option.generate.util.AbstractGeneratorContext;
import java.io.File;
@@ -71,12 +71,11 @@
}
public String getActionSuperClass() {
- return getGoal().getActionSuperClass();
+ return goal.getActionSuperClass();
}
-
public boolean isConcreteConfig() {
- return getGoal().isConcreteConfig();
+ return goal.isConcreteConfig();
}
public String getConfigPackageName() {
@@ -96,7 +95,7 @@
}
public String getConfigSuperClass() {
- return getGoal().getConfigSuperClass();
+ return goal.getConfigSuperClass();
}
@@ -120,6 +119,9 @@
return goal.getContextSuperClass();
}
+ public String getConcreteContextFQN() {
+ return goal.getConcreteContextFQN();
+ }
public String getOptionPackageName() {
return optionPackageName;
@@ -252,11 +254,11 @@
// do parse definitions and return parser
Map<String, String> injects = new HashMap<String, String>();
- injects.put(MandatoryConfigProperty.configFileName.name(),goal._configFileName);
- injects.put(MandatoryConfigProperty.projectName.name(),goal._projectName);
- injects.put(MandatoryConfigProperty.encoding.name(),goal._encoding);
- injects.put(MandatoryConfigProperty.locale.name(),goal._locale);
- injects.put(MandatoryConfigProperty.version.name(),goal._version.endsWith("-SNAPSHOT")?goal._version.substring(0,goal._version.indexOf("-SNAPSHOT")):goal._version);
+ injects.put(MandatoryConfigProperty.configFileName.name(), goal._configFileName);
+ injects.put(MandatoryConfigProperty.projectName.name(), goal._projectName);
+ injects.put(MandatoryConfigProperty.encoding.name(), goal._encoding);
+ injects.put(MandatoryConfigProperty.locale.name(), goal._locale);
+ injects.put(MandatoryConfigProperty.version.name(), goal._version.endsWith("-SNAPSHOT") ? goal._version.substring(0, goal._version.indexOf("-SNAPSHOT")) : goal._version);
parser = DefinitionParser.doParse(parserClass, source, injects);
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-25 22:28:50 UTC (rev 917)
+++ trunk/commandline/maven-plugin/src/main/java/org/codelutin/option/generate/JavaGeneratorGoal.java 2008-07-25 22:30:53 UTC (rev 918)
@@ -32,8 +32,10 @@
import org.codelutin.option.generate.java.OptionKeyJavaGenerator;
import org.codelutin.option.generate.java.OptionParserJavaGenerator;
import org.codelutin.option.generate.util.AbstractGeneratorGoal;
+import org.codelutin.util.FileUtil;
import java.io.File;
+import java.io.IOException;
import java.util.Map;
import java.util.TreeMap;
@@ -48,6 +50,24 @@
public class JavaGeneratorGoal extends AbstractGeneratorGoal<JavaGeneratorContext> {
/**
+ * @description chemin du répertoire de génération des resources.
+ * @parameter expression="${jaxx.outResource}" default-value="${basedir}/target/generated-sources/resources"
+ */
+ protected File outResource;
+
+ /**
+ * @description chemin du répertoire de compilation des resources.
+ * @parameter expression="${jaxx.outClass}" default-value="${basedir}/target/classes"
+ */
+ protected File outClass;
+
+ /**
+ * @description flag to copy generated resource files to outClass
+ * @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}"
* @required
@@ -62,6 +82,13 @@
protected File out;
/**
+ * @description le FQN de la classe concrete du Context
+ * @parameter expression="${commandline.concreteContextFQN}"
+ * @required
+ */
+ protected String concreteContextFQN;
+
+ /**
* @description le parser a utiliser
* @parameter expression="${commandline.parserFQN}" default-value="org.codelutin.option.def.DefinitionParserFromProperties"
*/
@@ -211,6 +238,9 @@
);
}
map.clear();
+
+ // generate ConcreteContext serivce declaration
+ generateConcreteContextDeclaration();
}
public File getOut() {
@@ -261,6 +291,10 @@
return parserFQN;
}
+ public String getConcreteContextFQN() {
+ return concreteContextFQN;
+ }
+
public void setConfigSuperClass(String configSuperClass) {
this.configSuperClass = configSuperClass;
}
@@ -301,4 +335,37 @@
this.parserFQN = parserFQN;
}
+ public void setConcreteContextFQN(String concreteContextFQN) {
+ this.concreteContextFQN = concreteContextFQN;
+ }
+
+ protected void generateConcreteContextDeclaration() throws IOException {
+ File generatedProviderDeclaration = new File(outResource, "META-INF/services/" + org.codelutin.option.Context.class.getName());
+ File parent = generatedProviderDeclaration.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
+
+ // just add the fqn inside the file :)
+ FileUtil.writeString(generatedProviderDeclaration, concreteContextFQN);
+
+ if (copyToCP) {
+ // save it also in classes (since we are in process-resources phase and resources has already been copied)
+ copyResourceToCP(generatedProviderDeclaration);
+ }
+ }
+
+ protected void copyResourceToCP(File file) throws IOException {
+
+ String path = file.getAbsolutePath().substring(outResource.getAbsolutePath().length() + 1);
+ File compiledFile = new File(outClass, path);
+ if (verbose) {
+ getLog().info("copy to classapth generated file " + compiledFile);
+ }
+ File parent = compiledFile.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
+ FileUtil.copy(file, compiledFile);
+ }
}
\ No newline at end of file
1
0
[Lutinutil-commits] r917 - trunk/commandline/maven-plugin/src/test/java/org/codelutin/option
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 22:28:50 +0000 (Fri, 25 Jul 2008)
New Revision: 917
Modified:
trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyContext.java
trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyContext1.java
Log:
add dispose method from Context
Modified: trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyContext.java
===================================================================
--- trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyContext.java 2008-07-25 21:46:07 UTC (rev 916)
+++ trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyContext.java 2008-07-25 22:28:50 UTC (rev 917)
@@ -1,8 +1,5 @@
package org.codelutin.option;
-import org.codelutin.option.AbstractContext;
-import org.codelutin.option.Config;
-
/** @author chemit */
public class MyContext extends AbstractContext<MyParser> {
@@ -16,4 +13,7 @@
public Config getMainConfig() {
return null;
}
+
+ public void dispose(boolean reload) {
+ }
}
Modified: trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyContext1.java
===================================================================
--- trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyContext1.java 2008-07-25 21:46:07 UTC (rev 916)
+++ trunk/commandline/maven-plugin/src/test/java/org/codelutin/option/MyContext1.java 2008-07-25 22:28:50 UTC (rev 917)
@@ -1,8 +1,5 @@
package org.codelutin.option;
-import org.codelutin.option.AbstractContext;
-import org.codelutin.option.Config;
-
/** @author chemit */
public class MyContext1 extends AbstractContext<MyParser1> {
@@ -18,5 +15,8 @@
return null;
}
+ public void dispose(boolean reload) {
+ }
+
}
1
0