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] 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
[Lutinutil-commits] r916 - trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui
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 21:46:07 +0000 (Fri, 25 Jul 2008)
New Revision: 916
Modified:
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java
trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java
Log:
introduce Context as a real contract
renmae old Context to AbstractContext
add in ConfigUI#init method the possibility to not pass the config to used : will use all the configs of the context
Modified: trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java
===================================================================
--- trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java 2008-07-25 21:38:49 UTC (rev 915)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUI.java 2008-07-25 21:46:07 UTC (rev 916)
@@ -17,11 +17,14 @@
* ##% */
package org.codelutin.option.ui;
-import org.codelutin.option.AbstractContext;
import org.codelutin.option.Config;
+import org.codelutin.option.Context;
-import javax.swing.*;
-import java.awt.*;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JComponent;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+import java.awt.Component;
import java.util.ArrayList;
import java.util.List;
@@ -66,7 +69,13 @@
}
}
- public ConfigUI init(AbstractContext context, Config... configs) {
+ public ConfigUI init(Context context, Config... configs) {
+ if (configs.length == 0) {
+ configs = context.getConfigs();
+ if (configs == null || configs.length == 0) {
+ throw new IllegalStateException("no config is defined in context " + context);
+ }
+ }
for (Config config : configs) {
add(context, config);
}
@@ -76,7 +85,7 @@
return this;
}
- public boolean add(AbstractContext context, Config config) {
+ public boolean add(Context context, Config config) {
int index = getConfigs().indexOf(config);
if (index > -1) {
return false;
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-25 21:38:49 UTC (rev 915)
+++ trunk/commandline/commandline-ui/src/main/java/org/codelutin/option/ui/ConfigUIHandler.java 2008-07-25 21:46:07 UTC (rev 916)
@@ -18,8 +18,8 @@
* ##% */
package org.codelutin.option.ui;
-import org.codelutin.option.AbstractContext;
import org.codelutin.option.Config;
+import org.codelutin.option.Context;
import javax.swing.*;
import javax.swing.event.TableModelEvent;
@@ -37,13 +37,13 @@
protected ConfigTableModel tableModel;
protected TableModelListener tableModelListener;
- protected AbstractContext context;
+ protected Context context;
public ConfigUIHandler(ConfigTab ui) {
this.ui = ui;
}
- public void init(AbstractContext context, Config config) {
+ public void init(Context context, Config config) {
this.config = config;
this.context = context;
tableModel = new ConfigTableModel(config);
1
0
[Lutinutil-commits] r915 - trunk/commandline/commandline-core/src/main/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 21:38:49 +0000 (Fri, 25 Jul 2008)
New Revision: 915
Added:
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextProvider.java
Log:
introduce ContextProvider which lookup for the commandline unique context as service (using java ServiceLoader mecanism).
in that way we can use the context in some module which does not known the Context real implementation.
Added: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextProvider.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextProvider.java (rev 0)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/ContextProvider.java 2008-07-25 21:38:49 UTC (rev 915)
@@ -0,0 +1,58 @@
+/**
+ * # #% 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;
+
+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}.
+ * <p/>
+ * Le contexte trouv� lors du premier appel � la m�thode {@link #getContext()} est cach�� dans le champ {@link #context}.
+ * <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>
+ *
+ * @author chemit
+ */
+public class ContextProvider {
+ /**
+ * share instance of the context
+ */
+ private static Context context;
+
+ public static synchronized Context getContext() {
+ 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");
+ }
+ }
+ return context;
+ }
+
+ public static void reset() {
+ context = null;
+ }
+}
1
0
[Lutinutil-commits] r914 - in trunk/commandline/commandline-core/src/main/java/org/codelutin/option: . 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 21:36:41 +0000 (Fri, 25 Jul 2008)
New Revision: 914
Modified:
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionAction.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
Log:
introduce Context as a real contract
renmae old Context to AbstractContext
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionAction.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionAction.java 2008-07-25 21:36:09 UTC (rev 913)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/OptionAction.java 2008-07-25 21:36:41 UTC (rev 914)
@@ -8,7 +8,7 @@
/**
* A simple empty action for an option.
* <p/>
- * Use method {@link #doRun(AbstractContext,Option[])} to launch action for the given options.
+ * Use method {@link #doRun(Context, Option[])} to launch action for the given options.
* <p/>
* This method offers some hooks to use for controling running :
* <p/>
@@ -23,7 +23,7 @@
* @author chemit
*/
-public abstract class OptionAction<O extends Option, P extends OptionParser, C extends AbstractContext<P>> {
+public abstract class OptionAction<O extends Option, P extends OptionParser, C extends Context<P>> {
protected final Log log = LogFactory.getLog(getClass());
@@ -43,7 +43,7 @@
* Method to implement logic of the action for the current option.
* <p/>
* <b>This method will never by directly called, you have to use
- * {@link #doRun(AbstractContext,Option[])} method instead which offers some hooks to control actions.</b>
+ * {@link #doRun(Context ,Option[])} method instead which offers some hooks to control actions.</b>
*
* @throws Exception if any problem while action
*/
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-25 21:36:09 UTC (rev 913)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionChangeConfigRunnable.java 2008-07-25 21:36:41 UTC (rev 914)
@@ -16,13 +16,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.option.AbstractContext;
import org.codelutin.option.Config;
import org.codelutin.option.ConfigKey;
import org.codelutin.option.ConfigPropertyKey;
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.
@@ -37,7 +37,7 @@
Option option = action.getOption();
- AbstractContext<?> context = action.getContext();
+ Context<?> context = action.getContext();
String category = getCategory(context, action.getOption());
@@ -75,7 +75,7 @@
* @param option the option to test
* @return the category of an IsisOptionConfig
*/
- protected String getCategory(AbstractContext context, Option option) {
+ protected String getCategory(Context context, Option option) {
String value = option.getConstantArgumentValue(-1);
if (value == null) {
// used by default main category
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-25 21:36:09 UTC (rev 913)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionEditConfigRunnable.java 2008-07-25 21:36:41 UTC (rev 914)
@@ -20,6 +20,7 @@
import org.codelutin.option.ConfigKey;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
+import org.codelutin.option.Context;
/** @author chemit */
public class OptionActionEditConfigRunnable implements OptionActionRunnable {
@@ -30,7 +31,7 @@
public void run(OptionAction action) throws Exception {
- AbstractContext<?> context = action.getContext();
+ Context<?> context = action.getContext();
Config[] configs = new Config[context.getConfigKeys().size()];
int i = 0;
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-25 21:36:09 UTC (rev 913)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpConfigRunnable.java 2008-07-25 21:36:41 UTC (rev 914)
@@ -16,11 +16,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.option.AbstractContext;
import org.codelutin.option.ConfigKey;
import org.codelutin.option.ConfigPropertyKey;
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;
@@ -34,7 +34,7 @@
protected final Log log = LogFactory.getLog(getClass());
public void run(OptionAction action) throws Exception {
- AbstractContext<?> context = action.getContext();
+ Context<?> context = action.getContext();
String category = action.getOption().getConstantArgumentValue(0);
log.info("required showConfig pour category [" + category + "]");
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-25 21:36:09 UTC (rev 913)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionHelpRunnable.java 2008-07-25 21:36:41 UTC (rev 914)
@@ -16,12 +16,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.option.AbstractContext;
import org.codelutin.option.ConfigKey;
import org.codelutin.option.ConfigPropertyKey;
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;
@@ -38,7 +38,7 @@
public void run(OptionAction action) throws Exception {
- AbstractContext<?> context = action.getContext();
+ Context<?> context = action.getContext();
StringWriter writer = new StringWriter();
String title = "TODO Add project name v " + context.getMainConfig().getPropertyKey("version").getCurrentValue();
@@ -56,7 +56,7 @@
* @param name title @throws java.io.IOException if any io pb while writing
* @throws java.io.IOException if any pb while writing
*/
- public void printUsage(AbstractContext<?> context, Writer w, String name) throws IOException {
+ public void printUsage(Context<?> context, Writer w, String name) throws IOException {
//TODO Use a Visitor in context
try {
@@ -71,7 +71,7 @@
}
}
- public void toString(AbstractContext<?> context, Writer w, String head, String prefix, String prefixOption, String prefixConfig) throws IOException {
+ public void toString(Context<?> context, Writer w, String head, String prefix, String prefixOption, String prefixConfig) throws IOException {
w.append(addTitle(head, '=', true)).append("\n\n");
w.append(addTitle(prefixOption, '-', false)).append("\n");
for (OptionKey key : context.getParser().getOptionKeys()) {
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-25 21:36:09 UTC (rev 913)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionResetConfigRunnable.java 2008-07-25 21:36:41 UTC (rev 914)
@@ -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.AbstractContext;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
+import org.codelutin.option.Context;
import java.io.File;
@@ -28,7 +28,7 @@
protected final Log log = LogFactory.getLog(getClass());
public void run(OptionAction action) throws Exception {
- AbstractContext<?> context = action.getContext();
+ Context<?> context = action.getContext();
File property = (File) context.getMainConfig().getProperty("configFileName");
property.delete();
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-25 21:36:09 UTC (rev 913)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionShowConfigRunnable.java 2008-07-25 21:36:41 UTC (rev 914)
@@ -15,11 +15,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.option.AbstractContext;
import org.codelutin.option.ConfigKey;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
import org.codelutin.option.ParserUtil;
+import org.codelutin.option.Context;
import java.io.StringWriter;
@@ -29,7 +29,7 @@
protected final Log log = LogFactory.getLog(getClass());
public void run(OptionAction action) throws Exception {
- AbstractContext<?> context = action.getContext();
+ Context<?> context = action.getContext();
String category = action.getOption().getConstantArgumentValue(0);
log.info("required showConfig pour category [" + category + "]");
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-25 21:36:09 UTC (rev 913)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/actions/OptionActionUiRunnable.java 2008-07-25 21:36:41 UTC (rev 914)
@@ -15,9 +15,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codelutin.option.AbstractContext;
import org.codelutin.option.OptionAction;
import org.codelutin.option.OptionActionRunnable;
+import org.codelutin.option.Context;
/** @author chemit */
public class OptionActionUiRunnable implements OptionActionRunnable {
@@ -27,7 +27,7 @@
protected boolean init = false;
public void run(OptionAction action) throws Exception {
- AbstractContext<?> context = action.getContext();
+ Context<?> context = action.getContext();
Boolean bool = action.getOption().getValuedArgumentValue(0, Boolean.class, "flag", false);
boolean launchUI = bool != null && bool;
log.info(action.getOption().getUsedAlias() + ", value:" + bool);
1
0
[Lutinutil-commits] r913 - trunk/commandline/commandline-core/src/main/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 21:36:09 +0000 (Fri, 25 Jul 2008)
New Revision: 913
Modified:
trunk/commandline/commandline-core/src/main/java/org/codelutin/option/Config.java
Log:
add a dynamic setProperty method using only the property's name to be used when we do not know real implementation of the Config
Modified: trunk/commandline/commandline-core/src/main/java/org/codelutin/option/Config.java
===================================================================
--- trunk/commandline/commandline-core/src/main/java/org/codelutin/option/Config.java 2008-07-25 21:34:18 UTC (rev 912)
+++ trunk/commandline/commandline-core/src/main/java/org/codelutin/option/Config.java 2008-07-25 21:36:09 UTC (rev 913)
@@ -524,6 +524,21 @@
}
/**
+ * Set the value for a given property using his <code>def</code> key.
+ *
+ * @param def the given key to use
+ * @param value the given valuer to set
+ */
+ public void setProperty(String def, Object value) {
+ ConfigPropertyKey<?> property = getKey(def);
+ if (property == null) {
+ throw new IllegalArgumentException("no property found with the key " + def);
+ }
+ setProperty(property, value);
+
+ }
+
+ /**
* Set the value for a given property using his <code>def</code>.
*
* @param def the given key to use
1
0