[Lutinutil-commits] r896 - trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions
Author: tchemit Date: 2008-07-24 20:47:24 +0000 (Thu, 24 Jul 2008) New Revision: 896 Added: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineAction.java Removed: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/MyAbstractAction.java Log: update from jaxx-swing-action framework Copied: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineAction.java (from rev 891, trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/MyAbstractAction.java) =================================================================== --- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineAction.java (rev 0) +++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/CommandLineAction.java 2008-07-24 20:47:24 UTC (rev 896) @@ -0,0 +1,112 @@ +/** + * # #% 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 jaxx.runtime.JAXXObject; +import org.apache.commons.logging.LogFactory; +import org.codelutin.commandline.demo.MyContext; +import org.codelutin.commandline.demo.MyMain; + +import javax.swing.AbstractAction; +import javax.swing.JComponent; +import java.awt.event.ActionEvent; + +/** @author chemit */ +public abstract class CommandLineAction extends AbstractAction { + + static org.apache.commons.logging.Log log = LogFactory.getLog(CommandLineAction.class); + + private static final long serialVersionUID = -810023044364620841L; + + protected ActionEvent e; + + public void actionPerformed(java.awt.event.ActionEvent e) { + + log.debug("------------------------------------------------------------"); + log.debug("event : " + e); + log.debug("source : " + e.getSource()); + this.e = e; + try { + boolean accepted = beforeAction(e); + log.debug("action : " + this); + if (accepted) { + log.info(getActionName() + " (treate:" + accepted + ") : " + this); + } else { + log.debug(getActionName() + " (treate:" + accepted + ") : " + this); + } + if (accepted) { + doAction(e); + updateUI(); + } + } catch (Exception e1) { + showError(e1); + } finally { + this.e = null; + // always clear action after use : actions are staless + clear(); + } + } + + protected String getActionName() { + return (String) getValue(ACTION_COMMAND_KEY); + } + + protected boolean beforeAction(ActionEvent e) throws Exception { + return isEnabled(); + } + + protected JComponent getUIObject(String name, JAXXObject container) { + if (container == null) { + return null; + } + return (JComponent) container.getObjectById(name); + } + + public String getI18nToolTipText() { + return "commandlinedemo.action." + getActionName() + ".tooltip"; + } + + protected void doAction(ActionEvent e) throws Exception { + // nothing by default + } + + public void updateUI() { + // nothing by default + } + + public void disposeUI() { + // nothing by default + } + + protected void clear() { + // nothing by default + } + + + protected void showError(Exception e) { + log.error(e); + } + + protected CommandLineAction(String name) { + super(name); + log.debug("> " + this); + } + + protected MyContext getContext() { + return MyMain.getContext(); + } + + +} Deleted: trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/MyAbstractAction.java =================================================================== --- trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/MyAbstractAction.java 2008-07-23 17:55:56 UTC (rev 895) +++ trunk/commandline/commandline-demo/src/main/java/org/codelutin/commandline/demo/ui/actions/MyAbstractAction.java 2008-07-24 20:47:24 UTC (rev 896) @@ -1,112 +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 jaxx.runtime.JAXXObject; -import org.apache.commons.logging.LogFactory; -import org.codelutin.commandline.demo.MyContext; -import org.codelutin.commandline.demo.MyMain; - -import javax.swing.AbstractAction; -import javax.swing.JComponent; -import java.awt.event.ActionEvent; - -/** @author chemit */ -public abstract class MyAbstractAction extends AbstractAction { - - static org.apache.commons.logging.Log log = LogFactory.getLog(MyAbstractAction.class); - - private static final long serialVersionUID = -810023044364620841L; - - protected ActionEvent e; - - public void actionPerformed(java.awt.event.ActionEvent e) { - - log.debug("------------------------------------------------------------"); - log.debug("event : " + e); - log.debug("source : " + e.getSource()); - this.e = e; - try { - boolean accepted = beforeAction(e); - log.debug("action : " + this); - if (accepted) { - log.info(getActionName() + " (treate:" + accepted + ") : " + this); - } else { - log.debug(getActionName() + " (treate:" + accepted + ") : " + this); - } - if (accepted) { - doAction(e); - updateUI(); - } - } catch (Exception e1) { - showError(e1); - } finally { - this.e = null; - // always clear action after use : actions are staless - clear(); - } - } - - protected String getActionName() { - return (String) getValue(ACTION_COMMAND_KEY); - } - - protected boolean beforeAction(ActionEvent e) throws Exception { - return isEnabled(); - } - - protected JComponent getUIObject(String name, JAXXObject container) { - if (container == null) { - return null; - } - return (JComponent) container.getObjectById(name); - } - - public String getI18nToolTipText() { - return "commandlinedemo.action." + getActionName() + ".tooltip"; - } - - protected void doAction(ActionEvent e) throws Exception { - // nothing by default - } - - public void updateUI() { - // nothing by default - } - - public void disposeUI() { - // nothing by default - } - - protected void clear() { - // nothing by default - } - - - protected void showError(Exception e) { - log.error(e); - } - - protected MyAbstractAction(String name) { - super(name); - log.debug("> " + this); - } - - protected MyContext getContext() { - return MyMain.getContext(); - } - - -}
participants (1)
-
tchemit@users.labs.libre-entreprise.org