Author: tchemit Date: 2008-04-20 10:47:40 +0000 (Sun, 20 Apr 2008) New Revision: 605 Added: trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java Removed: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java Log: generalisation de l'AbstractAction Copied: trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java (from rev 604, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java) =================================================================== --- trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java (rev 0) +++ trunk/lutinui/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:47:40 UTC (rev 605) @@ -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.ui; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.ui.DialogUI; +import org.codelutin.ui.DialogUIHandler; + +/** @author chemit */ +public abstract class AbstractUIAction<H extends DialogUIHandler<?, ?>> extends javax.swing.AbstractAction { + + protected static Log log = LogFactory.getLog(AbstractUIAction.class); + + protected transient DialogUI<? extends H> ui; + protected transient H handler; + + private static final long serialVersionUID = 1L; + + protected AbstractUIAction(String name, javax.swing.Icon icon) { + super(name, icon); + } + + public AbstractUIAction() { + } + + protected H getHandler() { + checkInit(); + if (handler == null) { + handler = ui.getHandler(); + } + return handler; + } + + protected void setUi(DialogUI<? extends H> ui) { + this.ui = ui; + this.handler = null; + } + + protected void checkInit() throws IllegalStateException { + if (handler == null && ui == null) { + throw new IllegalStateException("no handler, nor ui referenced in " + this); + } + } + +} Deleted: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:44:42 UTC (rev 604) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/ui/AbstractUIAction.java 2008-04-20 10:47:40 UTC (rev 605) @@ -1,58 +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.ui; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.codelutin.ui.DialogUI; -import org.codelutin.ui.DialogUIHandler; - -/** @author chemit */ -public abstract class AbstractUIAction<H extends DialogUIHandler<?, ?>> extends javax.swing.AbstractAction { - - protected static Log log = LogFactory.getLog(AbstractUIAction.class); - - protected transient DialogUI<? extends H> ui; - protected transient H handler; - - private static final long serialVersionUID = 1L; - - protected AbstractUIAction(String name, javax.swing.Icon icon) { - super(name, icon); - } - - public AbstractUIAction() { - } - - protected H getHandler() { - checkInit(); - if (handler == null) { - handler = ui.getHandler(); - } - return handler; - } - - protected void setUi(DialogUI<? extends H> ui) { - this.ui = ui; - this.handler = null; - } - - protected void checkInit() throws IllegalStateException { - if (handler == null && ui == null) { - throw new IllegalStateException("no handler, nor ui referenced in " + this); - } - } - -}