r1518 - in trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions: . util
Author: tchemit Date: 2008-07-26 11:23:57 +0000 (Sat, 26 Jul 2008) New Revision: 1518 Removed: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/AboutAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConfigAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HelpAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/QuitAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SiteAction.java trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ChangeLocaleAction.java Log: utilisation du module commandline-ui-action avec les actions de base (help,quit,i18n,config,about,help)... Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/AboutAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/AboutAction.java 2008-07-26 11:23:03 UTC (rev 1517) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/AboutAction.java 2008-07-26 11:23:57 UTC (rev 1518) @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008 Cemagref - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package fr.cemagref.simexplorer.is.ui.swing.actions; - -import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; -import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerBaseAction; - -import java.awt.event.ActionEvent; - -/** - * Action pour afficher la boit de dialogue About de l'application - * - * @author Code Lutin, Landais Gabriel, Chemit Tony - */ - at org.codelutin.jaxx.action.ActionConfig( - actionCommand = "about", - name = "simexplorer.action.about", - shortDescription = "simexplorer.action.about.tooltip", - longDescription = "simexplorer.action.about.help", - smallIcon = "action/about.png", - mnemonic = 'A', - hideActionText = false -) -public class AboutAction extends SimExplorerBaseAction { - - private static final long serialVersionUID = 8275852970637350877L; - - public AboutAction(String name) { - super(name); - } - - @Override - protected void doAction(ActionEvent e) throws Exception { - super.doAction(e); - throw new SimExplorerRuntimeException(this + " is not implemented yet!"); - } -} \ No newline at end of file Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConfigAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConfigAction.java 2008-07-26 11:23:03 UTC (rev 1517) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/ConfigAction.java 2008-07-26 11:23:57 UTC (rev 1518) @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2008 Cemagref - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package fr.cemagref.simexplorer.is.ui.swing.actions; - -import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerBaseAction; -import org.codelutin.option.ui.ConfigUI; - -/** - * Action pour afficher la dialogue de modification de configuration - * - * @author Code Lutin, Landais Gabriel, Chemit Tony - */ - at org.codelutin.jaxx.action.ActionConfig( - actionCommand = "config", - name = "simexplorer.action.config", - shortDescription = "simexplorer.action.config.tooltip", - longDescription = "simexplorer.action.config.help", - smallIcon = "action/config.png", - mnemonic = 'P', - hideActionText = false -) -public class ConfigAction extends SimExplorerBaseAction { - - 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().getLocalConfig(), getContext().getRemoteConfig()); - } - return ui; - } -} \ No newline at end of file Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HelpAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HelpAction.java 2008-07-26 11:23:03 UTC (rev 1517) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/HelpAction.java 2008-07-26 11:23:57 UTC (rev 1518) @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008 Cemagref - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package fr.cemagref.simexplorer.is.ui.swing.actions; - -import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; -import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerBaseAction; - -import java.awt.event.ActionEvent; - -/** - * Action pour afficher l'aide principale - * - * @author Code Lutin, Landais Gabriel, Chemit Tony - */ - at org.codelutin.jaxx.action.ActionConfig( - actionCommand = "help", - name = "simexplorer.action.help", - shortDescription = "simexplorer.action.help.tooltip", - longDescription = "simexplorer.action.help.help", - smallIcon = "action/help.png", - mnemonic = 'e', - hideActionText = false -) -public class HelpAction extends SimExplorerBaseAction { - - private static final long serialVersionUID = 8250247303366300958L; - - public HelpAction(String name) { - super(name); - } - - @Override - protected void doAction(ActionEvent e) throws Exception { - super.doAction(e); - throw new SimExplorerRuntimeException(this + " is not implemented yet!"); - } -} \ No newline at end of file Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/QuitAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/QuitAction.java 2008-07-26 11:23:03 UTC (rev 1517) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/QuitAction.java 2008-07-26 11:23:57 UTC (rev 1518) @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2008 Cemagref - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package fr.cemagref.simexplorer.is.ui.swing.actions; - -import fr.cemagref.simexplorer.is.ui.swing.SimExplorer; -import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerBaseAction; - -/** - * Action pour quitter l'application - * - * @author Code Lutin, Landais Gabriel, Chemit Tony - */ - at org.codelutin.jaxx.action.ActionConfig( - actionCommand = "quit", - name = "simexplorer.action.quit", - shortDescription = "simexplorer.action.quit.tooltip", - longDescription = "simexplorer.action.quit.help", - smallIcon = "action/quit.png", - mnemonic = 'Q', - hideActionText = false -) -public class QuitAction extends SimExplorerBaseAction { - - private static final long serialVersionUID = -2291089937320691627L; - - public QuitAction(String name) { - super(name); - } - - @Override - protected void doAction(java.awt.event.ActionEvent e) throws Exception { - //TODO Fermer tous les tabs - //TODO se deconnecter,... - SimExplorer.dispose(false); - } -} Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SiteAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SiteAction.java 2008-07-26 11:23:03 UTC (rev 1517) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/SiteAction.java 2008-07-26 11:23:57 UTC (rev 1518) @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2008 Cemagref - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package fr.cemagref.simexplorer.is.ui.swing.actions; - -import fr.cemagref.simexplorer.is.exceptions.SimExplorerRuntimeException; -import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerBaseAction; - -import java.awt.Desktop; -import java.awt.event.ActionEvent; -import java.net.URL; - -/** - * Action pour accéder au site de l'application - * - * @author Code Lutin, Landais Gabriel, Chemit Tony - */ - at org.codelutin.jaxx.action.ActionConfig( - actionCommand = "site", - name = "simexplorer.action.site", - shortDescription = "simexplorer.action.site.tooltip", - longDescription = "simexplorer.action.site.help", - smallIcon = "action/site.png", - mnemonic = 'S', - hideActionText = false -) -public class SiteAction extends SimExplorerBaseAction { - - private static final long serialVersionUID = 7458557977976803799L; - - protected URL siteUrl; - - public SiteAction(String name) { - super(name); - } - - @Override - protected boolean beforeAction(ActionEvent e) throws Exception { - if (!super.beforeAction(e)) { - return false; - } - siteUrl = getContext().getMainConfig().getSiteURL(); - return siteUrl != null; - } - - @Override - protected void doAction(ActionEvent e) throws Exception { - super.doAction(e); - if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { - Desktop.getDesktop().browse(siteUrl.toURI()); - } else { - //TODO log error ? - throw new SimExplorerRuntimeException(this + " browser is not supported"); - } - } -} \ No newline at end of file Deleted: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ChangeLocaleAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ChangeLocaleAction.java 2008-07-26 11:23:03 UTC (rev 1517) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/util/ChangeLocaleAction.java 2008-07-26 11:23:57 UTC (rev 1518) @@ -1,114 +0,0 @@ -/* - * Copyright (C) 2008 Cemagref - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -package fr.cemagref.simexplorer.is.ui.swing.actions.util; - -import fr.cemagref.simexplorer.is.ui.swing.SimExplorer; -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, Landais Gabriel, Chemit Tony - */ - at org.codelutin.jaxx.action.ActionConfig( - actionCommand = "changeLocale", - shortDescription = "simexplorer.action.changeLocale.tooltip", - longDescription = "simexplorer.action.changeLocale.help", - hideActionText = false, - multiNames = {"i18n_fr", "i18n_en"} -) - at org.codelutin.i18n.I18nable -public class ChangeLocaleAction extends SimExplorerBaseAction { - - 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 "simexplorer.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, _("simexplorer.confirm.changeLanguage", s), "changeLanguage", JOptionPane.YES_NO_OPTION); - //return result == JOptionPane.OK_OPTION; - } - - @Override - public void doAction(ActionEvent e) { - - // suppression de l'historique - getContext().getActionFactory().fireAction("historyReset", e.getSource()); - - 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 - SimExplorer.dispose(true); - } - - @Override - public String toString() { - return super.toString() + " Locale " + locale; - } - - public boolean equalsLocale(Locale locale) { - return this.locale == locale; - } - - public Locale getLocale() { - return locale; - } -} \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org