Author: tchemit Date: 2008-01-22 01:57:11 +0000 (Tue, 22 Jan 2008) New Revision: 359 Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractAction.java Log: action de base revisit?\195?\169e (reste ?\195?\160 ajouter la gestion de s?\195?\169curit?\195?\169 sur action) Modified: trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractAction.java =================================================================== --- trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractAction.java 2008-01-22 01:56:24 UTC (rev 358) +++ trunk/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/action/SimExplorerAbstractAction.java 2008-01-22 01:57:11 UTC (rev 359) @@ -20,10 +20,15 @@ import fr.cemagref.simexplorer.is.ui.SimExplorer; import fr.cemagref.simexplorer.is.ui.SimExplorerContext; +import fr.cemagref.simexplorer.is.ui.SimExplorerRuntimeException; import fr.cemagref.simexplorer.is.ui.swing.SimExplorerMainUI; +import jaxx.runtime.JAXXObject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import javax.swing.JComponent; +import java.awt.event.ActionEvent; + /** * La classe de base à utiliser pour toutes les action de l'application * @@ -35,13 +40,32 @@ static protected Log log = LogFactory.getLog(SimExplorerAbstractAction.class); + public void actionPerformed(java.awt.event.ActionEvent e) { + + log.info("------------------------------------------------------------"); + log.info("action : " + this); + log.info("event : " + e); + log.info("source : " + e.getSource()); + try { + boolean accepted = beforeAction(e); + log.info("doAction : ("+accepted+") : " + getActionName()); + if (accepted) { + doAction(e); + afterAction(e); + } + } catch (Exception e1) { + throw new SimExplorerRuntimeException(e1); + } finally { + // always clear action after use : actions are staless + clear(); + } + } + protected SimExplorerAbstractAction(String name) { super(name); + log.info("> " + this); } - protected SimExplorerAbstractAction() { - } - protected SimExplorerContext getContext() { return SimExplorer.getContext(); } @@ -50,11 +74,35 @@ return SimExplorer.getUI(); } + protected String getActionName() { + return (String) getValue(ACTION_COMMAND_KEY); + } + protected String getName() { return (String) getValue(NAME); } - public void actionPerformed(java.awt.event.ActionEvent e) { - log.info(this); + protected boolean beforeAction(ActionEvent e) throws Exception { + // nothing by default + return true; } + + protected void doAction(ActionEvent e) throws Exception { + // nothing by default + } + + protected void afterAction(ActionEvent e) throws Exception { + // nothing by default + } + + protected void clear() { + // nothing by default + } + + protected JComponent getUIObject(String name, JAXXObject container) { + if (container == null) { + return null; + } + return (JComponent) container.getObjectById(name); + } }
participants (1)
-
tchemit@users.labs.libre-entreprise.org