Author: tchemit Date: 2008-08-06 10:53:44 +0000 (Wed, 06 Aug 2008) New Revision: 817 Added: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java Removed: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java Log: simplification du code : on conserve uniquement l'interface ActionNameProvider et plus la classe ActionNameHelper et les diff?\195?\169rentes sortes ActionNameProvider car de toute facon il est tr?\195?\168s difficile au niveau de l'AnnotationProcessing d'utiliser une classe en scope compile car celle-ci n'est peut-?\195?\170tre pas compil?\195?\169, ce qui est assez probl?\195?\169matique (il faudrai g?\195?\169rer les rounds de compilation, ce que je ne veux pas faire...) Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-06 10:16:03 UTC (rev 816) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-06 10:53:44 UTC (rev 817) @@ -306,7 +306,7 @@ TypeMirror t = (TypeMirror) entry.getValue().accept(getAnnotationValueExtractor(), null); String classname = t.toString(); printDebug("actionCommandProvider = " + classname); - if (classname.endsWith(ActionNameHelper.ActionNameProvider.class.getName())) { + if (classname.equals(ActionNameProvider.class.getName())) { continue; } Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java 2008-08-06 10:16:03 UTC (rev 816) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java 2008-08-06 10:53:44 UTC (rev 817) @@ -48,7 +48,13 @@ /** @return array of names to be used in actions mapping */ String[] actionCommands() default {}; - Class<? extends ActionNameHelper.ActionNameProvider> actionCommandProvider() default ActionNameHelper.ActionNameProvider.class; + /** + * @return the class to obtain at runtime the array of names to be used in actions mapping. + * <p/> + * <b>Note : the special value {@link org.codelutin.jaxx.action.ActionNameProvider} is used to says not to used + * œthis mecanism since we can not set a null value in a annotation</b> + */ + Class<? extends ActionNameProvider> actionCommandProvider() default org.codelutin.jaxx.action.ActionNameProvider.class; /** * @return la clef i18n du texte de l'action, si vide ignoré Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java 2008-08-06 10:16:03 UTC (rev 816) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java 2008-08-06 10:53:44 UTC (rev 817) @@ -1,43 +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; - -/** @author chemit */ -public class ActionNameHelper { - - /** - * Contrat pour obtenir les noms d'une action. - * - * @author chemit - */ - public static interface ActionNameProvider { - - /** @return la liste des noms à utiliser par la classe d'action. */ - String[] getActionCommands(); - - } - - /** Contrat pour obtenir les noms d'actions au moment de la compilation. */ - public static interface CompileActionNameProvider extends ActionNameProvider { - - } - - /** Contrat pour obtenir les noms d'actions au moment du runtime. */ - public static interface RuntimeActionNameProvider extends ActionNameProvider { - - } - - -} Added: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java (rev 0) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java 2008-08-06 10:53:44 UTC (rev 817) @@ -0,0 +1,27 @@ +/** + * # #% 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; + +/** + * Contrat pour obtenir les noms d'une action de manière dynamique. + * + * @author chemit + */ +public interface ActionNameProvider { + + /** @return la liste des noms à utiliser par la classe d'action. */ + String[] getActionCommands(); + +} Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java 2008-08-06 10:16:03 UTC (rev 816) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java 2008-08-06 10:53:44 UTC (rev 817) @@ -48,7 +48,13 @@ /** @return array of names to be used in actions mapping */ String[] actionCommands() default {}; - Class<? extends ActionNameHelper.ActionNameProvider> actionCommandProvider() default ActionNameHelper.ActionNameProvider.class; + /** + * @return the class to obtain at runtime the array of names to be used in actions mapping. + * <p/> + * <b>Note : the special value {@link org.codelutin.jaxx.action.ActionNameProvider} is used to says not to used + * œthis mecanism since we can not set a null value in a annotation</b> + */ + Class<? extends ActionNameProvider> actionCommandProvider() default org.codelutin.jaxx.action.ActionNameProvider.class; /** * @return la clef i18n du texte de l'action, si vide ignoré Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java 2008-08-06 10:16:03 UTC (rev 816) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java 2008-08-06 10:53:44 UTC (rev 817) @@ -46,7 +46,13 @@ /** @return array of names to be used in actions mapping */ String[] actionCommands() default {}; - Class<? extends ActionNameHelper.ActionNameProvider> actionCommandProvider() default ActionNameHelper.ActionNameProvider.class; + /** + * @return the class to obtain at runtime the array of names to be used in actions mapping. + * <p/> + * <b>Note : the special value {@link org.codelutin.jaxx.action.ActionNameProvider} is used to says not to used + * œthis mecanism since we can not set a null value in a annotation</b> + */ + Class<? extends ActionNameProvider> actionCommandProvider() default org.codelutin.jaxx.action.ActionNameProvider.class; /** * @return la clef i18n du texte de l'action, si vide ignoré Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-06 10:16:03 UTC (rev 816) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-06 10:53:44 UTC (rev 817) @@ -44,14 +44,17 @@ import java.util.TreeMap; /** - * TODO Do javadoc which is not up to date... - * A simple implementation of {@link ActionFactory} using a properties file to - * load action mapping. + * A simple implementation of {@link ActionFactory} using some {@link ActionProvider} to seek actions. * <p/> + * <p/> * An entry is in that form : <code>action.actionName=fqn</code> where * <p/> * <code>actionName</code> is the key of action used in factory, and * <code>fqn</code> is the fully qualified name of the implemented action class. + * <p/> + * A special clase is to have for a given entry a key like this : <code>action.:fqn'=fqn</code>, in that case, + * le fqn' is a classe of type {@link org.codelutin.jaxx.action.ActionNameProvider} which gives us at + * runtime the names of each entry to put in cache for the givne action fqn. * * @author chemit */ Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java =================================================================== --- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-06 10:16:03 UTC (rev 816) +++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-06 10:53:44 UTC (rev 817) @@ -17,7 +17,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import static org.codelutin.i18n.I18n._; -import org.codelutin.jaxx.action.ActionNameHelper.RuntimeActionNameProvider; +import org.codelutin.jaxx.action.ActionNameProvider; import org.codelutin.jaxx.action.MyAbstractAction; import java.io.IOException; @@ -121,7 +121,7 @@ String actionKey = key.substring(prefix); if (actionKey.startsWith(":")) { // this is a RuntimeActionNameProvider - Class<RuntimeActionNameProvider> klazz = (Class<RuntimeActionNameProvider>) Class.forName(actionKey.substring(1)); + Class<ActionNameProvider> klazz = (Class<ActionNameProvider>) Class.forName(actionKey.substring(1)); for (String s : klazz.newInstance().getActionCommands()) { log.debug("found action <" + s + " : " + implCass + ">"); cache.put(s, implCass);
participants (1)
-
tchemit@users.labs.libre-entreprise.org