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 - */ -@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 - */ -@org.codelutin.jaxx.action.ActionConfig( - actionCommand = "changeLocale", - shortDescription = "commandlinedemo.action.changeLocale.tooltip", - longDescription = "commandlinedemo.action.changeLocale.help", - hideActionText = false, - multiNames = {"i18n_fr", "i18n_en"} -) -@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 - */ -@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 - */ -@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 - */ -@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 - */ -@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