Buix-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
July 2008
- 1 participants
- 124 discussions
r806 - in trunk/lutinjaxx: . core jaxx-swing jaxx-swing-action jaxx-swing-action/src/main/java/org/codelutin/jaxx/action jaxx-swing-action/src/main/resources jaxx-swing-action/src/main/resources/META-INF jaxx-swing-action/src/main/resources/META-INF/services jaxx-swing-tab maven maven/src/main/java/org/codelutin/jaxx runtime util
by tchemit@users.labs.libre-entreprise.org 31 Jul '08
by tchemit@users.labs.libre-entreprise.org 31 Jul '08
31 Jul '08
Author: tchemit
Date: 2008-07-31 13:17:21 +0000 (Thu, 31 Jul 2008)
New Revision: 806
Added:
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/ActionProviderAnnotation.java
trunk/lutinjaxx/jaxx-swing-action/src/main/resources/META-INF/
trunk/lutinjaxx/jaxx-swing-action/src/main/resources/META-INF/services/
trunk/lutinjaxx/jaxx-swing-action/src/main/resources/META-INF/services/javax.annotation.processing.Processor
Modified:
trunk/lutinjaxx/core/pom.xml
trunk/lutinjaxx/jaxx-swing-action/pom.xml
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-tab/pom.xml
trunk/lutinjaxx/jaxx-swing/pom.xml
trunk/lutinjaxx/maven/pom.xml
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java
trunk/lutinjaxx/pom.xml
trunk/lutinjaxx/runtime/pom.xml
trunk/lutinjaxx/util/pom.xml
Log:
mise en place de la version 0.3 avec utilisation d'un processor d'annotation pour traiter les jaxx-actions plutot qu'un plugin maven.
Du coup on travaille uniquement par annotation, plus aucune autre config n?\195?\169cessaire dans maven :)
Modified: trunk/lutinjaxx/core/pom.xml
===================================================================
--- trunk/lutinjaxx/core/pom.xml 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/core/pom.xml 2008-07-31 13:17:21 UTC (rev 806)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
</parent>
<artifactId>core</artifactId>
<name>core</name>
<packaging>jar</packaging>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
<description>Jaxx lutin library core</description>
<build>
Modified: trunk/lutinjaxx/jaxx-swing/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing/pom.xml 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/jaxx-swing/pom.xml 2008-07-31 13:17:21 UTC (rev 806)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
</parent>
<artifactId>jaxx-swing</artifactId>
<name>jaxx-swing</name>
<packaging>jar</packaging>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
<description>Jaxx library swing extension</description>
<dependencies>
Modified: trunk/lutinjaxx/jaxx-swing-action/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/pom.xml 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/jaxx-swing-action/pom.xml 2008-07-31 13:17:21 UTC (rev 806)
@@ -7,19 +7,26 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
</parent>
<artifactId>jaxx-swing-action</artifactId>
<name>jaxx-swing-action</name>
<packaging>jar</packaging>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
<description>Jaxx lutin library swing actions extension</description>
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>lutinplugin</groupId>
<artifactId>maven-i18n-plugin</artifactId>
<executions>
@@ -43,5 +50,12 @@
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.7.ga</version>
+ <scope>compile</scope>
+ </dependency>
+
</dependencies>
</project>
Added: 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 (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-07-31 13:17:21 UTC (rev 806)
@@ -0,0 +1,285 @@
+/**
+ * # #% 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;
+
+import javassist.CannotCompileException;
+import javassist.ClassPool;
+import javassist.CtClass;
+import javassist.CtConstructor;
+import javassist.LoaderClassPath;
+import javassist.NotFoundException;
+import org.codelutin.jaxx.action.provider.ActionProvider;
+import org.codelutin.jaxx.action.provider.ActionProviderFromProperties;
+import org.codelutin.util.SortedProperties;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedOptions;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.AnnotationValueVisitor;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.util.SimpleAnnotationValueVisitor6;
+import javax.tools.FileObject;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardLocation;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Properties;
+import java.util.Set;
+
+
+@SupportedAnnotationTypes(value = {"org.codelutin.jaxx.action.*"})
+(a)SupportedSourceVersion(SourceVersion.RELEASE_6)
+@SupportedOptions({"jaxx.verbose"})
+/**
+ * Annotation processor to compute actions mapping.
+ *
+ * @author chemit */
+public class ActionAnnotationProcessing extends AbstractProcessor {
+
+ protected ActionProviderAnnotation providerConfig;
+
+ protected String providerDeclarationLocation = "META-INF/services/" + ActionProvider.class.getName();
+
+ protected String actionsFileLocation = "META-INF/jaxx-%1$s-actions.properties";
+
+ protected boolean verbose;
+
+ protected java.util.List<String> processedClass;
+
+ protected Properties actions;
+
+ protected AnnotationValueVisitor<Object, Void> annotationValueExtractor;
+
+ protected TypeElement baseActionElement;
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv) {
+ super.init(processingEnv);
+ parseOptions();
+ printDebug("verbose : " + verbose);
+ printDebug("FileLocation : " + actionsFileLocation);
+ processedClass = new ArrayList<String>();
+ actions = new SortedProperties();
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ for (TypeElement annotation : annotations) {
+
+ Set<? extends Element> annotatedWith = roundEnv.getElementsAnnotatedWith(annotation);
+
+ if (annotation.getQualifiedName().toString().equals(ActionProviderAnnotation.class.getName())) {
+ // init provider
+ if (annotatedWith.size() != 1) {
+ throw new IllegalStateException("can have only one provider defined by the annotation " + ActionProviderAnnotation.class);
+ }
+
+ baseActionElement = (TypeElement) annotatedWith.iterator().next();
+
+ //fixme CheckbaseActionElement is assigned from MyAbstractAction
+ //if (!baseActionElement.getSuperclass()) ...
+
+ providerConfig = baseActionElement.getAnnotation(ActionProviderAnnotation.class);
+
+ actionsFileLocation = String.format(actionsFileLocation, providerConfig.name());
+ continue;
+ }
+
+ for (Element e : annotatedWith) {
+ String className = e.toString();
+
+ if (processedClass.contains(className)) {
+ // do not process class twice
+ continue;
+ }
+ printDebug("process class " + className);
+ registerActionsForClass(annotation.asType(), e);
+ processedClass.add(className);
+ }
+ }
+
+ if ((roundEnv.processingOver())) {
+ if (providerConfig == null) {
+ throw new IllegalStateException("no provider name found, you must add on baseaction the annotation " + ActionProviderAnnotation.class);
+ }
+ try {
+ writeProviderClass();
+ writeProviderServiceDeclaration();
+ writeActionMapping();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ processedClass.clear();
+ actions.clear();
+ }
+ }
+
+ return false;
+ }
+
+ protected void registerActionsForClass(TypeMirror annotationType, Element e) {
+ for (AnnotationMirror mirror : e.getAnnotationMirrors()) {
+ if (!mirror.getAnnotationType().equals(annotationType)) {
+ // do not treate other annotations
+ continue;
+ }
+ for (String name : getActionNames(mirror)) {
+ actions.put("action." + name, e.toString());
+ }
+ }
+ }
+
+ protected void parseOptions() {
+ java.util.Map options = processingEnv.getOptions();
+ verbose = options.containsKey("jaxx.verbose");
+ }
+
+ protected void writeProviderClass() throws IOException, NotFoundException, CannotCompileException, ClassNotFoundException {
+ OutputStream outputStream = null;
+ try {
+ String fqn = providerConfig.fqn();
+
+ ClassPool pool = ClassPool.getDefault();
+
+ pool.appendClassPath(new LoaderClassPath(ActionProviderFromProperties.class.getClassLoader()));
+
+ CtClass superClass = pool.get(ActionProviderFromProperties.class.getName());
+ CtClass clazz = pool.makeClass(fqn);
+ // define the base action class in javassist pool to make possible compilation
+ pool.makeClass(baseActionElement.asType().toString());
+ clazz.setSuperclass(superClass);
+ // add constructor
+ CtConstructor constructor = new CtConstructor(null, clazz);
+ constructor.setBody("super(\"" + providerConfig.name() + "\"," + baseActionElement.asType().toString() + ".class,\"/" + actionsFileLocation + "\");");
+ clazz.addConstructor(constructor);
+ byte[] byteCode = clazz.toBytecode();
+
+ JavaFileObject fo = processingEnv.getFiler().createClassFile(fqn);
+ printInfo("writing " + fo.toUri());
+ outputStream = fo.openOutputStream();
+ outputStream.write(byteCode);
+
+ } finally {
+ if (outputStream != null)
+ outputStream.close();
+ }
+ }
+
+ protected void writeProviderServiceDeclaration() throws IOException {
+ BufferedWriter w = null;
+ try {
+ FileObject fo = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", providerDeclarationLocation);
+ printInfo("writing " + fo.toUri());
+ w = new BufferedWriter(fo.openWriter());
+ w.append("# generated by ").append(getClass().getName()).append("\n").toString();
+ w.append("#").append(new java.util.Date().toString()).append("\n").toString();
+ w.append(providerConfig.fqn());
+ } finally {
+ if (w != null)
+ w.close();
+ }
+ }
+
+ protected void writeActionMapping() throws IOException {
+ BufferedWriter w = null;
+ try {
+ FileObject fo = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", actionsFileLocation);
+ printInfo("writing " + fo.toUri());
+ w = new BufferedWriter(fo.openWriter());
+ actions.store(w, "generated by " + getClass().getName());
+ } finally {
+ if (w != null)
+ w.close();
+ }
+ }
+
+ /**
+ * Obtain the array of names to be used by the annotation
+ *
+ * @param element the dictonnary of values found in a annotation
+ * @return thee array of names detected in the annotation
+ */
+ @SuppressWarnings({"unchecked"})
+ protected String[] getActionNames(AnnotationMirror element) {
+ String[] result = null;
+ for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : element.getElementValues().entrySet()) {
+ ExecutableElement type = entry.getKey();
+ String name = type.getSimpleName().toString();
+
+ if ("multiNames".equals(name)) {
+ List<String> stringList = (List<String>) entry.getValue().accept(getAnnotationValueExtractor(), null);
+ result = stringList.toArray(new String[stringList.size()]);
+ // a multiNames field means
+ break;
+ }
+ if ("actionCommand".equals(name)) {
+ result = new String[]{(String) entry.getValue().accept(getAnnotationValueExtractor(), null)};
+ }
+ }
+
+ return result;
+ }
+
+ protected AnnotationValueVisitor<Object, Void> getAnnotationValueExtractor() {
+ if (annotationValueExtractor == null) {
+ annotationValueExtractor = new SimpleAnnotationValueVisitor6<Object, Void>() {
+
+ @Override
+ protected Object defaultAction(Object o, Void aVoid) {
+ return o;
+ }
+
+ @Override
+ public Object visitArray(List<? extends AnnotationValue> vals, Void aVoid) {
+ List<Object> realVals = new java.util.ArrayList<Object>();
+ for (AnnotationValue val : vals) {
+ realVals.add(val.accept(this, aVoid));
+ }
+ return realVals;
+ }
+ };
+ }
+ return annotationValueExtractor;
+ }
+
+ protected void printWarning(String msg) {
+ System.out.println("[WARN] " + getClass().getName() + " : " + msg);
+ }
+
+ protected void printInfo(String msg) {
+ System.out.println("[INFO] " + getClass().getName() + " : " + msg);
+ }
+
+ protected void printDebug(String msg) {
+ if (verbose) {
+ System.out.println("[DEBUG] " + getClass().getName() + " : " + msg);
+ }
+ }
+}
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-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java 2008-07-31 13:17:21 UTC (rev 806)
@@ -19,6 +19,7 @@
package org.codelutin.jaxx.action;
import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -35,79 +36,79 @@
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
-
+@Inherited
public @interface ActionConfig {
/**
* @return la clef de la commande (doit �tre unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
- public abstract String actionCommand();
+ public String actionCommand();
/**
* @return la clef i18n du texte de l'action, si vide ignor�
* @see javax.swing.Action#NAME
*/
- public abstract String name() default "";
+ String name() default "";
/**
* @return la clef i18n du tooltip de l'action, si vide ignor�
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
- public abstract String shortDescription() default "";
+ String shortDescription() default "";
/**
* @return la clef i18n du texte de l'action, si vide ignor�
* @see javax.swing.Action#LONG_DESCRIPTION
*/
- public abstract String longDescription() default "";
+ String longDescription() default "";
/**
* @return le nom de l'icone associ�, si vide ignor�
* @see javax.swing.Action#SMALL_ICON
*/
- public abstract String smallIcon() default "";
+ String smallIcon() default "";
/**
* @return le nom du grande icone associ�, si vide ignor�
* @see javax.swing.Action#LARGE_ICON_KEY
*/
- public abstract String largeIcon() default "";
+ String largeIcon() default "";
/**
* @return accelerator
* @see javax.swing.Action#ACCELERATOR_KEY
*/
- public abstract String accelerator() default "";
+ String accelerator() default "";
/**
* @return mnemonic key
* @see javax.swing.Action#MNEMONIC_KEY
*/
- public abstract int mnemonic() default '\0';
+ int mnemonic() default '\0';
/**
* @return mnemonic key index
* @see javax.swing.Action#DISPLAYED_MNEMONIC_INDEX_KEY
*/
- public abstract int displayedMnemonicIndex() default '\0';
+ int displayedMnemonicIndex() default '\0';
/**
* @return la valeur par d�faut pour les component selectable
* @see javax.swing.Action#SELECTED_KEY
*/
- public abstract boolean selected() default false;
+ boolean selected() default false;
/**
* @return enabled state
* @see javax.swing.Action#isEnabled()
*/
- public abstract boolean enabled() default true;
+ boolean enabled() default true;
/** @return hideActionText state */
- public abstract boolean hideActionText() default false;
+ boolean hideActionText() default false;
/** @return array of names to be used in actions mapping */
- public abstract String[] multiNames() default {};
+ String[] multiNames() default {};
}
\ No newline at end of file
Added: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderAnnotation.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderAnnotation.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderAnnotation.java 2008-07-31 13:17:21 UTC (rev 806)
@@ -0,0 +1,41 @@
+/**
+ * # #% 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;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Pour enregister un provider d'action.
+ * <p/>
+ * Placer cette annotation sur la classe de base d'action,
+ * <p/>
+ *
+ * @author chemit
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+
+(a)Target(ElementType.TYPE)
+public @interface ActionProviderAnnotation {
+
+ /** @return le nom du provider */
+ String name();
+
+ /** @return le nom qualifie duprovider a generer */
+ String fqn();
+
+}
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-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java 2008-07-31 13:17:21 UTC (rev 806)
@@ -19,6 +19,7 @@
package org.codelutin.jaxx.action;
import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -35,7 +36,7 @@
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
-
+@Inherited
public @interface SelectActionConfig {
/**
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-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java 2008-07-31 13:17:21 UTC (rev 806)
@@ -19,6 +19,7 @@
package org.codelutin.jaxx.action;
import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@@ -33,9 +34,8 @@
* @author chemit
*/
@Retention(RetentionPolicy.RUNTIME)
-
@Target(ElementType.TYPE)
-
+@Inherited
public @interface ToggleActionConfig {
/**
* @return la clef de la commande (doit �tre unique)
Added: trunk/lutinjaxx/jaxx-swing-action/src/main/resources/META-INF/services/javax.annotation.processing.Processor
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/resources/META-INF/services/javax.annotation.processing.Processor (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/resources/META-INF/services/javax.annotation.processing.Processor 2008-07-31 13:17:21 UTC (rev 806)
@@ -0,0 +1 @@
+org.codelutin.jaxx.action.ActionAnnotationProcessing
\ No newline at end of file
Modified: trunk/lutinjaxx/jaxx-swing-tab/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing-tab/pom.xml 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/jaxx-swing-tab/pom.xml 2008-07-31 13:17:21 UTC (rev 806)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
</parent>
<artifactId>jaxx-swing-tab</artifactId>
<name>jaxx-swing-tab</name>
<packaging>jar</packaging>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
<description>Jaxx lutin library swing tab extension</description>
<build>
Modified: trunk/lutinjaxx/maven/pom.xml
===================================================================
--- trunk/lutinjaxx/maven/pom.xml 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/maven/pom.xml 2008-07-31 13:17:21 UTC (rev 806)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
</parent>
<artifactId>maven-jaxx-plugin</artifactId>
@@ -63,7 +63,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
<description>
Maven 2 plugin to generate java source from ui interface definitions
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-07-31 13:17:21 UTC (rev 806)
@@ -19,12 +19,16 @@
import java.io.File;
import java.io.IOException;
-/** @author chemit */
+/**
+ * @author chemit
+ * @deprecated Now we use the {@link org.codelutin.jaxx.action.ActionAnnotationProcessing}
+ */
public abstract class AbstractActionGeneratorMojo extends AbstractJaxxMojo {
/**
* @description Nom du fichier d'actions � g�n�rer.
- * @parameter expression="${jaxx.actionsFile}" default-value="/jaxx/${project.artifactId}-actions.properties"
+ * @parameter expression="${jaxx.actionsFile}"
+ * @required
*/
protected String actionsFile;
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-07-31 13:17:21 UTC (rev 806)
@@ -38,6 +38,7 @@
* @author chemit
* @goal generate-actions-properties
* @phase process-classes
+ * @deprecated Now we use the {@link org.codelutin.jaxx.action.ActionAnnotationProcessing}
*/
public class ActionGeneratorMojo extends AbstractActionGeneratorMojo {
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java 2008-07-31 13:17:21 UTC (rev 806)
@@ -32,6 +32,7 @@
* @author chemit
* @goal generate-actions-provider
* @phase process-resources
+ * @deprecated Now we use the {@link org.codelutin.jaxx.action.ActionAnnotationProcessing}
*/
public class ActionProviderGeneratorMojo extends AbstractActionGeneratorMojo {
Modified: trunk/lutinjaxx/pom.xml
===================================================================
--- trunk/lutinjaxx/pom.xml 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/pom.xml 2008-07-31 13:17:21 UTC (rev 806)
@@ -39,7 +39,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
<name>pom</name>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
<description>Jaxx lutin library main pom</description>
<inceptionYear>2008</inceptionYear>
@@ -65,7 +65,7 @@
<properties>
<!-- current version -->
- <current.version>0.2-SNAPSHOT</current.version>
+ <current.version>0.3</current.version>
<!-- id du projet du labs -->
<labs.id>38</labs.id>
Modified: trunk/lutinjaxx/runtime/pom.xml
===================================================================
--- trunk/lutinjaxx/runtime/pom.xml 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/runtime/pom.xml 2008-07-31 13:17:21 UTC (rev 806)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
</parent>
<artifactId>runtime</artifactId>
<name>runtime</name>
<packaging>jar</packaging>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
<description>Jaxx lutin library runtime</description>
<build>
Modified: trunk/lutinjaxx/util/pom.xml
===================================================================
--- trunk/lutinjaxx/util/pom.xml 2008-07-28 10:16:27 UTC (rev 805)
+++ trunk/lutinjaxx/util/pom.xml 2008-07-31 13:17:21 UTC (rev 806)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
</parent>
<artifactId>util</artifactId>
<name>util</name>
<packaging>jar</packaging>
- <version>0.2-SNAPSHOT</version>
+ <version>0.3</version>
<description>Jaxx lutin library utility</description>
<build>
1
0
r805 - trunk/lutinjaxx/core/src/main/java/jaxx/tags
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
28 Jul '08
Author: tchemit
Date: 2008-07-28 10:16:27 +0000 (Mon, 28 Jul 2008)
New Revision: 805
Modified:
trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java
Log:
rollback
Modified: trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java 2008-07-28 10:16:16 UTC (rev 804)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java 2008-07-28 10:16:27 UTC (rev 805)
@@ -52,12 +52,12 @@
if (tagHandler instanceof DefaultComponentHandler) {
containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate();
} else {
- tagHandler = TagManager.getTagHandler(getBeanClass());
+ /*tagHandler = TagManager.getTagHandler(getBeanClass());
if (tagHandler instanceof DefaultComponentHandler) {
containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate();
- } else {
- log.warn("could not find componentHandler for " + getBeanClass());
- }
+ } else {*/
+ log.warn("could not find componentHandler for " + getBeanClass());
+ //}
}
}
}
1
0
r804 - in trunk/lutinjaxx: core/src/main/java/jaxx/compiler maven/src/main/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
28 Jul '08
Author: tchemit
Date: 2008-07-28 10:16:16 +0000 (Mon, 28 Jul 2008)
New Revision: 804
Modified:
trunk/lutinjaxx/core/src/main/java/jaxx/compiler/CompilerOptions.java
trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
Log:
add verbose property to CompilerOption to make possible from compiler to debug
Modified: trunk/lutinjaxx/core/src/main/java/jaxx/compiler/CompilerOptions.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/compiler/CompilerOptions.java 2008-07-28 10:15:43 UTC (rev 803)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/compiler/CompilerOptions.java 2008-07-28 10:16:16 UTC (rev 804)
@@ -13,6 +13,7 @@
private String javacOpts;
private boolean keepJavaFiles;
private boolean optimize;
+ private boolean verbose;
/**
* Returns the target directory, generally specified with the "-d" option on the command line.
@@ -21,7 +22,7 @@
* @see #setTargetDirectory
*/
public File getJavacTargetDirectory() {
- if (javacTargetDirectory==null) {
+ if (javacTargetDirectory == null) {
// to use the old way : if javacTargetDirectory not specified,
// use same directory as targetDirectory (says where the java sources
// are generated)
@@ -29,6 +30,7 @@
}
return javacTargetDirectory;
}
+
/**
* Returns the target directory, generally specified with the "-d" option on the command line.
*
@@ -138,4 +140,12 @@
public void setOptimize(boolean optimize) {
this.optimize = optimize;
}
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
}
Modified: trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-07-28 10:15:43 UTC (rev 803)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-07-28 10:16:16 UTC (rev 804)
@@ -1797,8 +1797,8 @@
while (filesIterator.hasNext()) {
File file = filesIterator.next();
String className = classNamesIterator.next();
- if (log.isDebugEnabled()) {
- log.debug("compile first pass for " + className);
+ if (options.isVerbose()) {
+ log.info("compile first pass for " + className);
}
if (symbolTables.get(file) == null) {
compiled = true;
@@ -1838,18 +1838,21 @@
JAXXCompiler compiler = compilers.get(className);
if (compiler == null)
throw new CompilerException("Internal error: could not find compiler for " + className + " during second pass");
- if (log.isDebugEnabled()) {
- log.debug("runInitializers for " + className);
+ if (options.isVerbose()) {
+
+ log.info("runInitializers for " + className);
}
if (!compiler.failed) {
compiler.runInitializers();
}
- if (log.isDebugEnabled()) {
- log.debug("compile second pass for " + className);
+ if (options.isVerbose()) {
+
+ log.info("compile second pass for " + className);
}
compiler.compileSecondPass();
- if (log.isDebugEnabled()) {
- log.debug("done with result [" + !compiler.failed + "] for " + className);
+ if (options.isVerbose()) {
+
+ log.info("done with result [" + !compiler.failed + "] for " + className);
}
if (!compiler.failed) {
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-07-28 10:15:43 UTC (rev 803)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-07-28 10:16:16 UTC (rev 804)
@@ -108,6 +108,7 @@
result.setOptimize(optimize);
result.setJavacTargetDirectory(outClass);
result.setTargetDirectory(outJava);
+ result.setVerbose(verbose);
return result;
}
1
0
r803 - trunk/lutinjaxx/core/src/main/java/jaxx/tags
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
28 Jul '08
Author: tchemit
Date: 2008-07-28 10:15:43 +0000 (Mon, 28 Jul 2008)
New Revision: 803
Modified:
trunk/lutinjaxx/core/src/main/java/jaxx/tags/TagManager.java
Log:
add log
Modified: trunk/lutinjaxx/core/src/main/java/jaxx/tags/TagManager.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/tags/TagManager.java 2008-07-28 10:14:40 UTC (rev 802)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/tags/TagManager.java 2008-07-28 10:15:43 UTC (rev 803)
@@ -9,6 +9,8 @@
import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.lang.reflect.Constructor;
@@ -20,6 +22,9 @@
/** Manages TagHandlers, including automatically compiling .jaxx files corresponding to class tags. */
public class TagManager {
+ /** log */
+ protected static final Log log = LogFactory.getLog(TagManager.class);
+
/**
* Namespace for JAXX's non-class tags, such as <script;>. The namespace normally does not
* need to be specified but can be used to resolve ambiguities.
@@ -104,6 +109,9 @@
throw new IllegalArgumentException("handler class must be a subclass of DefaultObjectHandler");
}
registeredBeans.put(beanClass, handler);
+ if (log.isDebugEnabled()) {
+ log.debug(beanClass + " : " + handler);
+ }
String name = beanClass.getName();
int dotPos = name.lastIndexOf(".");
String namespace = name.substring(0, dotPos + 1) + "*";
@@ -152,6 +160,9 @@
namespace = "*";
}
//System.out.println("registerTag "+namespace+" : "+tag+" : "+handler);
+ if (log.isDebugEnabled()) {
+ log.debug(tag + " : " + handler);
+ }
registeredTags.put(new QName(namespace, tag), handler);
registerDefaultNamespace(tag, namespace);
}
1
0
r802 - trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
28 Jul '08
Author: tchemit
Date: 2008-07-28 10:14:40 +0000 (Mon, 28 Jul 2008)
New Revision: 802
Modified:
trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/SwingInitializer.java
Log:
fix bug : tagHandler is not always found...
reformat
log
Modified: trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/SwingInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/SwingInitializer.java 2008-07-28 10:14:30 UTC (rev 801)
+++ trunk/lutinjaxx/jaxx-swing/src/main/java/jaxx/tags/swing/SwingInitializer.java 2008-07-28 10:14:40 UTC (rev 802)
@@ -10,10 +10,11 @@
import jaxx.runtime.swing.JAXXButtonGroup;
import jaxx.runtime.swing.JAXXComboBox;
import jaxx.runtime.swing.JAXXList;
+import jaxx.runtime.swing.JAXXTab;
import jaxx.runtime.swing.JAXXTree;
import jaxx.runtime.swing.Table;
-import jaxx.runtime.swing.JAXXTab;
import jaxx.spi.Initializer;
+import jaxx.tags.DefaultComponentHandler;
import jaxx.tags.DefaultObjectHandler;
import jaxx.tags.TagManager;
import jaxx.types.KeyStrokeConverter;
@@ -24,6 +25,7 @@
import java.beans.Introspector;
public class SwingInitializer implements Initializer {
+
public void initialize() {
String[] searchPath = Introspector.getBeanInfoSearchPath();
String[] newSearchPath = new String[searchPath.length + 1];
@@ -33,6 +35,11 @@
TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+ // Begin Try to fix bug when component handler is not found, but this is not this...
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JButton.class), DefaultComponentHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTextField.class), JTextComponentHandler.class);
+ // End Try to fix bug when component handler is not found, but this is not this...
+
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
@@ -75,7 +82,7 @@
TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler());
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTab.class), JAXXTabHandler.class);
-
+
TypeManager.registerTypeConverter(KeyStroke.class, new KeyStrokeConverter());
}
}
\ No newline at end of file
1
0
r801 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
28 Jul '08
Author: tchemit
Date: 2008-07-28 10:14:30 +0000 (Mon, 28 Jul 2008)
New Revision: 801
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java
Log:
javadoc + add toString method on MyAbstractAction
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-07-28 09:13:35 UTC (rev 800)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-07-28 10:14:30 UTC (rev 801)
@@ -156,7 +156,7 @@
}
// -----------------------------------------------------------------------------
- // --- super classe delegate methods -------------------------------------------
+ // --- super class delegate methods -------------------------------------------
// -----------------------------------------------------------------------------
@Override
@@ -239,5 +239,15 @@
return super.clone();
}
-
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append(super.toString());
+ if (hasDelegate()) {
+ sb.append("[delegate: ").append(delegate.toString()).append("]");
+ } else {
+ sb.append("<key:").append(getActionName()).append(">");
+ }
+ return sb.toString();
+ }
}
1
0
r800 - trunk/lutinjaxx/core/src/main/java/jaxx/tags
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
by tchemit@users.labs.libre-entreprise.org 28 Jul '08
28 Jul '08
Author: tchemit
Date: 2008-07-28 09:13:35 +0000 (Mon, 28 Jul 2008)
New Revision: 800
Modified:
trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java
Log:
fix bug : tagHandler is not always found...
reformat
log
Modified: trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java 2008-07-25 21:23:01 UTC (rev 799)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/tags/DefaultComponentHandler.java 2008-07-28 09:13:35 UTC (rev 800)
@@ -10,6 +10,8 @@
import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;
import java.awt.Component;
@@ -20,13 +22,17 @@
import java.beans.IntrospectionException;
import java.io.IOException;
import java.lang.reflect.Field;
+import java.util.Arrays;
import java.util.List;
-import java.util.Arrays;
public class DefaultComponentHandler extends DefaultObjectHandler {
+ /** log */
+ protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class);
+
private String containerDelegate;
- private static final List<String> I18N_ATTRIBUTES = Arrays.asList("text","title","toolTipText");
+ private static final List<String> I18N_ATTRIBUTES = Arrays.asList("text", "title", "toolTipText");
+
public DefaultComponentHandler(ClassDescriptor beanClass) {
super(beanClass);
ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Component.class);
@@ -46,7 +52,12 @@
if (tagHandler instanceof DefaultComponentHandler) {
containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate();
} else {
- System.out.println("could not find componentHandler for "+getBeanClass());
+ tagHandler = TagManager.getTagHandler(getBeanClass());
+ if (tagHandler instanceof DefaultComponentHandler) {
+ containerDelegate = ((DefaultComponentHandler) tagHandler).getContainerDelegate();
+ } else {
+ log.warn("could not find componentHandler for " + getBeanClass());
+ }
}
}
}
@@ -194,7 +205,7 @@
// ajout du support i18n
if (I18N_ATTRIBUTES.contains(name)) {
if (valueCode.contains("_(") || valueCode.contains(")")) {
- compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '"+name+"' in component '"+id+"'");
+ compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '" + name + "' in component '" + id + "'");
} else {
valueCode = "_(" + valueCode + ")";
}
1
0
r799 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: factory initializer
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 21:23:01 +0000 (Fri, 25 Jul 2008)
New Revision: 799
Added:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java
Removed:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java
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/SelectActionConfigInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
Log:
rename ActionInitializer to ActionConfigurationResolver
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -23,11 +23,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.jaxx.action.MyAbstractAction;
-import org.codelutin.jaxx.action.initializer.AbstractActionInitializer;
-import org.codelutin.jaxx.action.initializer.ActionConfigInitializer;
-import org.codelutin.jaxx.action.initializer.ActionInitializer;
-import org.codelutin.jaxx.action.initializer.SelectActionConfigInitializer;
-import org.codelutin.jaxx.action.initializer.ToggleActionConfigInitializer;
+import org.codelutin.jaxx.action.initializer.AbstractActionConfigurationResolver;
+import org.codelutin.jaxx.action.initializer.ActionConfigConfigurationResolver;
+import org.codelutin.jaxx.action.initializer.ActionConfigurationResolver;
+import org.codelutin.jaxx.action.initializer.SelectActionConfigConfigurationResolver;
+import org.codelutin.jaxx.action.initializer.ToggleActionConfigConfigurationResolver;
import javax.swing.AbstractButton;
import javax.swing.Action;
@@ -68,22 +68,22 @@
/** dictionary of instanciated actions */
private Map<String, A> cache;
- protected final ActionConfigInitializer actionConfigInitializer;
- protected final ToggleActionConfigInitializer toggleActionConfigInitializer;
- protected final SelectActionConfigInitializer selectActionConfigInitializer;
+ protected final ActionConfigConfigurationResolver actionConfigInitializer;
+ protected final ToggleActionConfigConfigurationResolver toggleActionConfigInitializer;
+ protected final SelectActionConfigConfigurationResolver selectActionConfigInitializer;
- protected List<AbstractActionInitializer> configurationResolvers;
+ protected List<AbstractActionConfigurationResolver> configurationResolvers;
protected AbstractActionFactory(Class<A> baseImpl) {
this.baseImpl = baseImpl;
this.impls = init();
this.cache = new TreeMap<String, A>();
- this.configurationResolvers = new java.util.ArrayList<AbstractActionInitializer>();
+ this.configurationResolvers = new java.util.ArrayList<AbstractActionConfigurationResolver>();
- this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigInitializer.class);
- this.actionConfigInitializer = registerInitializer(ActionConfigInitializer.class);
- this.selectActionConfigInitializer = registerInitializer(SelectActionConfigInitializer.class);
+ this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigConfigurationResolver.class);
+ this.actionConfigInitializer = registerInitializer(ActionConfigConfigurationResolver.class);
+ this.selectActionConfigInitializer = registerInitializer(SelectActionConfigConfigurationResolver.class);
}
public Class<A> getBaseImpl() {
@@ -178,33 +178,33 @@
}
// recherche de l'annotation de configuration
- ActionInitializer<?, ?> initializer = resolveActionConfiguration(result);
+ ActionConfigurationResolver<?, ?> configurationResolver = resolveActionConfiguration(result);
- if (initializer != null) {
- initializer.applyConfiguration(component, result);
+ if (configurationResolver != null) {
+ configurationResolver.applyConfiguration(component, result);
}
try {
- if (initializer != null) {
- if (AbstractButton.class.isAssignableFrom(initializer.getComponentImpl())) {
- finalizeNewAction((AbstractButton) component, result, initializer);
+ if (configurationResolver != null) {
+ if (AbstractButton.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
+ finalizeNewAction((AbstractButton) component, result, configurationResolver);
}
- if (JComboBox.class.isAssignableFrom(initializer.getComponentImpl())) {
- finalizeNewAction((JComboBox) component, result, initializer);
+ if (JComboBox.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
+ finalizeNewAction((JComboBox) component, result, configurationResolver);
}
return result;
}
if (component == null || component instanceof AbstractButton) {
- finalizeNewAction((AbstractButton) component, result, initializer);
+ finalizeNewAction((AbstractButton) component, result, configurationResolver);
return result;
}
if (component instanceof JComboBox) {
- finalizeNewAction((JComboBox) component, result, initializer);
+ finalizeNewAction((JComboBox) component, result, configurationResolver);
}
} finally {
// save result in cache
@@ -280,14 +280,14 @@
}
/**
- * @param component le button o� rattacher l'action
- * @param action action
- * @param initializer initializer
+ * @param component le button o� rattacher l'action
+ * @param action action
+ * @param configurationResolver initializer
*/
- protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionInitializer<?, ?> initializer) {
+ protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
- if (initializer == null) {
- // no initializer matching,
+ if (configurationResolver == null) {
+ // no configurationResolver matching,
if (component != null) {
action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
@@ -323,13 +323,13 @@
}
/**
- * @param component le select box o� rattacher l'action
- * @param action action
- * @param initializer initializer
+ * @param component le select box o� rattacher l'action
+ * @param action action
+ * @param configurationResolver initializer
*/
- protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionInitializer<?, ?> initializer) {
+ protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
- if (initializer == null) {
+ if (configurationResolver == null) {
action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
//result.putValue("selectedIndex", component.getSelectedIndex());
@@ -337,8 +337,8 @@
}
- protected ActionInitializer resolveActionConfiguration(MyAbstractAction action) {
- for (ActionInitializer resolver : configurationResolvers) {
+ protected ActionConfigurationResolver resolveActionConfiguration(MyAbstractAction action) {
+ for (ActionConfigurationResolver resolver : configurationResolvers) {
if (resolver.resolveConfiguration(action) != null) {
return resolver;
}
@@ -346,7 +346,7 @@
return null;
}
- protected <I extends AbstractActionInitializer> I registerInitializer(Class<I> initizalizer) {
+ protected <I extends AbstractActionConfigurationResolver> I registerInitializer(Class<I> initizalizer) {
try {
I instance = initizalizer.newInstance();
configurationResolvers.add(instance);
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java (from rev 797, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,72 @@
+/**
+ * # #% 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 org.codelutin.jaxx.action.MyAbstractAction;
+
+import javax.swing.JComponent;
+
+/**
+ * Common abstract class of a resolver of action configuration.
+ * <p/>
+ * The class implements the logic of research of the configuration annotation.
+ *
+ * @author chemit
+ */
+public abstract class AbstractActionConfigurationResolver<A extends java.lang.annotation.Annotation, C extends JComponent> implements ActionConfigurationResolver<A, C> {
+
+ /** the type of configuration's annotation */
+ protected final Class<A> annotationImpl;
+
+ /** the type of component that can fire an action */
+ protected final Class<C> componentImpl;
+
+ /**
+ * The typed method (on component) to apply configuration on the action and component.
+ *
+ * @param component the component which fires the action
+ * @param action the given action
+ * @return the configuration's annotation
+ */
+ protected abstract A applyConfiguration0(C component, MyAbstractAction action);
+
+ protected AbstractActionConfigurationResolver(Class<A> annotationImpl, Class<C> componentImpl) {
+ this.annotationImpl = annotationImpl;
+ this.componentImpl = componentImpl;
+ }
+
+ public A resolveConfiguration(MyAbstractAction action) {
+ if (action.hasDelegate()) {
+ return resolveConfiguration(action.getDelegate());
+ }
+ return action.getClass().getAnnotation(annotationImpl);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public A applyConfiguration(JComponent component, MyAbstractAction action) {
+ if (component != null && componentImpl.isAssignableFrom(component.getClass()))
+ return applyConfiguration0((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/AbstractActionInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -1,72 +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 org.codelutin.jaxx.action.MyAbstractAction;
-
-import javax.swing.JComponent;
-
-/**
- * Common abstract class of a resolver of action configuration.
- * <p/>
- * The class implements the logic of research of the configuration annotation.
- *
- * @author chemit
- */
-public abstract class AbstractActionInitializer<A extends java.lang.annotation.Annotation, C extends JComponent> implements ActionInitializer<A, C> {
-
- /** the type of configuration's annotation */
- protected final Class<A> annotationImpl;
-
- /** the type of component that can fire an action */
- protected final Class<C> componentImpl;
-
- /**
- * The typed method (on component) to apply configuration on the action and component.
- *
- * @param component the component which fires the action
- * @param action the given action
- * @return the configuration's annotation
- */
- protected abstract A applyConfiguration0(C component, MyAbstractAction action);
-
- protected AbstractActionInitializer(Class<A> annotationImpl, Class<C> componentImpl) {
- this.annotationImpl = annotationImpl;
- this.componentImpl = componentImpl;
- }
-
- public A resolveConfiguration(MyAbstractAction action) {
- if (action.hasDelegate()) {
- return resolveConfiguration(action.getDelegate());
- }
- return action.getClass().getAnnotation(annotationImpl);
- }
-
- @SuppressWarnings({"unchecked"})
- public A applyConfiguration(JComponent component, MyAbstractAction action) {
- if (component != null && componentImpl.isAssignableFrom(component.getClass()))
- return applyConfiguration0((C) component, action);
-
- return null;
- }
-
- public Class<A> getAnnotationImpl() {
- return annotationImpl;
- }
-
- public Class<C> getComponentImpl() {
- return componentImpl;
- }
-}
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java (from rev 797, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,69 @@
+/**
+ * # #% 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 static org.codelutin.i18n.I18n._;
+import org.codelutin.jaxx.action.ActionConfig;
+import org.codelutin.jaxx.action.MyAbstractAction;
+
+import javax.swing.AbstractButton;
+import javax.swing.Action;
+
+/**
+ * Implementation of configuration's resolver for annotation {@link ActionConfig}
+ *
+ * @author chemit
+ */
+public class ActionConfigConfigurationResolver extends AbstractActionConfigurationResolver<ActionConfig, AbstractButton> {
+
+ public ActionConfigConfigurationResolver() {
+ super(ActionConfig.class, AbstractButton.class);
+ }
+
+ protected ActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) {
+ ActionConfig anno = resolveConfiguration(action);
+ if (anno == null) {
+ return null;
+ }
+ // inject les donn�es
+ if (!anno.name().isEmpty()) {
+ //System.out.println("found action with name : " + anno.name());
+ action.putValue(Action.NAME, _(anno.name()));
+ }
+ //if (!anno.shortDescription().isEmpty()) {
+ action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription()));
+ //}
+ if (!anno.smallIcon().isEmpty()) {
+ action.putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon()));
+ }
+ if (anno.mnemonic() != '\0') {
+ action.putValue(Action.MNEMONIC_KEY, anno.mnemonic());
+ } else if (component != null) {
+ action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
+ }
+ //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator());
+
+ if (component == null) {
+ action.putValue("hideActionText", anno.hideActionText());
+ } else {
+ boolean actionText = component.getHideActionText();
+ action.putValue("hideActionText", anno.hideActionText() || actionText);
+ }
+ action.putValue(Action.SELECTED_KEY, anno.selected());
+ action.setEnabled(anno.enabled());
+
+ return anno;
+ }
+}
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -1,69 +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 static org.codelutin.i18n.I18n._;
-import org.codelutin.jaxx.action.ActionConfig;
-import org.codelutin.jaxx.action.MyAbstractAction;
-
-import javax.swing.AbstractButton;
-import javax.swing.Action;
-
-/**
- * Implementation of configuration's resolver for annotation {@link ActionConfig}
- *
- * @author chemit
- */
-public class ActionConfigInitializer extends AbstractActionInitializer<ActionConfig, AbstractButton> {
-
- public ActionConfigInitializer() {
- super(ActionConfig.class, AbstractButton.class);
- }
-
- protected ActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) {
- ActionConfig anno = resolveConfiguration(action);
- if (anno == null) {
- return null;
- }
- // inject les donn�es
- if (!anno.name().isEmpty()) {
- //System.out.println("found action with name : " + anno.name());
- action.putValue(Action.NAME, _(anno.name()));
- }
- //if (!anno.shortDescription().isEmpty()) {
- action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription()));
- //}
- if (!anno.smallIcon().isEmpty()) {
- action.putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon()));
- }
- if (anno.mnemonic() != '\0') {
- action.putValue(Action.MNEMONIC_KEY, anno.mnemonic());
- } else if (component != null) {
- action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
- }
- //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator());
-
- if (component == null) {
- action.putValue("hideActionText", anno.hideActionText());
- } else {
- boolean actionText = component.getHideActionText();
- action.putValue("hideActionText", anno.hideActionText() || actionText);
- }
- action.putValue(Action.SELECTED_KEY, anno.selected());
- action.setEnabled(anno.enabled());
-
- return anno;
- }
-}
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java (from rev 797, 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/ActionConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,54 @@
+/**
+ * # #% 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 org.codelutin.jaxx.action.MyAbstractAction;
+
+import javax.swing.JComponent;
+
+/**
+ * The contract to be realized to resolve an {@link MyAbstractAction} configuration.
+ * <p/>
+ * Configuration is done by a Annotation of type {@link A} placed on the action class.
+ * <p/>
+ * If the instanciated action box the real action, we should always search on the boxed action.
+ * <p/>
+ * Moreover, a action can only be fired by a certain type of component (for example a Button or a ComboBox), the class
+ * of the component type is given by the {@link C} class.
+ *
+ * @author chemit
+ */
+public interface ActionConfigurationResolver<A extends java.lang.annotation.Annotation, C extends JComponent> {
+ /**
+ * Search the annotation that configure the given action (or the boxed action).
+ *
+ * @param action current action
+ * @return the configuration of the action
+ */
+ A resolveConfiguration(MyAbstractAction action);
+
+ /**
+ * @param component widget that requires the action
+ * @param action given action
+ * @return the configuration of the action
+ */
+ A applyConfiguration(JComponent component, MyAbstractAction action);
+
+ /** @return the configuration annotation dealed by this resolver */
+ Class<A> getAnnotationImpl();
+
+ /** @return the class of the component which can fired the action */
+ Class<C> getComponentImpl();
+}
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-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -1,54 +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 org.codelutin.jaxx.action.MyAbstractAction;
-
-import javax.swing.JComponent;
-
-/**
- * The contract to be realized to resolve an {@link MyAbstractAction} configuration.
- * <p/>
- * Configuration is done by a Annotation of type {@link A} placed on the action class.
- * <p/>
- * If the instanciated action box the real action, we should always search on the boxed action.
- * <p/>
- * Moreover, a action can only be fired by a certain type of component (for example a Button or a ComboBox), the class
- * of the component type is given by the {@link C} class.
- *
- * @author chemit
- */
-public interface ActionInitializer<A extends java.lang.annotation.Annotation, C extends JComponent> {
- /**
- * Search the annotation that configure the given action (or the boxed action).
- *
- * @param action current action
- * @return the configuration of the action
- */
- A resolveConfiguration(MyAbstractAction action);
-
- /**
- * @param component widget that requires the action
- * @param action given action
- * @return the configuration of the action
- */
- A applyConfiguration(JComponent component, MyAbstractAction action);
-
- /** @return the configuration annotation dealed by this resolver */
- Class<A> getAnnotationImpl();
-
- /** @return the class of the component which can fired the action */
- Class<C> getComponentImpl();
-}
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java (from rev 797, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,55 @@
+/**
+ * # #% 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 static org.codelutin.i18n.I18n._;
+import org.codelutin.jaxx.action.MyAbstractAction;
+import org.codelutin.jaxx.action.SelectActionConfig;
+
+import javax.swing.Action;
+import javax.swing.JComboBox;
+
+/**
+ * Implementation of configuration's resolver for annotation {@link SelectActionConfig}
+ *
+ * @author chemit
+ */
+public class SelectActionConfigConfigurationResolver extends AbstractActionConfigurationResolver<SelectActionConfig, JComboBox> {
+
+ public SelectActionConfigConfigurationResolver() {
+ super(SelectActionConfig.class, JComboBox.class);
+ }
+
+ protected SelectActionConfig applyConfiguration0(JComboBox component, MyAbstractAction action) {
+ SelectActionConfig anno = resolveConfiguration(action);
+ if (anno == null) {
+ return null;
+ }
+ // inject les donn�es
+ if (!anno.name().isEmpty()) {
+ action.putValue(Action.NAME, _(anno.name()));
+ }
+ if (!anno.shortDescription().isEmpty()) {
+ action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription()));
+ } else {
+ action.putValue(Action.SHORT_DESCRIPTION, _(component.getToolTipText()));
+ }
+ action.putValue("selectedIndex", anno.selectedIndex());
+ //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator());
+ action.setEnabled(anno.enabled());
+
+ return anno;
+ }
+}
\ No newline at end of file
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -1,55 +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 static org.codelutin.i18n.I18n._;
-import org.codelutin.jaxx.action.MyAbstractAction;
-import org.codelutin.jaxx.action.SelectActionConfig;
-
-import javax.swing.Action;
-import javax.swing.JComboBox;
-
-/**
- * Implementation of configuration's resolver for annotation {@link SelectActionConfig}
- *
- * @author chemit
- */
-public class SelectActionConfigInitializer extends AbstractActionInitializer<SelectActionConfig, JComboBox> {
-
- public SelectActionConfigInitializer() {
- super(SelectActionConfig.class, JComboBox.class);
- }
-
- protected SelectActionConfig applyConfiguration0(JComboBox component, MyAbstractAction action) {
- SelectActionConfig anno = resolveConfiguration(action);
- if (anno == null) {
- return null;
- }
- // inject les donn�es
- if (!anno.name().isEmpty()) {
- action.putValue(Action.NAME, _(anno.name()));
- }
- if (!anno.shortDescription().isEmpty()) {
- action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription()));
- } else {
- action.putValue(Action.SHORT_DESCRIPTION, _(component.getToolTipText()));
- }
- action.putValue("selectedIndex", anno.selectedIndex());
- //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator());
- action.setEnabled(anno.enabled());
-
- return anno;
- }
-}
\ No newline at end of file
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java (from rev 797, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -0,0 +1,81 @@
+/**
+ * # #% 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 static org.codelutin.i18n.I18n._;
+import org.codelutin.jaxx.action.MyAbstractAction;
+import org.codelutin.jaxx.action.ToggleActionConfig;
+
+import javax.swing.AbstractButton;
+import javax.swing.Action;
+
+/**
+ * Implementation of configuration's resolver for annotation {@link ToggleActionConfig}
+ *
+ * @author chemit
+ */
+public class ToggleActionConfigConfigurationResolver extends AbstractActionConfigurationResolver<ToggleActionConfig, AbstractButton> {
+
+ public ToggleActionConfigConfigurationResolver() {
+ super(ToggleActionConfig.class, AbstractButton.class);
+ }
+
+ protected ToggleActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) {
+ ToggleActionConfig anno = resolveConfiguration(action);
+ if (anno == null) {
+ return null;
+ }
+ // inject les donn�es
+ if (!anno.name().isEmpty()) {
+ //System.out.println("found action with name : " + anno.name());
+ action.putValue(Action.NAME, _(anno.name()));
+ }
+ if (!anno.name2().isEmpty()) {
+ //System.out.println("found action with name2 : " + anno.name2());
+ action.putValue(Action.NAME + "2", _(anno.name2()));
+ }
+
+ if (!anno.shortDescription().isEmpty()) {
+ action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription()));
+ }
+ if (!anno.shortDescription2().isEmpty()) {
+ action.putValue(Action.SHORT_DESCRIPTION + "2", _(anno.shortDescription2()));
+ }
+
+ if (!anno.smallIcon().isEmpty()) {
+ action.putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon()));
+ }
+ if (!anno.smallIcon2().isEmpty()) {
+ action.putValue(Action.SMALL_ICON + "2", org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon2()));
+ }
+
+ if (anno.mnemonic() != '\0') {
+ action.putValue(Action.MNEMONIC_KEY, anno.mnemonic());
+ } else if (component != null) {
+ action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
+ }
+ if (anno.mnemonic2() != '\0') {
+ action.putValue(Action.MNEMONIC_KEY + "2", anno.mnemonic2());
+ }
+ //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator());
+
+
+ action.putValue("hideActionText", anno.hideActionText());
+ action.putValue(Action.SELECTED_KEY, anno.selected());
+ action.setEnabled(anno.enabled());
+
+ return anno;
+ }
+}
\ No newline at end of file
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java 2008-07-25 21:21:46 UTC (rev 798)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java 2008-07-25 21:23:01 UTC (rev 799)
@@ -1,81 +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 static org.codelutin.i18n.I18n._;
-import org.codelutin.jaxx.action.MyAbstractAction;
-import org.codelutin.jaxx.action.ToggleActionConfig;
-
-import javax.swing.AbstractButton;
-import javax.swing.Action;
-
-/**
- * Implementation of configuration's resolver for annotation {@link ToggleActionConfig}
- *
- * @author chemit
- */
-public class ToggleActionConfigInitializer extends AbstractActionInitializer<ToggleActionConfig, AbstractButton> {
-
- public ToggleActionConfigInitializer() {
- super(ToggleActionConfig.class, AbstractButton.class);
- }
-
- protected ToggleActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) {
- ToggleActionConfig anno = resolveConfiguration(action);
- if (anno == null) {
- return null;
- }
- // inject les donn�es
- if (!anno.name().isEmpty()) {
- //System.out.println("found action with name : " + anno.name());
- action.putValue(Action.NAME, _(anno.name()));
- }
- if (!anno.name2().isEmpty()) {
- //System.out.println("found action with name2 : " + anno.name2());
- action.putValue(Action.NAME + "2", _(anno.name2()));
- }
-
- if (!anno.shortDescription().isEmpty()) {
- action.putValue(Action.SHORT_DESCRIPTION, _(anno.shortDescription()));
- }
- if (!anno.shortDescription2().isEmpty()) {
- action.putValue(Action.SHORT_DESCRIPTION + "2", _(anno.shortDescription2()));
- }
-
- if (!anno.smallIcon().isEmpty()) {
- action.putValue(Action.SMALL_ICON, org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon()));
- }
- if (!anno.smallIcon2().isEmpty()) {
- action.putValue(Action.SMALL_ICON + "2", org.codelutin.jaxx.util.UIHelper.createImageIcon(anno.smallIcon2()));
- }
-
- if (anno.mnemonic() != '\0') {
- action.putValue(Action.MNEMONIC_KEY, anno.mnemonic());
- } else if (component != null) {
- action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
- }
- if (anno.mnemonic2() != '\0') {
- action.putValue(Action.MNEMONIC_KEY + "2", anno.mnemonic2());
- }
- //TODO Convert it from String action.putValue(Action.ACCELERATOR_KEY, anno.accelerator());
-
-
- action.putValue("hideActionText", anno.hideActionText());
- action.putValue(Action.SELECTED_KEY, anno.selected());
- action.setEnabled(anno.enabled());
-
- return anno;
- }
-}
\ No newline at end of file
1
0
r798 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 21:21:46 +0000 (Fri, 25 Jul 2008)
New Revision: 798
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
Log:
ActionInitializer must be search annotation of instance of Action, and not on his class since Action could not be holder of configuration (with delegation)...
add javadoc.
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 21:20:58 UTC (rev 797)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 21:21:46 UTC (rev 798)
@@ -29,7 +29,6 @@
import org.codelutin.jaxx.action.initializer.SelectActionConfigInitializer;
import org.codelutin.jaxx.action.initializer.ToggleActionConfigInitializer;
-import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
import javax.swing.Icon;
@@ -73,14 +72,14 @@
protected final ToggleActionConfigInitializer toggleActionConfigInitializer;
protected final SelectActionConfigInitializer selectActionConfigInitializer;
- protected List<AbstractActionInitializer> registredInitializers;
+ protected List<AbstractActionInitializer> configurationResolvers;
protected AbstractActionFactory(Class<A> baseImpl) {
this.baseImpl = baseImpl;
this.impls = init();
this.cache = new TreeMap<String, A>();
- this.registredInitializers = new java.util.ArrayList<AbstractActionInitializer>();
+ this.configurationResolvers = new java.util.ArrayList<AbstractActionInitializer>();
this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigInitializer.class);
this.actionConfigInitializer = registerInitializer(ActionConfigInitializer.class);
@@ -103,7 +102,6 @@
if (log.isDebugEnabled()) {
log.debug("for ui " + ui.getClass());
}
- //List<A> result = new ArrayList<A>();
for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
String actionKey = entry.getKey();
Object comp = ui.getObjectById(actionKey);
@@ -142,7 +140,6 @@
Boolean value = (Boolean) action.getValue("hideActionText");
component.setHideActionText(value != null && value);
action.setEnabled(true);
- //result.add(action);
continue;
}
// is JComboBox
@@ -154,9 +151,7 @@
if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
component.setSelectedIndex(val);
}
- //result.add(action);
}
- //return (A[]) result.toArray(new MyAbstractAction[result.size()]);
}
/**
@@ -183,10 +178,10 @@
}
// recherche de l'annotation de configuration
- ActionInitializer<?, ?> initializer = findInitializer(result.getClass());
+ ActionInitializer<?, ?> initializer = resolveActionConfiguration(result);
if (initializer != null) {
- initializer.initAction(component, result);
+ initializer.applyConfiguration(component, result);
}
try {
@@ -342,10 +337,10 @@
}
- protected ActionInitializer findInitializer(Class<? extends AbstractAction> action) {
- for (ActionInitializer registredInitializer : registredInitializers) {
- if (registredInitializer.getAnnotation(action) != null) {
- return registredInitializer;
+ protected ActionInitializer resolveActionConfiguration(MyAbstractAction action) {
+ for (ActionInitializer resolver : configurationResolvers) {
+ if (resolver.resolveConfiguration(action) != null) {
+ return resolver;
}
}
return null;
@@ -354,7 +349,7 @@
protected <I extends AbstractActionInitializer> I registerInitializer(Class<I> initizalizer) {
try {
I instance = initizalizer.newInstance();
- registredInitializers.add(instance);
+ configurationResolvers.add(instance);
return instance;
} catch (Exception e) {
throw new RuntimeException(e);
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 21:20:58 UTC (rev 797)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 21:21:46 UTC (rev 798)
@@ -108,7 +108,7 @@
void fireAction(String actionKey, Object source);
/**
- * Fire an action given his action's key, his source and the reaal action.
+ * Fire an action given his action's key, his source and the real action.
* <p/>
* This is a convinient method when you need to modified action before fire it.
*
1
0
r797 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
by tchemit@users.labs.libre-entreprise.org 25 Jul '08
25 Jul '08
Author: tchemit
Date: 2008-07-25 21:20:58 +0000 (Fri, 25 Jul 2008)
New Revision: 797
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java
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/SelectActionConfigInitializer.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java
Log:
ActionInitializer must be search annotation of instance of Action, and not on his class since Action could not be holder of configuration (with delegation)...
add javadoc.
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java 2008-07-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -14,35 +14,50 @@
*/
package org.codelutin.jaxx.action.initializer;
-import javax.swing.AbstractAction;
+import org.codelutin.jaxx.action.MyAbstractAction;
+
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.
+ * Common abstract class of a resolver of action configuration.
+ * <p/>
+ * The class implements the logic of research of the configuration annotation.
*
* @author chemit
*/
public abstract class AbstractActionInitializer<A extends java.lang.annotation.Annotation, C extends JComponent> implements ActionInitializer<A, C> {
- final Class<A> annotationImpl;
- final Class<C> componentImpl;
+ /** the type of configuration's annotation */
+ protected final Class<A> annotationImpl;
- protected abstract A initAction0(C component, AbstractAction action);
+ /** the type of component that can fire an action */
+ protected final Class<C> componentImpl;
+ /**
+ * The typed method (on component) to apply configuration on the action and component.
+ *
+ * @param component the component which fires the action
+ * @param action the given action
+ * @return the configuration's annotation
+ */
+ protected abstract A applyConfiguration0(C component, MyAbstractAction 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);
+ public A resolveConfiguration(MyAbstractAction action) {
+ if (action.hasDelegate()) {
+ return resolveConfiguration(action.getDelegate());
+ }
+ return action.getClass().getAnnotation(annotationImpl);
}
@SuppressWarnings({"unchecked"})
- public A initAction(JComponent component, AbstractAction action) {
+ public A applyConfiguration(JComponent component, MyAbstractAction action) {
if (component != null && componentImpl.isAssignableFrom(component.getClass()))
- return initAction0((C) component, action);
+ return applyConfiguration0((C) component, action);
return null;
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java 2008-07-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -16,20 +16,24 @@
import static org.codelutin.i18n.I18n._;
import org.codelutin.jaxx.action.ActionConfig;
+import org.codelutin.jaxx.action.MyAbstractAction;
-import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
-/** @author chemit */
+/**
+ * Implementation of configuration's resolver for annotation {@link ActionConfig}
+ *
+ * @author chemit
+ */
public class ActionConfigInitializer extends AbstractActionInitializer<ActionConfig, AbstractButton> {
public ActionConfigInitializer() {
super(ActionConfig.class, AbstractButton.class);
}
- protected ActionConfig initAction0(AbstractButton component, AbstractAction action) {
- ActionConfig anno = getAnnotation(action.getClass());
+ protected ActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) {
+ ActionConfig anno = resolveConfiguration(action);
if (anno == null) {
return null;
}
Modified: 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-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -14,17 +14,41 @@
*/
package org.codelutin.jaxx.action.initializer;
-import javax.swing.AbstractAction;
+import org.codelutin.jaxx.action.MyAbstractAction;
+
import javax.swing.JComponent;
-/** @author chemit */
+/**
+ * The contract to be realized to resolve an {@link MyAbstractAction} configuration.
+ * <p/>
+ * Configuration is done by a Annotation of type {@link A} placed on the action class.
+ * <p/>
+ * If the instanciated action box the real action, we should always search on the boxed action.
+ * <p/>
+ * Moreover, a action can only be fired by a certain type of component (for example a Button or a ComboBox), the class
+ * of the component type is given by the {@link C} class.
+ *
+ * @author chemit
+ */
public interface ActionInitializer<A extends java.lang.annotation.Annotation, C extends JComponent> {
+ /**
+ * Search the annotation that configure the given action (or the boxed action).
+ *
+ * @param action current action
+ * @return the configuration of the action
+ */
+ A resolveConfiguration(MyAbstractAction action);
- A getAnnotation(Class<? extends AbstractAction> action);
+ /**
+ * @param component widget that requires the action
+ * @param action given action
+ * @return the configuration of the action
+ */
+ A applyConfiguration(JComponent component, MyAbstractAction action);
- A initAction(JComponent component, AbstractAction action);
-
+ /** @return the configuration annotation dealed by this resolver */
Class<A> getAnnotationImpl();
+ /** @return the class of the component which can fired the action */
Class<C> getComponentImpl();
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java 2008-07-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -15,21 +15,25 @@
package org.codelutin.jaxx.action.initializer;
import static org.codelutin.i18n.I18n._;
+import org.codelutin.jaxx.action.MyAbstractAction;
import org.codelutin.jaxx.action.SelectActionConfig;
-import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JComboBox;
-/** @author chemit */
+/**
+ * Implementation of configuration's resolver for annotation {@link SelectActionConfig}
+ *
+ * @author chemit
+ */
public class SelectActionConfigInitializer extends AbstractActionInitializer<SelectActionConfig, JComboBox> {
public SelectActionConfigInitializer() {
super(SelectActionConfig.class, JComboBox.class);
}
- protected SelectActionConfig initAction0(JComboBox component, AbstractAction action) {
- SelectActionConfig anno = getAnnotation(action.getClass());
+ protected SelectActionConfig applyConfiguration0(JComboBox component, MyAbstractAction action) {
+ SelectActionConfig anno = resolveConfiguration(action);
if (anno == null) {
return null;
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java 2008-07-25 17:55:55 UTC (rev 796)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigInitializer.java 2008-07-25 21:20:58 UTC (rev 797)
@@ -15,21 +15,25 @@
package org.codelutin.jaxx.action.initializer;
import static org.codelutin.i18n.I18n._;
+import org.codelutin.jaxx.action.MyAbstractAction;
import org.codelutin.jaxx.action.ToggleActionConfig;
-import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.Action;
-/** @author chemit */
+/**
+ * Implementation of configuration's resolver for annotation {@link ToggleActionConfig}
+ *
+ * @author chemit
+ */
public class ToggleActionConfigInitializer extends AbstractActionInitializer<ToggleActionConfig, AbstractButton> {
public ToggleActionConfigInitializer() {
super(ToggleActionConfig.class, AbstractButton.class);
}
- protected ToggleActionConfig initAction0(AbstractButton component, AbstractAction action) {
- ToggleActionConfig anno = getAnnotation(action.getClass());
+ protected ToggleActionConfig applyConfiguration0(AbstractButton component, MyAbstractAction action) {
+ ToggleActionConfig anno = resolveConfiguration(action);
if (anno == null) {
return null;
}
1
0