Author: tchemit Date: 2008-07-24 18:14:26 +0000 (Thu, 24 Jul 2008) New Revision: 779 Added: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java Removed: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java Log: rename to abstract Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java (from rev 772, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java) =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java (rev 0) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java 2008-07-24 18:14:26 UTC (rev 779) @@ -0,0 +1,57 @@ +/** + * # #% 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.jaxx.action.initializer; + +import javax.swing.AbstractAction; +import javax.swing.JComponent; + +/** + * Initializer of a MyAbstractAction described by a typed Annotation <code>A</code> and for a certain type + * <code>C</code> of component. + * + * @author chemit + */ +public abstract class AbstractActionInitializer<A extends java.lang.annotation.Annotation, C extends JComponent> { + + final Class<A> annotationImpl; + final Class<C> componentImpl; + + protected abstract A initAction0(C component, AbstractAction action); + + protected AbstractActionInitializer(Class<A> annotationImpl, Class<C> componentImpl) { + this.annotationImpl = annotationImpl; + this.componentImpl = componentImpl; + } + + public A getAnnotation(Class<? extends AbstractAction> action) { + return action.getAnnotation(annotationImpl); + } + + @SuppressWarnings({"unchecked"}) + public A initAction(JComponent component, AbstractAction action) { + if (component != null && componentImpl.isAssignableFrom(component.getClass())) + return initAction0((C) component, action); + + return null; + } + + public Class<A> getAnnotationImpl() { + return annotationImpl; + } + + public Class<C> getComponentImpl() { + return componentImpl; + } +} Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java 2008-07-24 16:49:08 UTC (rev 778) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java 2008-07-24 18:14:26 UTC (rev 779) @@ -1,57 +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.jaxx.action.initializer; - -import javax.swing.AbstractAction; -import javax.swing.JComponent; - -/** - * Initializer of a MyAbstractAction described by a typed Annotation <code>A</code> and for a certain type - * <code>C</code> of component. - * - * @author chemit - */ -public abstract class ActionInitializer<A extends java.lang.annotation.Annotation, C extends JComponent> { - - final Class<A> annotationImpl; - final Class<C> componentImpl; - - protected abstract A initAction0(C component, AbstractAction action); - - protected ActionInitializer(Class<A> annotationImpl, Class<C> componentImpl) { - this.annotationImpl = annotationImpl; - this.componentImpl = componentImpl; - } - - public A getAnnotation(Class<? extends AbstractAction> action) { - return action.getAnnotation(annotationImpl); - } - - @SuppressWarnings({"unchecked"}) - public A initAction(JComponent component, AbstractAction action) { - if (component != null && componentImpl.isAssignableFrom(component.getClass())) - return initAction0((C) component, action); - - return null; - } - - public Class<A> getAnnotationImpl() { - return annotationImpl; - } - - public Class<C> getComponentImpl() { - return componentImpl; - } -}