Buix-commits
Threads by month
- ----- 2026 -----
- August
- July
- 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
- 1440 discussions
Author: tchemit
Date: 2008-08-11 10:04:09 +0000 (Mon, 11 Aug 2008)
New Revision: 832
Modified:
trunk/lutinjaxx/pom.xml
Log:
passage en version 0.4 (version stable int?\195?\169grant les derni?\195?\168re corrections sur le processor d'annotation) : resources en UTF-8
Modified: trunk/lutinjaxx/pom.xml
===================================================================
--- trunk/lutinjaxx/pom.xml 2008-08-11 09:52:40 UTC (rev 831)
+++ trunk/lutinjaxx/pom.xml 2008-08-11 10:04:09 UTC (rev 832)
@@ -65,7 +65,7 @@
<properties>
<!-- current version -->
- <current.version>0.3</current.version>
+ <current.version>0.4</current.version>
<!-- id du projet du labs -->
<labs.id>38</labs.id>
@@ -77,7 +77,7 @@
<!-- compile with ? -->
<maven.compile.source>1.6</maven.compile.source>
<maven.compile.target>1.6</maven.compile.target>
- <maven.compile.compile>UTF-8</maven.compile.compile>
+ <maven.compile.encoding>UTF-8</maven.compile.encoding>
<!-- Lists URL -->
<labs.lists>
@@ -131,7 +131,25 @@
<build>
<plugins>
+
<plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${maven.compile.source}</source>
+ <target>${maven.compile.target}</target>
+ <encoding>${maven.compile.encoding}</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <encoding>${maven.compile.encoding}</encoding>
+ </configuration>
+ </plugin>
+
+ <plugin>
<groupId>lutinplugin</groupId>
<artifactId>maven-i18n-plugin</artifactId>
<configuration>
1
0
r831 - in trunk/lutinjaxx: . core jaxx-swing jaxx-swing-action jaxx-swing-tab maven runtime util
by tchemit@users.labs.libre-entreprise.org Aug. 11, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 11, 2008
Aug. 11, 2008
Author: tchemit
Date: 2008-08-11 09:52:40 +0000 (Mon, 11 Aug 2008)
New Revision: 831
Modified:
trunk/lutinjaxx/core/pom.xml
trunk/lutinjaxx/jaxx-swing-action/pom.xml
trunk/lutinjaxx/jaxx-swing-tab/pom.xml
trunk/lutinjaxx/jaxx-swing/pom.xml
trunk/lutinjaxx/maven/pom.xml
trunk/lutinjaxx/pom.xml
trunk/lutinjaxx/runtime/pom.xml
trunk/lutinjaxx/util/pom.xml
Log:
passage en version 0.4 (version stable int?\195?\169grant les derni?\195?\168re corrections sur le processor d'annotation)
Modified: trunk/lutinjaxx/core/pom.xml
===================================================================
--- trunk/lutinjaxx/core/pom.xml 2008-08-11 09:51:33 UTC (rev 830)
+++ trunk/lutinjaxx/core/pom.xml 2008-08-11 09:52:40 UTC (rev 831)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
</parent>
<artifactId>core</artifactId>
<name>core</name>
<packaging>jar</packaging>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
<description>Jaxx lutin library core</description>
<build>
Modified: trunk/lutinjaxx/jaxx-swing/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing/pom.xml 2008-08-11 09:51:33 UTC (rev 830)
+++ trunk/lutinjaxx/jaxx-swing/pom.xml 2008-08-11 09:52:40 UTC (rev 831)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
</parent>
<artifactId>jaxx-swing</artifactId>
<name>jaxx-swing</name>
<packaging>jar</packaging>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
<description>Jaxx library swing extension</description>
<dependencies>
Modified: trunk/lutinjaxx/jaxx-swing-action/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/pom.xml 2008-08-11 09:51:33 UTC (rev 830)
+++ trunk/lutinjaxx/jaxx-swing-action/pom.xml 2008-08-11 09:52:40 UTC (rev 831)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
</parent>
<artifactId>jaxx-swing-action</artifactId>
<name>jaxx-swing-action</name>
<packaging>jar</packaging>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
<description>Jaxx lutin library swing actions extension</description>
<build>
Modified: trunk/lutinjaxx/jaxx-swing-tab/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing-tab/pom.xml 2008-08-11 09:51:33 UTC (rev 830)
+++ trunk/lutinjaxx/jaxx-swing-tab/pom.xml 2008-08-11 09:52:40 UTC (rev 831)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
</parent>
<artifactId>jaxx-swing-tab</artifactId>
<name>jaxx-swing-tab</name>
<packaging>jar</packaging>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
<description>Jaxx lutin library swing tab extension</description>
<build>
Modified: trunk/lutinjaxx/maven/pom.xml
===================================================================
--- trunk/lutinjaxx/maven/pom.xml 2008-08-11 09:51:33 UTC (rev 830)
+++ trunk/lutinjaxx/maven/pom.xml 2008-08-11 09:52:40 UTC (rev 831)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
</parent>
<artifactId>maven-jaxx-plugin</artifactId>
@@ -63,7 +63,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
<description>
Maven 2 plugin to generate java source from ui interface definitions
Modified: trunk/lutinjaxx/pom.xml
===================================================================
--- trunk/lutinjaxx/pom.xml 2008-08-11 09:51:33 UTC (rev 830)
+++ trunk/lutinjaxx/pom.xml 2008-08-11 09:52:40 UTC (rev 831)
@@ -39,7 +39,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
<name>pom</name>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
<description>Jaxx lutin library main pom</description>
<inceptionYear>2008</inceptionYear>
Modified: trunk/lutinjaxx/runtime/pom.xml
===================================================================
--- trunk/lutinjaxx/runtime/pom.xml 2008-08-11 09:51:33 UTC (rev 830)
+++ trunk/lutinjaxx/runtime/pom.xml 2008-08-11 09:52:40 UTC (rev 831)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
</parent>
<artifactId>runtime</artifactId>
<name>runtime</name>
<packaging>jar</packaging>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
<description>Jaxx lutin library runtime</description>
<build>
Modified: trunk/lutinjaxx/util/pom.xml
===================================================================
--- trunk/lutinjaxx/util/pom.xml 2008-08-11 09:51:33 UTC (rev 830)
+++ trunk/lutinjaxx/util/pom.xml 2008-08-11 09:52:40 UTC (rev 831)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
</parent>
<artifactId>util</artifactId>
<name>util</name>
<packaging>jar</packaging>
- <version>0.3-SNAPSHOT</version>
+ <version>0.4</version>
<description>Jaxx lutin library utility</description>
<build>
1
0
r830 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org Aug. 11, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 11, 2008
Aug. 11, 2008
Author: tchemit
Date: 2008-08-11 09:51:33 +0000 (Mon, 11 Aug 2008)
New Revision: 830
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
Log:
javadoc
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-11 08:43:07 UTC (rev 829)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-11 09:51:33 UTC (rev 830)
@@ -64,24 +64,31 @@
* @author chemit */
public class ActionAnnotationProcessing extends AbstractProcessor {
- //protected ActionProviderAnnotation providerConfig;
-
+ /** the {@link ActionProvider} service declaration relative path */
protected String providerDeclarationLocation = "META-INF/services/" + ActionProvider.class.getName();
+ /** the relative path where to store actions mapping, will be complete with the name of base action to use */
protected String actionsFileLocation = ActionProviderFromProperties.actionsFileLocation;
+ /** verbose flag (can be activated by passing an annotation parameter to compiler via <code>-Ai18n.verbose</code>) */
protected boolean verbose;
+ /** the list of class processed by the processor */
protected java.util.List<String> processedClass;
+ /** the map of actions processed, keys are the action commaned and values are fqn of implementations */
protected Properties actions;
+ /** Extractor of values of annotations found */
protected AnnotationValueVisitor<Object, Void> annotationValueExtractor;
+ /** the type element of the base action to be used by {@link ActionProvider} */
protected TypeElement baseActionElement;
+ /** the fqn of the action provider to generate */
protected String providerFQN;
+ /** the fqn of the base action class to be used */
protected String baseFQN;
@Override
@@ -108,18 +115,16 @@
baseActionElement = (TypeElement) annotatedWith.iterator().next();
- //fixme CheckbaseActionElement is assigned from MyAbstractAction
- //if (!baseActionElement.getSuperclass()) ...
+ //fixme it is not possible to know if baseActionElement is assigned from MyAbstractAction, since we
+ // can NOT garanted at this stage thaht the class was compiled...
- //providerConfig = baseActionElement.getAnnotation(ActionProviderAnnotation.class);
-
baseFQN = baseActionElement.asType().toString();
- int index = baseFQN.lastIndexOf(".");
- String baseSimpleName = baseFQN.substring(index + 1);
- String packageName = baseFQN.substring(0, index + 1);
+ int index = baseFQN.lastIndexOf(".") + 1;
+ String baseSimpleName = baseFQN.substring(index);
+ String packageName = baseFQN.substring(0, index);
providerFQN = packageName + baseSimpleName + "Provider";
- printInfo("providerFQN " + packageName + "," + baseSimpleName + "," + providerFQN);
+ printDebug("providerFQN " + providerFQN);
actionsFileLocation = String.format(actionsFileLocation, baseSimpleName);
continue;
}
1
0
r829 - in trunk/lutinjaxx: jaxx-swing-action/src/main/java/org/codelutin/jaxx/action util/src/main/java/org/codelutin/jaxx/util
by tchemit@users.labs.libre-entreprise.org Aug. 11, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 11, 2008
Aug. 11, 2008
Author: tchemit
Date: 2008-08-11 08:43:07 +0000 (Mon, 11 Aug 2008)
New Revision: 829
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java
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/ActionConfigConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactory.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java
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/ActionProviderFromProperties.java
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/SelectActionConfigConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FormElement.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java
trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIProvider.java
Log:
preparation pour changement de licence + javadoc
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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.
- * # #%
+ * ##%
*/
@@ -81,7 +81,7 @@
protected TypeElement baseActionElement;
protected String providerFQN;
-
+
protected String baseFQN;
@Override
@@ -115,11 +115,11 @@
baseFQN = baseActionElement.asType().toString();
int index = baseFQN.lastIndexOf(".");
- String baseSimpleName = baseFQN.substring(index+1);
- String packageName = baseFQN.substring(0, index+1);
+ String baseSimpleName = baseFQN.substring(index + 1);
+ String packageName = baseFQN.substring(0, index + 1);
providerFQN = packageName + baseSimpleName + "Provider";
- printInfo("providerFQN "+packageName+","+baseSimpleName+","+providerFQN);
+ printInfo("providerFQN " + packageName + "," + baseSimpleName + "," + providerFQN);
actionsFileLocation = String.format(actionsFileLocation, baseSimpleName);
continue;
}
@@ -220,7 +220,7 @@
protected void writeProviderClass() throws IOException, NotFoundException, CannotCompileException, ClassNotFoundException {
OutputStream outputStream = null;
try {
-
+
ClassPool pool = ClassPool.getDefault();
pool.appendClassPath(new LoaderClassPath(ActionProviderFromProperties.class.getClassLoader()));
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactory.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactory.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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;
@@ -22,14 +22,29 @@
import java.util.Set;
/**
- * Action factory using the ActionConfig annotations to configure the action.
+ * Action factory using the <code>ActionConfig-like</code> annotations to configure actions.
* <p/>
- * Use after the {@link #loadActions(jaxx.runtime.JAXXObject)} to instanciate
- * actions in ui with id equals a known action...
* <p/>
- * TODO Finish doc
+ * An {@link ActionFactory} builds actions always on a same type <code>A</code> and obtain them from some
+ * {@link ActionProvider} via methods {@link #newAction(String, JComponent)} and {@link #newAction(String)} .
+ * <p/>
+ * If the action coming from the provider is not on the same type <code>A</code>, then the action is boxed in a *
+ * action <code>A</code> and use the generic mecanism of delegation provided by {@link MyAbstractAction}.
+ * <p/>
+ * Use after the {@link #loadActions(jaxx.runtime.JAXXObject)} to instanciate actions in ui with id equals a known
+ * action...
+ * <p/>
+ * All actions instanciated are stored in a cache that you can request via method {@link #getActionFromCache(String)},
+ * {@link #cacheEntrySet()} and {@link #resetCache()}.
+ * <p/>
+ * You can also from this factory fires some action via the methods {@link #fireAction(String, Object, JComponent)} ,
+ * {@link #fireAction(String, Object)} , {@link #fireAction0(String, Object, MyAbstractAction)}.
+ * <p/>
+ * Finally, a {@link #dispose()} method is there to shut down all instanciated action when you want to dispose all uis.
*
* @author chemit
+ * @see ActionProvider
+ * @see MyAbstractAction
*/
public interface ActionFactory<A extends MyAbstractAction> {
@@ -41,8 +56,23 @@
Map<String, Class<? extends MyAbstractAction>> init();
/** @return the class of the base action of the factory. */
- Class<A> getBaseImpl();
+ Class<A> getBaseClass();
+ /** @return the set of all the action's classes known by the factory. */
+ Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
+
+ /** @return the array of names of all actions known by the factory */
+ String[] getActionNames();
+
+ /** @return the set of all actions cached in factory indexed by their name */
+ Set<Entry<String, A>> cacheEntrySet();
+
+ /**
+ * @param actionKey the action's key
+ * @return the action in cache or <code>null</code> if action is not in cache
+ */
+ MyAbstractAction getActionFromCache(String actionKey);
+
/** clear the cache of instanciated actions. */
void resetCache();
@@ -50,8 +80,9 @@
* @param actionKey the key of an action
* @return the action with this key from cache, or <code>null</code> if this action is not in cache
*/
- A get(String actionKey);
+ //A get(String actionKey);
+
/**
* For a given ui, load all actions registred in factory.
* <p/>
@@ -71,7 +102,7 @@
A newAction(String actionKey, JComponent component);
/**
- * Obtain an action instance given his key (should call {@link #newAction(String, javax.swing.JComponent)}
+ * Obtain an action instance given his key (should call {@link #newAction(String, JComponent)}
* <p/>
* This is a convinient method when you want to obtain an action with no attached widget.
*
@@ -80,15 +111,7 @@
*/
A newAction(String actionKey);
- /** @return the array of names of all actions known by the factory */
- String[] getActionNames();
- /** @return the set of all the action's classes known by the factory. */
- Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
-
- /** @return the set of all actions cached in factory indexed by their name */
- Set<Entry<String, A>> cacheEntrySet();
-
/**
* Fire an action given his key, his source and tthe widget responsible of action
*
@@ -117,14 +140,9 @@
*/
void fireAction0(String actionKey, Object source, A action);
- /**
- * @param actionKey the action's key
- * @return the action in cache or <code>null</code> if action is not in cache
- */
- MyAbstractAction getActionFromCache(String actionKey);
/**
- * dispose all actions in cache using {@link org.codelutin.jaxx.action.MyAbstractAction#disposeUI()} on each
+ * dispose all actions in cache using {@link MyAbstractAction#disposeUI()} on each
* action, then {@link #resetCache()}
*/
void dispose();
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -85,7 +85,7 @@
this.selectActionConfigInitializer = registerInitializer(SelectActionConfigConfigurationResolver.class);
}
- public Class<A> getBaseImpl() {
+ public Class<A> getBaseClass() {
return baseImpl;
}
@@ -93,9 +93,9 @@
cache.clear();
}
- public A get(String actionKey) {
+ /*public A get(String actionKey) {
return cache.get(actionKey);
- }
+ }*/
public void loadActions(JAXXObject ui) {
if (log.isDebugEnabled()) {
@@ -246,16 +246,16 @@
// on vérifie que l'action existe bien
checkRegistredAction(actionKey);
+ A action = null;
// try in cache
if (cache.containsKey(actionKey)) {
// use cached action
- A action = cache.get(actionKey);
+ action = cache.get(actionKey);
if (log.isDebugEnabled()) {
log.debug("use cache action " + action);
}
- return action;
}
- return null;
+ return action;
}
public void dispose() {
@@ -377,9 +377,9 @@
MyAbstractAction result;
result = klazz.getConstructor(String.class).newInstance(actionKey);
result.putValue(Action.ACTION_COMMAND_KEY, actionKey);
- if (!getBaseImpl().isAssignableFrom(klazz)) {
+ if (!getBaseClass().isAssignableFrom(klazz)) {
// the instanciated action must be boxed in the base Action of the factory
- result = getBaseImpl().getConstructor(MyAbstractAction.class).newInstance(result);
+ result = getBaseClass().getConstructor(MyAbstractAction.class).newInstance(result);
}
return (A) result;
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,19 +10,19 @@
* should have received a copy of the GNU General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
* - Suite 330, Boston, MA 02111-1307, USA.
- * # #%
+ * ##%
*/
package org.codelutin.jaxx.action;
/**
- * Contrat pour obtenir les noms d'une action de manière dynamique.
+ * Contrat pour obtenir les noms d'une action de maniere dynamique.
* <p/>
- * Cette méthode sera appelé par un {@link ActionProvider} lorsque la clef dans le
- * fichier de mapping est :fqn (où fqn correspond à une implantation de ce contrat).
+ * Cette méthode sera appelee par un {@link ActionProvider} lorsque la clef dans le
+ * fichier de mapping est <code>:fqn</code> (où fqn correspond à une implantation de ce contrat).
* <p/>
- * Ainsi on peut associer à une action donnée plusieurs instances avec des noms différents mais avec le même comportement.
+ * Ainsi on peut associer à une action donnee plusieurs instances avec des noms différents mais de le meme comportement.
* <p/>
- * Par exemple, une changement de locale où seule la locale varie (et elle sera retrouvée à partir du nom de l'action).
+ * Par exemple, une changement de locale ou seule la locale varie (et elle sera retrouvee a partir du nom de l'action).
*
* @author chemit
*/
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,16 +10,19 @@
* 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;
/**
* Contract to be realized by a provider of Actions.
* <p/>
- * A provider of actions
+ * A provider of actions is based on a certain type of {@link MyAbstractAction} (<code>A</code>) with an accessor
+ * {@link #getBaseClass()} and deliver some implementations of such actions indexed by their logical names via the
+ * method {#link #getClasses()}.
*
* @author chemit
+ * @see MyAbstractAction
*/
public interface ActionProvider<A extends MyAbstractAction> {
Modified: 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 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderAnnotation.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderFromProperties.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderFromProperties.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderFromProperties.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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;
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-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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.util;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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.util;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FormElement.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FormElement.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/FormElement.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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.util;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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.util;
Modified: trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIProvider.java
===================================================================
--- trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIProvider.java 2008-08-10 16:40:49 UTC (rev 828)
+++ trunk/lutinjaxx/util/src/main/java/org/codelutin/jaxx/util/UIProvider.java 2008-08-11 08:43:07 UTC (rev 829)
@@ -1,5 +1,5 @@
/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * ##% 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
@@ -10,7 +10,7 @@
* 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.util;
1
0
r828 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org Aug. 10, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 10, 2008
Aug. 10, 2008
Author: tchemit
Date: 2008-08-10 16:40:49 +0000 (Sun, 10 Aug 2008)
New Revision: 828
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java
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/ActionProviderFromProperties.java
Log:
simplify code : all is fully generated now : nothing has to be configured via the annotation. just placed it :)
suppression name field in ActionProvider
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-10 15:18:09 UTC (rev 827)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-10 16:40:49 UTC (rev 828)
@@ -64,11 +64,11 @@
* @author chemit */
public class ActionAnnotationProcessing extends AbstractProcessor {
- protected ActionProviderAnnotation providerConfig;
+ //protected ActionProviderAnnotation providerConfig;
protected String providerDeclarationLocation = "META-INF/services/" + ActionProvider.class.getName();
- protected String actionsFileLocation = "META-INF/jaxx-%1$s-actions.properties";
+ protected String actionsFileLocation = ActionProviderFromProperties.actionsFileLocation;
protected boolean verbose;
@@ -80,6 +80,10 @@
protected TypeElement baseActionElement;
+ protected String providerFQN;
+
+ protected String baseFQN;
+
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init(processingEnv);
@@ -107,9 +111,16 @@
//fixme CheckbaseActionElement is assigned from MyAbstractAction
//if (!baseActionElement.getSuperclass()) ...
- providerConfig = baseActionElement.getAnnotation(ActionProviderAnnotation.class);
+ //providerConfig = baseActionElement.getAnnotation(ActionProviderAnnotation.class);
- actionsFileLocation = String.format(actionsFileLocation, providerConfig.name());
+ baseFQN = baseActionElement.asType().toString();
+ int index = baseFQN.lastIndexOf(".");
+ String baseSimpleName = baseFQN.substring(index+1);
+ String packageName = baseFQN.substring(0, index+1);
+
+ providerFQN = packageName + baseSimpleName + "Provider";
+ printInfo("providerFQN "+packageName+","+baseSimpleName+","+providerFQN);
+ actionsFileLocation = String.format(actionsFileLocation, baseSimpleName);
continue;
}
@@ -135,7 +146,7 @@
if ((roundEnv.processingOver())) {
printDebug("round is over " + roundEnv);
try {
- if (providerConfig != null) {
+ if (baseActionElement != null) {
// found the base action class to be compiled, so we have to write provider things...
writeProviderClass();
writeProviderServiceDeclaration();
@@ -184,25 +195,6 @@
return f.getAbsolutePath().substring(index);
}
- /**
- * @throws ClassNotFoundException ifclass not find
- * @deprecated Can not use anylonger this class, beacause at compile time we are not garanted to have
- * some actions classes compiled, so can not use {@link Class#forName(String)} method.
- */
- @Deprecated
- protected void findProviderConfigFromCompiledClass() throws ClassNotFoundException {
- if (!actions.isEmpty()) {
- Class<?> klazz = Class.forName(processedClass.get(0));
- providerConfig = klazz.getAnnotation(ActionProviderAnnotation.class);
- while (klazz != null && providerConfig == null) {
- klazz = klazz.getSuperclass();
- if (klazz != null) {
- providerConfig = klazz.getAnnotation(ActionProviderAnnotation.class);
- }
- }
- }
- }
-
protected boolean registerActionsForClass(TypeMirror annotationType, Element e) {
boolean doTreate = false;
for (AnnotationMirror mirror : e.getAnnotationMirrors()) {
@@ -228,24 +220,23 @@
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);
+ CtClass clazz = pool.makeClass(providerFQN);
// define the base action class in javassist pool to make possible compilation
- pool.makeClass(baseActionElement.asType().toString());
+ pool.makeClass(baseFQN);
clazz.setSuperclass(superClass);
// add constructor
CtConstructor constructor = new CtConstructor(null, clazz);
- constructor.setBody("super(\"" + providerConfig.name() + "\"," + baseActionElement.asType().toString() + ".class,\"/" + actionsFileLocation + "\");");
+ constructor.setBody("super( " + baseFQN + ".class);");
clazz.addConstructor(constructor);
byte[] byteCode = clazz.toBytecode();
- JavaFileObject fo = processingEnv.getFiler().createClassFile(fqn);
+ JavaFileObject fo = processingEnv.getFiler().createClassFile(providerFQN);
printInfo("writing " + fo.toUri());
outputStream = fo.openOutputStream();
outputStream.write(byteCode);
@@ -264,7 +255,7 @@
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());
+ w.append(providerFQN);
} finally {
if (w != null)
w.close();
@@ -345,23 +336,9 @@
continue;
}
- /*Class<ActionNameHelper.ActionNameProvider> klazz = (Class<ActionNameHelper.ActionNameProvider>) entry.getValue().accept(getAnnotationValueExtractor(), null);
- if (ActionNameHelper.CompileActionNameProvider.class.isAssignableFrom(klazz)) {
- // means there is a compile time names provider
- try {
- result = klazz.newInstance().getActionCommands();
- break;
- } catch (InstantiationException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
- if (ActionNameHelper.RuntimeActionNameProvider.class.isAssignableFrom(klazz)) {*/
// means there is a runtime names provider
result = new String[]{":" + classname};
break;
- //}
}
if ("actionCommand".equals(name)) {
result = new String[]{(String) entry.getValue().accept(getAnnotationValueExtractor(), null)};
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java 2008-08-10 15:18:09 UTC (rev 827)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java 2008-08-10 16:40:49 UTC (rev 828)
@@ -23,9 +23,6 @@
*/
public interface ActionProvider<A extends MyAbstractAction> {
- /** @return the name of the provider */
- String getName();
-
/** @return the base classe of provided actions */
Class<A> getBaseClass();
Modified: 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 2008-08-10 15:18:09 UTC (rev 827)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderAnnotation.java 2008-08-10 16:40:49 UTC (rev 828)
@@ -31,11 +31,4 @@
@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/ActionProviderFromProperties.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderFromProperties.java 2008-08-10 15:18:09 UTC (rev 827)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderFromProperties.java 2008-08-10 16:40:49 UTC (rev 828)
@@ -30,30 +30,24 @@
/** default prefix for an entryin mapping file. */
protected static final String ACTION_KEY_PREFIX = "action.";
+ protected static final String actionsFileLocation = "META-INF/jaxx-%1$s-actions.properties";
+
protected String propertiesPath;
protected static Log log = LogFactory.getLog(ActionProviderFromProperties.class);
- protected String name;
-
protected Class<A> baseClass;
protected Map<String, Class<? extends A>> actions;
- protected ActionProviderFromProperties(String name, Class<A> baseClass, String propertiesPath) {
+ protected ActionProviderFromProperties(Class<A> baseClass) {
- this.name = name;
this.baseClass = baseClass;
-
- this.propertiesPath = propertiesPath;
+ this.propertiesPath = "/" + String.format(actionsFileLocation, baseClass.getSimpleName());
this.actions = initCache();
}
- public String getName() {
- return name;
- }
-
public Class<A> getBaseClass() {
return baseClass;
}
@@ -64,7 +58,7 @@
@Override
public String toString() {
- return super.toString() + "<name:" + name + ", baseClass:" + baseClass.getSimpleName() + ">";
+ return super.toString() + "<baseClass:" + baseClass.getSimpleName() + ">";
}
protected void clearCache() {
@@ -90,13 +84,16 @@
try {
inputStream = getClass().getResourceAsStream(propertiesPath);
if (inputStream == null) {
- throw new NullPointerException("could not find action file " + propertiesPath);
+ //throw new NullPointerException("could not find action file " + propertiesPath);
+ // actually, there is nothing to load, this is not an error
+ } else {
+ log.info("load " + propertiesPath);
+ properties.load(inputStream);
}
- log.info("load " + propertiesPath);
- properties.load(inputStream);
} catch (IOException e) {
- log.warn(_("jaxx.error.load.actions.file", e.getMessage()));
- throw new RuntimeException(_("jaxx.error.load.actions.file", e.getMessage()));
+ String message = _("jaxx.error.load.actions.file", e.getMessage());
+ log.warn(message);
+ throw new RuntimeException(message);
} finally {
if (inputStream != null) {
try {
@@ -128,12 +125,8 @@
}
log.debug("found action <" + actionKey + " : " + implCass + ">");
cache.put(actionKey, implCass);
- } catch (ClassNotFoundException e) {
+ } catch (Exception e) {
throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
- } catch (InstantiationException e) {
- throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
}
}
1
0
r827 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org Aug. 10, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 10, 2008
Aug. 10, 2008
Author: tchemit
Date: 2008-08-10 15:18:09 +0000 (Sun, 10 Aug 2008)
New Revision: 827
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
Log:
fix bug : can not use Class.forname on uncompiled classes
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-10 13:14:47 UTC (rev 826)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-10 15:18:09 UTC (rev 827)
@@ -43,6 +43,8 @@
import javax.tools.JavaFileObject;
import javax.tools.StandardLocation;
import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -133,20 +135,22 @@
if ((roundEnv.processingOver())) {
printDebug("round is over " + roundEnv);
try {
- if (providerConfig == null) {
+ if (providerConfig != null) {
+ // found the base action class to be compiled, so we have to write provider things...
+ writeProviderClass();
+ writeProviderServiceDeclaration();
+ } else {
+
// baseActionClass was not compiled at this time, must find it back
+ // this means they should have an already mapping file written
- findProviderConfigFromCompiledClass();
+ actionsFileLocation = findMappingFile();
- if (providerConfig == null) {
- throw new IllegalStateException("no provider name found, you must add on baseaction the annotation " + ActionProviderAnnotation.class);
- }
- actionsFileLocation = String.format(actionsFileLocation, providerConfig.name());
- } else {
- writeProviderClass();
- writeProviderServiceDeclaration();
+ printInfo("reused actionFilesLocation " + actionsFileLocation);
}
+
writeActionMapping();
+
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
@@ -158,8 +162,36 @@
return true;
}
+ protected String findMappingFile() throws IOException {
+ String path = String.format(actionsFileLocation, "dummy_" + System.nanoTime());
+
+
+ FileObject oldFo = processingEnv.getFiler().getResource(StandardLocation.SOURCE_OUTPUT, "", path);
+ File dummyFile = new File(oldFo.toUri().toString()).getParentFile();
+ File[] files = dummyFile.listFiles(new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ return name.startsWith("jaxx-") && name.endsWith("-actions.properties");
+ }
+ });
+ if (files.length < 1) {
+ // this is not normal, should have exactly one file here
+ throw new IllegalStateException("no provider name found, you must add on baseaction the annotation " + ActionProviderAnnotation.class);
+ }
+ File f = files[0];
+ int index = f.getAbsolutePath().indexOf("META-INF");
+
+ return f.getAbsolutePath().substring(index);
+ }
+
+ /**
+ * @throws ClassNotFoundException ifclass not find
+ * @deprecated Can not use anylonger this class, beacause at compile time we are not garanted to have
+ * some actions classes compiled, so can not use {@link Class#forName(String)} method.
+ */
+ @Deprecated
protected void findProviderConfigFromCompiledClass() throws ClassNotFoundException {
- if (!processedClass.isEmpty()) {
+ if (!actions.isEmpty()) {
Class<?> klazz = Class.forName(processedClass.get(0));
providerConfig = klazz.getAnnotation(ActionProviderAnnotation.class);
while (klazz != null && providerConfig == null) {
@@ -240,11 +272,17 @@
}
protected void writeActionMapping() throws IOException {
+ if (actions.isEmpty()) {
+ // nothing to write or overwrite
+ return;
+ }
+
BufferedWriter w = null;
try {
Properties oldProps = loadOldActionMapping();
if (oldProps != null) {
- actions.putAll(oldProps);
+ oldProps.putAll(actions);
+ actions = oldProps;
}
// ecriture de toutes les actions trouvees
FileObject fo = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", actionsFileLocation);
@@ -260,11 +298,10 @@
protected Properties loadOldActionMapping() throws IOException {
// reprise sur une ancienne compilation
FileObject oldFo = processingEnv.getFiler().getResource(StandardLocation.SOURCE_OUTPUT, "", actionsFileLocation);
- System.out.println("URI " + oldFo.toUri());
- if (!new java.io.File(oldFo.toUri().toString()).exists()) {
+ if (!new File(oldFo.toUri().toString()).exists()) {
return null;
}
- Properties oldProps = new Properties();
+ Properties oldProps = new SortedProperties();
InputStream inputStream = null;
try {
inputStream = oldFo.openInputStream();
1
0
r826 - trunk/lutinjaxx/core/src/main/java/jaxx/runtime
by tchemit@users.labs.libre-entreprise.org Aug. 10, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 10, 2008
Aug. 10, 2008
Author: tchemit
Date: 2008-08-10 13:14:47 +0000 (Sun, 10 Aug 2008)
New Revision: 826
Modified:
trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObject.java
Log:
ajout en visibilite public de la methode get$objectMap pour pouvoir utiliser de l'exterieur cet dictionnaire
Modified: trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObject.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObject.java 2008-08-09 10:27:18 UTC (rev 825)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObject.java 2008-08-10 13:14:47 UTC (rev 826)
@@ -14,6 +14,11 @@
*/
public Object getObjectById(String id);
+ /**
+ * Pretrieves the dictonary of knwon objects indexed by their ids.
+ * @return the dictonary of objects.
+ */
+ public java.util.Map<String,Object> get$objectMap();
public void applyDataBinding(String id);
1
0
r825 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
Aug. 9, 2008
Author: tchemit
Date: 2008-08-09 10:27:18 +0000 (Sat, 09 Aug 2008)
New Revision: 825
Removed:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/
Log:
simplification du code : suppression du paquetage initializer
1
0
r824 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
Aug. 9, 2008
Author: tchemit
Date: 2008-08-09 10:26:55 +0000 (Sat, 09 Aug 2008)
New Revision: 824
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java
Log:
simplification du code : suppression du paquetage initializer
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java 2008-08-09 10:26:44 UTC (rev 823)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java 2008-08-09 10:26:55 UTC (rev 824)
@@ -21,11 +21,6 @@
import jaxx.runtime.swing.JAXXToggleButton;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-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;
1
0
r823 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . initializer
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
Aug. 9, 2008
Author: tchemit
Date: 2008-08-09 10:26:44 +0000 (Sat, 09 Aug 2008)
New Revision: 823
Added:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java
Removed:
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
Log:
simplification du code : suppression du paquetage initializer
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java (from rev 820, 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/AbstractActionConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/AbstractActionConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -0,0 +1,70 @@
+/**
+ * # #% 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 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;
+ }
+}
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java (from rev 820, 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/ActionConfigConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -0,0 +1,67 @@
+/**
+ * # #% 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 static org.codelutin.i18n.I18n._;
+
+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;
+ }
+}
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java (from rev 820, 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/ActionConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -0,0 +1,52 @@
+/**
+ * # #% 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 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();
+}
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java (from rev 820, 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/SelectActionConfigConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -0,0 +1,53 @@
+/**
+ * # #% 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 static org.codelutin.i18n.I18n._;
+
+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
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java (from rev 820, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -0,0 +1,79 @@
+/**
+ * # #% 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 static org.codelutin.i18n.I18n._;
+
+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/AbstractActionConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/AbstractActionConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -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 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/ActionConfigConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -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 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/ActionConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -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 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/SelectActionConfigConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -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 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/ToggleActionConfigConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java 2008-08-09 10:26:02 UTC (rev 822)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java 2008-08-09 10:26:44 UTC (rev 823)
@@ -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 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
1
0
r822 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
Aug. 9, 2008
Author: tchemit
Date: 2008-08-09 10:26:02 +0000 (Sat, 09 Aug 2008)
New Revision: 822
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java
Log:
javadoc
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-08-09 09:33:42 UTC (rev 821)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-08-09 10:26:02 UTC (rev 822)
@@ -24,7 +24,13 @@
import java.awt.event.ActionEvent;
import java.beans.PropertyChangeListener;
-/** @author chemit */
+/**
+ * Action de base à utiliser pour encapsuler toutes les actions du système.
+ * <p/>
+ * Ces actions seront chargées par des {@link ActionProvider} et des {@link ActionFactory}.
+ *
+ * @author chemit
+ */
public abstract class MyAbstractAction extends AbstractAction {
protected static org.apache.commons.logging.Log log = LogFactory.getLog(MyAbstractAction.class);
1
0
r821 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
Aug. 9, 2008
Author: tchemit
Date: 2008-08-09 09:33:42 +0000 (Sat, 09 Aug 2008)
New Revision: 821
Removed:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/
Log:
simplification du code : suppression du paquetage factory et provider
1
0
r820 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . factory
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
Aug. 9, 2008
Author: tchemit
Date: 2008-08-09 09:32:42 +0000 (Sat, 09 Aug 2008)
New Revision: 820
Added:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactory.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java
Removed:
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/ActionFactoryFromProvider.java
Log:
simplification du code : suppression du paquetage factory
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactory.java (from rev 798, 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/ActionFactory.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactory.java 2008-08-09 09:32:42 UTC (rev 820)
@@ -0,0 +1,131 @@
+/**
+ * # #% 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 jaxx.runtime.JAXXObject;
+
+import javax.swing.JComponent;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * Action factory using the ActionConfig annotations to configure the action.
+ * <p/>
+ * Use after the {@link #loadActions(jaxx.runtime.JAXXObject)} to instanciate
+ * actions in ui with id equals a known action...
+ * <p/>
+ * TODO Finish doc
+ *
+ * @author chemit
+ */
+public interface ActionFactory<A extends MyAbstractAction> {
+
+ /**
+ * Method to init the dictionary of knwon action implementations.
+ *
+ * @return the dictionary of known action implementations
+ */
+ Map<String, Class<? extends MyAbstractAction>> init();
+
+ /** @return the class of the base action of the factory. */
+ Class<A> getBaseImpl();
+
+ /** clear the cache of instanciated actions. */
+ void resetCache();
+
+ /**
+ * @param actionKey the key of an action
+ * @return the action with this key from cache, or <code>null</code> if this action is not in cache
+ */
+ A get(String actionKey);
+
+ /**
+ * For a given ui, load all actions registred in factory.
+ * <p/>
+ * The id of the widget in ui is directly mapped to a action key.
+ *
+ * @param ui the ui to treate
+ */
+ void loadActions(JAXXObject ui);
+
+ /**
+ * Obtain an action instance given his key and widget
+ *
+ * @param actionKey the key of action
+ * @param component the component using the action
+ * @return the instanciated action (could come from cache if already instanciated {@link #getActionFromCache(String)}
+ */
+ A newAction(String actionKey, JComponent component);
+
+ /**
+ * Obtain an action instance given his key (should call {@link #newAction(String, javax.swing.JComponent)}
+ * <p/>
+ * This is a convinient method when you want to obtain an action with no attached widget.
+ *
+ * @param actionKey the key of action
+ * @return the instanciated action (could come from cache if already instanciated {@link #getActionFromCache(String)}
+ */
+ A newAction(String actionKey);
+
+ /** @return the array of names of all actions known by the factory */
+ String[] getActionNames();
+
+ /** @return the set of all the action's classes known by the factory. */
+ Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
+
+ /** @return the set of all actions cached in factory indexed by their name */
+ Set<Entry<String, A>> cacheEntrySet();
+
+ /**
+ * Fire an action given his key, his source and tthe widget responsible of action
+ *
+ * @param actionKey the action's key
+ * @param source the object source of action
+ * @param component the component doing the action
+ */
+ void fireAction(String actionKey, Object source, JComponent component);
+
+ /**
+ * Fire an action given his key and his source, no widget are involved here
+ *
+ * @param actionKey the action's key
+ * @param source the object source of action
+ */
+ void fireAction(String actionKey, Object source);
+
+ /**
+ * 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.
+ *
+ * @param actionKey action's key
+ * @param source source of action
+ * @param action real action
+ */
+ void fireAction0(String actionKey, Object source, A action);
+
+ /**
+ * @param actionKey the action's key
+ * @return the action in cache or <code>null</code> if action is not in cache
+ */
+ MyAbstractAction getActionFromCache(String actionKey);
+
+ /**
+ * dispose all actions in cache using {@link org.codelutin.jaxx.action.MyAbstractAction#disposeUI()} on each
+ * action, then {@link #resetCache()}
+ */
+ void dispose();
+}
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java (from rev 819, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java 2008-08-09 09:32:42 UTC (rev 820)
@@ -0,0 +1,410 @@
+/*
+* ##% Copyright (C) 2007, 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 jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.JAXXToggleButton;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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;
+import javax.swing.Icon;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import java.awt.event.ActionEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * A simple implementation of {@link ActionFactory} using some {@link ActionProvider} to seek actions.
+ * <p/>
+ * <p/>
+ * An entry is in that form : <code>action.actionName=fqn</code> where
+ * <p/>
+ * <code>actionName</code> is the key of action used in factory, and
+ * <code>fqn</code> is the fully qualified name of the implemented action class.
+ * <p/>
+ * A special clase is to have for a given entry a key like this : <code>action.:fqn'=fqn</code>, in that case,
+ * le fqn' is a classe of type {@link org.codelutin.jaxx.action.ActionNameProvider} which gives us at
+ * runtime the names of each entry to put in cache for the givne action fqn.
+ *
+ * @author chemit
+ */
+public class ActionFactoryFromProvider<A extends MyAbstractAction> implements ActionFactory<A> {
+
+ protected static Log log = LogFactory.getLog(ActionFactoryFromProvider.class);
+
+ public static <A extends MyAbstractAction> ActionFactory<A> newInstance(Class<A> klazz) {
+ return new ActionFactoryFromProvider<A>(klazz);
+ }
+
+ /** class of encapsuling action */
+ protected Class<A> baseImpl;
+
+ /** dictionary of known actions implementations */
+ private Map<String, Class<? extends MyAbstractAction>> impls;
+
+ /** dictionary of instanciated actions */
+ private Map<String, A> cache;
+
+ protected final ActionConfigConfigurationResolver actionConfigInitializer;
+ protected final ToggleActionConfigConfigurationResolver toggleActionConfigInitializer;
+ protected final SelectActionConfigConfigurationResolver selectActionConfigInitializer;
+
+ protected List<AbstractActionConfigurationResolver> configurationResolvers;
+
+ protected ActionFactoryFromProvider(Class<A> baseImpl) {
+ this.baseImpl = baseImpl;
+ this.impls = init();
+ this.cache = new TreeMap<String, A>();
+ this.configurationResolvers = new java.util.ArrayList<AbstractActionConfigurationResolver>();
+
+ this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigConfigurationResolver.class);
+ this.actionConfigInitializer = registerInitializer(ActionConfigConfigurationResolver.class);
+ this.selectActionConfigInitializer = registerInitializer(SelectActionConfigConfigurationResolver.class);
+ }
+
+ public Class<A> getBaseImpl() {
+ return baseImpl;
+ }
+
+ public void resetCache() {
+ cache.clear();
+ }
+
+ public A get(String actionKey) {
+ return cache.get(actionKey);
+ }
+
+ public void loadActions(JAXXObject ui) {
+ if (log.isDebugEnabled()) {
+ log.debug("for ui " + ui.getClass());
+ }
+ for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
+ String actionKey = entry.getKey();
+ Object comp = ui.getObjectById(actionKey);
+ if (comp == null || !(comp instanceof AbstractButton || comp instanceof JComboBox)) {
+ // nothing to do
+ continue;
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("detect action " + actionKey);
+ }
+ if (comp instanceof AbstractButton) {
+ AbstractButton component = (AbstractButton) comp;
+ A action = newAction(actionKey, component);
+
+ component.setAction(action);
+
+ if (component instanceof JAXXToggleButton) {
+ JAXXToggleButton glueComponent = (JAXXToggleButton) component;
+ glueComponent.setIcon((Icon) action.getValue(Action.SMALL_ICON));
+ Integer integer = (Integer) action.getValue(Action.MNEMONIC_KEY);
+ if (integer != null) {
+ glueComponent.setNormalMnemonic(integer);
+ }
+ glueComponent.setSelectedIcon((Icon) action.getValue(Action.SMALL_ICON + 2));
+ integer = (Integer) action.getValue(Action.MNEMONIC_KEY + 2);
+ if (integer != null) {
+ glueComponent.setGlueMnemonic(integer);
+ }
+ glueComponent.setGlueText((String) action.getValue(Action.NAME + 2));
+ glueComponent.setGlueTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION + 2));
+
+ glueComponent.setNormalText((String) action.getValue(Action.NAME));
+ glueComponent.setNormalTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION));
+ }
+
+ Boolean value = (Boolean) action.getValue("hideActionText");
+ component.setHideActionText(value != null && value);
+ action.setEnabled(true);
+ continue;
+ }
+ // is JComboBox
+ JComboBox component = (JComboBox) comp;
+ A action = newAction(actionKey, component);
+
+ component.setAction(action);
+ Integer val = (Integer) action.getValue("selectedIndex");
+ if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
+ component.setSelectedIndex(val);
+ }
+ }
+ }
+
+ /**
+ * @param actionKey le nom de l'action tel que définie dans le fichier
+ * de mapping (sans le prefix action.)
+ * @param component le button où rattacher l'action
+ * @return une nouvelle instance de l'action associée à sa clef.
+ */
+ public A newAction(String actionKey, JComponent component) {
+ // try first in cache
+ A result = getActionFromCache(actionKey);
+ if (result != null) {
+ return result;
+ }
+
+ try {
+ result = newActionInstance(actionKey);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("create <" + actionKey + " : " + result + ">");
+ }
+
+ // recherche de l'annotation de configuration
+ ActionConfigurationResolver<?, ?> configurationResolver = resolveActionConfiguration(result);
+
+ if (configurationResolver != null) {
+ configurationResolver.applyConfiguration(component, result);
+ }
+
+ try {
+
+ if (configurationResolver != null) {
+ if (AbstractButton.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
+ finalizeNewAction((AbstractButton) component, result, configurationResolver);
+ }
+
+ if (JComboBox.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
+ finalizeNewAction((JComboBox) component, result, configurationResolver);
+ }
+
+ return result;
+ }
+
+ if (component == null || component instanceof AbstractButton) {
+ finalizeNewAction((AbstractButton) component, result, configurationResolver);
+ return result;
+ }
+
+ if (component instanceof JComboBox) {
+ finalizeNewAction((JComboBox) component, result, configurationResolver);
+ }
+ } finally {
+ // save result in cache
+ cache.put(actionKey, result);
+ }
+
+ return result;
+ }
+
+ public A newAction(String actionKey) {
+ return newAction(actionKey, null);
+ }
+
+ public String[] getActionNames() {
+ return impls.keySet().toArray(new String[impls.size()]);
+ }
+
+ public Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet() {
+ return impls.entrySet();
+ }
+
+ public Set<Entry<String, A>> cacheEntrySet() {
+ return cache.entrySet();
+ }
+
+ public void fireAction(String actionKey, Object source, JComponent component) {
+ A action = newAction(actionKey, component);
+ fireAction0(actionKey, source, action);
+ }
+
+ public void fireAction(String actionKey, Object source) {
+ fireAction(actionKey, source, null);
+ }
+
+ /**
+ * @param actionKey la clef de l'action
+ * @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouvée.
+ */
+ public A getActionFromCache(String actionKey) {
+ // on vérifie que l'action existe bien
+ checkRegistredAction(actionKey);
+
+ // try in cache
+ if (cache.containsKey(actionKey)) {
+ // use cached action
+ A action = cache.get(actionKey);
+ if (log.isDebugEnabled()) {
+ log.debug("use cache action " + action);
+ }
+ return action;
+ }
+ return null;
+ }
+
+ public void dispose() {
+ if (log.isInfoEnabled()) {
+ log.info(this);
+ }
+ for (String actionKey : getActionNames()) {
+ MyAbstractAction action = getActionFromCache(actionKey);
+ if (action != null) {
+ action.disposeUI();
+ }
+ }
+ resetCache();
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ resetCache();
+ impls.clear();
+ }
+
+ /**
+ * @param component le button où rattacher l'action
+ * @param action action
+ * @param configurationResolver initializer
+ */
+ protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
+
+ if (configurationResolver == null) {
+ // no configurationResolver matching,
+ if (component != null) {
+ action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
+ action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
+ action.putValue(Action.SMALL_ICON, component.getIcon());
+ action.putValue(Action.NAME, component.getText());
+ action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
+ action.putValue("hideActionText", component.getHideActionText());
+ if (component instanceof JAXXToggleButton) {
+ JAXXToggleButton glueComponent = (JAXXToggleButton) component;
+ action.putValue(Action.SHORT_DESCRIPTION, glueComponent.getNormalTooltipText());
+ action.putValue(Action.NAME, glueComponent.getNormalText());
+ action.putValue(Action.SMALL_ICON, glueComponent.getIcon());
+ action.putValue(Action.MNEMONIC_KEY, glueComponent.getNormalMnemonic());
+ action.putValue(Action.SHORT_DESCRIPTION + 2, glueComponent.getGlueTooltipText());
+ action.putValue(Action.NAME + 2, glueComponent.getGlueText());
+ action.putValue(Action.SMALL_ICON + 2, glueComponent.getSelectedIcon());
+ action.putValue(Action.MNEMONIC_KEY + 2, glueComponent.getGlueMnemonic());
+ }
+ }
+
+ }
+
+ String text = (String) action.getValue(Action.NAME);
+ Integer mnemo = (Integer) action.getValue(Action.MNEMONIC_KEY);
+ if (mnemo != null && mnemo != '\0') {
+ int pos = text.indexOf((char) mnemo.intValue());
+ if (pos == -1) {
+ pos = text.indexOf(Character.toLowerCase((char) mnemo.intValue()));
+ }
+ action.putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, pos);
+ }
+
+ }
+
+ /**
+ * @param component le select box où rattacher l'action
+ * @param action action
+ * @param configurationResolver initializer
+ */
+ protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
+
+ if (configurationResolver == null) {
+ action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
+ action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
+ //result.putValue("selectedIndex", component.getSelectedIndex());
+ }
+
+ }
+
+ protected ActionConfigurationResolver resolveActionConfiguration(MyAbstractAction action) {
+ for (ActionConfigurationResolver resolver : configurationResolvers) {
+ if (resolver.resolveConfiguration(action) != null) {
+ return resolver;
+ }
+ }
+ return null;
+ }
+
+ protected <I extends AbstractActionConfigurationResolver> I registerInitializer(Class<I> initizalizer) {
+ try {
+ I instance = initizalizer.newInstance();
+ configurationResolvers.add(instance);
+ return instance;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void fireAction0(String actionKey, Object source, A action) {
+ if (action == null) {
+ log.warn("could not find action " + actionKey);
+ return;
+ }
+ ActionEvent event = new ActionEvent(source, ActionEvent.ACTION_FIRST, actionKey);
+ action.actionPerformed(event);
+ }
+
+ protected void checkRegistredAction(String actionKey) {
+ if (!impls.containsKey(actionKey)) {
+ throw new IllegalStateException("can not find a registered action for key " + actionKey);
+ }
+ }
+
+
+ @SuppressWarnings({"unchecked"})
+ protected A newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+ Class<? extends MyAbstractAction> klazz = impls.get(actionKey);
+ MyAbstractAction result;
+ result = klazz.getConstructor(String.class).newInstance(actionKey);
+ result.putValue(Action.ACTION_COMMAND_KEY, actionKey);
+ if (!getBaseImpl().isAssignableFrom(klazz)) {
+ // the instanciated action must be boxed in the base Action of the factory
+ result = getBaseImpl().getConstructor(MyAbstractAction.class).newInstance(result);
+ }
+ return (A) result;
+ }
+
+
+ public Map<String, Class<? extends MyAbstractAction>> init() {
+ if (log.isDebugEnabled()) {
+ log.debug("start loading " + this);
+ }
+ // obtain a ServiceLoader on ActionProvider
+ ServiceLoader<ActionProvider> loader = ServiceLoader.load(ActionProvider.class);
+ Map<String, Class<? extends MyAbstractAction>> cache = new TreeMap<String, Class<? extends MyAbstractAction>>();
+
+ for (ActionProvider<?> actionProvider : loader) {
+ if (log.isDebugEnabled()) {
+ log.debug("found " + actionProvider);
+ }
+ cache.putAll(actionProvider.getClasses());
+ }
+ return cache;
+ }
+
+}
\ No newline at end of file
Deleted: 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-08-09 09:32:14 UTC (rev 819)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-08-09 09:32:42 UTC (rev 820)
@@ -1,132 +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.factory;
-
-import jaxx.runtime.JAXXObject;
-import org.codelutin.jaxx.action.MyAbstractAction;
-
-import javax.swing.JComponent;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * Action factory using the ActionConfig annotations to configure the action.
- * <p/>
- * Use after the {@link #loadActions(jaxx.runtime.JAXXObject)} to instanciate
- * actions in ui with id equals a known action...
- * <p/>
- * TODO Finish doc
- *
- * @author chemit
- */
-public interface ActionFactory<A extends MyAbstractAction> {
-
- /**
- * Method to init the dictionary of knwon action implementations.
- *
- * @return the dictionary of known action implementations
- */
- Map<String, Class<? extends MyAbstractAction>> init();
-
- /** @return the class of the base action of the factory. */
- Class<A> getBaseImpl();
-
- /** clear the cache of instanciated actions. */
- void resetCache();
-
- /**
- * @param actionKey the key of an action
- * @return the action with this key from cache, or <code>null</code> if this action is not in cache
- */
- A get(String actionKey);
-
- /**
- * For a given ui, load all actions registred in factory.
- * <p/>
- * The id of the widget in ui is directly mapped to a action key.
- *
- * @param ui the ui to treate
- */
- void loadActions(JAXXObject ui);
-
- /**
- * Obtain an action instance given his key and widget
- *
- * @param actionKey the key of action
- * @param component the component using the action
- * @return the instanciated action (could come from cache if already instanciated {@link #getActionFromCache(String)}
- */
- A newAction(String actionKey, JComponent component);
-
- /**
- * Obtain an action instance given his key (should call {@link #newAction(String, javax.swing.JComponent)}
- * <p/>
- * This is a convinient method when you want to obtain an action with no attached widget.
- *
- * @param actionKey the key of action
- * @return the instanciated action (could come from cache if already instanciated {@link #getActionFromCache(String)}
- */
- A newAction(String actionKey);
-
- /** @return the array of names of all actions known by the factory */
- String[] getActionNames();
-
- /** @return the set of all the action's classes known by the factory. */
- Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
-
- /** @return the set of all actions cached in factory indexed by their name */
- Set<Entry<String, A>> cacheEntrySet();
-
- /**
- * Fire an action given his key, his source and tthe widget responsible of action
- *
- * @param actionKey the action's key
- * @param source the object source of action
- * @param component the component doing the action
- */
- void fireAction(String actionKey, Object source, JComponent component);
-
- /**
- * Fire an action given his key and his source, no widget are involved here
- *
- * @param actionKey the action's key
- * @param source the object source of action
- */
- void fireAction(String actionKey, Object source);
-
- /**
- * 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.
- *
- * @param actionKey action's key
- * @param source source of action
- * @param action real action
- */
- void fireAction0(String actionKey, Object source, A action);
-
- /**
- * @param actionKey the action's key
- * @return the action in cache or <code>null</code> if action is not in cache
- */
- MyAbstractAction getActionFromCache(String actionKey);
-
- /**
- * dispose all actions in cache using {@link org.codelutin.jaxx.action.MyAbstractAction#disposeUI()} on each
- * action, then {@link #resetCache()}
- */
- void dispose();
-}
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-09 09:32:14 UTC (rev 819)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-09 09:32:42 UTC (rev 820)
@@ -1,412 +0,0 @@
-/*
-* ##% Copyright (C) 2007, 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.factory;
-
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.swing.JAXXToggleButton;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.jaxx.action.ActionProvider;
-import org.codelutin.jaxx.action.MyAbstractAction;
-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;
-import javax.swing.Icon;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import java.awt.event.ActionEvent;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.TreeMap;
-
-/**
- * A simple implementation of {@link ActionFactory} using some {@link ActionProvider} to seek actions.
- * <p/>
- * <p/>
- * An entry is in that form : <code>action.actionName=fqn</code> where
- * <p/>
- * <code>actionName</code> is the key of action used in factory, and
- * <code>fqn</code> is the fully qualified name of the implemented action class.
- * <p/>
- * A special clase is to have for a given entry a key like this : <code>action.:fqn'=fqn</code>, in that case,
- * le fqn' is a classe of type {@link org.codelutin.jaxx.action.ActionNameProvider} which gives us at
- * runtime the names of each entry to put in cache for the givne action fqn.
- *
- * @author chemit
- */
-public class ActionFactoryFromProvider<A extends MyAbstractAction> implements ActionFactory<A> {
-
- protected static Log log = LogFactory.getLog(ActionFactoryFromProvider.class);
-
- public static <A extends MyAbstractAction> ActionFactory<A> newInstance(Class<A> klazz) {
- return new ActionFactoryFromProvider<A>(klazz);
- }
-
- /** class of encapsuling action */
- protected Class<A> baseImpl;
-
- /** dictionary of known actions implementations */
- private Map<String, Class<? extends MyAbstractAction>> impls;
-
- /** dictionary of instanciated actions */
- private Map<String, A> cache;
-
- protected final ActionConfigConfigurationResolver actionConfigInitializer;
- protected final ToggleActionConfigConfigurationResolver toggleActionConfigInitializer;
- protected final SelectActionConfigConfigurationResolver selectActionConfigInitializer;
-
- protected List<AbstractActionConfigurationResolver> configurationResolvers;
-
- protected ActionFactoryFromProvider(Class<A> baseImpl) {
- this.baseImpl = baseImpl;
- this.impls = init();
- this.cache = new TreeMap<String, A>();
- this.configurationResolvers = new java.util.ArrayList<AbstractActionConfigurationResolver>();
-
- this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigConfigurationResolver.class);
- this.actionConfigInitializer = registerInitializer(ActionConfigConfigurationResolver.class);
- this.selectActionConfigInitializer = registerInitializer(SelectActionConfigConfigurationResolver.class);
- }
-
- public Class<A> getBaseImpl() {
- return baseImpl;
- }
-
- public void resetCache() {
- cache.clear();
- }
-
- public A get(String actionKey) {
- return cache.get(actionKey);
- }
-
- public void loadActions(JAXXObject ui) {
- if (log.isDebugEnabled()) {
- log.debug("for ui " + ui.getClass());
- }
- for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
- String actionKey = entry.getKey();
- Object comp = ui.getObjectById(actionKey);
- if (comp == null || !(comp instanceof AbstractButton || comp instanceof JComboBox)) {
- // nothing to do
- continue;
- }
- if (log.isTraceEnabled()) {
- log.trace("detect action " + actionKey);
- }
- if (comp instanceof AbstractButton) {
- AbstractButton component = (AbstractButton) comp;
- A action = newAction(actionKey, component);
-
- component.setAction(action);
-
- if (component instanceof JAXXToggleButton) {
- JAXXToggleButton glueComponent = (JAXXToggleButton) component;
- glueComponent.setIcon((Icon) action.getValue(Action.SMALL_ICON));
- Integer integer = (Integer) action.getValue(Action.MNEMONIC_KEY);
- if (integer != null) {
- glueComponent.setNormalMnemonic(integer);
- }
- glueComponent.setSelectedIcon((Icon) action.getValue(Action.SMALL_ICON + 2));
- integer = (Integer) action.getValue(Action.MNEMONIC_KEY + 2);
- if (integer != null) {
- glueComponent.setGlueMnemonic(integer);
- }
- glueComponent.setGlueText((String) action.getValue(Action.NAME + 2));
- glueComponent.setGlueTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION + 2));
-
- glueComponent.setNormalText((String) action.getValue(Action.NAME));
- glueComponent.setNormalTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION));
- }
-
- Boolean value = (Boolean) action.getValue("hideActionText");
- component.setHideActionText(value != null && value);
- action.setEnabled(true);
- continue;
- }
- // is JComboBox
- JComboBox component = (JComboBox) comp;
- A action = newAction(actionKey, component);
-
- component.setAction(action);
- Integer val = (Integer) action.getValue("selectedIndex");
- if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
- component.setSelectedIndex(val);
- }
- }
- }
-
- /**
- * @param actionKey le nom de l'action tel que définie dans le fichier
- * de mapping (sans le prefix action.)
- * @param component le button où rattacher l'action
- * @return une nouvelle instance de l'action associée à sa clef.
- */
- public A newAction(String actionKey, JComponent component) {
- // try first in cache
- A result = getActionFromCache(actionKey);
- if (result != null) {
- return result;
- }
-
- try {
- result = newActionInstance(actionKey);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("create <" + actionKey + " : " + result + ">");
- }
-
- // recherche de l'annotation de configuration
- ActionConfigurationResolver<?, ?> configurationResolver = resolveActionConfiguration(result);
-
- if (configurationResolver != null) {
- configurationResolver.applyConfiguration(component, result);
- }
-
- try {
-
- if (configurationResolver != null) {
- if (AbstractButton.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
- finalizeNewAction((AbstractButton) component, result, configurationResolver);
- }
-
- if (JComboBox.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
- finalizeNewAction((JComboBox) component, result, configurationResolver);
- }
-
- return result;
- }
-
- if (component == null || component instanceof AbstractButton) {
- finalizeNewAction((AbstractButton) component, result, configurationResolver);
- return result;
- }
-
- if (component instanceof JComboBox) {
- finalizeNewAction((JComboBox) component, result, configurationResolver);
- }
- } finally {
- // save result in cache
- cache.put(actionKey, result);
- }
-
- return result;
- }
-
- public A newAction(String actionKey) {
- return newAction(actionKey, null);
- }
-
- public String[] getActionNames() {
- return impls.keySet().toArray(new String[impls.size()]);
- }
-
- public Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet() {
- return impls.entrySet();
- }
-
- public Set<Entry<String, A>> cacheEntrySet() {
- return cache.entrySet();
- }
-
- public void fireAction(String actionKey, Object source, JComponent component) {
- A action = newAction(actionKey, component);
- fireAction0(actionKey, source, action);
- }
-
- public void fireAction(String actionKey, Object source) {
- fireAction(actionKey, source, null);
- }
-
- /**
- * @param actionKey la clef de l'action
- * @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouvée.
- */
- public A getActionFromCache(String actionKey) {
- // on vérifie que l'action existe bien
- checkRegistredAction(actionKey);
-
- // try in cache
- if (cache.containsKey(actionKey)) {
- // use cached action
- A action = cache.get(actionKey);
- if (log.isDebugEnabled()) {
- log.debug("use cache action " + action);
- }
- return action;
- }
- return null;
- }
-
- public void dispose() {
- if (log.isInfoEnabled()) {
- log.info(this);
- }
- for (String actionKey : getActionNames()) {
- MyAbstractAction action = getActionFromCache(actionKey);
- if (action != null) {
- action.disposeUI();
- }
- }
- resetCache();
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- resetCache();
- impls.clear();
- }
-
- /**
- * @param component le button où rattacher l'action
- * @param action action
- * @param configurationResolver initializer
- */
- protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
-
- if (configurationResolver == null) {
- // no configurationResolver matching,
- if (component != null) {
- action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
- action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
- action.putValue(Action.SMALL_ICON, component.getIcon());
- action.putValue(Action.NAME, component.getText());
- action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
- action.putValue("hideActionText", component.getHideActionText());
- if (component instanceof JAXXToggleButton) {
- JAXXToggleButton glueComponent = (JAXXToggleButton) component;
- action.putValue(Action.SHORT_DESCRIPTION, glueComponent.getNormalTooltipText());
- action.putValue(Action.NAME, glueComponent.getNormalText());
- action.putValue(Action.SMALL_ICON, glueComponent.getIcon());
- action.putValue(Action.MNEMONIC_KEY, glueComponent.getNormalMnemonic());
- action.putValue(Action.SHORT_DESCRIPTION + 2, glueComponent.getGlueTooltipText());
- action.putValue(Action.NAME + 2, glueComponent.getGlueText());
- action.putValue(Action.SMALL_ICON + 2, glueComponent.getSelectedIcon());
- action.putValue(Action.MNEMONIC_KEY + 2, glueComponent.getGlueMnemonic());
- }
- }
-
- }
-
- String text = (String) action.getValue(Action.NAME);
- Integer mnemo = (Integer) action.getValue(Action.MNEMONIC_KEY);
- if (mnemo != null && mnemo != '\0') {
- int pos = text.indexOf((char) mnemo.intValue());
- if (pos == -1) {
- pos = text.indexOf(Character.toLowerCase((char) mnemo.intValue()));
- }
- action.putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, pos);
- }
-
- }
-
- /**
- * @param component le select box où rattacher l'action
- * @param action action
- * @param configurationResolver initializer
- */
- protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
-
- if (configurationResolver == null) {
- action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
- action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
- //result.putValue("selectedIndex", component.getSelectedIndex());
- }
-
- }
-
- protected ActionConfigurationResolver resolveActionConfiguration(MyAbstractAction action) {
- for (ActionConfigurationResolver resolver : configurationResolvers) {
- if (resolver.resolveConfiguration(action) != null) {
- return resolver;
- }
- }
- return null;
- }
-
- protected <I extends AbstractActionConfigurationResolver> I registerInitializer(Class<I> initizalizer) {
- try {
- I instance = initizalizer.newInstance();
- configurationResolvers.add(instance);
- return instance;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public void fireAction0(String actionKey, Object source, A action) {
- if (action == null) {
- log.warn("could not find action " + actionKey);
- return;
- }
- ActionEvent event = new ActionEvent(source, ActionEvent.ACTION_FIRST, actionKey);
- action.actionPerformed(event);
- }
-
- protected void checkRegistredAction(String actionKey) {
- if (!impls.containsKey(actionKey)) {
- throw new IllegalStateException("can not find a registered action for key " + actionKey);
- }
- }
-
-
- @SuppressWarnings({"unchecked"})
- protected A newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
- Class<? extends MyAbstractAction> klazz = impls.get(actionKey);
- MyAbstractAction result;
- result = klazz.getConstructor(String.class).newInstance(actionKey);
- result.putValue(Action.ACTION_COMMAND_KEY, actionKey);
- if (!getBaseImpl().isAssignableFrom(klazz)) {
- // the instanciated action must be boxed in the base Action of the factory
- result = getBaseImpl().getConstructor(MyAbstractAction.class).newInstance(result);
- }
- return (A) result;
- }
-
-
- public Map<String, Class<? extends MyAbstractAction>> init() {
- if (log.isDebugEnabled()) {
- log.debug("start loading " + this);
- }
- // obtain a ServiceLoader on ActionProvider
- ServiceLoader<ActionProvider> loader = ServiceLoader.load(ActionProvider.class);
- Map<String, Class<? extends MyAbstractAction>> cache = new TreeMap<String, Class<? extends MyAbstractAction>>();
-
- for (ActionProvider<?> actionProvider : loader) {
- if (log.isDebugEnabled()) {
- log.debug("found " + actionProvider);
- }
- cache.putAll(actionProvider.getClasses());
- }
- return cache;
- }
-
-}
\ No newline at end of file
1
0
r819 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . factory
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
Aug. 9, 2008
Author: tchemit
Date: 2008-08-09 09:32:14 +0000 (Sat, 09 Aug 2008)
New Revision: 819
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
Log:
simplification du code : suppression du paquetage provider
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-09 09:31:56 UTC (rev 818)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-09 09:32:14 UTC (rev 819)
@@ -22,8 +22,6 @@
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;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-09 09:31:56 UTC (rev 818)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-09 09:32:14 UTC (rev 819)
@@ -21,13 +21,13 @@
import jaxx.runtime.swing.JAXXToggleButton;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.jaxx.action.ActionProvider;
import org.codelutin.jaxx.action.MyAbstractAction;
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 org.codelutin.jaxx.action.provider.ActionProvider;
import javax.swing.AbstractButton;
import javax.swing.Action;
1
0
r818 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . provider
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 9, 2008
Aug. 9, 2008
Author: tchemit
Date: 2008-08-09 09:31:56 +0000 (Sat, 09 Aug 2008)
New Revision: 818
Added:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderFromProperties.java
Removed:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java
Log:
simplification du code : suppression du paquetage provider
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java 2008-08-06 10:53:44 UTC (rev 817)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java 2008-08-09 09:31:56 UTC (rev 818)
@@ -16,6 +16,13 @@
/**
* Contrat pour obtenir les noms d'une action de manière dynamique.
+ * <p/>
+ * Cette méthode sera appelé par un {@link ActionProvider} lorsque la clef dans le
+ * fichier de mapping est :fqn (où fqn correspond à une implantation de ce contrat).
+ * <p/>
+ * Ainsi on peut associer à une action donnée plusieurs instances avec des noms différents mais avec le même comportement.
+ * <p/>
+ * Par exemple, une changement de locale où seule la locale varie (et elle sera retrouvée à partir du nom de l'action).
*
* @author chemit
*/
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java (from rev 796, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProvider.java 2008-08-09 09:31:56 UTC (rev 818)
@@ -0,0 +1,35 @@
+/**
+ * # #% 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;
+
+/**
+ * Contract to be realized by a provider of Actions.
+ * <p/>
+ * A provider of actions
+ *
+ * @author chemit
+ */
+public interface ActionProvider<A extends MyAbstractAction> {
+
+ /** @return the name of the provider */
+ String getName();
+
+ /** @return the base classe of provided actions */
+ Class<A> getBaseClass();
+
+ /** @return the provided actions classes */
+ java.util.Map<String, Class<? extends A>> getClasses();
+
+}
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderFromProperties.java (from rev 817, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderFromProperties.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionProviderFromProperties.java 2008-08-09 09:31:56 UTC (rev 818)
@@ -0,0 +1,142 @@
+/**
+ * # #% 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import static org.codelutin.i18n.I18n._;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
+
+/** @author chemit */
+public class ActionProviderFromProperties<A extends MyAbstractAction> implements ActionProvider<A> {
+
+ /** default prefix for an entryin mapping file. */
+ protected static final String ACTION_KEY_PREFIX = "action.";
+
+ protected String propertiesPath;
+
+ protected static Log log = LogFactory.getLog(ActionProviderFromProperties.class);
+
+ protected String name;
+
+ protected Class<A> baseClass;
+
+ protected Map<String, Class<? extends A>> actions;
+
+
+ protected ActionProviderFromProperties(String name, Class<A> baseClass, String propertiesPath) {
+
+ this.name = name;
+ this.baseClass = baseClass;
+
+ this.propertiesPath = propertiesPath;
+ this.actions = initCache();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<A> getBaseClass() {
+ return baseClass;
+ }
+
+ public Map<String, Class<? extends A>> getClasses() {
+ return actions;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<name:" + name + ", baseClass:" + baseClass.getSimpleName() + ">";
+ }
+
+ protected void clearCache() {
+ if (actions != null) {
+ actions.clear();
+ actions = null;
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ clearCache();
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected Map<String, Class<? extends A>> initCache() {
+
+ InputStream inputStream = null;
+
+ Properties properties = new Properties();
+
+ try {
+ inputStream = getClass().getResourceAsStream(propertiesPath);
+ if (inputStream == null) {
+ throw new NullPointerException("could not find action file " + propertiesPath);
+ }
+ log.info("load " + propertiesPath);
+ properties.load(inputStream);
+ } catch (IOException e) {
+ log.warn(_("jaxx.error.load.actions.file", e.getMessage()));
+ throw new RuntimeException(_("jaxx.error.load.actions.file", e.getMessage()));
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ log.warn(_("jaxx.error.close.actions.file", e.getMessage()));
+ //throw new RuntimeException(_("jaxx.error.load.actions.file", e.getMessage()));
+ }
+ }
+ }
+
+ Map<String, Class<? extends A>> cache = new TreeMap<String, Class<? extends A>>();
+ int prefix = ACTION_KEY_PREFIX.length();
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ String key = entry.getKey() + "";
+ String qfn = entry.getValue() + "";
+ try {
+ Class<? extends A> implCass;
+ implCass = (Class<? extends A>) Class.forName(qfn);
+ String actionKey = key.substring(prefix);
+ if (actionKey.startsWith(":")) {
+ // this is a RuntimeActionNameProvider
+ Class<ActionNameProvider> klazz = (Class<ActionNameProvider>) Class.forName(actionKey.substring(1));
+ for (String s : klazz.newInstance().getActionCommands()) {
+ log.debug("found action <" + s + " : " + implCass + ">");
+ cache.put(s, implCass);
+ }
+ continue;
+ }
+ log.debug("found action <" + actionKey + " : " + implCass + ">");
+ cache.put(actionKey, implCass);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
+ }
+ }
+
+ return cache;
+ }
+}
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java 2008-08-06 10:53:44 UTC (rev 817)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java 2008-08-09 09:31:56 UTC (rev 818)
@@ -1,37 +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.provider;
-
-import org.codelutin.jaxx.action.MyAbstractAction;
-
-/**
- * Contract to be realized by a provider of Actions.
- * <p/>
- * A provider of actions
- *
- * @author chemit
- */
-public interface ActionProvider<A extends MyAbstractAction> {
-
- /** @return the name of the provider */
- String getName();
-
- /** @return the base classe of provided actions */
- Class<A> getBaseClass();
-
- /** @return the provided actions classes */
- java.util.Map<String, Class<? extends A>> getClasses();
-
-}
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-06 10:53:44 UTC (rev 817)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-09 09:31:56 UTC (rev 818)
@@ -1,144 +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.provider;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import static org.codelutin.i18n.I18n._;
-import org.codelutin.jaxx.action.ActionNameProvider;
-import org.codelutin.jaxx.action.MyAbstractAction;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TreeMap;
-
-/** @author chemit */
-public class ActionProviderFromProperties<A extends MyAbstractAction> implements ActionProvider<A> {
-
- /** default prefix for an entryin mapping file. */
- protected static final String ACTION_KEY_PREFIX = "action.";
-
- protected String propertiesPath;
-
- protected static Log log = LogFactory.getLog(ActionProviderFromProperties.class);
-
- protected String name;
-
- protected Class<A> baseClass;
-
- protected Map<String, Class<? extends A>> actions;
-
-
- protected ActionProviderFromProperties(String name, Class<A> baseClass, String propertiesPath) {
-
- this.name = name;
- this.baseClass = baseClass;
-
- this.propertiesPath = propertiesPath;
- this.actions = initCache();
- }
-
- public String getName() {
- return name;
- }
-
- public Class<A> getBaseClass() {
- return baseClass;
- }
-
- public Map<String, Class<? extends A>> getClasses() {
- return actions;
- }
-
- @Override
- public String toString() {
- return super.toString() + "<name:" + name + ", baseClass:" + baseClass.getSimpleName() + ">";
- }
-
- protected void clearCache() {
- if (actions != null) {
- actions.clear();
- actions = null;
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- clearCache();
- }
-
- @SuppressWarnings({"unchecked"})
- protected Map<String, Class<? extends A>> initCache() {
-
- InputStream inputStream = null;
-
- Properties properties = new Properties();
-
- try {
- inputStream = getClass().getResourceAsStream(propertiesPath);
- if (inputStream == null) {
- throw new NullPointerException("could not find action file " + propertiesPath);
- }
- log.info("load " + propertiesPath);
- properties.load(inputStream);
- } catch (IOException e) {
- log.warn(_("jaxx.error.load.actions.file", e.getMessage()));
- throw new RuntimeException(_("jaxx.error.load.actions.file", e.getMessage()));
- } finally {
- if (inputStream != null) {
- try {
- inputStream.close();
- } catch (IOException e) {
- log.warn(_("jaxx.error.close.actions.file", e.getMessage()));
- //throw new RuntimeException(_("jaxx.error.load.actions.file", e.getMessage()));
- }
- }
- }
-
- Map<String, Class<? extends A>> cache = new TreeMap<String, Class<? extends A>>();
- int prefix = ACTION_KEY_PREFIX.length();
- for (Map.Entry<Object, Object> entry : properties.entrySet()) {
- String key = entry.getKey() + "";
- String qfn = entry.getValue() + "";
- try {
- Class<? extends A> implCass;
- implCass = (Class<? extends A>) Class.forName(qfn);
- String actionKey = key.substring(prefix);
- if (actionKey.startsWith(":")) {
- // this is a RuntimeActionNameProvider
- Class<ActionNameProvider> klazz = (Class<ActionNameProvider>) Class.forName(actionKey.substring(1));
- for (String s : klazz.newInstance().getActionCommands()) {
- log.debug("found action <" + s + " : " + implCass + ">");
- cache.put(s, implCass);
- }
- continue;
- }
- log.debug("found action <" + actionKey + " : " + implCass + ">");
- cache.put(actionKey, implCass);
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
- } catch (InstantiationException e) {
- throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
- }
- }
-
- return cache;
- }
-}
1
0
r817 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . factory provider
by tchemit@users.labs.libre-entreprise.org Aug. 6, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 6, 2008
Aug. 6, 2008
Author: tchemit
Date: 2008-08-06 10:53:44 +0000 (Wed, 06 Aug 2008)
New Revision: 817
Added:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java
Removed:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java
Log:
simplification du code : on conserve uniquement l'interface ActionNameProvider et plus la classe ActionNameHelper et les diff?\195?\169rentes sortes ActionNameProvider car de toute facon il est tr?\195?\168s difficile au niveau de l'AnnotationProcessing d'utiliser une classe en scope compile car celle-ci n'est peut-?\195?\170tre pas compil?\195?\169, ce qui est assez probl?\195?\169matique (il faudrai g?\195?\169rer les rounds de compilation, ce que je ne veux pas faire...)
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-06 10:16:03 UTC (rev 816)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-06 10:53:44 UTC (rev 817)
@@ -306,7 +306,7 @@
TypeMirror t = (TypeMirror) entry.getValue().accept(getAnnotationValueExtractor(), null);
String classname = t.toString();
printDebug("actionCommandProvider = " + classname);
- if (classname.endsWith(ActionNameHelper.ActionNameProvider.class.getName())) {
+ if (classname.equals(ActionNameProvider.class.getName())) {
continue;
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java 2008-08-06 10:16:03 UTC (rev 816)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java 2008-08-06 10:53:44 UTC (rev 817)
@@ -48,7 +48,13 @@
/** @return array of names to be used in actions mapping */
String[] actionCommands() default {};
- Class<? extends ActionNameHelper.ActionNameProvider> actionCommandProvider() default ActionNameHelper.ActionNameProvider.class;
+ /**
+ * @return the class to obtain at runtime the array of names to be used in actions mapping.
+ * <p/>
+ * <b>Note : the special value {@link org.codelutin.jaxx.action.ActionNameProvider} is used to says not to used
+ * œthis mecanism since we can not set a null value in a annotation</b>
+ */
+ Class<? extends ActionNameProvider> actionCommandProvider() default org.codelutin.jaxx.action.ActionNameProvider.class;
/**
* @return la clef i18n du texte de l'action, si vide ignoré
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java 2008-08-06 10:16:03 UTC (rev 816)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java 2008-08-06 10:53:44 UTC (rev 817)
@@ -1,43 +0,0 @@
-/**
- * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
- * This program is free software; you
- * can redistribute it and/or modify it under the terms of the GNU General
- * Public License as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. This program is
- * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- * should have received a copy of the GNU General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
- * - Suite 330, Boston, MA 02111-1307, USA.
- * # #%
- */
-package org.codelutin.jaxx.action;
-
-/** @author chemit */
-public class ActionNameHelper {
-
- /**
- * Contrat pour obtenir les noms d'une action.
- *
- * @author chemit
- */
- public static interface ActionNameProvider {
-
- /** @return la liste des noms à utiliser par la classe d'action. */
- String[] getActionCommands();
-
- }
-
- /** Contrat pour obtenir les noms d'actions au moment de la compilation. */
- public static interface CompileActionNameProvider extends ActionNameProvider {
-
- }
-
- /** Contrat pour obtenir les noms d'actions au moment du runtime. */
- public static interface RuntimeActionNameProvider extends ActionNameProvider {
-
- }
-
-
-}
Added: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameProvider.java 2008-08-06 10:53:44 UTC (rev 817)
@@ -0,0 +1,27 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.jaxx.action;
+
+/**
+ * Contrat pour obtenir les noms d'une action de manière dynamique.
+ *
+ * @author chemit
+ */
+public interface ActionNameProvider {
+
+ /** @return la liste des noms à utiliser par la classe d'action. */
+ String[] getActionCommands();
+
+}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java 2008-08-06 10:16:03 UTC (rev 816)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java 2008-08-06 10:53:44 UTC (rev 817)
@@ -48,7 +48,13 @@
/** @return array of names to be used in actions mapping */
String[] actionCommands() default {};
- Class<? extends ActionNameHelper.ActionNameProvider> actionCommandProvider() default ActionNameHelper.ActionNameProvider.class;
+ /**
+ * @return the class to obtain at runtime the array of names to be used in actions mapping.
+ * <p/>
+ * <b>Note : the special value {@link org.codelutin.jaxx.action.ActionNameProvider} is used to says not to used
+ * œthis mecanism since we can not set a null value in a annotation</b>
+ */
+ Class<? extends ActionNameProvider> actionCommandProvider() default org.codelutin.jaxx.action.ActionNameProvider.class;
/**
* @return la clef i18n du texte de l'action, si vide ignoré
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java 2008-08-06 10:16:03 UTC (rev 816)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java 2008-08-06 10:53:44 UTC (rev 817)
@@ -46,7 +46,13 @@
/** @return array of names to be used in actions mapping */
String[] actionCommands() default {};
- Class<? extends ActionNameHelper.ActionNameProvider> actionCommandProvider() default ActionNameHelper.ActionNameProvider.class;
+ /**
+ * @return the class to obtain at runtime the array of names to be used in actions mapping.
+ * <p/>
+ * <b>Note : the special value {@link org.codelutin.jaxx.action.ActionNameProvider} is used to says not to used
+ * œthis mecanism since we can not set a null value in a annotation</b>
+ */
+ Class<? extends ActionNameProvider> actionCommandProvider() default org.codelutin.jaxx.action.ActionNameProvider.class;
/**
* @return la clef i18n du texte de l'action, si vide ignoré
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-06 10:16:03 UTC (rev 816)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-06 10:53:44 UTC (rev 817)
@@ -44,14 +44,17 @@
import java.util.TreeMap;
/**
- * TODO Do javadoc which is not up to date...
- * A simple implementation of {@link ActionFactory} using a properties file to
- * load action mapping.
+ * A simple implementation of {@link ActionFactory} using some {@link ActionProvider} to seek actions.
* <p/>
+ * <p/>
* An entry is in that form : <code>action.actionName=fqn</code> where
* <p/>
* <code>actionName</code> is the key of action used in factory, and
* <code>fqn</code> is the fully qualified name of the implemented action class.
+ * <p/>
+ * A special clase is to have for a given entry a key like this : <code>action.:fqn'=fqn</code>, in that case,
+ * le fqn' is a classe of type {@link org.codelutin.jaxx.action.ActionNameProvider} which gives us at
+ * runtime the names of each entry to put in cache for the givne action fqn.
*
* @author chemit
*/
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-06 10:16:03 UTC (rev 816)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-06 10:53:44 UTC (rev 817)
@@ -17,7 +17,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
-import org.codelutin.jaxx.action.ActionNameHelper.RuntimeActionNameProvider;
+import org.codelutin.jaxx.action.ActionNameProvider;
import org.codelutin.jaxx.action.MyAbstractAction;
import java.io.IOException;
@@ -121,7 +121,7 @@
String actionKey = key.substring(prefix);
if (actionKey.startsWith(":")) {
// this is a RuntimeActionNameProvider
- Class<RuntimeActionNameProvider> klazz = (Class<RuntimeActionNameProvider>) Class.forName(actionKey.substring(1));
+ Class<ActionNameProvider> klazz = (Class<ActionNameProvider>) Class.forName(actionKey.substring(1));
for (String s : klazz.newInstance().getActionCommands()) {
log.debug("found action <" + s + " : " + implCass + ">");
cache.put(s, implCass);
1
0
r816 - trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org Aug. 6, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 6, 2008
Aug. 6, 2008
Author: tchemit
Date: 2008-08-06 10:16:03 +0000 (Wed, 06 Aug 2008)
New Revision: 816
Removed:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java
Modified:
trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
Log:
simplification du code : on supprime la classe abstraite car pour le moment y'a qu'une seule implantation :)
Deleted: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-08-06 10:15:00 UTC (rev 815)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-08-06 10:16:03 UTC (rev 816)
@@ -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;
-
-import org.codelutin.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * @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}"
- * @required
- */
- protected String actionsFile;
-
- /**
- * @description flag to copy generated resource files to outClass
- * @parameter expression="${jaxx.copyToCP}" default-value="false"
- */
- protected boolean copyToCP;
-
- protected void copyResourceToCP(File file) throws IOException {
-
- String path = file.getAbsolutePath().substring(outResource.getAbsolutePath().length() + 1);
- File compiledFile = new File(outClass, path);
- if (verbose) {
- getLog().info("copy to classapth generated file " + compiledFile);
- }
- File parent = compiledFile.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
- FileUtil.copy(file, compiledFile);
- }
-
-}
Deleted: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2008-08-06 10:15:00 UTC (rev 815)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2008-08-06 10:16:03 UTC (rev 816)
@@ -1,183 +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;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.plugin.logging.Log;
-import org.apache.maven.project.MavenProject;
-import static org.codelutin.i18n.I18n._;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Set;
-
-/**
- * Le mojo de base pour les goals Jaxx.
- *
- * @author chemit
- */
-public abstract class AbstractJaxxMojo extends AbstractMojo {
-
- /**
- * @description Dépendance du projet.
- * @parameter default-value="${project}"
- * @readonly
- */
- protected MavenProject project;
-
- /**
- * @description Répertoire de destination des fichiers java à générer.
- * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
- */
- protected File outJava;
-
- /**
- * @description chemin du répertoire de génération des resources.
- * @parameter expression="${jaxx.outResource}" default-value="${basedir}/target/generated-sources/resources"
- */
- protected File outResource;
-
- /**
- * @description chemin du répertoire de compilation des resources.
- * @parameter expression="${jaxx.outClass}" default-value="${basedir}/target/classes"
- */
- protected File outClass;
-
- /**
- * @description verbose
- * @parameter expression="${jaxx.verbose}" default-value="false"
- */
- protected boolean verbose;
-
-
- protected abstract void doExecute() throws Exception;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- init();
-
- try {
-
- doExecute();
-
- } catch (Exception e) {
- getLog().error(e);
- Throwable e2 = e;
- while (e2.getCause() != null) {
- e2 = e.getCause();
- }
- getLog().error(e2);
-
- throw new MojoExecutionException(e.getMessage(), e);
- }
-
- }
-
- protected void init() {
-
- if (!outResource.exists()) {
- outResource.mkdirs();
- }
-
- if (!outJava.exists()) {
- outJava.mkdirs();
- }
-
- }
-
- protected void fixCompileSourceRoots() {
- if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
- project.addCompileSourceRoot(outJava.getPath());
- }
- }
-
- @SuppressWarnings({"unchecked"})
- protected URLClassLoader initClassLoader(MavenProject project, Log log) {
- URLClassLoader loader = null;
- if (project != null) {
- URLClassLoader result;
- try {
- Set<Artifact> compileClasspathElements = project.getArtifacts();
- URL[] url = new URL[compileClasspathElements.size() + 1];
- url[0] = outClass.toURI().toURL();
- int i = 1;
- for (Artifact artifact : compileClasspathElements) {
- File file = new File(artifact.getFile().getAbsolutePath());
- if (file.getName().endsWith(".jar")) {
- url[i] = new URL("jar", "", file.toURI().toURL().toString() + "!/");
- } else {
- url[i] = file.toURI().toURL();
- }
- i++;
- }
- //ClassLoader parent = Thread.currentThread().getContextClassLoader();
- if (compileClasspathElements.size() == 0) {
- result = new URLClassLoader(url, getClass().getClassLoader());
- } else {
- result = new URLClassLoader(url, getClass().getClassLoader());
- }
- } catch (MalformedURLException eee) {
- throw new RuntimeException(_("Can't create ClassLoader for script, bad directory: {0} for reason {1}", outClass, eee.getMessage()), eee);
- } catch (IOException e) {
- throw new RuntimeException(_("Can't create ClassLoader for script, bad directory: {0} for reason {1}", outClass, e.getMessage()), e);
- }
- loader = result;
- }
- if (verbose && loader != null) {
- for (URL entry : loader.getURLs()) {
- log.info("outClass url " + entry);
- }
- }
- return loader;
- }
-
- public File getOutJava() {
- return outJava;
- }
-
- public void setOutJava(File outJava) {
- this.outJava = outJava;
- }
-
- public File getOutResource() {
- return outResource;
- }
-
- public void setOutResource(File outResource) {
- this.outResource = outResource;
- }
-
- public File getOutClass() {
- return outClass;
- }
-
- public void setOutClass(File outClass) {
- this.outClass = outClass;
- }
-
- public boolean isVerbose() {
- return verbose;
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-08-06 10:15:00 UTC (rev 815)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-08-06 10:16:03 UTC (rev 816)
@@ -1,259 +0,0 @@
-/* *##%
- * Copyright (C) 2007
- * JaxxPlugin, Code Lutin
- *
- * 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;
-
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.codelutin.jaxx.action.ActionConfig;
-import org.codelutin.jaxx.action.SelectActionConfig;
-import org.codelutin.jaxx.action.ToggleActionConfig;
-import org.codelutin.util.SortedProperties;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Properties;
-
-/**
- * Classe permettant de generer le fichier de propriétés des actions détectées.
- *
- * @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 {
-
- /**
- * @description Répertoire sources des fichiers java à traiter.
- * @parameter expression="${jaxx.src}" default-value="${basedir}/src/main/java"
- */
- protected File src;
-
- /**
- * @description pour filter
- * @parameter expression="${jaxx.includes}"
- */
- protected String[] includes;
-
- /**
- * @description pour filter
- * @parameter expression="${jaxx.excludes}"
- */
- protected String[] excludes;
-
- protected String[] files;
-
- protected URLClassLoader loader;
-
- private static final String[] INCLUDES = {"**\\/*.java"};
-
-
- protected void doExecute() throws Exception {
-
- if (verbose) {
- printInit();
- }
-
- Properties result = loadProperties();
-
-
- saveProperties(result);
-
- }
-
- protected Properties loadProperties() throws ClassNotFoundException {
- Properties result = new SortedProperties();
- for (String file : files) {
- String fqn = file.substring(0, file.length() - 5).replaceAll("\\/", ".");
-
- if (verbose) {
- getLog().info("fqn to treate " + fqn);
- }
-
- Class<?> clazz = Class.forName(fqn, false, loader);
-
- // try a ActionConfig
- ActionConfig actionConfig = clazz.getAnnotation(ActionConfig.class);
- if (actionConfig != null) {
-
- if (actionConfig.multiNames().length > 0) {
- // multinames
- registerEntry(clazz, result, actionConfig.multiNames());
- continue;
- }
-
- if (!actionConfig.actionCommand().isEmpty()) {
- registerEntry(clazz, result, actionConfig.actionCommand());
- continue;
- }
-
- getLog().warn("could not treate class " + clazz);
- continue;
- }
-
- // try a SelectActionConfig
- SelectActionConfig selectActionConfig = clazz.getAnnotation(SelectActionConfig.class);
- if (selectActionConfig != null) {
- if (selectActionConfig.multiNames().length > 0) {
- // multinames
- registerEntry(clazz, result, selectActionConfig.multiNames());
- continue;
- }
-
- if (!selectActionConfig.actionCommand().isEmpty()) {
- registerEntry(clazz, result, selectActionConfig.actionCommand());
- continue;
- }
- getLog().warn("could not treate class " + clazz);
- continue;
- }
-
- // try a toggleAction
- ToggleActionConfig toggleActionConfig = clazz.getAnnotation(ToggleActionConfig.class);
- if (toggleActionConfig != null) {
- if (toggleActionConfig.multiNames().length > 0) {
- // multinames
- registerEntry(clazz, result, toggleActionConfig.multiNames());
- continue;
- }
-
- if (!toggleActionConfig.actionCommand().isEmpty()) {
- registerEntry(clazz, result, toggleActionConfig.actionCommand());
- continue;
- }
-
- getLog().warn("could not treate class " + clazz);
- }
-
- }
- return result;
- }
-
- protected void saveProperties(Properties result) throws IOException {
- OutputStream writer = null;
- File generatedFile = new File(outResource, actionsFile);
- File parent = generatedFile.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
- try {
- writer = new org.codelutin.util.PropertiesDateRemoveFilterStream(new java.io.FileOutputStream(generatedFile));
-
- result.store(writer, null);
-
-
- } finally {
- if (writer != null) {
- writer.flush();
- writer.close();
- }
- }
-
- if (copyToCP) {
- // save it also in classes
- copyResourceToCP(generatedFile);
- }
- }
-
-
- @Override
- protected void init() {
-
- super.init();
-
- DirectoryScanner ds;
- ds = new DirectoryScanner();
- ds.setBasedir(src);
- boolean noIncludes = includes == null || includes.length == 0;
- ds.setIncludes(noIncludes ? INCLUDES : includes);
- boolean noExcludes = excludes == null || excludes.length == 0;
- if (!noExcludes) {
- ds.setExcludes(excludes);
- }
- ds.scan();
- files = ds.getIncludedFiles();
-
- getLog().info("jaxx-actions - found " + files.length + " file(s) to treate. ");
-
- loader = initClassLoader(project, getLog());
- }
-
- protected void registerEntry(Class<?> clazz, Properties result, String... names) {
- for (String name : names) {
- if (verbose) {
- getLog().info("name: " + name + ", class:" + clazz);
- }
- result.put("action." + name, clazz.getName());
- }
- }
-
- protected void printInit() {
-
- for (String file : files) {
- getLog().info(file);
- }
-
- printCP();
- }
-
- protected void printCP() {
-
- getLog().info(loader.toString());
-
- for (URL url : loader.getURLs()) {
- getLog().info("url in class loader " + url);
- }
- }
-
- public File getSrc() {
- return src;
- }
-
- public void setSrc(File src) {
- this.src = src;
- }
-
- public String[] getIncludes() {
- return includes;
- }
-
- public void setIncludes(String[] includes) {
- this.includes = includes;
- }
-
- public String[] getExcludes() {
- return excludes;
- }
-
- public void setExcludes(String[] excludes) {
- this.excludes = excludes;
- }
-
- public String[] getFiles() {
- return files;
- }
-
- public void setFiles(String[] files) {
- this.files = files;
- }
-
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java 2008-08-06 10:15:00 UTC (rev 815)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java 2008-08-06 10:16:03 UTC (rev 816)
@@ -1,145 +0,0 @@
-/* *##%
- * Copyright (C) 2007
- * JaxxPlugin, Code Lutin
- *
- * 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;
-
-import org.codelutin.jaxx.action.provider.ActionProvider;
-import org.codelutin.jaxx.action.provider.ActionProviderFromProperties;
-import org.codelutin.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Classe permettant de generer un {@link org.codelutin.jaxx.action.provider.ActionProvider} et son fichier de déclaration.
- *
- * @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 {
-
- /**
- * @description FQN de la classe à générer.
- * @parameter expression="${jaxx.fqn}"
- * @required
- */
- protected String fqn;
-
- /**
- * @description nom logique du provider à générer.
- * @parameter expression="${jaxx.providerName}"
- * @required
- */
- protected String providerName;
-
- /**
- * @description FQN de la classe d'action à utiliser.
- * @parameter expression="${jaxx.fqnAction}"
- * @required
- */
- protected String fqnAction;
-
- /**
- * template of ActionProvider
- * $1 : package of class
- * $2 : simple name of class
- * $3 : abstract action fqn
- * $4 : path to actions properties file
- * $5 : provider name
- */
- protected static final String PROVIDER_TEMPLATE =
- "package %1$s;\n" +
- "\n" +
- "public class %2$s extends " + ActionProviderFromProperties.class.getName() + "<%3$s> {\n" +
- "\n" +
- " public %2$s() {\n" +
- " super(\"%5$s\", %3$s.class, \"%4$s\");\n" +
- " }\n" +
- "\n" +
- "}\n";
-
- protected File generateJavaProvider;
-
- protected File generatedProviderDeclaration;
-
-
- protected void doExecute() throws Exception {
-
- generateProvider();
-
- generateProviderDeclaration();
-
- }
-
- protected void generateProvider() throws IOException {
-
- int index = fqn.lastIndexOf(".");
- String packageJava = fqn.substring(0, index);
- String simpleJavaName = fqn.substring(index + 1);
-
- //TODO check if file was modified
- String content = String.format(PROVIDER_TEMPLATE,
- packageJava,
- simpleJavaName,
- fqnAction,
- actionsFile,
- providerName
- );
-
- FileUtil.writeString(generateJavaProvider, content);
- }
-
- protected void generateProviderDeclaration() throws IOException {
-
- //TODO check if file was modified
-
- // just add the fqn inside the file :)
- FileUtil.writeString(generatedProviderDeclaration, fqn);
-
- if (copyToCP) {
- // save it also in classes (since we are in process-resources phase and resources has already been copied)
- copyResourceToCP(generatedProviderDeclaration);
- }
- }
-
- @Override
- protected void init() {
-
- super.init();
-
- generateJavaProvider = new File(outJava, fqn.replaceAll("\\.", java.io.File.separator) + ".java");
-
- File parent = generateJavaProvider.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
-
- generatedProviderDeclaration = new File(outResource, "META-INF/services/" + ActionProvider.class.getName());
- parent = generatedProviderDeclaration.getParentFile();
- if (!parent.exists()) {
- parent.mkdirs();
- }
-
- fixCompileSourceRoots();
-
- }
-
-}
\ No newline at end of file
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-08-06 10:15:00 UTC (rev 815)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-08-06 10:16:03 UTC (rev 816)
@@ -22,11 +22,20 @@
import jaxx.compiler.CompilerOptions;
import jaxx.compiler.JAXXCompiler;
import jaxx.tags.TagManager;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.DirectoryScanner;
import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Set;
/**
* Classe permettant de transformer des sources jaxx vers du source java.
@@ -35,9 +44,40 @@
* @goal generate
* @phase process-resources
*/
-public class JaxxGeneratorMojo extends AbstractJaxxMojo {
+public class JaxxGeneratorMojo extends AbstractMojo {
/**
+ * @description Dépendance du projet.
+ * @parameter default-value="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * @description Répertoire de destination des fichiers java à générer.
+ * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
+ */
+ protected File outJava;
+
+ /**
+ * @description chemin du répertoire de génération des resources.
+ * @parameter expression="${jaxx.outResource}" default-value="${basedir}/target/generated-sources/resources"
+ */
+ protected File outResource;
+
+ /**
+ * @description chemin du répertoire de compilation des resources.
+ * @parameter expression="${jaxx.outClass}" default-value="${basedir}/target/classes"
+ */
+ protected File outClass;
+
+ /**
+ * @description verbose
+ * @parameter expression="${jaxx.verbose}" default-value="false"
+ */
+ protected boolean verbose;
+
+ /**
* @description Répertoire sources des fichiers jaxx à générer.
* @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/uimodel"
*/
@@ -68,8 +108,15 @@
protected CompilerOptions options;
protected void init() {
- super.init();
+ if (!outResource.exists()) {
+ outResource.mkdirs();
+ }
+
+ if (!outJava.exists()) {
+ outJava.mkdirs();
+ }
+
fixCompileSourceRoots();
DirectoryScanner ds;
@@ -143,6 +190,105 @@
}
}
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ init();
+
+ try {
+
+ doExecute();
+
+ } catch (Exception e) {
+ getLog().error(e);
+ Throwable e2 = e;
+ while (e2.getCause() != null) {
+ e2 = e.getCause();
+ }
+ getLog().error(e2);
+
+ throw new MojoExecutionException(e.getMessage(), e);
+ }
+
+ }
+
+ protected void fixCompileSourceRoots() {
+ if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
+ project.addCompileSourceRoot(outJava.getPath());
+ }
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected URLClassLoader initClassLoader(MavenProject project, Log log) {
+ URLClassLoader loader = null;
+ if (project != null) {
+ URLClassLoader result;
+ try {
+ Set<Artifact> compileClasspathElements = project.getArtifacts();
+ URL[] url = new URL[compileClasspathElements.size() + 1];
+ url[0] = outClass.toURI().toURL();
+ int i = 1;
+ for (Artifact artifact : compileClasspathElements) {
+ File file = new File(artifact.getFile().getAbsolutePath());
+ if (file.getName().endsWith(".jar")) {
+ url[i] = new URL("jar", "", file.toURI().toURL().toString() + "!/");
+ } else {
+ url[i] = file.toURI().toURL();
+ }
+ i++;
+ }
+ //ClassLoader parent = Thread.currentThread().getContextClassLoader();
+ if (compileClasspathElements.size() == 0) {
+ result = new URLClassLoader(url, getClass().getClassLoader());
+ } else {
+ result = new URLClassLoader(url, getClass().getClassLoader());
+ }
+ } catch (MalformedURLException eee) {
+ throw new RuntimeException("Can't create ClassLoader for script, bad directory: " + outClass + " for reason " + eee.getMessage(), eee);
+ } catch (IOException e) {
+ throw new RuntimeException("Can't create ClassLoader for script, bad directory: " + outClass + " for reason " + e.getMessage(), e);
+ }
+ loader = result;
+ }
+ if (verbose && loader != null) {
+ for (URL entry : loader.getURLs()) {
+ log.info("outClass url " + entry);
+ }
+ }
+ return loader;
+ }
+
+ public File getOutJava() {
+ return outJava;
+ }
+
+ public void setOutJava(File outJava) {
+ this.outJava = outJava;
+ }
+
+ public File getOutResource() {
+ return outResource;
+ }
+
+ public void setOutResource(File outResource) {
+ this.outResource = outResource;
+ }
+
+ public File getOutClass() {
+ return outClass;
+ }
+
+ public void setOutClass(File outClass) {
+ this.outClass = outClass;
+ }
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
public File getSrc() {
return src;
}
1
0
r815 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: factory provider
by tchemit@users.labs.libre-entreprise.org Aug. 6, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 6, 2008
Aug. 6, 2008
Author: tchemit
Date: 2008-08-06 10:15:00 +0000 (Wed, 06 Aug 2008)
New Revision: 815
Removed:
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/provider/AbstractActionProvider.java
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java
Log:
simplification du code : on supprime la classe abstraite car pour le moment y'a qu'une seule implantation :)
Deleted: 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-08-05 22:30:47 UTC (rev 814)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-08-06 10:15:00 UTC (rev 815)
@@ -1,387 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 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.factory;
-
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.swing.JAXXToggleButton;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.jaxx.action.MyAbstractAction;
-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;
-import javax.swing.Icon;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import java.awt.event.ActionEvent;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-
-/**
- * Action factory using the ActionConfig annotations to configure the action.
- * <p/>
- * The factory is abstract, implements method {@link #init()} to fill the
- * dictonary of known action implementations.
- * <p/>
- * Use after the {@link #loadActions(jaxx.runtime.JAXXObject)} to instanciate
- * actions in ui with id equals a known action...
- * <p/>
- * TODO Finish doc
- *
- * @author chemit
- */
-public abstract class AbstractActionFactory<A extends MyAbstractAction> implements ActionFactory<A> {
-
- protected static Log log = LogFactory.getLog(AbstractActionFactory.class);
-
- /** class of encapsuling action */
- protected Class<A> baseImpl;
-
- /** dictionary of known actions implementations */
- private Map<String, Class<? extends MyAbstractAction>> impls;
-
- /** dictionary of instanciated actions */
- private Map<String, A> cache;
-
- protected final ActionConfigConfigurationResolver actionConfigInitializer;
- protected final ToggleActionConfigConfigurationResolver toggleActionConfigInitializer;
- protected final SelectActionConfigConfigurationResolver selectActionConfigInitializer;
-
- 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<AbstractActionConfigurationResolver>();
-
- this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigConfigurationResolver.class);
- this.actionConfigInitializer = registerInitializer(ActionConfigConfigurationResolver.class);
- this.selectActionConfigInitializer = registerInitializer(SelectActionConfigConfigurationResolver.class);
- }
-
- public Class<A> getBaseImpl() {
- return baseImpl;
- }
-
- public void resetCache() {
- cache.clear();
- }
-
- public A get(String actionKey) {
- return cache.get(actionKey);
- }
-
- public void loadActions(JAXXObject ui) {
- if (log.isDebugEnabled()) {
- log.debug("for ui " + ui.getClass());
- }
- for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
- String actionKey = entry.getKey();
- Object comp = ui.getObjectById(actionKey);
- if (comp == null || !(comp instanceof AbstractButton || comp instanceof JComboBox)) {
- // nothing to do
- continue;
- }
- if (log.isTraceEnabled()) {
- log.trace("detect action " + actionKey);
- }
- if (comp instanceof AbstractButton) {
- AbstractButton component = (AbstractButton) comp;
- A action = newAction(actionKey, component);
-
- component.setAction(action);
-
- if (component instanceof JAXXToggleButton) {
- JAXXToggleButton glueComponent = (JAXXToggleButton) component;
- glueComponent.setIcon((Icon) action.getValue(Action.SMALL_ICON));
- Integer integer = (Integer) action.getValue(Action.MNEMONIC_KEY);
- if (integer != null) {
- glueComponent.setNormalMnemonic(integer);
- }
- glueComponent.setSelectedIcon((Icon) action.getValue(Action.SMALL_ICON + 2));
- integer = (Integer) action.getValue(Action.MNEMONIC_KEY + 2);
- if (integer != null) {
- glueComponent.setGlueMnemonic(integer);
- }
- glueComponent.setGlueText((String) action.getValue(Action.NAME + 2));
- glueComponent.setGlueTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION + 2));
-
- glueComponent.setNormalText((String) action.getValue(Action.NAME));
- glueComponent.setNormalTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION));
- }
-
- Boolean value = (Boolean) action.getValue("hideActionText");
- component.setHideActionText(value != null && value);
- action.setEnabled(true);
- continue;
- }
- // is JComboBox
- JComboBox component = (JComboBox) comp;
- A action = newAction(actionKey, component);
-
- component.setAction(action);
- Integer val = (Integer) action.getValue("selectedIndex");
- if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
- component.setSelectedIndex(val);
- }
- }
- }
-
- /**
- * @param actionKey le nom de l'action tel que définie dans le fichier
- * de mapping (sans le prefix action.)
- * @param component le button où rattacher l'action
- * @return une nouvelle instance de l'action associée à sa clef.
- */
- public A newAction(String actionKey, JComponent component) {
- // try first in cache
- A result = getActionFromCache(actionKey);
- if (result != null) {
- return result;
- }
-
- try {
- result = newActionInstance(actionKey);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("create <" + actionKey + " : " + result + ">");
- }
-
- // recherche de l'annotation de configuration
- ActionConfigurationResolver<?, ?> configurationResolver = resolveActionConfiguration(result);
-
- if (configurationResolver != null) {
- configurationResolver.applyConfiguration(component, result);
- }
-
- try {
-
- if (configurationResolver != null) {
- if (AbstractButton.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
- finalizeNewAction((AbstractButton) component, result, configurationResolver);
- }
-
- if (JComboBox.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
- finalizeNewAction((JComboBox) component, result, configurationResolver);
- }
-
- return result;
- }
-
- if (component == null || component instanceof AbstractButton) {
- finalizeNewAction((AbstractButton) component, result, configurationResolver);
- return result;
- }
-
- if (component instanceof JComboBox) {
- finalizeNewAction((JComboBox) component, result, configurationResolver);
- }
- } finally {
- // save result in cache
- cache.put(actionKey, result);
- }
-
- return result;
- }
-
- public A newAction(String actionKey) {
- return newAction(actionKey, null);
- }
-
- public String[] getActionNames() {
- return impls.keySet().toArray(new String[impls.size()]);
- }
-
- public Set<Map.Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet() {
- return impls.entrySet();
- }
-
- public Set<Entry<String, A>> cacheEntrySet() {
- return cache.entrySet();
- }
-
- public void fireAction(String actionKey, Object source, JComponent component) {
- A action = newAction(actionKey, component);
- fireAction0(actionKey, source, action);
- }
-
- public void fireAction(String actionKey, Object source) {
- fireAction(actionKey, source, null);
- }
-
- /**
- * @param actionKey la clef de l'action
- * @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouvée.
- */
- public A getActionFromCache(String actionKey) {
- // on vérifie que l'action existe bien
- checkRegistredAction(actionKey);
-
- // try in cache
- if (cache.containsKey(actionKey)) {
- // use cached action
- A action = cache.get(actionKey);
- if (log.isDebugEnabled()) {
- log.debug("use cache action " + action);
- }
- return action;
- }
- return null;
- }
-
- public void dispose() {
- if (log.isInfoEnabled()) {
- log.info(this);
- }
- for (String actionKey : getActionNames()) {
- MyAbstractAction action = getActionFromCache(actionKey);
- if (action != null) {
- action.disposeUI();
- }
- }
- resetCache();
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- resetCache();
- impls.clear();
- }
-
- /**
- * @param component le button où rattacher l'action
- * @param action action
- * @param configurationResolver initializer
- */
- protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
-
- if (configurationResolver == null) {
- // no configurationResolver matching,
- if (component != null) {
- action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
- action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
- action.putValue(Action.SMALL_ICON, component.getIcon());
- action.putValue(Action.NAME, component.getText());
- action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
- action.putValue("hideActionText", component.getHideActionText());
- if (component instanceof JAXXToggleButton) {
- JAXXToggleButton glueComponent = (JAXXToggleButton) component;
- action.putValue(Action.SHORT_DESCRIPTION, glueComponent.getNormalTooltipText());
- action.putValue(Action.NAME, glueComponent.getNormalText());
- action.putValue(Action.SMALL_ICON, glueComponent.getIcon());
- action.putValue(Action.MNEMONIC_KEY, glueComponent.getNormalMnemonic());
- action.putValue(Action.SHORT_DESCRIPTION + 2, glueComponent.getGlueTooltipText());
- action.putValue(Action.NAME + 2, glueComponent.getGlueText());
- action.putValue(Action.SMALL_ICON + 2, glueComponent.getSelectedIcon());
- action.putValue(Action.MNEMONIC_KEY + 2, glueComponent.getGlueMnemonic());
- }
- }
-
- }
-
- String text = (String) action.getValue(Action.NAME);
- Integer mnemo = (Integer) action.getValue(Action.MNEMONIC_KEY);
- if (mnemo != null && mnemo != '\0') {
- int pos = text.indexOf((char) mnemo.intValue());
- if (pos == -1) {
- pos = text.indexOf(Character.toLowerCase((char) mnemo.intValue()));
- }
- action.putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, pos);
- }
-
- }
-
- /**
- * @param component le select box où rattacher l'action
- * @param action action
- * @param configurationResolver initializer
- */
- protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
-
- if (configurationResolver == null) {
- action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
- action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
- //result.putValue("selectedIndex", component.getSelectedIndex());
- }
-
- }
-
- protected ActionConfigurationResolver resolveActionConfiguration(MyAbstractAction action) {
- for (ActionConfigurationResolver resolver : configurationResolvers) {
- if (resolver.resolveConfiguration(action) != null) {
- return resolver;
- }
- }
- return null;
- }
-
- protected <I extends AbstractActionConfigurationResolver> I registerInitializer(Class<I> initizalizer) {
- try {
- I instance = initizalizer.newInstance();
- configurationResolvers.add(instance);
- return instance;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public void fireAction0(String actionKey, Object source, A action) {
- if (action == null) {
- log.warn("could not find action " + actionKey);
- return;
- }
- ActionEvent event = new ActionEvent(source, ActionEvent.ACTION_FIRST, actionKey);
- action.actionPerformed(event);
- }
-
- protected void checkRegistredAction(String actionKey) {
- if (!impls.containsKey(actionKey)) {
- throw new IllegalStateException("can not find a registered action for key " + actionKey);
- }
- }
-
-
- @SuppressWarnings({"unchecked"})
- protected A newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
- Class<? extends MyAbstractAction> klazz = impls.get(actionKey);
- MyAbstractAction result;
- result = klazz.getConstructor(String.class).newInstance(actionKey);
- result.putValue(Action.ACTION_COMMAND_KEY, actionKey);
- if (!getBaseImpl().isAssignableFrom(klazz)) {
- // the instanciated action must be boxed in the base Action of the factory
- result = getBaseImpl().getConstructor(MyAbstractAction.class).newInstance(result);
- }
- return (A) result;
- }
-}
\ No newline at end of file
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-05 22:30:47 UTC (rev 814)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-08-06 10:15:00 UTC (rev 815)
@@ -17,16 +17,35 @@
* ##% */
package org.codelutin.jaxx.action.factory;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.JAXXToggleButton;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.codelutin.jaxx.action.MyAbstractAction;
+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 org.codelutin.jaxx.action.provider.ActionProvider;
+import javax.swing.AbstractButton;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import java.awt.event.ActionEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.ServiceLoader;
+import java.util.Set;
import java.util.TreeMap;
/**
* TODO Do javadoc which is not up to date...
- * A simple implementation of {@link AbstractActionFactory} using a properties file to
+ * A simple implementation of {@link ActionFactory} using a properties file to
* load action mapping.
* <p/>
* An entry is in that form : <code>action.actionName=fqn</code> where
@@ -36,16 +55,340 @@
*
* @author chemit
*/
-public class ActionFactoryFromProvider<A extends MyAbstractAction> extends AbstractActionFactory<A> {
+public class ActionFactoryFromProvider<A extends MyAbstractAction> implements ActionFactory<A> {
- public static <A extends MyAbstractAction> ActionFactoryFromProvider<A> newInstance(Class<A> klazz) {
+ protected static Log log = LogFactory.getLog(ActionFactoryFromProvider.class);
+
+ public static <A extends MyAbstractAction> ActionFactory<A> newInstance(Class<A> klazz) {
return new ActionFactoryFromProvider<A>(klazz);
}
- protected ActionFactoryFromProvider(Class<A> baseClass) {
- super(baseClass);
+ /** class of encapsuling action */
+ protected Class<A> baseImpl;
+
+ /** dictionary of known actions implementations */
+ private Map<String, Class<? extends MyAbstractAction>> impls;
+
+ /** dictionary of instanciated actions */
+ private Map<String, A> cache;
+
+ protected final ActionConfigConfigurationResolver actionConfigInitializer;
+ protected final ToggleActionConfigConfigurationResolver toggleActionConfigInitializer;
+ protected final SelectActionConfigConfigurationResolver selectActionConfigInitializer;
+
+ protected List<AbstractActionConfigurationResolver> configurationResolvers;
+
+ protected ActionFactoryFromProvider(Class<A> baseImpl) {
+ this.baseImpl = baseImpl;
+ this.impls = init();
+ this.cache = new TreeMap<String, A>();
+ this.configurationResolvers = new java.util.ArrayList<AbstractActionConfigurationResolver>();
+
+ this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigConfigurationResolver.class);
+ this.actionConfigInitializer = registerInitializer(ActionConfigConfigurationResolver.class);
+ this.selectActionConfigInitializer = registerInitializer(SelectActionConfigConfigurationResolver.class);
}
+ public Class<A> getBaseImpl() {
+ return baseImpl;
+ }
+
+ public void resetCache() {
+ cache.clear();
+ }
+
+ public A get(String actionKey) {
+ return cache.get(actionKey);
+ }
+
+ public void loadActions(JAXXObject ui) {
+ if (log.isDebugEnabled()) {
+ log.debug("for ui " + ui.getClass());
+ }
+ for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
+ String actionKey = entry.getKey();
+ Object comp = ui.getObjectById(actionKey);
+ if (comp == null || !(comp instanceof AbstractButton || comp instanceof JComboBox)) {
+ // nothing to do
+ continue;
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("detect action " + actionKey);
+ }
+ if (comp instanceof AbstractButton) {
+ AbstractButton component = (AbstractButton) comp;
+ A action = newAction(actionKey, component);
+
+ component.setAction(action);
+
+ if (component instanceof JAXXToggleButton) {
+ JAXXToggleButton glueComponent = (JAXXToggleButton) component;
+ glueComponent.setIcon((Icon) action.getValue(Action.SMALL_ICON));
+ Integer integer = (Integer) action.getValue(Action.MNEMONIC_KEY);
+ if (integer != null) {
+ glueComponent.setNormalMnemonic(integer);
+ }
+ glueComponent.setSelectedIcon((Icon) action.getValue(Action.SMALL_ICON + 2));
+ integer = (Integer) action.getValue(Action.MNEMONIC_KEY + 2);
+ if (integer != null) {
+ glueComponent.setGlueMnemonic(integer);
+ }
+ glueComponent.setGlueText((String) action.getValue(Action.NAME + 2));
+ glueComponent.setGlueTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION + 2));
+
+ glueComponent.setNormalText((String) action.getValue(Action.NAME));
+ glueComponent.setNormalTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION));
+ }
+
+ Boolean value = (Boolean) action.getValue("hideActionText");
+ component.setHideActionText(value != null && value);
+ action.setEnabled(true);
+ continue;
+ }
+ // is JComboBox
+ JComboBox component = (JComboBox) comp;
+ A action = newAction(actionKey, component);
+
+ component.setAction(action);
+ Integer val = (Integer) action.getValue("selectedIndex");
+ if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
+ component.setSelectedIndex(val);
+ }
+ }
+ }
+
+ /**
+ * @param actionKey le nom de l'action tel que définie dans le fichier
+ * de mapping (sans le prefix action.)
+ * @param component le button où rattacher l'action
+ * @return une nouvelle instance de l'action associée à sa clef.
+ */
+ public A newAction(String actionKey, JComponent component) {
+ // try first in cache
+ A result = getActionFromCache(actionKey);
+ if (result != null) {
+ return result;
+ }
+
+ try {
+ result = newActionInstance(actionKey);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("create <" + actionKey + " : " + result + ">");
+ }
+
+ // recherche de l'annotation de configuration
+ ActionConfigurationResolver<?, ?> configurationResolver = resolveActionConfiguration(result);
+
+ if (configurationResolver != null) {
+ configurationResolver.applyConfiguration(component, result);
+ }
+
+ try {
+
+ if (configurationResolver != null) {
+ if (AbstractButton.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
+ finalizeNewAction((AbstractButton) component, result, configurationResolver);
+ }
+
+ if (JComboBox.class.isAssignableFrom(configurationResolver.getComponentImpl())) {
+ finalizeNewAction((JComboBox) component, result, configurationResolver);
+ }
+
+ return result;
+ }
+
+ if (component == null || component instanceof AbstractButton) {
+ finalizeNewAction((AbstractButton) component, result, configurationResolver);
+ return result;
+ }
+
+ if (component instanceof JComboBox) {
+ finalizeNewAction((JComboBox) component, result, configurationResolver);
+ }
+ } finally {
+ // save result in cache
+ cache.put(actionKey, result);
+ }
+
+ return result;
+ }
+
+ public A newAction(String actionKey) {
+ return newAction(actionKey, null);
+ }
+
+ public String[] getActionNames() {
+ return impls.keySet().toArray(new String[impls.size()]);
+ }
+
+ public Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet() {
+ return impls.entrySet();
+ }
+
+ public Set<Entry<String, A>> cacheEntrySet() {
+ return cache.entrySet();
+ }
+
+ public void fireAction(String actionKey, Object source, JComponent component) {
+ A action = newAction(actionKey, component);
+ fireAction0(actionKey, source, action);
+ }
+
+ public void fireAction(String actionKey, Object source) {
+ fireAction(actionKey, source, null);
+ }
+
+ /**
+ * @param actionKey la clef de l'action
+ * @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouvée.
+ */
+ public A getActionFromCache(String actionKey) {
+ // on vérifie que l'action existe bien
+ checkRegistredAction(actionKey);
+
+ // try in cache
+ if (cache.containsKey(actionKey)) {
+ // use cached action
+ A action = cache.get(actionKey);
+ if (log.isDebugEnabled()) {
+ log.debug("use cache action " + action);
+ }
+ return action;
+ }
+ return null;
+ }
+
+ public void dispose() {
+ if (log.isInfoEnabled()) {
+ log.info(this);
+ }
+ for (String actionKey : getActionNames()) {
+ MyAbstractAction action = getActionFromCache(actionKey);
+ if (action != null) {
+ action.disposeUI();
+ }
+ }
+ resetCache();
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ resetCache();
+ impls.clear();
+ }
+
+ /**
+ * @param component le button où rattacher l'action
+ * @param action action
+ * @param configurationResolver initializer
+ */
+ protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
+
+ if (configurationResolver == null) {
+ // no configurationResolver matching,
+ if (component != null) {
+ action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
+ action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
+ action.putValue(Action.SMALL_ICON, component.getIcon());
+ action.putValue(Action.NAME, component.getText());
+ action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
+ action.putValue("hideActionText", component.getHideActionText());
+ if (component instanceof JAXXToggleButton) {
+ JAXXToggleButton glueComponent = (JAXXToggleButton) component;
+ action.putValue(Action.SHORT_DESCRIPTION, glueComponent.getNormalTooltipText());
+ action.putValue(Action.NAME, glueComponent.getNormalText());
+ action.putValue(Action.SMALL_ICON, glueComponent.getIcon());
+ action.putValue(Action.MNEMONIC_KEY, glueComponent.getNormalMnemonic());
+ action.putValue(Action.SHORT_DESCRIPTION + 2, glueComponent.getGlueTooltipText());
+ action.putValue(Action.NAME + 2, glueComponent.getGlueText());
+ action.putValue(Action.SMALL_ICON + 2, glueComponent.getSelectedIcon());
+ action.putValue(Action.MNEMONIC_KEY + 2, glueComponent.getGlueMnemonic());
+ }
+ }
+
+ }
+
+ String text = (String) action.getValue(Action.NAME);
+ Integer mnemo = (Integer) action.getValue(Action.MNEMONIC_KEY);
+ if (mnemo != null && mnemo != '\0') {
+ int pos = text.indexOf((char) mnemo.intValue());
+ if (pos == -1) {
+ pos = text.indexOf(Character.toLowerCase((char) mnemo.intValue()));
+ }
+ action.putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, pos);
+ }
+
+ }
+
+ /**
+ * @param component le select box où rattacher l'action
+ * @param action action
+ * @param configurationResolver initializer
+ */
+ protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionConfigurationResolver<?, ?> configurationResolver) {
+
+ if (configurationResolver == null) {
+ action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
+ action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
+ //result.putValue("selectedIndex", component.getSelectedIndex());
+ }
+
+ }
+
+ protected ActionConfigurationResolver resolveActionConfiguration(MyAbstractAction action) {
+ for (ActionConfigurationResolver resolver : configurationResolvers) {
+ if (resolver.resolveConfiguration(action) != null) {
+ return resolver;
+ }
+ }
+ return null;
+ }
+
+ protected <I extends AbstractActionConfigurationResolver> I registerInitializer(Class<I> initizalizer) {
+ try {
+ I instance = initizalizer.newInstance();
+ configurationResolvers.add(instance);
+ return instance;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void fireAction0(String actionKey, Object source, A action) {
+ if (action == null) {
+ log.warn("could not find action " + actionKey);
+ return;
+ }
+ ActionEvent event = new ActionEvent(source, ActionEvent.ACTION_FIRST, actionKey);
+ action.actionPerformed(event);
+ }
+
+ protected void checkRegistredAction(String actionKey) {
+ if (!impls.containsKey(actionKey)) {
+ throw new IllegalStateException("can not find a registered action for key " + actionKey);
+ }
+ }
+
+
+ @SuppressWarnings({"unchecked"})
+ protected A newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+ Class<? extends MyAbstractAction> klazz = impls.get(actionKey);
+ MyAbstractAction result;
+ result = klazz.getConstructor(String.class).newInstance(actionKey);
+ result.putValue(Action.ACTION_COMMAND_KEY, actionKey);
+ if (!getBaseImpl().isAssignableFrom(klazz)) {
+ // the instanciated action must be boxed in the base Action of the factory
+ result = getBaseImpl().getConstructor(MyAbstractAction.class).newInstance(result);
+ }
+ return (A) result;
+ }
+
+
public Map<String, Class<? extends MyAbstractAction>> init() {
if (log.isDebugEnabled()) {
log.debug("start loading " + this);
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/AbstractActionProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/AbstractActionProvider.java 2008-08-05 22:30:47 UTC (rev 814)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/AbstractActionProvider.java 2008-08-06 10:15:00 UTC (rev 815)
@@ -1,73 +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.provider;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.jaxx.action.MyAbstractAction;
-
-import java.util.Map;
-
-/** @author chemit */
-public abstract class AbstractActionProvider<A extends MyAbstractAction> implements ActionProvider<A> {
-
- protected static Log log = LogFactory.getLog(AbstractActionProvider.class);
-
- protected String name;
-
- protected Class<A> baseClass;
-
- protected Map<String, Class<? extends A>> actions;
-
- protected abstract Map<String, Class<? extends A>> initCache();
-
- protected AbstractActionProvider(String name, Class<A> baseClass, boolean doInitCache) {
- this.name = name;
- this.baseClass = baseClass;
- if (doInitCache) {
- this.actions = initCache();
- }
- }
-
- public String getName() {
- return name;
- }
-
- public Class<A> getBaseClass() {
- return baseClass;
- }
-
- public Map<String, Class<? extends A>> getClasses() {
- return actions;
- }
-
- @Override
- public String toString() {
- return super.toString() + "<name:" + name + ", baseClass:" + baseClass.getSimpleName() + ">";
- }
-
- protected void clearCache() {
- if (actions != null) {
- actions.clear();
- actions = null;
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- clearCache();
- }
-}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-05 22:30:47 UTC (rev 814)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-06 10:15:00 UTC (rev 815)
@@ -14,6 +14,8 @@
*/
package org.codelutin.jaxx.action.provider;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
import org.codelutin.jaxx.action.ActionNameHelper.RuntimeActionNameProvider;
import org.codelutin.jaxx.action.MyAbstractAction;
@@ -25,19 +27,61 @@
import java.util.TreeMap;
/** @author chemit */
-public class ActionProviderFromProperties<A extends MyAbstractAction> extends AbstractActionProvider<A> {
+public class ActionProviderFromProperties<A extends MyAbstractAction> implements ActionProvider<A> {
/** default prefix for an entryin mapping file. */
protected static final String ACTION_KEY_PREFIX = "action.";
protected String propertiesPath;
+ protected static Log log = LogFactory.getLog(ActionProviderFromProperties.class);
+
+ protected String name;
+
+ protected Class<A> baseClass;
+
+ protected Map<String, Class<? extends A>> actions;
+
+
protected ActionProviderFromProperties(String name, Class<A> baseClass, String propertiesPath) {
- super(name, baseClass, false);
+
+ this.name = name;
+ this.baseClass = baseClass;
+
this.propertiesPath = propertiesPath;
this.actions = initCache();
}
+ public String getName() {
+ return name;
+ }
+
+ public Class<A> getBaseClass() {
+ return baseClass;
+ }
+
+ public Map<String, Class<? extends A>> getClasses() {
+ return actions;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<name:" + name + ", baseClass:" + baseClass.getSimpleName() + ">";
+ }
+
+ protected void clearCache() {
+ if (actions != null) {
+ actions.clear();
+ actions = null;
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ clearCache();
+ }
+
@SuppressWarnings({"unchecked"})
protected Map<String, Class<? extends A>> initCache() {
1
0
r814 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . provider
by tchemit@users.labs.libre-entreprise.org Aug. 5, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 5, 2008
Aug. 5, 2008
Author: tchemit
Date: 2008-08-05 22:30:47 +0000 (Tue, 05 Aug 2008)
New Revision: 814
Added:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java
Log:
fix bug : on doit faire une reprise sur ancien fichier de mapping si on recompile
ajout de la possibilit?\195?\169 de calculer les noms d'action au runtime
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-05 11:08:02 UTC (rev 813)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-05 22:30:47 UTC (rev 814)
@@ -46,6 +46,7 @@
import javax.tools.StandardLocation;
import java.io.BufferedWriter;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -243,6 +244,11 @@
protected void writeActionMapping() throws IOException {
BufferedWriter w = null;
try {
+ Properties oldProps = loadOldActionMapping();
+ if (oldProps != null) {
+ actions.putAll(oldProps);
+ }
+ // ecriture de toutes les actions trouvees
FileObject fo = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, "", actionsFileLocation);
printInfo("writing " + fo.toUri());
w = new BufferedWriter(fo.openWriter());
@@ -253,6 +259,30 @@
}
}
+ protected Properties loadOldActionMapping() throws IOException {
+ // reprise sur une ancienne compilation
+ FileObject oldFo = processingEnv.getFiler().getResource(StandardLocation.SOURCE_OUTPUT, "", actionsFileLocation);
+ System.out.println("URI " + oldFo.toUri());
+ if (!new java.io.File(oldFo.toUri().toString()).exists()) {
+ return null;
+ }
+ Properties oldProps = new Properties();
+ InputStream inputStream = null;
+ try {
+ inputStream = oldFo.openInputStream();
+ if (inputStream != null) {
+ oldProps.load(inputStream);
+ }
+ oldFo.delete();
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+
+ return oldProps;
+ }
+
/**
* Obtain the array of names to be used by the annotation
*
@@ -266,12 +296,38 @@
ExecutableElement type = entry.getKey();
String name = type.getSimpleName().toString();
- if ("multiNames".equals(name)) {
+ if ("actionCommands".equals(name)) {
List<String> stringList = (List<String>) entry.getValue().accept(getAnnotationValueExtractor(), null);
result = stringList.toArray(new String[stringList.size()]);
- // a multiNames field means
+ // a actionCommands field means
break;
}
+ if ("actionCommandProvider".equals(name)) {
+ TypeMirror t = (TypeMirror) entry.getValue().accept(getAnnotationValueExtractor(), null);
+ String classname = t.toString();
+ printDebug("actionCommandProvider = " + classname);
+ if (classname.endsWith(ActionNameHelper.ActionNameProvider.class.getName())) {
+ continue;
+ }
+
+ /*Class<ActionNameHelper.ActionNameProvider> klazz = (Class<ActionNameHelper.ActionNameProvider>) entry.getValue().accept(getAnnotationValueExtractor(), null);
+ if (ActionNameHelper.CompileActionNameProvider.class.isAssignableFrom(klazz)) {
+ // means there is a compile time names provider
+ try {
+ result = klazz.newInstance().getActionCommands();
+ break;
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ if (ActionNameHelper.RuntimeActionNameProvider.class.isAssignableFrom(klazz)) {*/
+ // means there is a runtime names provider
+ result = new String[]{":" + classname};
+ break;
+ //}
+ }
if ("actionCommand".equals(name)) {
result = new String[]{(String) entry.getValue().accept(getAnnotationValueExtractor(), null)};
}
@@ -297,6 +353,10 @@
}
return realVals;
}
+
+ public Object visitType(TypeMirror t, Void aVoid) {
+ return t;
+ }
};
}
return annotationValueExtractor;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java 2008-08-05 11:08:02 UTC (rev 813)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java 2008-08-05 22:30:47 UTC (rev 814)
@@ -43,8 +43,13 @@
* @return la clef de la commande (doit être unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
- public String actionCommand();
+ String actionCommand();
+ /** @return array of names to be used in actions mapping */
+ String[] actionCommands() default {};
+
+ Class<? extends ActionNameHelper.ActionNameProvider> actionCommandProvider() default ActionNameHelper.ActionNameProvider.class;
+
/**
* @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
@@ -108,7 +113,4 @@
/** @return hideActionText state */
boolean hideActionText() default false;
- /** @return array of names to be used in actions mapping */
- String[] multiNames() default {};
-
}
\ No newline at end of file
Added: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionNameHelper.java 2008-08-05 22:30:47 UTC (rev 814)
@@ -0,0 +1,43 @@
+/**
+ * # #% Copyright (C) 2008 Code Lutin, Tony Chemit
+ * This program is free software; you
+ * can redistribute it and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. This program is
+ * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place
+ * - Suite 330, Boston, MA 02111-1307, USA.
+ * # #%
+ */
+package org.codelutin.jaxx.action;
+
+/** @author chemit */
+public class ActionNameHelper {
+
+ /**
+ * Contrat pour obtenir les noms d'une action.
+ *
+ * @author chemit
+ */
+ public static interface ActionNameProvider {
+
+ /** @return la liste des noms à utiliser par la classe d'action. */
+ String[] getActionCommands();
+
+ }
+
+ /** Contrat pour obtenir les noms d'actions au moment de la compilation. */
+ public static interface CompileActionNameProvider extends ActionNameProvider {
+
+ }
+
+ /** Contrat pour obtenir les noms d'actions au moment du runtime. */
+ public static interface RuntimeActionNameProvider extends ActionNameProvider {
+
+ }
+
+
+}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java 2008-08-05 11:08:02 UTC (rev 813)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java 2008-08-05 22:30:47 UTC (rev 814)
@@ -43,45 +43,47 @@
* @return la clef de la commande (doit être unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
- public abstract String actionCommand();
+ String actionCommand();
+ /** @return array of names to be used in actions mapping */
+ String[] actionCommands() default {};
+
+ Class<? extends ActionNameHelper.ActionNameProvider> actionCommandProvider() default ActionNameHelper.ActionNameProvider.class;
+
/**
* @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 accelerator key
* @see javax.swing.Action#ACCELERATOR_KEY
*/
- public abstract String accelerator() default "";
+ String accelerator() default "";
/**
* @return la valeur par défaut pour les component selectable
* @see javax.swing.Action#SELECTED_KEY
*/
- public abstract int selectedIndex() default 0;
+ int selectedIndex() default 0;
/**
* @return enabled state
* @see javax.swing.Action#isEnabled()
*/
- public abstract boolean enabled() default true;
+ boolean enabled() default true;
- /** @return array of names to be used in actions mapping */
- public abstract String[] multiNames() default {};
-
}
\ No newline at end of file
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java 2008-08-05 11:08:02 UTC (rev 813)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java 2008-08-05 22:30:47 UTC (rev 814)
@@ -41,107 +41,110 @@
* @return la clef de la commande (doit être unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
- public abstract String actionCommand();
+ String actionCommand();
+ /** @return array of names to be used in actions mapping */
+ String[] actionCommands() default {};
+
+ Class<? extends ActionNameHelper.ActionNameProvider> actionCommandProvider() default ActionNameHelper.ActionNameProvider.class;
+
/**
* @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 key of default state
* @see javax.swing.Action#ACCELERATOR_KEY
*/
- public abstract String accelerator() default "";
+ String accelerator() default "";
/**
* @return mnemonic key of default state
* @see javax.swing.Action#MNEMONIC_KEY
*/
- public abstract int mnemonic() default '\0';
+ int mnemonic() default '\0';
/**
* @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
*/
- public abstract String name2() default "";
+ String name2() default "";
/**
* @return la clef i18n du tooltip de l'action, si vide ignoré
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
- public abstract String shortDescription2() default "";
+ String shortDescription2() default "";
/**
* @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#LONG_DESCRIPTION
*/
- public abstract String longDescription2() default "";
+ String longDescription2() default "";
/**
* @return le nom de l'icone associé, si vide ignoré
* @see javax.swing.Action#SMALL_ICON
*/
- public abstract String smallIcon2() default "";
+ String smallIcon2() default "";
/**
* @return le nom du grande icone associé, si vide ignoré
* @see javax.swing.Action#LARGE_ICON_KEY
*/
- public abstract String largeIcon2() default "";
+ String largeIcon2() default "";
/**
* @return accelerator key of default state
* @see javax.swing.Action#ACCELERATOR_KEY
*/
- public abstract String accelerator2() default "";
+ String accelerator2() default "";
/**
* @return mnemonic key of second state
* @see javax.swing.Action#MNEMONIC_KEY
*/
- public abstract int mnemonic2() default '\0';
+ int mnemonic2() 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 enaled 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 {};
}
\ No newline at end of file
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-05 11:08:02 UTC (rev 813)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProviderFromProperties.java 2008-08-05 22:30:47 UTC (rev 814)
@@ -15,6 +15,7 @@
package org.codelutin.jaxx.action.provider;
import static org.codelutin.i18n.I18n._;
+import org.codelutin.jaxx.action.ActionNameHelper.RuntimeActionNameProvider;
import org.codelutin.jaxx.action.MyAbstractAction;
import java.io.IOException;
@@ -74,10 +75,23 @@
Class<? extends A> implCass;
implCass = (Class<? extends A>) Class.forName(qfn);
String actionKey = key.substring(prefix);
+ if (actionKey.startsWith(":")) {
+ // this is a RuntimeActionNameProvider
+ Class<RuntimeActionNameProvider> klazz = (Class<RuntimeActionNameProvider>) Class.forName(actionKey.substring(1));
+ for (String s : klazz.newInstance().getActionCommands()) {
+ log.debug("found action <" + s + " : " + implCass + ">");
+ cache.put(s, implCass);
+ }
+ continue;
+ }
log.debug("found action <" + actionKey + " : " + implCass + ">");
cache.put(actionKey, implCass);
} catch (ClassNotFoundException e) {
throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(_("jaxx.error.load.actions.class", key, qfn), e);
}
}
1
0
r813 - in trunk/lutinjaxx: . core jaxx-swing jaxx-swing-action jaxx-swing-action/src/main/java/org/codelutin/jaxx/action jaxx-swing-tab maven runtime util
by tchemit@users.labs.libre-entreprise.org Aug. 5, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 5, 2008
Aug. 5, 2008
Author: tchemit
Date: 2008-08-05 11:08:02 +0000 (Tue, 05 Aug 2008)
New Revision: 813
Added:
trunk/lutinjaxx/jaxx-swing-action/changelog
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/ActionAnnotationProcessing.java
trunk/lutinjaxx/jaxx-swing-tab/pom.xml
trunk/lutinjaxx/jaxx-swing/pom.xml
trunk/lutinjaxx/maven/pom.xml
trunk/lutinjaxx/pom.xml
trunk/lutinjaxx/runtime/pom.xml
trunk/lutinjaxx/util/pom.xml
Log:
passage version 0.3-SNAPSHOT pour corriger 2 bugs sur l'annotation processor : (voir changelog)
ajout changelog
Modified: trunk/lutinjaxx/core/pom.xml
===================================================================
--- trunk/lutinjaxx/core/pom.xml 2008-08-05 10:39:58 UTC (rev 812)
+++ trunk/lutinjaxx/core/pom.xml 2008-08-05 11:08:02 UTC (rev 813)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
</parent>
<artifactId>core</artifactId>
<name>core</name>
<packaging>jar</packaging>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
<description>Jaxx lutin library core</description>
<build>
Modified: trunk/lutinjaxx/jaxx-swing/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing/pom.xml 2008-08-05 10:39:58 UTC (rev 812)
+++ trunk/lutinjaxx/jaxx-swing/pom.xml 2008-08-05 11:08:02 UTC (rev 813)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
</parent>
<artifactId>jaxx-swing</artifactId>
<name>jaxx-swing</name>
<packaging>jar</packaging>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
<description>Jaxx library swing extension</description>
<dependencies>
Added: trunk/lutinjaxx/jaxx-swing-action/changelog
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/changelog (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/changelog 2008-08-05 11:08:02 UTC (rev 813)
@@ -0,0 +1,7 @@
+jaxx-swing-action (0.4) stable; urgency=high
+
+ * bug correction when have to compile actions but not the baseAction, providerConfig was null
+ * bug correction when action herites from another not base action, the action has te be treated after the mother action
+ * usemaven-i18n-plugin v0.4
+
+ -- Tony Chemit <chemit(a)codelutin.com> Fri, 05 Aug 2008 02:02:02 +0200
Modified: trunk/lutinjaxx/jaxx-swing-action/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/pom.xml 2008-08-05 10:39:58 UTC (rev 812)
+++ trunk/lutinjaxx/jaxx-swing-action/pom.xml 2008-08-05 11:08:02 UTC (rev 813)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
</parent>
<artifactId>jaxx-swing-action</artifactId>
<name>jaxx-swing-action</name>
<packaging>jar</packaging>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
<description>Jaxx lutin library swing actions extension</description>
<build>
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-05 10:39:58 UTC (rev 812)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-05 11:08:02 UTC (rev 813)
@@ -116,16 +116,23 @@
String className = e.toString();
if (processedClass.contains(className)) {
+ printWarning("class already processed " + className);
// do not process class twice
continue;
}
- printDebug("process class " + className);
- registerActionsForClass(annotation.asType(), e);
- processedClass.add(className);
+
+ boolean wasTreated = registerActionsForClass(annotation.asType(), e);
+ if (wasTreated) {
+ printDebug("process class " + className);
+ processedClass.add(className);
+ } else {
+ printDebug("class was not processed " + e);
+ }
}
}
if ((roundEnv.processingOver())) {
+ printDebug("round is over " + roundEnv);
try {
if (providerConfig == null) {
// baseActionClass was not compiled at this time, must find it back
@@ -165,16 +172,21 @@
}
}
- protected void registerActionsForClass(TypeMirror annotationType, Element e) {
+ protected boolean registerActionsForClass(TypeMirror annotationType, Element e) {
+ boolean doTreate = false;
for (AnnotationMirror mirror : e.getAnnotationMirrors()) {
if (!mirror.getAnnotationType().equals(annotationType)) {
// do not treate other annotations
continue;
}
+ doTreate = true;
+ printDebug("found a annotation to treate : " + mirror + " for action : " + e.toString());
for (String name : getActionNames(mirror)) {
actions.put("action." + name, e.toString());
+ printDebug("registerActionForClass " + name + " : " + e.toString());
}
}
+ return doTreate;
}
protected void parseOptions() {
Modified: trunk/lutinjaxx/jaxx-swing-tab/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing-tab/pom.xml 2008-08-05 10:39:58 UTC (rev 812)
+++ trunk/lutinjaxx/jaxx-swing-tab/pom.xml 2008-08-05 11:08:02 UTC (rev 813)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
</parent>
<artifactId>jaxx-swing-tab</artifactId>
<name>jaxx-swing-tab</name>
<packaging>jar</packaging>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
<description>Jaxx lutin library swing tab extension</description>
<build>
Modified: trunk/lutinjaxx/maven/pom.xml
===================================================================
--- trunk/lutinjaxx/maven/pom.xml 2008-08-05 10:39:58 UTC (rev 812)
+++ trunk/lutinjaxx/maven/pom.xml 2008-08-05 11:08:02 UTC (rev 813)
@@ -12,7 +12,7 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
</parent>
<artifactId>maven-jaxx-plugin</artifactId>
@@ -63,7 +63,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
<description>
Maven 2 plugin to generate java source from ui interface definitions
Modified: trunk/lutinjaxx/pom.xml
===================================================================
--- trunk/lutinjaxx/pom.xml 2008-08-05 10:39:58 UTC (rev 812)
+++ trunk/lutinjaxx/pom.xml 2008-08-05 11:08:02 UTC (rev 813)
@@ -39,7 +39,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
<name>pom</name>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
<description>Jaxx lutin library main pom</description>
<inceptionYear>2008</inceptionYear>
Modified: trunk/lutinjaxx/runtime/pom.xml
===================================================================
--- trunk/lutinjaxx/runtime/pom.xml 2008-08-05 10:39:58 UTC (rev 812)
+++ trunk/lutinjaxx/runtime/pom.xml 2008-08-05 11:08:02 UTC (rev 813)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
</parent>
<artifactId>runtime</artifactId>
<name>runtime</name>
<packaging>jar</packaging>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
<description>Jaxx lutin library runtime</description>
<build>
Modified: trunk/lutinjaxx/util/pom.xml
===================================================================
--- trunk/lutinjaxx/util/pom.xml 2008-08-05 10:39:58 UTC (rev 812)
+++ trunk/lutinjaxx/util/pom.xml 2008-08-05 11:08:02 UTC (rev 813)
@@ -7,14 +7,14 @@
<parent>
<groupId>org.codelutin.jaxx</groupId>
<artifactId>pom</artifactId>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
</parent>
<artifactId>util</artifactId>
<name>util</name>
<packaging>jar</packaging>
- <version>0.3</version>
+ <version>0.3-SNAPSHOT</version>
<description>Jaxx lutin library utility</description>
<build>
1
0
r812 - in trunk: buix buix/doc buix/src/java/org/codelutin/buix jaxx/doc jaxx/src/main/java/jaxx/parser jaxx/src/main/java/jaxx/runtime/builder
by tchemit@users.labs.libre-entreprise.org Aug. 5, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 5, 2008
Aug. 5, 2008
Author: tchemit
Date: 2008-08-05 10:39:58 +0000 (Tue, 05 Aug 2008)
New Revision: 812
Modified:
trunk/buix/TODO
trunk/buix/doc/analyze-guide.rst
trunk/buix/doc/bilanExport.rst
trunk/buix/doc/loading-guide.rst
trunk/buix/doc/newConcept.rst
trunk/buix/doc/user-guide.rst
trunk/buix/doc/xmlencoder.rst
trunk/buix/lutinheader.txt
trunk/buix/src/java/org/codelutin/buix/BeanLayoutPropertiesTableModel.java
trunk/buix/src/java/org/codelutin/buix/BeanPropertiesTableModel.java
trunk/buix/src/java/org/codelutin/buix/Buix.java
trunk/buix/src/java/org/codelutin/buix/BuixXMLEncoder.java
trunk/buix/src/java/org/codelutin/buix/EditorManager.java
trunk/buix/src/java/org/codelutin/buix/PropertiesSelectionManager.java
trunk/buix/src/java/org/codelutin/buix/ShelfTreeModel.java
trunk/buix/src/java/org/codelutin/buix/WidgetManager.java
trunk/buix/src/java/org/codelutin/buix/WidgetManagerEvent.java
trunk/jaxx/doc/index.rst
trunk/jaxx/src/main/java/jaxx/parser/Java1.5.jjt
trunk/jaxx/src/main/java/jaxx/runtime/builder/ActionConfig.java
trunk/jaxx/src/main/java/jaxx/runtime/builder/ActionFactory.java
trunk/jaxx/src/main/java/jaxx/runtime/builder/SelectActionConfig.java
trunk/jaxx/src/main/java/jaxx/runtime/builder/TabFactory.java
trunk/jaxx/src/main/java/jaxx/runtime/builder/ToggleActionConfig.java
Log:
convert to UTF-8
Modified: trunk/buix/TODO
===================================================================
--- trunk/buix/TODO 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/TODO 2008-08-05 10:39:58 UTC (rev 812)
@@ -12,18 +12,18 @@
* ajouter l'icone du widget dans l'arbre
-* am�liorer le fonctionnement du clipboard : drag and drop, d�placer
-du clipboard au tree et vice versa et incr�menter les chiffres du
-nom de l'objet copi�
+* améliorer le fonctionnement du clipboard : drag and drop, déplacer
+du clipboard au tree et vice versa et incrémenter les chiffres du
+nom de l'objet copié
-* les propri�t�s pourraient-elles �tre valid�es automatiquement ?
+* les propriétés pourraient-elles être validées automatiquement ?
-* Il faudrait cr�er des nouveaux editors pour les propri�t�s et en
+* Il faudrait créer des nouveaux editors pour les propriétés et en
particulier pour l'objet de type Insets du GridBagLayout
* Methode getIcon de AbstractLayoutInfo
-* Implanter BoxLayout : l'implantation est faite mais il faut tester et surtout il faut que Buix puisse g�rer les objets qui n'ont pas de construteur sans argument (ce qui est le cas de BoxLayout)
+* Implanter BoxLayout : l'implantation est faite mais il faut tester et surtout il faut que Buix puisse gérer les objets qui n'ont pas de construteur sans argument (ce qui est le cas de BoxLayout)
* Modification de CellX du GridLayout
@@ -33,7 +33,7 @@
Bugs
====
-* Affichage double des propri�t�s s�lectionn�es
+* Affichage double des propriétés sélectionnées
* Erreur lorsqu'on ajoutte de composant avant de modifier le layout en
BorderLayout
Modified: trunk/buix/doc/analyze-guide.rst
===================================================================
--- trunk/buix/doc/analyze-guide.rst 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/doc/analyze-guide.rst 2008-08-05 10:39:58 UTC (rev 812)
@@ -2,7 +2,7 @@
BUIX
====
-:Authors: Aur�lie Mazelier <mazelier(a)codelutin.org>
+:Authors: Aurélie Mazelier <mazelier(a)codelutin.org>
:Revision: $Revision$
:Date: $Date$
@@ -10,209 +10,209 @@
.. contents::
-La finalit� de document est d'expliquer les choix de conception de
+La finalité de document est d'expliquer les choix de conception de
Buix.
-Propri�t�s layout des composants
+Propriétés layout des composants
================================
-Utilisation du m�canisme d'introspection:
+Utilisation du mécanisme d'introspection:
-- Impossible d'utiliser Introspector de Java (le m�canisme ne r�agissait pas
+- Impossible d'utiliser Introspector de Java (le mécanisme ne réagissait pas
comme nous le souhaitions)
-- D�veloppement d'une classe LayoutIntrospector avec une m�thode
+- Développement d'une classe LayoutIntrospector avec une méthode
getLayoutInfo(Class clazz) qui retourne une instance de LayoutInfo
-- D�veloppement de LayoutInfo �quivalent � BeanInfo. Chaque layout poss�de
+- Développement de LayoutInfo équivalent à BeanInfo. Chaque layout possède
sa classe layoutInfo.
En fait, les layouts ne sont pas des beans. En effet, certaines de
-leurs propri�t�s ne poss�dent pas de m�thodes get et set. C'est
+leurs propriétés ne possèdent pas de méthodes get et set. C'est
pourquoi, elles ne sont pas reconnues en tant que
-PropertyDescriptor. Je devais donc cr�er des PropertyDescriptor
-adapt�es � ces propri�t�s sp�ciales. Ainsi, le LayoutInfo pouvait
+PropertyDescriptor. Je devais donc créer des PropertyDescriptor
+adaptées à ces propriétés spéciales. Ainsi, le LayoutInfo pouvait
retourner une liste de PropertyChildDescriptor. L'objet
-PropertyChildDescriptor se pr�sente comme PropertyDescriptor. Il
-poss�de un nom, un type, un �diteur, etc. Cette classe poss�de aussi
-deux m�thodes abstraites:
+PropertyChildDescriptor se présente comme PropertyDescriptor. Il
+possède un nom, un type, un éditeur, etc. Cette classe possède aussi
+deux méthodes abstraites:
- abstract public Object getValue(Object comp);
- abstract public void setValue(Object comp, Object newValue);
-Chaque classe de propri�t� sp�ciale du layout va h�riter de cette
+Chaque classe de propriété spéciale du layout va hériter de cette
classe PropertyChildDescriptor.
-Je n'ai pas expliqu� pourquoi il existait une m�thode � add(Container
-container, Component component) � dans chaque layoutInfo. La m�thode
-add est par d�faut celle de Java sauf pour un layout : le
+Je n'ai pas expliqué pourquoi il existait une méthode « add(Container
+container, Component component) » dans chaque layoutInfo. La méthode
+add est par défaut celle de Java sauf pour un layout : le
BorderLayout. En effet, lorsqu'on ajoute des composants dans le
-container, ceux-ci doivent avoir une valeur � place � par
-d�faut. Ainsi, le premier aura la valeur ��Center��, le deuxi�me �
-North � etc. Il est n�cessaire de g�rer le cas o� il n'y a plus de
+container, ceux-ci doivent avoir une valeur « place » par
+défaut. Ainsi, le premier aura la valeur « Center », le deuxième «
+North » etc. Il est nécessaire de gérer le cas où il n'y a plus de
place dans le container. En outre, lorsque toutes les places sont
-prises sauf une et qui en plus n'est pas la derni�re par d�faut, le
-composant doit s'ajouter par d�faut � cette place libre, par exemple
+prises sauf une et qui en plus n'est pas la dernière par défaut, le
+composant doit s'ajouter par défaut à cette place libre, par exemple
au centre.
-Pour que le changement sur l'une des propri�t�s du GridBagLayout soit
-prise en compte, il est n�cessaire de "reconstruire" la contrainte
-dans la m�thode setValue.
+Pour que le changement sur l'une des propriétés du GridBagLayout soit
+prise en compte, il est nécessaire de "reconstruire" la contrainte
+dans la méthode setValue.
ClipBoard
=========
-Le clipboard se base selon le m�me principe que le preview sauf qu'il
+Le clipboard se base selon le même principe que le preview sauf qu'il
a fallu instancier un nouvel arbre, une nouvelle instance de
-BuixGlassPane et un nouveau mod�le, mais surtout un nouveau
+BuixGlassPane et un nouveau modèle, mais surtout un nouveau
SwingTreeNode. Il a fallu aussi effectuer des copies en profondeur en
-utilisant la s�rialisation (m�thode makeDeepCopy).
+utilisant la sérialisation (méthode makeDeepCopy).
-Chargement des composants Swing et des interfaces g�n�r�es
+Chargement des composants Swing et des interfaces générées
==========================================================
Le chargement des onglets s'effectue par le parcours d'un ou plusieurs
-fichiers xml. Il y a trois fichiers XML qui sont pars�s.
+fichiers xml. Il y a trois fichiers XML qui sont parsés.
-Le parcours est r�alis� � l'aide de l'objet SaxReader implant� dans
-DOM4J. A chaque fois que le tag <widget> est rencontr�, on r�cup�re
-l'attribut shelf qui va d�terminer la valeur de la biblioth�que dans
-laquelle le composant sera class�. L'attribut ��class�� permet de
-conna�tre le composant. Une fois que ces deux valeurs sont connues, il
+Le parcours est réalisé à l'aide de l'objet SaxReader implanté dans
+DOM4J. A chaque fois que le tag <widget> est rencontré, on récupère
+l'attribut shelf qui va déterminer la valeur de la bibliothèque dans
+laquelle le composant sera classé. L'attribut « class » permet de
+connaître le composant. Une fois que ces deux valeurs sont connues, il
est possible d'instancier un WidgetButtons. Dans le cas des
-LayoutButton, le cas est quasi similaire. La diff�rence provient des
+LayoutButton, le cas est quasi similaire. La différence provient des
tags du fichiers XML. Il n'existe pas de tags widgets mais des tags
-layout. Par contre, nous pouvons constat� la pr�sence des attributs
+layout. Par contre, nous pouvons constaté la présence des attributs
shelf et class.
-:WidgetsButtons: boutons qui caract�risent les composants
+:WidgetsButtons: boutons qui caractérisent les composants
-:LayoutButtons: boutons qui caract�risent les layouts.
+:LayoutButtons: boutons qui caractérisent les layouts.
-Ces fichiers xml se trouvent dans une arborescence particuli�re :
-src/resources. L'application va alors chercher � cet endroit les
-fichiers xml pour charger les diff�rentes entit�s pr�sentes dans tous
-les fichiers xml du r�pertoire. Toutefois, il est indispensable que
-les fichiers xml se terminent soit par -widget.xml pour les entit�s de
-types widget, soit par -layout.xml. Si ces fichiers sont ajout�s dans
-src/resources alors Buix doit �tre compil� pour que le chargement de
-ces nouvelles entit�s soit pris en compte.
+Ces fichiers xml se trouvent dans une arborescence particulière :
+src/resources. L'application va alors chercher à cet endroit les
+fichiers xml pour charger les différentes entités présentes dans tous
+les fichiers xml du répertoire. Toutefois, il est indispensable que
+les fichiers xml se terminent soit par -widget.xml pour les entités de
+types widget, soit par -layout.xml. Si ces fichiers sont ajoutés dans
+src/resources alors Buix doit être compilé pour que le chargement de
+ces nouvelles entités soit pris en compte.
-Ces fichiers xml peuvent �galement se trouver dans un fichier
-jar. Ainsi, il est possible de charger des entit�s pr�alablement
-cr��es ou g�n�r�es. En effet, ces fichiers jar sont charg�s dans le
-classLoader. Ensuite une m�thode parcourt en profondeur le r�pertoire
+Ces fichiers xml peuvent également se trouver dans un fichier
+jar. Ainsi, il est possible de charger des entités préalablement
+créées ou générées. En effet, ces fichiers jar sont chargés dans le
+classLoader. Ensuite une méthode parcourt en profondeur le répertoire
et les fichiers jar ou zip, afin de retourner la liste des fichiers
-xml correspondant au pattern pass� en param�tre, dans notre cas
-*. xml. Cette m�thode statique se trouve dans un autre module de Code
-Lutin : LutinUtil. Elle est d�velopp�e dans la classe Ressource
+xml correspondant au pattern passé en paramètre, dans notre cas
+*. xml. Cette méthode statique se trouve dans un autre module de Code
+Lutin : LutinUtil. Elle est développée dans la classe Ressource
-S'il existe un probl�me lors du chargement de l'une des classes du
-fichier xml alors les composants swing pr�sents dans swing-widgets.xml
-et les layouts ne seront pas charg�s.
+S'il existe un problème lors du chargement de l'une des classes du
+fichier xml alors les composants swing présents dans swing-widgets.xml
+et les layouts ne seront pas chargés.
Encoders
========
-Les interfaces cr��es sont sauvegard�es avec XMLEncoder.L'organisation
-des donn�es dans le fichier xml n'�tait pas vraiment adapt�e �
-l'utilisation post�rieure du fichier. Des informations �taient
-inutiles et d'autres redondantes. En outre, la pr�sentation �tait trop
-d�taill�e, on trouve en particulier les m�thodes Java comme
+Les interfaces créées sont sauvegardées avec XMLEncoder.L'organisation
+des données dans le fichier xml n'était pas vraiment adaptée à
+l'utilisation postérieure du fichier. Des informations étaient
+inutiles et d'autres redondantes. En outre, la présentation était trop
+détaillée, on trouve en particulier les méthodes Java comme
addLayoutComponent. De plus, il n'y avait aucun sous composant au
-container de type Chorem. C'est pourquoi, un autre encoder a �t�
-d�velopp�.
+container de type Chorem. C'est pourquoi, un autre encoder a été
+développé.
-En premier lieu, nous avons souhait� cr�er un encodeur qui h�riterait
-de XmlEncoder. Le principe est d'utiliser le m�me syst�me de parcours
-que l'encodeur de Java mais en surchargeant les m�thodes writeObject,
-writeStatement, writeExpression afin de r�cup�rer, dans un premier
-temps, seulement les �l�ments qui nous int�ressent. Ces �l�ments sont
-stock�s dans des HashMap. Dans un deuxi�me temps, les HashMap sont
-lues en partant de l'�l�ment racine pour ensuite construire le fichier
-xml. Voici l'implantation lors de la lecture des donn�es et la
-construction du fichier xml. Nous avons constat� l'ordre dans lequel
-sont mises les donn�es dans l'uimodel.
+En premier lieu, nous avons souhaité créer un encodeur qui hériterait
+de XmlEncoder. Le principe est d'utiliser le même système de parcours
+que l'encodeur de Java mais en surchargeant les méthodes writeObject,
+writeStatement, writeExpression afin de récupérer, dans un premier
+temps, seulement les éléments qui nous intéressent. Ces éléments sont
+stockés dans des HashMap. Dans un deuxième temps, les HashMap sont
+lues en partant de l'élément racine pour ensuite construire le fichier
+xml. Voici l'implantation lors de la lecture des données et la
+construction du fichier xml. Nous avons constaté l'ordre dans lequel
+sont mises les données dans l'uimodel.
-Cet encoder fonctionnait tr�s bien avec les panels cr��s dans
-Buix. Par contre, il existait de nombreux probl�mes. Ces probl�mes
-sont d�crits dans la documentation bilanExport.rst.
+Cet encoder fonctionnait très bien avec les panels créés dans
+Buix. Par contre, il existait de nombreux problèmes. Ces problèmes
+sont décrits dans la documentation bilanExport.rst.
-C'est pourquoi, nous avons d�cid� de cr�er un nouvel encoder mais qui
-n'h�riterait pas de XMLEncoder. Il fallait donc obtenir les enfants
-des objets, les propri�t�s, les events ... Pour r�cup�rer ces
-informations, j'ai de nouveau utilis� l'introspection. Par la m�me
-occasion, la s�rialisation s'effectue en une seule passe. En outre,
-l'application devait pouvoir g�rer plusieurs encoders diff�rents avec
-des formats de sortie xml diff�rents.
+C'est pourquoi, nous avons décidé de créer un nouvel encoder mais qui
+n'hériterait pas de XMLEncoder. Il fallait donc obtenir les enfants
+des objets, les propriétés, les events ... Pour récupérer ces
+informations, j'ai de nouveau utilisé l'introspection. Par la même
+occasion, la sérialisation s'effectue en une seule passe. En outre,
+l'application devait pouvoir gérer plusieurs encoders différents avec
+des formats de sortie xml différents.
-UIModelWriter est construit gr�ce � DOM4J. ComponentWalker est une
-interface qui propose un ensemble de m�thodes permettant de construire
-le fichier xml. UIModelWriter h�rite de cette interface. Une fois
-l'implantation termin�e, je me suis aper�ue que la s�rialisation des
-arguments �tait incorrecte. Il a donc fallu abandonner cette voie.
+UIModelWriter est construit grâce à DOM4J. ComponentWalker est une
+interface qui propose un ensemble de méthodes permettant de construire
+le fichier xml. UIModelWriter hérite de cette interface. Une fois
+l'implantation terminée, je me suis aperçue que la sérialisation des
+arguments était incorrecte. Il a donc fallu abandonner cette voie.
-Nous avons donc souhait� reprendre l'ancien encoder BuixXmlEncoder et
-corriger les erreurs. Par la m�me occasion, j'ai revu la s�rialisation
-et UIModelWriter a �t� modifi� pour s'adapter � la lecture des HashMap
-pr�sents dans cet encoder.
+Nous avons donc souhaité reprendre l'ancien encoder BuixXmlEncoder et
+corriger les erreurs. Par la même occasion, j'ai revu la sérialisation
+et UIModelWriter a été modifié pour s'adapter à la lecture des HashMap
+présents dans cet encoder.
-Par la suite, nous avons test� le fonctionnement de ce syst�me pour
+Par la suite, nous avons testé le fonctionnement de ce système pour
XMLEncoder. En toute logique, l'ensemble des enfants du panel
apparaissait dans le fichier xml. A ce stade du stage, nous avons
-r�alis� que notre encoder �tait devenu aussi compliqu� que celui de
-Java. Nous avons alors abandonn� l'id�e d'un encoder suppl�mentaire
-pour utiliser celui propos� par Java. En outre, nous disposions du
-d�codeur.
+réalisé que notre encoder était devenu aussi compliqué que celui de
+Java. Nous avons alors abandonné l'idée d'un encoder supplémentaire
+pour utiliser celui proposé par Java. En outre, nous disposions du
+décodeur.
-En premier lieu, l'objet Chorem devait �tre reconnu lors de
-l'exportation ce qui n'�tait pas le cas. Le fichier jar de Chorem
-�tait bien charg� au d�marrage dans le classLoader mais le chargement
-n'�tait pas conserv�. Dans ce cas, l'objet n'�tait pas trouv� lors de
-l'ex�cution en phase d'exportation. Nous avons tent� de modifier le
-classLoader � l'aide du thread par exemple. Nous avons finalement
-r�ussi � trouver une solution qui reste plus ou moins
+En premier lieu, l'objet Chorem devait être reconnu lors de
+l'exportation ce qui n'était pas le cas. Le fichier jar de Chorem
+était bien chargé au démarrage dans le classLoader mais le chargement
+n'était pas conservé. Dans ce cas, l'objet n'était pas trouvé lors de
+l'exécution en phase d'exportation. Nous avons tenté de modifier le
+classLoader à l'aide du thread par exemple. Nous avons finalement
+réussi à trouver une solution qui reste plus ou moins
satisfaisante. L'instanciation de l'encoder doit s'effectuer dans un
-thread et c'est seulement dans ce thread que le classLoader peut �tre
-modifi�. Ce probl�me est li� au JDK 1.4.2. C'est pourquoi, nous avons
-choisi cette solution. N�anmoins, cette difficult� n'est pas pr�sente
+thread et c'est seulement dans ce thread que le classLoader peut être
+modifié. Ce problème est lié au JDK 1.4.2. C'est pourquoi, nous avons
+choisi cette solution. Néanmoins, cette difficulté n'est pas présente
dans le JDK 1.5.
-Mais il restait toujours le probl�me des sous composants d'un
+Mais il restait toujours le problème des sous composants d'un
container de type Chorem. Ces composants n'apparaissaient pas dans le
-fichier xml. Nous avons donc souhait� modifier la g�n�ration pour que
-le panel h�rite d'un panel particulier TopiaPanel. Le but de cet
-h�ritage est de permettre � l'encoder de ��reconnaitre�� les panels
-issus de Chorem. Nous avons cr��e un nouveau PersistenceDelegate pour
+fichier xml. Nous avons donc souhaité modifier la génération pour que
+le panel hérite d'un panel particulier TopiaPanel. Le but de cet
+héritage est de permettre à l'encoder de « reconnaitre » les panels
+issus de Chorem. Nous avons créée un nouveau PersistenceDelegate pour
ce genre de panels. Ainsi, lorsque l'encoder souhaitera encoder ce
-panel, il utilisera les m�thodes surcharg�es dans cette nouvelle
-classe : TopiaPanel_PersistenceDelegate (pr�sente dans BuixXmlEncoder).
+panel, il utilisera les méthodes surchargées dans cette nouvelle
+classe : TopiaPanel_PersistenceDelegate (présente dans BuixXmlEncoder).
Avec l'encoder BuixXmlEncoder, l'utilisateur devait saisir le nom du
-package gr�ce � l'objet JOptionPane ainsi l'attribut de UIModelImpl
-�tait initialis� avec cette valeur. En outre, la derni�re valeur �tait
-conserv�e dans les pr�f�rence de l'utilisateur. Toutefois, avec
-l'encoder Java il est impossible de s�rialiser le nom du package ainsi
-l'attribut packageName de l'UIModelImpl ne poss�de aucune
-valeur. C'est pourquoi, il est n�cessaire de saisir l'arborescence du
-package pour les fichiers javaxml (fichiers export�s avec
+package grâce à l'objet JOptionPane ainsi l'attribut de UIModelImpl
+était initialisé avec cette valeur. En outre, la dernière valeur était
+conservée dans les préférence de l'utilisateur. Toutefois, avec
+l'encoder Java il est impossible de sérialiser le nom du package ainsi
+l'attribut packageName de l'UIModelImpl ne possède aucune
+valeur. C'est pourquoi, il est nécessaire de saisir l'arborescence du
+package pour les fichiers javaxml (fichiers exportés avec
XMLEncoder). Par exemple, le fichier LoggedPanel.javaxml dans
-org.codelutin.chorem.entities.ui doit �tre entregistr� comme ceci :
+org.codelutin.chorem.entities.ui doit être entregistré comme ceci :
org.codelutin.chorem.entities.ui.LoggedPanel.javaxml. Vous pouvez
consulter la doc de LutinGenerator pour savoir comment ce fichier sera
-utilis� dans ce projet.
+utilisé dans ce projet.
-Pour que les propri�t�s apparaissent dans le fichier export�, elles
-devront �tre modifi�es et valid�es avant l'exportation.
+Pour que les propriétés apparaissent dans le fichier exporté, elles
+devront être modifiées et validées avant l'exportation.
-Il existe une d�pendance avec Topia dans Buix. En effet, les panels
-Chorem contiennent des panneaux non g�n�r�s comme ButtonsPanel. Ces
-derniers sont des panels implant� dans Topia d'o� cette d�pendance. Il
-existe une deuxi�me cons�quence. Il est impossible voir l'arborescence
-de ces panels.Ainsi, on ne peut acc�der au bouton Save, Cancel
-... pr�sent dans ButtonsPanel.
+Il existe une dépendance avec Topia dans Buix. En effet, les panels
+Chorem contiennent des panneaux non générés comme ButtonsPanel. Ces
+derniers sont des panels implanté dans Topia d'où cette dépendance. Il
+existe une deuxième conséquence. Il est impossible voir l'arborescence
+de ces panels.Ainsi, on ne peut accéder au bouton Save, Cancel
+... présent dans ButtonsPanel.
Autres
@@ -220,5 +220,5 @@
Voici comment est construit le TreeNode:
-- � l'indice 0 -> layout,
+- à l'indice 0 -> layout,
- aux autres indices se trouvent les enfants.
Modified: trunk/buix/doc/bilanExport.rst
===================================================================
--- trunk/buix/doc/bilanExport.rst 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/doc/bilanExport.rst 2008-08-05 10:39:58 UTC (rev 812)
@@ -1,7 +1,7 @@
Exportation dans Buix
=====================
-:Authors: Aur�lie Mazelier <mazelier(a)codelutin.org>
+:Authors: Aurélie Mazelier <mazelier(a)codelutin.org>
:Revision: $Revision$
:Date: $Date$
@@ -9,12 +9,12 @@
.. contents::
-Voici le bilan des probl�mes rencontr�s lors de l'exportation d'un
-objet dans Buix. Les tests ont �t� effectu�s alors qu'il y avait
+Voici le bilan des problèmes rencontrés lors de l'exportation d'un
+objet dans Buix. Les tests ont été effectués alors qu'il y avait
classLoader dans WidgetManager.
1. Lors du chargement des panels de Chorem, les classes ne sont plus
- trouv�es si le classLoader n'est plus dans WidgetManager mais dans
+ trouvées si le classLoader n'est plus dans WidgetManager mais dans
Buix.
2. Si on a un arbre de la form JFrame avec JRootPane comme "layout" et
@@ -22,11 +22,11 @@
le panel Chorem lors de l'export et uniquement si l'objet est un panel
Chorem.
-3. Lorsqu'on ajoute un enfant � la JFrame (en gardant la m�me
- configuration que ci-dessus), le <layout> n'appara�t plus du tout !
+3. Lorsqu'on ajoute un enfant à la JFrame (en gardant la même
+ configuration que ci-dessus), le <layout> n'apparaît plus du tout !
4. Les enfants d'un panel Chorem ne sont pas visibles lors de l'export
- m�me si on ajoute un nouvel enfant au panel et si on modifie l'un
+ même si on ajoute un nouvel enfant au panel et si on modifie l'un
d'entre eux.
5. Modification d'un enfant du panel Chorem:
@@ -42,9 +42,9 @@
<arguments>
7. Lorsqu'on exporte JFrame et que le preview est visible alors la
- propriete visible appara�t dans le fichier export�.
+ propriete visible apparaît dans le fichier exporté.
-8. Dans le cas o� la racine est le panel Chorem:
+8. Dans le cas où la racine est le panel Chorem:
- pas de layout
- pas d'enfants
@@ -52,7 +52,7 @@
- pas de name
9. Il est possible aussi qu'il n'y ait pas d'events mais que les tags
- <events> soient quand m�me pr�sents dans le fichier export� (voir le
- cas o� au args[0]=null, addContainerListener).
+ <events> soient quand même présents dans le fichier exporté (voir le
+ cas où au args[0]=null, addContainerListener).
Modified: trunk/buix/doc/loading-guide.rst
===================================================================
--- trunk/buix/doc/loading-guide.rst 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/doc/loading-guide.rst 2008-08-05 10:39:58 UTC (rev 812)
@@ -2,7 +2,7 @@
BUIX
====
-:Authors: Aur�lie Mazelier <mazelier(a)codelutin.org>
+:Authors: Aurélie Mazelier <mazelier(a)codelutin.org>
:Revision: $Revision$
:Date: $Date$
@@ -11,11 +11,11 @@
.. contents::
-Guide pour charger des entit�s dans Buix
+Guide pour charger des entités dans Buix
========================================
-1. Copier le .jar dans le r�pertoire src/resources de Buix
+1. Copier le .jar dans le répertoire src/resources de Buix
2. Construire un fichier xml :
* dans le cas de composant
@@ -39,13 +39,13 @@
</layouts>
-3. 2 possibilit�s :
+3. 2 possibilités :
- mettre le fichier xml dans src/resources de Buix
- ou le placer dans le .jar
4. Compiler Buix
-5. Ex�cuter Buix
+5. Exécuter Buix
-6. ATTENTION : Seul les entit�s ayant un constructeur sans argument peuvent �tre charg�s dans Buix.
+6. ATTENTION : Seul les entités ayant un constructeur sans argument peuvent être chargés dans Buix.
Modified: trunk/buix/doc/newConcept.rst
===================================================================
--- trunk/buix/doc/newConcept.rst 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/doc/newConcept.rst 2008-08-05 10:39:58 UTC (rev 812)
@@ -1,4 +1,4 @@
-Nouvelle r�flexion sur buix
+Nouvelle réflexion sur buix
===========================
Un ensemble de widget:
@@ -27,12 +27,12 @@
Pour utiliser un widget non connu on utilise le tag unknown avec un attribut
type="com.bbn.OpenMap".
-Dans ce cas ce widget sera directement utilis�.
+Dans ce cas ce widget sera directement utilisé.
Les events
==========
-Il suffit d'avoir une m�thode avec une certaine signature pour savoir
-qu'elle est le callback d'un event lev� par un objet.
+Il suffit d'avoir une méthode avec une certaine signature pour savoir
+qu'elle est le callback d'un event levé par un objet.
La signature est du genre: on[id][eventType]([UI], [Event])
Modified: trunk/buix/doc/user-guide.rst
===================================================================
--- trunk/buix/doc/user-guide.rst 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/doc/user-guide.rst 2008-08-05 10:39:58 UTC (rev 812)
@@ -2,7 +2,7 @@
BUIX
====
-:Authors: Aur�lie Mazelier <mazelier(a)codelutin.org>
+:Authors: Aurélie Mazelier <mazelier(a)codelutin.org>
:Revision: $Revision$
:Date: $Date$
@@ -17,31 +17,31 @@
Pour utiliser Buix il faut avoir dans son classpath le fichier
${JAVA_HOME}/lib/dt.jar. Le mieux pour cela est de le mettre dans le
-r�pertoire ${JAVA_HOME}/jre/lib/ext ou de faire un lien dans ce
-r�pertoire vers le fichier dt.jar.
+répertoire ${JAVA_HOME}/jre/lib/ext ou de faire un lien dans ce
+répertoire vers le fichier dt.jar.
-Lancer le script buix.sh pour ex�cuter l'application Buix
+Lancer le script buix.sh pour exécuter l'application Buix
-Composition g�n�rale de Buix
+Composition générale de Buix
============================
-Buix est compos�e de 5 parties :
+Buix est composée de 5 parties :
Menu
----
-Dans ce menu, il est possible de cr�er une nouvelle interface "New",
+Dans ce menu, il est possible de créer une nouvelle interface "New",
d'enregistrer cette interface Save ou Save As. Attention, si vous
-souhaitez g�n�rer ce fichier en java dans Topia, Il est imp�ratif
+souhaitez générer ce fichier en java dans Topia, Il est impératif
d'indiquer le package comme ceci par exemple
org.codelutin.entities.ui.NomDuFichier.javaxml lors de
-l'enregistrement. Ainsi, le d�but du nom correspond au package, vient
-ensuite le nom du fichier. Enfin l'extension javaxml est n�cessaire
-pour que la g�n�ration ait bien lieu !
+l'enregistrement. Ainsi, le début du nom correspond au package, vient
+ensuite le nom du fichier. Enfin l'extension javaxml est nécessaire
+pour que la génération ait bien lieu !
En cliquant sur preview ou sur clipboard, il est possible de
visualiser le preview ou le clipboard de l'application en mode
@@ -50,125 +50,125 @@
Pour quitter l'application, il faut utiliser Quit du menu.
Pour le moment, Export ne fonctionne pas correctement mais il agit
-selon le m�me principe que Save.
+selon le même principe que Save.
La partie Configuration du menu permet de verrouiller un bouton
-lorsque l'utilisateur souhaite ajouter la m�me entit� plusieurs fois
-sur l'interface. Cela �vite de s�lectionner � nouveau le bouton de
-l'entit�.
+lorsque l'utilisateur souhaite ajouter la même entité plusieurs fois
+sur l'interface. Cela évite de sélectionner à nouveau le bouton de
+l'entité.
Remarque : il est impossible d'ajouter un layout ou un composant de
type Window au preview. De plus, il est impossible de "visionner" un
arbre vide.
-Interface cr��e
+Interface créée
---------------
-La zone o� se situe l'interface graphique est en haut � gauche. Elle
-se pr�sente sous forme d'arbre mais il est possible de voir
-l'interface en mode preview. C'est dans cette zone que peuvent �tre
-ajout�es, supprim�es ou modifi�es les entit�s.
+La zone où se situe l'interface graphique est en haut à gauche. Elle
+se présente sous forme d'arbre mais il est possible de voir
+l'interface en mode preview. C'est dans cette zone que peuvent être
+ajoutées, supprimées ou modifiées les entités.
Remarque : il est impossible de supprimer un layout
-* Ajouter un composant ou un layout : cf. partie Entit�s disponibles
+* Ajouter un composant ou un layout : cf. partie Entités disponibles
* Supprimer un composant :
- - s�lectionner le composant dans l'arbre ou le preview
+ - sélectionner le composant dans l'arbre ou le preview
- cliquer sur suppr.
-* Modifier une entit� : cf. partie Propri�r�s des entit�s
+* Modifier une entité : cf. partie Propriérés des entités
-Entit�s disponibles
+Entités disponibles
-------------------
-La zone en bas � gauche regroupe l'ensemble des entit�s (composants +
-layouts) qui peuvent �tre ajout� � l'interface.
+La zone en bas à gauche regroupe l'ensemble des entités (composants +
+layouts) qui peuvent être ajouté à l'interface.
-Pour agrandir la liste des entit�s propos�e, il est possible de
-charger des nouvelles entit�s, je vous invite � consulter le document
+Pour agrandir la liste des entités proposée, il est possible de
+charger des nouvelles entités, je vous invite à consulter le document
loading-guide.
* Ajouter un composant :
- - cliquer sur le bouton du composant pr�sent dans les onglets
+ - cliquer sur le bouton du composant présent dans les onglets
- cliquer sur le container de l'arbre de l'interface qui doit
contenir le composant
* Ajouter un layout :
- - cliquer sur le bouton du layout pr�sent dans les onglets
+ - cliquer sur le bouton du layout présent dans les onglets
- cliquer sur le container de l'arbre de l'interface dont on
souhaite modifier le layout
-:Remarque : une fois l'entit� ajout�e, le bouton de l'onglet est
- "d�ss�lectionn�". Si vous ajoutez � nouveau le m�me composant, il est
- n�cessaire de cliquer � nouveau! C'est pourquoi, il est possible de
- laisser s�lectionner le bouton si seulement vous avez validez
- "S�lection" dans le menu Configuration.
+:Remarque : une fois l'entité ajoutée, le bouton de l'onglet est
+ "déssélectionné". Si vous ajoutez à nouveau le même composant, il est
+ nécessaire de cliquer à nouveau! C'est pourquoi, il est possible de
+ laisser sélectionner le bouton si seulement vous avez validez
+ "Sélection" dans le menu Configuration.
-Propri�t�s des entit�s
+Propriétés des entités
----------------------
-Cette zone situ�e en bas � droite permet d'obtenir, de modifier toutes
-les propri�t�s de l'entit� s�lectionn�e dans l'arbre. Cette zone
-pr�sente diff�rents onglets :
+Cette zone située en bas à droite permet d'obtenir, de modifier toutes
+les propriétés de l'entité sélectionnée dans l'arbre. Cette zone
+présente différents onglets :
-- l'onglet Properties pr�sente un ensemble de propri�t�s mais
+- l'onglet Properties présente un ensemble de propriétés mais
les modifications ne sont pas prisses en comptes. Cet onglet
- sert pour le moment � tester l'utilisation du librairie.
+ sert pour le moment à tester l'utilisation du librairie.
-- l'onglet All Properties pr�sente toutes les propri�t�s de
- l'entit�. Il y a trois colonnes. La premi�re permet de faire
- appara�tre cette propri�t� dans l'onglet Selected Properties
- afin de s�lectionner seulement les propri�t�s les plus
- utilis�es. La deuxi�me et la troisi�me colonne pr�sente
- respectivement le nom et la valeur de la propri�t�.
+- l'onglet All Properties présente toutes les propriétés de
+ l'entité. Il y a trois colonnes. La première permet de faire
+ apparaître cette propriété dans l'onglet Selected Properties
+ afin de sélectionner seulement les propriétés les plus
+ utilisées. La deuxième et la troisième colonne présente
+ respectivement le nom et la valeur de la propriété.
-- l'onglet Selected Properties pr�sente les propri�t�s
- s�lectionn�es dans l'onglet All Properties.
+- l'onglet Selected Properties présente les propriétés
+ sélectionnées dans l'onglet All Properties.
-- l'onglet Layout pr�sente les propri�t�s layout du composant
- s�lectionn� dans l'arbre. Par exemple, si un composant se
+- l'onglet Layout présente les propriétés layout du composant
+ sélectionné dans l'arbre. Par exemple, si un composant se
situe dans un container ayant le layout GridBagLayout par
- exemple, vous pourrez d�finir la contrainte du layout dans cet
- onglet c'est � dire gridx, gridy, gridwidth ...
+ exemple, vous pourrez définir la contrainte du layout dans cet
+ onglet c'est à dire gridx, gridy, gridwidth ...
-- l'onglet Event pr�sente l'ensemble des �v�nements possibles
+- l'onglet Event présente l'ensemble des évènements possibles
sur ce composant. Vous pouvez choisir un listener et la
- m�thode associ�e parmi la liste propos�e pour le bean
- s�lectionn�. Il faut ensuite saisir le nom de la m�thode de
+ méthode associée parmi la liste proposée pour le bean
+ sélectionné. Il faut ensuite saisir le nom de la méthode de
l'action ainsi que ces arguments. Puis, il suffit de cliquer
- sur � Add � pour ajouter un nouvel �v�nement � la liste des
- �v�nements. Pour enlever un �v�nement, il faut le s�lectionner
- dans cette m�me liste et cliquer sur � Remove �.
+ sur « Add » pour ajouter un nouvel événement à la liste des
+ évènements. Pour enlever un événement, il faut le sélectionner
+ dans cette même liste et cliquer sur « Remove ».
-:Remarque: Pour valider la modification de la propri�t�, il est
-imp�ratif d'appuyer sur "Entr�e".
+:Remarque: Pour valider la modification de la propriété, il est
+impératif d'appuyer sur "Entrée".
Presse papier
-------------
-La zone situ�e en haut � droite pr�sente le presse papier de
-l'application. Pour copier un �l�ment dans le presse papier, il suffit de
-s�lectionner un composant (et seulement un composant dans l'arbre ou
+La zone située en haut à droite présente le presse papier de
+l'application. Pour copier un élément dans le presse papier, il suffit de
+sélectionner un composant (et seulement un composant dans l'arbre ou
dans le preview) puis d'appuyer sur les touches Ctrl + C, pour couper
Ctrl + X. On peut constater que le composant est venu s'ajouter dans
l'arbre et dans le clipboard (mode graphique). Par contre, pour coller
-un composant du presse papier dans l'arbre, il faut s�lectionner le
-composant � coller dans l'une des vues du clipBoard puis l'utilisateur
-doit cliquer sur le container dans lequel le composant doit �tre
-ajout�. Ensuite, il peut appuyer sur les touches Ctrl + V.
+un composant du presse papier dans l'arbre, il faut sélectionner le
+composant à coller dans l'une des vues du clipBoard puis l'utilisateur
+doit cliquer sur le container dans lequel le composant doit être
+ajouté. Ensuite, il peut appuyer sur les touches Ctrl + V.
Il est possible de supprimer un composant sur le clipboard quelque
soit la vue en appuyant sur le bouton Suppr.
Modified: trunk/buix/doc/xmlencoder.rst
===================================================================
--- trunk/buix/doc/xmlencoder.rst 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/doc/xmlencoder.rst 2008-08-05 10:39:58 UTC (rev 812)
@@ -1,8 +1,8 @@
==============================
-Syntaxe utilis� par XMLEncoder
+Syntaxe utilisé par XMLEncoder
==============================
-:Authors: Aur�lie Mazelier <mazelier(a)codelutin.org>
+:Authors: Aurélie Mazelier <mazelier(a)codelutin.org>
:Revision: $Revision$
:Date: $Date$
@@ -15,7 +15,7 @@
------------
-Le root �l�ment est un tag *java* qui � deux attributs *version* et *class*.
+Le root élément est un tag *java* qui à deux attributs *version* et *class*.
La class permet de savoir quel objet utiliser pour relire le fichier XML::
<java version="1.4.2_02" class="java.beans.XMLDecoder">
@@ -26,7 +26,7 @@
Les types primitifs ont chacun leur propre tag, quelques objets sont aussi
-assimil�s � des type primitif::
+assimilés à des type primitif::
<int>154</int>
<boolean>true</boolean>
@@ -39,7 +39,7 @@
------------
-Les tableaux sont repr�sent� pas un tag *array*::
+Les tableaux sont représenté pas un tag *array*::
<array class="java.lang.Object" length="1">
<void index="0">
@@ -52,23 +52,23 @@
--------------
-Un bean ou un objet est d�clar� avec le tag *object* il a un attribut
+Un bean ou un objet est déclaré avec le tag *object* il a un attribut
*class* qui donne la class de l'objet::
<object class="javax.swing.JFrame">
-Si l'objet utilise une m�thode statique comme construteur il faut ajouter
-l'attribut *method* contenant le nom de la m�thode statique � utiliser::
+Si l'objet utilise une méthode statique comme construteur il faut ajouter
+l'attribut *method* contenant le nom de la méthode statique à utiliser::
<object class="java.beans.EventHandler" method="create">
-L'objet peut aussi contenir un attribut *id* pour �tre r�utilis�
-ult�rieurement::
+L'objet peut aussi contenir un attribut *id* pour être réutilisé
+ultérieurement::
<object id="JTextField0" class="javax.swing.JTextField">
Si l'objet pour son instanciation prend des arguments, il faut ajouter en sous
-�l�ment les valeurs des arguements::
+élément les valeurs des arguements::
<object class="java.awt.Dimension">
<int>154</int>
@@ -76,35 +76,35 @@
</object>
-R�utilisation d'objet d�j� d'�crit
+Réutilisation d'objet déjà d'écrit
----------------------------------
-Pour utiliser un objet d�j� d'�crit il faut utiliser l'attribut *idref* qui
-prend comme valeur *id* qui avait �t� donn� � l'objet lors de sa premi�re
+Pour utiliser un objet déjà d'écrit il faut utiliser l'attribut *idref* qui
+prend comme valeur *id* qui avait été donné à l'objet lors de sa première
utilisation::
<object id="JTextField0" class="javax.swing.JTextField">
-puis lorsque l'on souhaite r�utiliser l'objet::
+puis lorsque l'on souhaite réutiliser l'objet::
<object idref="JTextField0"/>
-Appel de m�thode
+Appel de méthode
----------------
-Si l'on souhaite appeler une m�thode apr�s l'instanciation de l'objet, il
-faut ajouter en sous �l�ment un tag *void* avec un attribut *method*, cette
-m�thode est alors appel� sur l'objet courant. Le tag d'appelle de la m�thode
-contient comme sous �l�ment les param�tres d'appel de la m�thode::
+Si l'on souhaite appeler une méthode après l'instanciation de l'objet, il
+faut ajouter en sous élément un tag *void* avec un attribut *method*, cette
+méthode est alors appelé sur l'objet courant. Le tag d'appelle de la méthode
+contient comme sous élément les paramètres d'appel de la méthode::
<void method="add">
<object idref="JButton0"/>
</void>
-Utilisation de propri�t�
+Utilisation de propriété
------------------------
Modified: trunk/buix/lutinheader.txt
===================================================================
--- trunk/buix/lutinheader.txt 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/lutinheader.txt 2008-08-05 10:39:58 UTC (rev 812)
@@ -1,6 +1,6 @@
/* *##%
* Copyright (C) 2002, 2003, 2004, 2005 Code Lutin,
-* C�dric Pineau, Benjamin Poussin,
+* Cédric Pineau, Benjamin Poussin,
*
*
* This program is free software; you can redistribute it and/or
Modified: trunk/buix/src/java/org/codelutin/buix/BeanLayoutPropertiesTableModel.java
===================================================================
--- trunk/buix/src/java/org/codelutin/buix/BeanLayoutPropertiesTableModel.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/src/java/org/codelutin/buix/BeanLayoutPropertiesTableModel.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -62,13 +62,13 @@
import org.codelutin.widget.MessageDialog;
/**
-* Model de table pour les propri�t�s. Le model prend en param�tre un bean.
-* Toutes les propri�t�s du bean sont affich�s, si on ne veut pas toutes les
-* propri�t�s il est possible de surcharger la m�thode
-* {@link #isfilteredProperty} pour n'afficher que les propri�t�s que l'on
-* souhaites. La colonne de s�lection permet de s�lectionner des propri�t�s,
-* les propri�t�s s�lectionn�es sont conserv� dans l'environnement de
-* l'utilisateur gr�ce au {@link PropertiesSelectionManager}
+* Model de table pour les propriétés. Le model prend en paramètre un bean.
+* Toutes les propriétés du bean sont affichés, si on ne veut pas toutes les
+* propriétés il est possible de surcharger la méthode
+* {@link #isfilteredProperty} pour n'afficher que les propriétés que l'on
+* souhaites. La colonne de sélection permet de sélectionner des propriétés,
+* les propriétés sélectionnées sont conservé dans l'environnement de
+* l'utilisateur grâce au {@link PropertiesSelectionManager}
*/
public class BeanLayoutPropertiesTableModel extends AbstractTableModel implements BuixSelectionListener { // BeanLayoutPropertiesTableModel
@@ -83,7 +83,7 @@
/**
* Constructeur
- * @param bean le bean dont le model doit refl�ter les propri�t�s
+ * @param bean le bean dont le model doit reflèter les propriétés
*/
public BeanLayoutPropertiesTableModel(Object bean){
setBean(bean);
@@ -95,7 +95,7 @@
/**
* Mise a jour du bean pour un layout
- * @param bean le nouveau bean dont le model doit refl�ter les propri�t�s
+ * @param bean le nouveau bean dont le model doit reflèter les propriétés
*/
public void setBean(Object bean){
@@ -159,7 +159,7 @@
/**
* Permet de savoir si une colonne est la colonne d'affichage des valeurs
- * de la propri�t�.
+ * de la propriété.
*/
public boolean isValueColumn(int column){
return column == VALUE_COLUMN;
@@ -167,7 +167,7 @@
/**
* Permet de savoir si une colonne est la colonne d'affichage des noms
- * de propri�t�.
+ * de propriété.
*/
public boolean isNameColumn(int column){
return column == NAME_COLUMN;
@@ -239,7 +239,7 @@
}
/**
- * Retourne un �diteur pour la ligne souhaite pret a etre utilise.
+ * Retourne un éditeur pour la ligne souhaite pret a etre utilise.
* Il est reinitialise
*/
public PropertyEditor getPropertyEditor(int row){
Modified: trunk/buix/src/java/org/codelutin/buix/BeanPropertiesTableModel.java
===================================================================
--- trunk/buix/src/java/org/codelutin/buix/BeanPropertiesTableModel.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/src/java/org/codelutin/buix/BeanPropertiesTableModel.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -56,13 +56,13 @@
/**
-* Model de table pour les propri�t�s. Le model prend en param�tre un bean.
-* Toutes les propri�t�s du bean sont affich�s, si on ne veut pas toutes les
-* propri�t�s il est possible de surcharger la m�thode
-* {@link #isfilteredProperty} pour n'afficher que les propri�t�s que l'on
-* souhaites. La colonne de s�lection permet de s�lectionner des propri�t�s,
-* les propri�t�s s�lectionn�es sont conserv� dans l'environnement de
-* l'utilisateur gr�ce au {@link PropertiesSelectionManager}
+* Model de table pour les propriétés. Le model prend en paramètre un bean.
+* Toutes les propriétés du bean sont affichés, si on ne veut pas toutes les
+* propriétés il est possible de surcharger la méthode
+* {@link #isfilteredProperty} pour n'afficher que les propriétés que l'on
+* souhaites. La colonne de sélection permet de sélectionner des propriétés,
+* les propriétés sélectionnées sont conservé dans l'environnement de
+* l'utilisateur grâce au {@link PropertiesSelectionManager}
*/
public class BeanPropertiesTableModel extends AbstractTableModel implements PropertiesSelectionManagerListener, BuixSelectionListener{ // BeanPropertiesTableModel
@@ -78,8 +78,8 @@
int showSelectionColumn = 0;
/**
- * Constructeur qui par d�faut affiche la colonne de s�lection.
- * @param bean le bean dont le model doit refl�ter les propri�t�s
+ * Constructeur qui par défaut affiche la colonne de sélection.
+ * @param bean le bean dont le model doit reflèter les propriétés
*/
public BeanPropertiesTableModel(Object bean){
this(bean, true);
@@ -91,7 +91,7 @@
}
/**
- * @return vrai si la propri�t� doit �tre affich�e.
+ * @return vrai si la propriété doit être affichée.
*/
protected boolean isfilteredProperty(PropertyDescriptor desc){
return true;
@@ -163,8 +163,8 @@
/**
* Permet de savoir si une colonne est la colonne d'affichage des valeurs
- * de la propri�t�. Cette m�thode prend en compte si la colonne de s�lection
- * est affich�e ou non.
+ * de la propriété. Cette méthode prend en compte si la colonne de sélection
+ * est affichée ou non.
*/
public boolean isValueColumn(int column){
column = column + showSelectionColumn;
@@ -173,8 +173,8 @@
/**
* Permet de savoir si une colonne est la colonne d'affichage des noms
- * de propri�t�. Cette m�thode prend en compte si la colonne de s�lection
- * est affich�e ou non.
+ * de propriété. Cette méthode prend en compte si la colonne de sélection
+ * est affichée ou non.
*/
public boolean isNameColumn(int column){
column = column + showSelectionColumn;
@@ -256,10 +256,10 @@
}
/**
- * Retourne un �diteur pour la ligne souhaite pret a etre utilise.
+ * Retourne un éditeur pour la ligne souhaite pret a etre utilise.
* Il est reinitialise
- * @param row ligne dont on souhaite l'�diteur
- * @return l'�diteur de la ligne souhait�e
+ * @param row ligne dont on souhaite l'éditeur
+ * @return l'éditeur de la ligne souhaitée
*/
public PropertyEditor getPropertyEditor(int row){
PropertyEditor result = (PropertyEditor)editors.get(row);
@@ -267,7 +267,7 @@
}
/**
- * Retourne la classe correspondant � l'index de la colonne
+ * Retourne la classe correspondant à l'index de la colonne
* @param columnIndex index de la colonne
* @return classe de la colonne souhaitee
*/
Modified: trunk/buix/src/java/org/codelutin/buix/Buix.java
===================================================================
--- trunk/buix/src/java/org/codelutin/buix/Buix.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/src/java/org/codelutin/buix/Buix.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -521,7 +521,7 @@
setCurrentBean(bean);
}catch(Exception eee){
- Logger.getLogger(getClass().getName() + ".on_addEvent").log(Level.WARNING, "Impossible d'ajouter cet evenement � l'objet", eee);
+ Logger.getLogger(getClass().getName() + ".on_addEvent").log(Level.WARNING, "Impossible d'ajouter cet evenement à l'objet", eee);
MessageDialog.error("Error", "Impossible d'ajouter cet evenement a l'objet", eee);
}
}
Modified: trunk/buix/src/java/org/codelutin/buix/BuixXMLEncoder.java
===================================================================
--- trunk/buix/src/java/org/codelutin/buix/BuixXMLEncoder.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/src/java/org/codelutin/buix/BuixXMLEncoder.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -59,8 +59,8 @@
import java.net.URL;
/**
-* Cette classe n'�tend pas {@link java.beans.XMLEncoder} car celle-ci ne permet
-* pas la surcharge de m�thode, on etend donc {@link java.beans.Encoder}
+* Cette classe n'étend pas {@link java.beans.XMLEncoder} car celle-ci ne permet
+* pas la surcharge de méthode, on etend donc {@link java.beans.Encoder}
* @deprecated Cette classe ne donne pas le xml souhaite
*/
public class BuixXMLEncoder extends Encoder { // BuixXMLEncoder
Modified: trunk/buix/src/java/org/codelutin/buix/EditorManager.java
===================================================================
--- trunk/buix/src/java/org/codelutin/buix/EditorManager.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/src/java/org/codelutin/buix/EditorManager.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -92,7 +92,7 @@
}
/**
- * Cette m�thode permet de r�cup�r� l'editeur d'un type particulier
+ * Cette méthode permet de récupéré l'editeur d'un type particulier
*/
public static PropertyEditor getPropertyEditor(PropertyDescriptor descriptor){
PropertyEditor result = null;
@@ -113,7 +113,7 @@
}
/**
- * Cette m�thode permet de r�cup�r� l'editeur d'un type particulier
+ * Cette méthode permet de récupéré l'editeur d'un type particulier
*/
public static PropertyEditor getPropertyEditor(PropertyChildDescriptor descriptor){
PropertyEditor result = null;
Modified: trunk/buix/src/java/org/codelutin/buix/PropertiesSelectionManager.java
===================================================================
--- trunk/buix/src/java/org/codelutin/buix/PropertiesSelectionManager.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/src/java/org/codelutin/buix/PropertiesSelectionManager.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -45,10 +45,10 @@
/**
-* Classe permettant � l'utilisateur de d�finir les propri�t�s des beans qu'il
+* Classe permettant à l'utilisateur de définir les propriétés des beans qu'il
* souhait voir pour chaque type de bean.
* @todo l'utilisation de les hashmap et des pref sont redondant, si les prefs marche bien il faudra supprimer les hashmap
-* @todo si l'utilisateur n'a pas encore d�fini de preference pour un bean, on recherche un ancetre du bean qui lui aurait des preferences.
+* @todo si l'utilisateur n'a pas encore défini de preference pour un bean, on recherche un ancetre du bean qui lui aurait des preferences.
* @todo si aucune preference utilisateur n'a ete trouve on lit les preferences par defaut de buix pour le bean.
*/
public class PropertiesSelectionManager { // PropertiesSelectionManager
Modified: trunk/buix/src/java/org/codelutin/buix/ShelfTreeModel.java
===================================================================
--- trunk/buix/src/java/org/codelutin/buix/ShelfTreeModel.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/src/java/org/codelutin/buix/ShelfTreeModel.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -46,7 +46,7 @@
/**
* Tous les noeuds sont des ShelfTreeNode. Chacun encapsule un Objet.
-* Lorsqu'un ShelfTreeNode est cr�e il est ajout� dans childNodes
+* Lorsqu'un ShelfTreeNode est crée il est ajouté dans childNodes
* Ce qui permet de retrouver simplement le noeud associe a un Component ou a un Layout
*/
public class ShelfTreeModel extends DefaultTreeModel { // ShelfTreeModel
Modified: trunk/buix/src/java/org/codelutin/buix/WidgetManager.java
===================================================================
--- trunk/buix/src/java/org/codelutin/buix/WidgetManager.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/src/java/org/codelutin/buix/WidgetManager.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -62,7 +62,7 @@
/**
* Boite a widget, cette classe sert a savoir qu'elle est le widget actuellement
-* s�lectionne.
+* sélectionne.
*/
public class WidgetManager implements ActionListener { // WidgetManager
Modified: trunk/buix/src/java/org/codelutin/buix/WidgetManagerEvent.java
===================================================================
--- trunk/buix/src/java/org/codelutin/buix/WidgetManagerEvent.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/buix/src/java/org/codelutin/buix/WidgetManagerEvent.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -47,7 +47,7 @@
}
/**
- * Utilis� pour les events d'ajout
+ * Utilisé pour les events d'ajout
*/
public WidgetManagerEvent(WidgetManager source, ShelfButton shelfButton, String shelf){
super(source);
Modified: trunk/jaxx/doc/index.rst
===================================================================
--- trunk/jaxx/doc/index.rst 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/jaxx/doc/index.rst 2008-08-05 10:39:58 UTC (rev 812)
@@ -4,10 +4,10 @@
.. contents::
-Pr�sentation
+Présentation
------------
TODO
-**Veuillez consulter la JavaDoc pour de plus ample d�tails sur les diff�rentes
+**Veuillez consulter la JavaDoc pour de plus ample détails sur les différentes
librairies.**
Modified: trunk/jaxx/src/main/java/jaxx/parser/Java1.5.jjt
===================================================================
--- trunk/jaxx/src/main/java/jaxx/parser/Java1.5.jjt 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/jaxx/src/main/java/jaxx/parser/Java1.5.jjt 2008-08-05 10:39:58 UTC (rev 812)
@@ -1,6 +1,6 @@
/*
- * Copyright � 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
Modified: trunk/jaxx/src/main/java/jaxx/runtime/builder/ActionConfig.java
===================================================================
--- trunk/jaxx/src/main/java/jaxx/runtime/builder/ActionConfig.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/jaxx/src/main/java/jaxx/runtime/builder/ActionConfig.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -28,7 +28,7 @@
* <p/>
* Placer cette annotation sur la classe implantant l'action,
* <p/>
- * les informations d�crites seront utilis�es pour instancier l'action
+ * les informations décrites seront utilisées pour instancier l'action
*
* @author chemit
*/
@@ -39,37 +39,37 @@
public @interface ActionConfig {
/**
- * @return la clef de la commande (doit �tre unique)
+ * @return la clef de la commande (doit être unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
String actionCommand();
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
*/
String name() default "";
/**
- * @return la clef i18n du tooltip de l'action, si vide ignor�
+ * @return la clef i18n du tooltip de l'action, si vide ignoré
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
String shortDescription() default "";
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#LONG_DESCRIPTION
*/
String longDescription() default "";
/**
- * @return le nom de l'icone associ�, si vide ignor�
+ * @return le nom de l'icone associé, si vide ignoré
* @see javax.swing.Action#SMALL_ICON
*/
String smallIcon() default "";
/**
- * @return le nom du grande icone associ�, si vide ignor�
+ * @return le nom du grande icone associé, si vide ignoré
* @see javax.swing.Action#LARGE_ICON_KEY
*/
String largeIcon() default "";
@@ -93,7 +93,7 @@
int displayedMnemonicIndex() default '\0';
/**
- * @return la valeur par d�faut pour les component selectable
+ * @return la valeur par défaut pour les component selectable
* @see javax.swing.Action#SELECTED_KEY
*/
boolean selected() default false;
Modified: trunk/jaxx/src/main/java/jaxx/runtime/builder/ActionFactory.java
===================================================================
--- trunk/jaxx/src/main/java/jaxx/runtime/builder/ActionFactory.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/jaxx/src/main/java/jaxx/runtime/builder/ActionFactory.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -143,7 +143,7 @@
}
public AbstractAction newAction0(String actionKey) {
- // on v�rifie que l'action existe bien
+ // on vérifie que l'action existe bien
checkRegistredAction(actionKey);
// try in cache
@@ -158,10 +158,10 @@
return null;
}
/**
- * @param actionKey le nom de l'action tel que d�finie dans le fichier
+ * @param actionKey le nom de l'action tel que définie dans le fichier
* de mapping (sans le prefix action.)
- * @param component le button o� rattacher l'action
- * @return une nouvelle instance de l'action associ�e � sa clef.
+ * @param component le button où rattacher l'action
+ * @return une nouvelle instance de l'action associée à sa clef.
*/
public AbstractAction newAction(String actionKey, AbstractButton component) {
@@ -170,7 +170,7 @@
if (result!=null) {
return result;
}
- // on r�cup�re la classe d'implantation de l'action
+ // on récupère la classe d'implantation de l'action
Class<? extends AbstractAction> klazz = impls.get(actionKey);
try {
@@ -223,10 +223,10 @@
}
/**
- * @param actionKey le nom de l'action tel que d�finie dans le fichier
+ * @param actionKey le nom de l'action tel que définie dans le fichier
* de mapping (sans le prefix action.)
- * @param component le button o� rattacher l'action
- * @return une nouvelle instance de l'action associ�e � sa clef.
+ * @param component le button où rattacher l'action
+ * @return une nouvelle instance de l'action associée à sa clef.
*/
public AbstractAction newAction(String actionKey, JComboBox component) {
@@ -236,7 +236,7 @@
return result;
}
- // on r�cup�re la classe d'implantation de l'action
+ // on récupère la classe d'implantation de l'action
Class<? extends AbstractAction> klazz = impls.get(actionKey);
try {
@@ -261,7 +261,7 @@
public static ToggleActionConfig initToggleActionConfig(AbstractButton component, AbstractAction result) {
ToggleActionConfig anno = result.getClass().getAnnotation(ToggleActionConfig.class);
if (anno != null) {
- // inject les donn�es
+ // inject les données
if (!anno.name().isEmpty()) {
//System.out.println("found action with name : " + anno.name());
result.putValue(Action.NAME, _(anno.name()));
@@ -306,7 +306,7 @@
public static ActionConfig initActionConfig(AbstractButton component, AbstractAction result) {
ActionConfig anno = result.getClass().getAnnotation(ActionConfig.class);
if (anno != null) {
- // inject les donn�es
+ // inject les données
if (!anno.name().isEmpty()) {
//System.out.println("found action with name : " + anno.name());
result.putValue(Action.NAME, _(anno.name()));
@@ -340,7 +340,7 @@
public static SelectActionConfig initSelectActionConfig(JComboBox component, AbstractAction result) {
SelectActionConfig anno = result.getClass().getAnnotation(SelectActionConfig.class);
if (anno != null) {
- // inject les donn�es
+ // inject les données
if (!anno.name().isEmpty()) {
result.putValue(Action.NAME, _(anno.name()));
}
Modified: trunk/jaxx/src/main/java/jaxx/runtime/builder/SelectActionConfig.java
===================================================================
--- trunk/jaxx/src/main/java/jaxx/runtime/builder/SelectActionConfig.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/jaxx/src/main/java/jaxx/runtime/builder/SelectActionConfig.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -28,7 +28,7 @@
* <p/>
* Placer cette annotation sur la classe implantant l'action,
* <p/>
- * les informations d�crites seront utilis�es pour instancier l'action
+ * les informations décrites seront utilisées pour instancier l'action
*
* @author chemit
*/
@@ -39,25 +39,25 @@
public @interface SelectActionConfig {
/**
- * @return la clef de la commande (doit �tre unique)
+ * @return la clef de la commande (doit être unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
public abstract String actionCommand();
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
*/
public abstract String name() default "";
/**
- * @return la clef i18n du tooltip de l'action, si vide ignor�
+ * @return la clef i18n du tooltip de l'action, si vide ignoré
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
public abstract String shortDescription() default "";
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#LONG_DESCRIPTION
*/
public abstract String longDescription() default "";
@@ -69,7 +69,7 @@
public abstract String accelerator() default "";
/**
- * @return la valeur par d�faut pour les component selectable
+ * @return la valeur par défaut pour les component selectable
* @see javax.swing.Action#SELECTED_KEY
*/
public abstract int selectedIndex() default 0;
Modified: trunk/jaxx/src/main/java/jaxx/runtime/builder/TabFactory.java
===================================================================
--- trunk/jaxx/src/main/java/jaxx/runtime/builder/TabFactory.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/jaxx/src/main/java/jaxx/runtime/builder/TabFactory.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -32,7 +32,7 @@
import java.util.Set;
/**
- * Une usine pour les Tabs, leur configs et leur mod�les
+ * Une usine pour les Tabs, leur configs et leur modèles
*
* @author tony
* @see jaxx.runtime.builder.TabContentConfig
Modified: trunk/jaxx/src/main/java/jaxx/runtime/builder/ToggleActionConfig.java
===================================================================
--- trunk/jaxx/src/main/java/jaxx/runtime/builder/ToggleActionConfig.java 2008-08-04 20:15:46 UTC (rev 811)
+++ trunk/jaxx/src/main/java/jaxx/runtime/builder/ToggleActionConfig.java 2008-08-05 10:39:58 UTC (rev 812)
@@ -28,7 +28,7 @@
* <p/>
* Placer cette annotation sur la classe implantant l'action,
* <p/>
- * les informations d�crites seront utilis�es pour instancier l'action
+ * les informations décrites seront utilisées pour instancier l'action
*
* @author chemit
*/
@@ -38,37 +38,37 @@
public @interface ToggleActionConfig {
/**
- * @return la clef de la commande (doit �tre unique)
+ * @return la clef de la commande (doit être unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
public abstract String actionCommand();
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
*/
public abstract String name() default "";
/**
- * @return la clef i18n du tooltip de l'action, si vide ignor�
+ * @return la clef i18n du tooltip de l'action, si vide ignoré
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
public abstract String shortDescription() default "";
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#LONG_DESCRIPTION
*/
public abstract String longDescription() default "";
/**
- * @return le nom de l'icone associ�, si vide ignor�
+ * @return le nom de l'icone associé, si vide ignoré
* @see javax.swing.Action#SMALL_ICON
*/
public abstract String smallIcon() default "";
/**
- * @return le nom du grande icone associ�, si vide ignor�
+ * @return le nom du grande icone associé, si vide ignoré
* @see javax.swing.Action#LARGE_ICON_KEY
*/
public abstract String largeIcon() default "";
@@ -86,31 +86,31 @@
public abstract int mnemonic() default '\0';
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
*/
public abstract String name2() default "";
/**
- * @return la clef i18n du tooltip de l'action, si vide ignor�
+ * @return la clef i18n du tooltip de l'action, si vide ignoré
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
public abstract String shortDescription2() default "";
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#LONG_DESCRIPTION
*/
public abstract String longDescription2() default "";
/**
- * @return le nom de l'icone associ�, si vide ignor�
+ * @return le nom de l'icone associé, si vide ignoré
* @see javax.swing.Action#SMALL_ICON
*/
public abstract String smallIcon2() default "";
/**
- * @return le nom du grande icone associ�, si vide ignor�
+ * @return le nom du grande icone associé, si vide ignoré
* @see javax.swing.Action#LARGE_ICON_KEY
*/
public abstract String largeIcon2() default "";
@@ -128,7 +128,7 @@
public abstract int mnemonic2() default '\0';
/**
- * @return la valeur par d�faut pour les component selectable
+ * @return la valeur par défaut pour les component selectable
* @see javax.swing.Action#SELECTED_KEY
*/
public abstract boolean selected() default false;
1
0
r811 - in trunk/lutinjaxx: . core core/src/main/java/jaxx/parser jaxx-swing jaxx-swing-action jaxx-swing-action/src/main/java/org/codelutin/jaxx/action jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer jaxx-swing-tab jaxx-swing-tab/src/main/java/org/codelutin/jaxx/tab maven maven/src/main/java/org/codelutin/jaxx runtime util
by tchemit@users.labs.libre-entreprise.org Aug. 4, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 4, 2008
Aug. 4, 2008
Author: tchemit
Date: 2008-08-04 20:15:46 +0000 (Mon, 04 Aug 2008)
New Revision: 811
Modified:
trunk/lutinjaxx/core/pom.xml
trunk/lutinjaxx/core/src/main/java/jaxx/parser/Java1.5.jjt
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-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.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/SelectActionConfigConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java
trunk/lutinjaxx/jaxx-swing-tab/pom.xml
trunk/lutinjaxx/jaxx-swing-tab/src/main/java/org/codelutin/jaxx/tab/TabFactory.java
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/AbstractJaxxMojo.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/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
trunk/lutinjaxx/pom.xml
trunk/lutinjaxx/runtime/pom.xml
trunk/lutinjaxx/util/pom.xml
Log:
passage en UTF-8
Modified: trunk/lutinjaxx/core/pom.xml
===================================================================
--- trunk/lutinjaxx/core/pom.xml 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/core/pom.xml 2008-08-04 20:15:46 UTC (rev 811)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Modified: trunk/lutinjaxx/core/src/main/java/jaxx/parser/Java1.5.jjt
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/parser/Java1.5.jjt 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/parser/Java1.5.jjt 2008-08-04 20:15:46 UTC (rev 811)
@@ -1,6 +1,6 @@
/*
- * Copyright � 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
* intellectual property rights relating to technology embodied in the product
* that is described in this document. In particular, and without limitation,
Modified: trunk/lutinjaxx/jaxx-swing/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing/pom.xml 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing/pom.xml 2008-08-04 20:15:46 UTC (rev 811)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Modified: trunk/lutinjaxx/jaxx-swing-action/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/pom.xml 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-action/pom.xml 2008-08-04 20:15:46 UTC (rev 811)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionConfig.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -29,7 +29,7 @@
* <p/>
* Placer cette annotation sur la classe implantant l'action,
* <p/>
- * les informations d�crites seront utilis�es pour instancier l'action
+ * les informations décrites seront utilisées pour instancier l'action
*
* @author chemit
*/
@@ -40,37 +40,37 @@
public @interface ActionConfig {
/**
- * @return la clef de la commande (doit �tre unique)
+ * @return la clef de la commande (doit être unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
public String actionCommand();
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
*/
String name() default "";
/**
- * @return la clef i18n du tooltip de l'action, si vide ignor�
+ * @return la clef i18n du tooltip de l'action, si vide ignoré
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
String shortDescription() default "";
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#LONG_DESCRIPTION
*/
String longDescription() default "";
/**
- * @return le nom de l'icone associ�, si vide ignor�
+ * @return le nom de l'icone associé, si vide ignoré
* @see javax.swing.Action#SMALL_ICON
*/
String smallIcon() default "";
/**
- * @return le nom du grande icone associ�, si vide ignor�
+ * @return le nom du grande icone associé, si vide ignoré
* @see javax.swing.Action#LARGE_ICON_KEY
*/
String largeIcon() default "";
@@ -94,7 +94,7 @@
int displayedMnemonicIndex() default '\0';
/**
- * @return la valeur par d�faut pour les component selectable
+ * @return la valeur par défaut pour les component selectable
* @see javax.swing.Action#SELECTED_KEY
*/
boolean selected() default false;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/SelectActionConfig.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -29,7 +29,7 @@
* <p/>
* Placer cette annotation sur la classe implantant l'action,
* <p/>
- * les informations d�crites seront utilis�es pour instancier l'action
+ * les informations décrites seront utilisées pour instancier l'action
*
* @author chemit
*/
@@ -40,25 +40,25 @@
public @interface SelectActionConfig {
/**
- * @return la clef de la commande (doit �tre unique)
+ * @return la clef de la commande (doit être unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
public abstract String actionCommand();
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
*/
public abstract String name() default "";
/**
- * @return la clef i18n du tooltip de l'action, si vide ignor�
+ * @return la clef i18n du tooltip de l'action, si vide ignoré
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
public abstract String shortDescription() default "";
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#LONG_DESCRIPTION
*/
public abstract String longDescription() default "";
@@ -70,7 +70,7 @@
public abstract String accelerator() default "";
/**
- * @return la valeur par d�faut pour les component selectable
+ * @return la valeur par défaut pour les component selectable
* @see javax.swing.Action#SELECTED_KEY
*/
public abstract int selectedIndex() default 0;
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ToggleActionConfig.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -29,7 +29,7 @@
* <p/>
* Placer cette annotation sur la classe implantant l'action,
* <p/>
- * les informations d�crites seront utilis�es pour instancier l'action
+ * les informations décrites seront utilisées pour instancier l'action
*
* @author chemit
*/
@@ -38,37 +38,37 @@
@Inherited
public @interface ToggleActionConfig {
/**
- * @return la clef de la commande (doit �tre unique)
+ * @return la clef de la commande (doit être unique)
* @see javax.swing.Action#ACTION_COMMAND_KEY
*/
public abstract String actionCommand();
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
*/
public abstract String name() default "";
/**
- * @return la clef i18n du tooltip de l'action, si vide ignor�
+ * @return la clef i18n du tooltip de l'action, si vide ignoré
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
public abstract String shortDescription() default "";
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#LONG_DESCRIPTION
*/
public abstract String longDescription() default "";
/**
- * @return le nom de l'icone associ�, si vide ignor�
+ * @return le nom de l'icone associé, si vide ignoré
* @see javax.swing.Action#SMALL_ICON
*/
public abstract String smallIcon() default "";
/**
- * @return le nom du grande icone associ�, si vide ignor�
+ * @return le nom du grande icone associé, si vide ignoré
* @see javax.swing.Action#LARGE_ICON_KEY
*/
public abstract String largeIcon() default "";
@@ -86,31 +86,31 @@
public abstract int mnemonic() default '\0';
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#NAME
*/
public abstract String name2() default "";
/**
- * @return la clef i18n du tooltip de l'action, si vide ignor�
+ * @return la clef i18n du tooltip de l'action, si vide ignoré
* @see javax.swing.Action#SHORT_DESCRIPTION
*/
public abstract String shortDescription2() default "";
/**
- * @return la clef i18n du texte de l'action, si vide ignor�
+ * @return la clef i18n du texte de l'action, si vide ignoré
* @see javax.swing.Action#LONG_DESCRIPTION
*/
public abstract String longDescription2() default "";
/**
- * @return le nom de l'icone associ�, si vide ignor�
+ * @return le nom de l'icone associé, si vide ignoré
* @see javax.swing.Action#SMALL_ICON
*/
public abstract String smallIcon2() default "";
/**
- * @return le nom du grande icone associ�, si vide ignor�
+ * @return le nom du grande icone associé, si vide ignoré
* @see javax.swing.Action#LARGE_ICON_KEY
*/
public abstract String largeIcon2() default "";
@@ -128,7 +128,7 @@
public abstract int mnemonic2() default '\0';
/**
- * @return la valeur par d�faut pour les component selectable
+ * @return la valeur par défaut pour les component selectable
* @see javax.swing.Action#SELECTED_KEY
*/
public abstract boolean selected() default false;
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-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -155,10 +155,10 @@
}
/**
- * @param actionKey le nom de l'action tel que d�finie dans le fichier
+ * @param actionKey le nom de l'action tel que définie dans le fichier
* de mapping (sans le prefix action.)
- * @param component le button o� rattacher l'action
- * @return une nouvelle instance de l'action associ�e � sa clef.
+ * @param component le button où rattacher l'action
+ * @return une nouvelle instance de l'action associée à sa clef.
*/
public A newAction(String actionKey, JComponent component) {
// try first in cache
@@ -241,10 +241,10 @@
/**
* @param actionKey la clef de l'action
- * @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouv�e.
+ * @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouvée.
*/
public A getActionFromCache(String actionKey) {
- // on v�rifie que l'action existe bien
+ // on vérifie que l'action existe bien
checkRegistredAction(actionKey);
// try in cache
@@ -280,7 +280,7 @@
}
/**
- * @param component le button o� rattacher l'action
+ * @param component le button où rattacher l'action
* @param action action
* @param configurationResolver initializer
*/
@@ -323,7 +323,7 @@
}
/**
- * @param component le select box o� rattacher l'action
+ * @param component le select box où rattacher l'action
* @param action action
* @param configurationResolver initializer
*/
Modified: 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/ActionConfigConfigurationResolver.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ActionConfigConfigurationResolver.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -37,7 +37,7 @@
if (anno == null) {
return null;
}
- // inject les donn�es
+ // inject les données
if (!anno.name().isEmpty()) {
//System.out.println("found action with name : " + anno.name());
action.putValue(Action.NAME, _(anno.name()));
Modified: 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/SelectActionConfigConfigurationResolver.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/SelectActionConfigConfigurationResolver.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -37,7 +37,7 @@
if (anno == null) {
return null;
}
- // inject les donn�es
+ // inject les données
if (!anno.name().isEmpty()) {
action.putValue(Action.NAME, _(anno.name()));
}
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/initializer/ToggleActionConfigConfigurationResolver.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -37,7 +37,7 @@
if (anno == null) {
return null;
}
- // inject les donn�es
+ // inject les données
if (!anno.name().isEmpty()) {
//System.out.println("found action with name : " + anno.name());
action.putValue(Action.NAME, _(anno.name()));
Modified: trunk/lutinjaxx/jaxx-swing-tab/pom.xml
===================================================================
--- trunk/lutinjaxx/jaxx-swing-tab/pom.xml 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-tab/pom.xml 2008-08-04 20:15:46 UTC (rev 811)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Modified: trunk/lutinjaxx/jaxx-swing-tab/src/main/java/org/codelutin/jaxx/tab/TabFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-tab/src/main/java/org/codelutin/jaxx/tab/TabFactory.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/jaxx-swing-tab/src/main/java/org/codelutin/jaxx/tab/TabFactory.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -32,7 +32,7 @@
import java.util.TreeMap;
/**
- * Une usine pour les Tabs, leur configs et leur mod�les
+ * Une usine pour les Tabs, leur configs et leur modèles
*
* @author tony
* @see TabContentConfig
Modified: trunk/lutinjaxx/maven/pom.xml
===================================================================
--- trunk/lutinjaxx/maven/pom.xml 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/maven/pom.xml 2008-08-04 20:15:46 UTC (rev 811)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -26,7 +26,7 @@
public abstract class AbstractActionGeneratorMojo extends AbstractJaxxMojo {
/**
- * @description Nom du fichier d'actions � g�n�rer.
+ * @description Nom du fichier d'actions à générer.
* @parameter expression="${jaxx.actionsFile}"
* @required
*/
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -37,26 +37,26 @@
public abstract class AbstractJaxxMojo extends AbstractMojo {
/**
- * @description D�pendance du projet.
+ * @description Dépendance du projet.
* @parameter default-value="${project}"
* @readonly
*/
protected MavenProject project;
/**
- * @description R�pertoire de destination des fichiers java � g�n�rer.
+ * @description Répertoire de destination des fichiers java à générer.
* @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
*/
protected File outJava;
/**
- * @description chemin du r�pertoire de g�n�ration des resources.
+ * @description chemin du répertoire de génération des resources.
* @parameter expression="${jaxx.outResource}" default-value="${basedir}/target/generated-sources/resources"
*/
protected File outResource;
/**
- * @description chemin du r�pertoire de compilation des resources.
+ * @description chemin du répertoire de compilation des resources.
* @parameter expression="${jaxx.outClass}" default-value="${basedir}/target/classes"
*/
protected File outClass;
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -33,7 +33,7 @@
import java.util.Properties;
/**
- * Classe permettant de generer le fichier de propri�t�s des actions d�tect�es.
+ * Classe permettant de generer le fichier de propriétés des actions détectées.
*
* @author chemit
* @goal generate-actions-properties
@@ -43,7 +43,7 @@
public class ActionGeneratorMojo extends AbstractActionGeneratorMojo {
/**
- * @description R�pertoire sources des fichiers java � traiter.
+ * @description Répertoire sources des fichiers java à traiter.
* @parameter expression="${jaxx.src}" default-value="${basedir}/src/main/java"
*/
protected File src;
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionProviderGeneratorMojo.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -27,7 +27,7 @@
import java.io.IOException;
/**
- * Classe permettant de generer un {@link org.codelutin.jaxx.action.provider.ActionProvider} et son fichier de d�claration.
+ * Classe permettant de generer un {@link org.codelutin.jaxx.action.provider.ActionProvider} et son fichier de déclaration.
*
* @author chemit
* @goal generate-actions-provider
@@ -37,21 +37,21 @@
public class ActionProviderGeneratorMojo extends AbstractActionGeneratorMojo {
/**
- * @description FQN de la classe � g�n�rer.
+ * @description FQN de la classe à générer.
* @parameter expression="${jaxx.fqn}"
* @required
*/
protected String fqn;
/**
- * @description nom logique du provider � g�n�rer.
+ * @description nom logique du provider à générer.
* @parameter expression="${jaxx.providerName}"
* @required
*/
protected String providerName;
/**
- * @description FQN de la classe d'action � utiliser.
+ * @description FQN de la classe d'action à utiliser.
* @parameter expression="${jaxx.fqnAction}"
* @required
*/
Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
===================================================================
--- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-08-04 20:15:46 UTC (rev 811)
@@ -38,13 +38,13 @@
public class JaxxGeneratorMojo extends AbstractJaxxMojo {
/**
- * @description R�pertoire sources des fichiers jaxx � g�n�rer.
+ * @description Répertoire sources des fichiers jaxx à générer.
* @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/uimodel"
*/
protected File src;
/**
- * @description pour optimizer le code compil� ou g�n�r� ?
+ * @description pour optimizer le code compilé ou généré ?
* @parameter expression="${jaxx.optimize}" default-value="false"
*/
protected boolean optimize;
Modified: trunk/lutinjaxx/pom.xml
===================================================================
--- trunk/lutinjaxx/pom.xml 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/pom.xml 2008-08-04 20:15:46 UTC (rev 811)
@@ -77,6 +77,7 @@
<!-- compile with ? -->
<maven.compile.source>1.6</maven.compile.source>
<maven.compile.target>1.6</maven.compile.target>
+ <maven.compile.compile>UTF-8</maven.compile.compile>
<!-- Lists URL -->
<labs.lists>
@@ -238,7 +239,7 @@
<dependency>
<groupId>lutinplugin</groupId>
<artifactId>maven-i18n-plugin</artifactId>
- <version>0.3</version>
+ <version>0.4</version>
</dependency>
<dependency>
Modified: trunk/lutinjaxx/runtime/pom.xml
===================================================================
--- trunk/lutinjaxx/runtime/pom.xml 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/runtime/pom.xml 2008-08-04 20:15:46 UTC (rev 811)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
Modified: trunk/lutinjaxx/util/pom.xml
===================================================================
--- trunk/lutinjaxx/util/pom.xml 2008-08-04 20:05:24 UTC (rev 810)
+++ trunk/lutinjaxx/util/pom.xml 2008-08-04 20:15:46 UTC (rev 811)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1
0
Author: tchemit
Date: 2008-08-04 20:05:24 +0000 (Mon, 04 Aug 2008)
New Revision: 810
Removed:
trunk/maven-jaxx-plugin/
Log:
bye-bye tony :)
1
0
Author: tchemit
Date: 2008-08-04 20:05:16 +0000 (Mon, 04 Aug 2008)
New Revision: 809
Removed:
trunk/lutinvcs/
Log:
bye-bye tony :)
1
0
Author: tchemit
Date: 2008-08-04 20:05:05 +0000 (Mon, 04 Aug 2008)
New Revision: 808
Removed:
trunk/lutinui/
Log:
bye-bye tony :)
1
0
r807 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org Aug. 4, 2008
by tchemit@users.labs.libre-entreprise.org Aug. 4, 2008
Aug. 4, 2008
Author: tchemit
Date: 2008-08-04 00:00:05 +0000 (Mon, 04 Aug 2008)
New Revision: 807
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
Log:
fix bug : when a class has to be compiled but not the baseAction class, we did not have the providerConfig, in that casespecial case we try to find it in a super class of on of found action class
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-07-31 13:17:21 UTC (rev 806)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionAnnotationProcessing.java 2008-08-04 00:00:05 UTC (rev 807)
@@ -126,12 +126,20 @@
}
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();
+ if (providerConfig == null) {
+ // baseActionClass was not compiled at this time, must find it back
+
+ findProviderConfigFromCompiledClass();
+
+ if (providerConfig == null) {
+ throw new IllegalStateException("no provider name found, you must add on baseaction the annotation " + ActionProviderAnnotation.class);
+ }
+ actionsFileLocation = String.format(actionsFileLocation, providerConfig.name());
+ } else {
+ writeProviderClass();
+ writeProviderServiceDeclaration();
+ }
writeActionMapping();
} catch (Exception e) {
throw new RuntimeException(e);
@@ -141,9 +149,22 @@
}
}
- return false;
+ return true;
}
+ protected void findProviderConfigFromCompiledClass() throws ClassNotFoundException {
+ if (!processedClass.isEmpty()) {
+ Class<?> klazz = Class.forName(processedClass.get(0));
+ providerConfig = klazz.getAnnotation(ActionProviderAnnotation.class);
+ while (klazz != null && providerConfig == null) {
+ klazz = klazz.getSuperclass();
+ if (klazz != null) {
+ providerConfig = klazz.getAnnotation(ActionProviderAnnotation.class);
+ }
+ }
+ }
+ }
+
protected void registerActionsForClass(TypeMirror annotationType, Element e) {
for (AnnotationMirror mirror : e.getAnnotationMirrors()) {
if (!mirror.getAnnotationType().equals(annotationType)) {
1
0
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 July 31, 2008
by tchemit@users.labs.libre-entreprise.org July 31, 2008
July 31, 2008
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 July 28, 2008
by tchemit@users.labs.libre-entreprise.org July 28, 2008
July 28, 2008
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 July 28, 2008
by tchemit@users.labs.libre-entreprise.org July 28, 2008
July 28, 2008
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 July 28, 2008
by tchemit@users.labs.libre-entreprise.org July 28, 2008
July 28, 2008
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 July 28, 2008
by tchemit@users.labs.libre-entreprise.org July 28, 2008
July 28, 2008
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 July 28, 2008
by tchemit@users.labs.libre-entreprise.org July 28, 2008
July 28, 2008
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 July 28, 2008
by tchemit@users.labs.libre-entreprise.org July 28, 2008
July 28, 2008
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 July 25, 2008
by tchemit@users.labs.libre-entreprise.org July 25, 2008
July 25, 2008
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 July 25, 2008
by tchemit@users.labs.libre-entreprise.org July 25, 2008
July 25, 2008
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 July 25, 2008
by tchemit@users.labs.libre-entreprise.org July 25, 2008
July 25, 2008
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
r796 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider
by tchemit@users.labs.libre-entreprise.org July 25, 2008
by tchemit@users.labs.libre-entreprise.org July 25, 2008
July 25, 2008
Author: tchemit
Date: 2008-07-25 17:55:55 +0000 (Fri, 25 Jul 2008)
New Revision: 796
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java
Log:
ActionProviderjavadoc
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java 2008-07-25 17:55:34 UTC (rev 795)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/provider/ActionProvider.java 2008-07-25 17:55:55 UTC (rev 796)
@@ -17,7 +17,9 @@
import org.codelutin.jaxx.action.MyAbstractAction;
/**
- * Contract to be realized by a provider of Actions
+ * Contract to be realized by a provider of Actions.
+ * <p/>
+ * A provider of actions
*
* @author chemit
*/
1
0
r795 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org July 25, 2008
by tchemit@users.labs.libre-entreprise.org July 25, 2008
July 25, 2008
Author: tchemit
Date: 2008-07-25 17:55:34 +0000 (Fri, 25 Jul 2008)
New Revision: 795
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:
ActionFactory javadoc
add methode newAction(String) to ActionFactory
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 14:00:19 UTC (rev 794)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 17:55:34 UTC (rev 795)
@@ -219,6 +219,10 @@
return result;
}
+ public A newAction(String actionKey) {
+ return newAction(actionKey, null);
+ }
+
public String[] getActionNames() {
return impls.keySet().toArray(new String[impls.size()]);
}
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 14:00:19 UTC (rev 794)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 17:55:34 UTC (rev 795)
@@ -41,29 +41,92 @@
*/
Map<String, Class<? extends MyAbstractAction>> init();
+ /** @return the class of the base action of the factory. */
Class<A> getBaseImpl();
+ /** clear the cache of instanciated actions. */
void resetCache();
+ /**
+ * @param actionKey the key of an action
+ * @return the action with this key from cache, or <code>null</code> if this action is not in cache
+ */
A get(String actionKey);
+ /**
+ * For a given ui, load all actions registred in factory.
+ * <p/>
+ * The id of the widget in ui is directly mapped to a action key.
+ *
+ * @param ui the ui to treate
+ */
void loadActions(JAXXObject ui);
+ /**
+ * Obtain an action instance given his key and widget
+ *
+ * @param actionKey the key of action
+ * @param component the component using the action
+ * @return the instanciated action (could come from cache if already instanciated {@link #getActionFromCache(String)}
+ */
A newAction(String actionKey, JComponent component);
+ /**
+ * Obtain an action instance given his key (should call {@link #newAction(String, javax.swing.JComponent)}
+ * <p/>
+ * This is a convinient method when you want to obtain an action with no attached widget.
+ *
+ * @param actionKey the key of action
+ * @return the instanciated action (could come from cache if already instanciated {@link #getActionFromCache(String)}
+ */
+ A newAction(String actionKey);
+
+ /** @return the array of names of all actions known by the factory */
String[] getActionNames();
+ /** @return the set of all the action's classes known by the factory. */
Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
+ /** @return the set of all actions cached in factory indexed by their name */
Set<Entry<String, A>> cacheEntrySet();
+ /**
+ * Fire an action given his key, his source and tthe widget responsible of action
+ *
+ * @param actionKey the action's key
+ * @param source the object source of action
+ * @param component the component doing the action
+ */
void fireAction(String actionKey, Object source, JComponent component);
+ /**
+ * Fire an action given his key and his source, no widget are involved here
+ *
+ * @param actionKey the action's key
+ * @param source the object source of action
+ */
void fireAction(String actionKey, Object source);
+ /**
+ * Fire an action given his action's key, his source and the reaal action.
+ * <p/>
+ * This is a convinient method when you need to modified action before fire it.
+ *
+ * @param actionKey action's key
+ * @param source source of action
+ * @param action real action
+ */
void fireAction0(String actionKey, Object source, A action);
+ /**
+ * @param actionKey the action's key
+ * @return the action in cache or <code>null</code> if action is not in cache
+ */
MyAbstractAction getActionFromCache(String actionKey);
+ /**
+ * dispose all actions in cache using {@link org.codelutin.jaxx.action.MyAbstractAction#disposeUI()} on each
+ * action, then {@link #resetCache()}
+ */
void dispose();
}
1
0
r794 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . factory
by tchemit@users.labs.libre-entreprise.org July 25, 2008
by tchemit@users.labs.libre-entreprise.org July 25, 2008
July 25, 2008
Author: tchemit
Date: 2008-07-25 14:00:19 +0000 (Fri, 25 Jul 2008)
New Revision: 794
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/factory/AbstractActionFactory.java
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
Log:
add fireAction0 in ActionFactory contract
add setStatus method in 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-25 13:58:48 UTC (rev 793)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-07-25 14:00:19 UTC (rev 794)
@@ -16,6 +16,7 @@
import jaxx.runtime.JAXXObject;
import org.apache.commons.logging.LogFactory;
+import static org.codelutin.i18n.I18n._;
import javax.swing.AbstractAction;
import javax.swing.Action;
@@ -65,6 +66,7 @@
}
if (accepted) {
doAction(e);
+ setStatus(_("jaxx.action.done", getName()));
updateUI();
}
} catch (Exception e1) {
@@ -105,10 +107,21 @@
return delegate != null;
}
+ protected String getName() {
+ return (String) getValue(NAME);
+ }
+
protected String getActionName() {
return (String) getValue(ACTION_COMMAND_KEY);
}
+ protected void setStatus(String status) {
+ // do nothing from here
+ if (log.isDebugEnabled()) {
+ log.debug(status);
+ }
+ }
+
protected boolean beforeAction(ActionEvent evt) throws Exception {
boolean enabled = isEnabled();
if (enabled && hasDelegate()) {
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 13:58:48 UTC (rev 793)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-25 14:00:19 UTC (rev 794)
@@ -357,7 +357,7 @@
}
}
- protected void fireAction0(String actionKey, Object source, A action) {
+ public void fireAction0(String actionKey, Object source, A action) {
if (action == null) {
log.warn("could not find action " + actionKey);
return;
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 13:58:48 UTC (rev 793)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-25 14:00:19 UTC (rev 794)
@@ -61,6 +61,8 @@
void fireAction(String actionKey, Object source);
+ void fireAction0(String actionKey, Object source, A action);
+
MyAbstractAction getActionFromCache(String actionKey);
void dispose();
1
0
July 25, 2008
Author: tchemit
Date: 2008-07-25 13:58:48 +0000 (Fri, 25 Jul 2008)
New Revision: 793
Removed:
trunk/lutinjaxx/maven/src/main/java/jaxx/
Log:
no more use
1
0
r792 - trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n
by tchemit@users.labs.libre-entreprise.org July 25, 2008
by tchemit@users.labs.libre-entreprise.org July 25, 2008
July 25, 2008
Author: tchemit
Date: 2008-07-25 13:58:29 +0000 (Fri, 25 Jul 2008)
New Revision: 792
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties
trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties
Log:
i18n
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties 2008-07-24 20:59:46 UTC (rev 791)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties 2008-07-25 13:58:29 UTC (rev 792)
@@ -1,3 +1,4 @@
+jaxx.action.done=Action ''{0}'' done.
jaxx.error.close.actions.file=Error while closing file of actions
jaxx.error.load.actions.class=Error while loading actions
jaxx.error.load.actions.file=Error while loading file of actions
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties 2008-07-24 20:59:46 UTC (rev 791)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties 2008-07-25 13:58:29 UTC (rev 792)
@@ -1,3 +1,4 @@
+jaxx.action.done=Action ''{0}'' termin\u00E9e.
jaxx.error.close.actions.file=Erreur lors de la fermeture du fichier d'actions
jaxx.error.load.actions.class=Erreur lors du chargement des actions
jaxx.error.load.actions.file=Erreur lors du chargement du fchier d'actions
1
0
r791 - in trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action: . factory
by tchemit@users.labs.libre-entreprise.org July 24, 2008
by tchemit@users.labs.libre-entreprise.org July 24, 2008
July 24, 2008
Author: tchemit
Date: 2008-07-24 20:59:46 +0000 (Thu, 24 Jul 2008)
New Revision: 791
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/factory/AbstractActionFactory.java
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/ActionFactoryFromProvider.java
Log:
ActionFactory is typed with MyAbstractionAction
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-24 19:18:03 UTC (rev 790)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-07-24 20:59:46 UTC (rev 791)
@@ -18,8 +18,10 @@
import org.apache.commons.logging.LogFactory;
import javax.swing.AbstractAction;
+import javax.swing.Action;
import javax.swing.JComponent;
import java.awt.event.ActionEvent;
+import java.beans.PropertyChangeListener;
/** @author chemit */
public abstract class MyAbstractAction extends AbstractAction {
@@ -38,13 +40,13 @@
super(name);
}
- protected MyAbstractAction(String name, MyAbstractAction delegate) {
- super(name);
+ protected MyAbstractAction(MyAbstractAction delegate) {
+ super((String) delegate.getValue(Action.NAME));
this.delegate = delegate;
}
public void actionPerformed(java.awt.event.ActionEvent e) {
- if (delegate != null) {
+ if (hasDelegate()) {
// delegate to real action
delegate.actionPerformed(e);
return;
@@ -75,21 +77,21 @@
}
public String getI18nToolTipText() {
- if (delegate != null) {
+ if (hasDelegate()) {
return delegate.getI18nToolTipText();
}
return getPrefix() + ".action." + getActionName() + ".tooltip";
}
public void updateUI() {
- if (delegate != null) {
+ if (hasDelegate()) {
delegate.updateUI();
}
// nothing by default
}
public void disposeUI() {
- if (delegate != null) {
+ if (hasDelegate()) {
delegate.disposeUI();
}
// nothing by default
@@ -99,20 +101,24 @@
return delegate;
}
+ public boolean hasDelegate() {
+ return delegate != null;
+ }
+
protected String getActionName() {
return (String) getValue(ACTION_COMMAND_KEY);
}
protected boolean beforeAction(ActionEvent evt) throws Exception {
boolean enabled = isEnabled();
- if (enabled && delegate != null) {
+ if (enabled && hasDelegate()) {
return delegate.beforeAction(evt);
}
return enabled;
}
protected void doAction(ActionEvent evt) throws Exception {
- if (delegate != null) {
+ if (hasDelegate()) {
delegate.doAction(evt);
}
// nothing by default
@@ -126,7 +132,7 @@
}
protected void clear() {
- if (delegate != null) {
+ if (hasDelegate()) {
delegate.clear();
}
// nothing by default
@@ -136,4 +142,89 @@
log.error(e);
}
+ // -----------------------------------------------------------------------------
+ // --- super classe delegate methods -------------------------------------------
+ // -----------------------------------------------------------------------------
+
+ @Override
+ public Object getValue(String key) {
+ if (hasDelegate()) {
+ return delegate.getValue(key);
+ }
+ return super.getValue(key);
+ }
+
+ @Override
+ public void putValue(String key, Object newValue) {
+ if (hasDelegate()) {
+ delegate.putValue(key, newValue);
+ }
+ super.putValue(key, newValue);
+ }
+
+ @Override
+ public boolean isEnabled() {
+ if (hasDelegate()) {
+ return delegate.isEnabled();
+ }
+ return super.isEnabled();
+ }
+
+ @Override
+ public void setEnabled(boolean newValue) {
+ if (hasDelegate()) {
+ delegate.setEnabled(newValue);
+ }
+ super.setEnabled(newValue);
+ }
+
+ @Override
+ public Object[] getKeys() {
+ if (hasDelegate()) {
+ return getKeys();
+ }
+ return super.getKeys();
+ }
+
+ @Override
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ if (hasDelegate()) {
+ delegate.firePropertyChange(propertyName, oldValue, newValue);
+ }
+ super.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ @Override
+ public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
+ if (hasDelegate()) {
+ delegate.addPropertyChangeListener(listener);
+ }
+ super.addPropertyChangeListener(listener);
+ }
+
+ @Override
+ public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
+ if (hasDelegate()) {
+ delegate.removePropertyChangeListener(listener);
+ }
+ super.removePropertyChangeListener(listener);
+ }
+
+ @Override
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ if (hasDelegate()) {
+ return delegate.getPropertyChangeListeners();
+ }
+ return super.getPropertyChangeListeners();
+ }
+
+ @Override
+ protected Object clone() throws CloneNotSupportedException {
+ if (hasDelegate()) {
+ return clone();
+ }
+ return super.clone();
+ }
+
+
}
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-24 19:18:03 UTC (rev 790)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-24 20:59:46 UTC (rev 791)
@@ -37,9 +37,9 @@
import javax.swing.JComponent;
import java.awt.event.ActionEvent;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
@@ -67,7 +67,7 @@
private Map<String, Class<? extends MyAbstractAction>> impls;
/** dictionary of instanciated actions */
- private Map<String, MyAbstractAction> cache;
+ private Map<String, A> cache;
protected final ActionConfigInitializer actionConfigInitializer;
protected final ToggleActionConfigInitializer toggleActionConfigInitializer;
@@ -79,7 +79,7 @@
protected AbstractActionFactory(Class<A> baseImpl) {
this.baseImpl = baseImpl;
this.impls = init();
- this.cache = new TreeMap<String, MyAbstractAction>();
+ this.cache = new TreeMap<String, A>();
this.registredInitializers = new java.util.ArrayList<AbstractActionInitializer>();
this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigInitializer.class);
@@ -95,15 +95,15 @@
cache.clear();
}
- public MyAbstractAction get(String actionKey) {
+ public A get(String actionKey) {
return cache.get(actionKey);
}
- public MyAbstractAction[] loadActions(JAXXObject ui) {
+ public void loadActions(JAXXObject ui) {
if (log.isDebugEnabled()) {
log.debug("for ui " + ui.getClass());
}
- List<MyAbstractAction> result = new ArrayList<MyAbstractAction>();
+ //List<A> result = new ArrayList<A>();
for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
String actionKey = entry.getKey();
Object comp = ui.getObjectById(actionKey);
@@ -116,7 +116,7 @@
}
if (comp instanceof AbstractButton) {
AbstractButton component = (AbstractButton) comp;
- MyAbstractAction action = newAction(actionKey, component);
+ A action = newAction(actionKey, component);
component.setAction(action);
@@ -142,21 +142,21 @@
Boolean value = (Boolean) action.getValue("hideActionText");
component.setHideActionText(value != null && value);
action.setEnabled(true);
- result.add(action);
+ //result.add(action);
continue;
}
// is JComboBox
JComboBox component = (JComboBox) comp;
- MyAbstractAction action = newAction(actionKey, component);
+ A action = newAction(actionKey, component);
component.setAction(action);
Integer val = (Integer) action.getValue("selectedIndex");
if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
component.setSelectedIndex(val);
}
- result.add(action);
+ //result.add(action);
}
- return result.toArray(new MyAbstractAction[result.size()]);
+ //return (A[]) result.toArray(new MyAbstractAction[result.size()]);
}
/**
@@ -165,9 +165,9 @@
* @param component le button o� rattacher l'action
* @return une nouvelle instance de l'action associ�e � sa clef.
*/
- public MyAbstractAction newAction(String actionKey, JComponent component) {
+ public A newAction(String actionKey, JComponent component) {
// try first in cache
- MyAbstractAction result = getActionFromCache(actionKey);
+ A result = getActionFromCache(actionKey);
if (result != null) {
return result;
}
@@ -227,12 +227,12 @@
return impls.entrySet();
}
- public Set<Map.Entry<String, MyAbstractAction>> cacheEntrySet() {
+ public Set<Entry<String, A>> cacheEntrySet() {
return cache.entrySet();
}
public void fireAction(String actionKey, Object source, JComponent component) {
- AbstractAction action = newAction(actionKey, component);
+ A action = newAction(actionKey, component);
fireAction0(actionKey, source, action);
}
@@ -244,14 +244,14 @@
* @param actionKey la clef de l'action
* @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouv�e.
*/
- public MyAbstractAction getActionFromCache(String actionKey) {
+ public A getActionFromCache(String actionKey) {
// on v�rifie que l'action existe bien
checkRegistredAction(actionKey);
// try in cache
if (cache.containsKey(actionKey)) {
// use cached action
- MyAbstractAction action = cache.get(actionKey);
+ A action = cache.get(actionKey);
if (log.isDebugEnabled()) {
log.debug("use cache action " + action);
}
@@ -357,7 +357,7 @@
}
}
- protected void fireAction0(String actionKey, Object source, AbstractAction action) {
+ protected void fireAction0(String actionKey, Object source, A action) {
if (action == null) {
log.warn("could not find action " + actionKey);
return;
@@ -373,11 +373,16 @@
}
- protected MyAbstractAction newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+ @SuppressWarnings({"unchecked"})
+ protected A newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
Class<? extends MyAbstractAction> klazz = impls.get(actionKey);
MyAbstractAction result;
result = klazz.getConstructor(String.class).newInstance(actionKey);
result.putValue(Action.ACTION_COMMAND_KEY, actionKey);
- return result;
+ if (!getBaseImpl().isAssignableFrom(klazz)) {
+ // the instanciated action must be boxed in the base Action of the factory
+ result = getBaseImpl().getConstructor(MyAbstractAction.class).newInstance(result);
+ }
+ return (A) result;
}
}
\ No newline at end of file
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-24 19:18:03 UTC (rev 790)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-24 20:59:46 UTC (rev 791)
@@ -45,17 +45,17 @@
void resetCache();
- MyAbstractAction get(String actionKey);
+ A get(String actionKey);
- MyAbstractAction[] loadActions(JAXXObject ui);
+ void loadActions(JAXXObject ui);
- MyAbstractAction newAction(String actionKey, JComponent component);
+ A newAction(String actionKey, JComponent component);
String[] getActionNames();
Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
- Set<Entry<String, MyAbstractAction>> cacheEntrySet();
+ Set<Entry<String, A>> cacheEntrySet();
void fireAction(String actionKey, Object source, JComponent component);
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-07-24 19:18:03 UTC (rev 790)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-07-24 20:59:46 UTC (rev 791)
@@ -25,6 +25,7 @@
import java.util.TreeMap;
/**
+ * TODO Do javadoc which is not up to date...
* A simple implementation of {@link AbstractActionFactory} using a properties file to
* load action mapping.
* <p/>
1
0
r790 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org July 24, 2008
by tchemit@users.labs.libre-entreprise.org July 24, 2008
July 24, 2008
Author: tchemit
Date: 2008-07-24 19:18:03 +0000 (Thu, 24 Jul 2008)
New Revision: 790
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:
ActionFactory is typed with MyAbstractionAction
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-24 19:04:53 UTC (rev 789)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-24 19:18:03 UTC (rev 790)
@@ -56,7 +56,7 @@
*
* @author chemit
*/
-public abstract class AbstractActionFactory<A extends MyAbstractAction> implements ActionFactory {
+public abstract class AbstractActionFactory<A extends MyAbstractAction> implements ActionFactory<A> {
protected static Log log = LogFactory.getLog(AbstractActionFactory.class);
@@ -87,6 +87,10 @@
this.selectActionConfigInitializer = registerInitializer(SelectActionConfigInitializer.class);
}
+ public Class<A> getBaseImpl() {
+ return baseImpl;
+ }
+
public void resetCache() {
cache.clear();
}
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-24 19:04:53 UTC (rev 789)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-24 19:18:03 UTC (rev 790)
@@ -32,7 +32,7 @@
*
* @author chemit
*/
-public interface ActionFactory {
+public interface ActionFactory<A extends MyAbstractAction> {
/**
* Method to init the dictionary of knwon action implementations.
@@ -41,6 +41,8 @@
*/
Map<String, Class<? extends MyAbstractAction>> init();
+ Class<A> getBaseImpl();
+
void resetCache();
MyAbstractAction get(String actionKey);
1
0
r789 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by tchemit@users.labs.libre-entreprise.org July 24, 2008
by tchemit@users.labs.libre-entreprise.org July 24, 2008
July 24, 2008
Author: tchemit
Date: 2008-07-24 19:04:53 +0000 (Thu, 24 Jul 2008)
New Revision: 789
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java
Log:
introduce delegate mecanism in Action
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-24 18:52:48 UTC (rev 788)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/MyAbstractAction.java 2008-07-24 19:04:53 UTC (rev 789)
@@ -30,14 +30,25 @@
protected ActionEvent e;
+ protected MyAbstractAction delegate;
+
+ protected abstract String getPrefix();
+
protected MyAbstractAction(String name) {
super(name);
}
- protected abstract String getPrefix();
+ protected MyAbstractAction(String name, MyAbstractAction delegate) {
+ super(name);
+ this.delegate = delegate;
+ }
public void actionPerformed(java.awt.event.ActionEvent e) {
-
+ if (delegate != null) {
+ // delegate to real action
+ delegate.actionPerformed(e);
+ return;
+ }
log.debug("------------------------------------------------------------");
log.debug("event : " + e);
log.debug("source : " + e.getSource());
@@ -63,39 +74,61 @@
}
}
- protected String getActionName() {
- return (String) getValue(ACTION_COMMAND_KEY);
+ public String getI18nToolTipText() {
+ if (delegate != null) {
+ return delegate.getI18nToolTipText();
+ }
+ return getPrefix() + ".action." + getActionName() + ".tooltip";
}
- protected boolean beforeAction(ActionEvent e) throws Exception {
- return isEnabled();
+ public void updateUI() {
+ if (delegate != null) {
+ delegate.updateUI();
+ }
+ // nothing by default
}
- protected JComponent getUIObject(String name, JAXXObject container) {
- if (container == null) {
- return null;
+ public void disposeUI() {
+ if (delegate != null) {
+ delegate.disposeUI();
}
- return (JComponent) container.getObjectById(name);
+ // nothing by default
}
- public String getI18nToolTipText() {
- return getPrefix() + ".action." + getActionName() + ".tooltip";
+ public MyAbstractAction getDelegate() {
+ return delegate;
}
- protected void doAction(ActionEvent e) throws Exception {
- // nothing by default
+ protected String getActionName() {
+ return (String) getValue(ACTION_COMMAND_KEY);
}
- public void updateUI() {
- // nothing by default
+ protected boolean beforeAction(ActionEvent evt) throws Exception {
+ boolean enabled = isEnabled();
+ if (enabled && delegate != null) {
+ return delegate.beforeAction(evt);
+ }
+ return enabled;
}
- public void disposeUI() {
+ protected void doAction(ActionEvent evt) throws Exception {
+ if (delegate != null) {
+ delegate.doAction(evt);
+ }
// nothing by default
}
+ protected JComponent getUIObject(String name, JAXXObject container) {
+ if (container == null) {
+ return null;
+ }
+ return (JComponent) container.getObjectById(name);
+ }
protected void clear() {
+ if (delegate != null) {
+ delegate.clear();
+ }
// nothing by default
}
1
0
r788 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org July 24, 2008
by tchemit@users.labs.libre-entreprise.org July 24, 2008
July 24, 2008
Author: tchemit
Date: 2008-07-24 18:52:48 +0000 (Thu, 24 Jul 2008)
New Revision: 788
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
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
Log:
introduction ActionFactory interface
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-24 18:50:12 UTC (rev 787)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-24 18:52:48 UTC (rev 788)
@@ -73,13 +73,6 @@
protected final ToggleActionConfigInitializer toggleActionConfigInitializer;
protected final SelectActionConfigInitializer selectActionConfigInitializer;
- /**
- * Method to init the dictionary of knwon action implementations.
- *
- * @return the dictionary of known action implementations
- */
- protected abstract Map<String, Class<? extends MyAbstractAction>> init();
-
protected List<AbstractActionInitializer> registredInitializers;
@@ -98,13 +91,6 @@
cache.clear();
}
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- resetCache();
- impls.clear();
- }
-
public MyAbstractAction get(String actionKey) {
return cache.get(actionKey);
}
@@ -283,6 +269,13 @@
resetCache();
}
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ resetCache();
+ impls.clear();
+ }
+
/**
* @param component le button o� rattacher l'action
* @param action action
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-24 18:50:12 UTC (rev 787)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-24 18:52:48 UTC (rev 788)
@@ -18,11 +18,29 @@
import org.codelutin.jaxx.action.MyAbstractAction;
import javax.swing.JComponent;
+import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-/** @author chemit */
+/**
+ * Action factory using the ActionConfig annotations to configure the action.
+ * <p/>
+ * Use after the {@link #loadActions(jaxx.runtime.JAXXObject)} to instanciate
+ * actions in ui with id equals a known action...
+ * <p/>
+ * TODO Finish doc
+ *
+ * @author chemit
+ */
public interface ActionFactory {
+
+ /**
+ * Method to init the dictionary of knwon action implementations.
+ *
+ * @return the dictionary of known action implementations
+ */
+ Map<String, Class<? extends MyAbstractAction>> init();
+
void resetCache();
MyAbstractAction get(String actionKey);
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-07-24 18:50:12 UTC (rev 787)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-07-24 18:52:48 UTC (rev 788)
@@ -45,7 +45,7 @@
super(baseClass);
}
- protected Map<String, Class<? extends MyAbstractAction>> init() {
+ public Map<String, Class<? extends MyAbstractAction>> init() {
if (log.isDebugEnabled()) {
log.debug("start loading " + this);
}
1
0
r787 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org July 24, 2008
by tchemit@users.labs.libre-entreprise.org July 24, 2008
July 24, 2008
Author: tchemit
Date: 2008-07-24 18:50:12 +0000 (Thu, 24 Jul 2008)
New Revision: 787
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
Log:
introduction ActionFactory interface
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-24 18:50:03 UTC (rev 786)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-24 18:50:12 UTC (rev 787)
@@ -56,7 +56,7 @@
*
* @author chemit
*/
-public abstract class AbstractActionFactory<A extends MyAbstractAction> implements IActionFactory {
+public abstract class AbstractActionFactory<A extends MyAbstractAction> implements ActionFactory {
protected static Log log = LogFactory.getLog(AbstractActionFactory.class);
1
0
r786 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org July 24, 2008
by tchemit@users.labs.libre-entreprise.org July 24, 2008
July 24, 2008
Author: tchemit
Date: 2008-07-24 18:50:03 +0000 (Thu, 24 Jul 2008)
New Revision: 786
Added:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
Removed:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/IActionFactory.java
Log:
introduction ActionFactory interface
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java (from rev 783, trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/IActionFactory.java)
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-24 18:50:03 UTC (rev 786)
@@ -0,0 +1,47 @@
+/**
+ * # #% 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.factory;
+
+import jaxx.runtime.JAXXObject;
+import org.codelutin.jaxx.action.MyAbstractAction;
+
+import javax.swing.JComponent;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/** @author chemit */
+public interface ActionFactory {
+ void resetCache();
+
+ MyAbstractAction get(String actionKey);
+
+ MyAbstractAction[] loadActions(JAXXObject ui);
+
+ MyAbstractAction newAction(String actionKey, JComponent component);
+
+ String[] getActionNames();
+
+ Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
+
+ Set<Entry<String, MyAbstractAction>> cacheEntrySet();
+
+ void fireAction(String actionKey, Object source, JComponent component);
+
+ void fireAction(String actionKey, Object source);
+
+ MyAbstractAction getActionFromCache(String actionKey);
+
+ void dispose();
+}
Deleted: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/IActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/IActionFactory.java 2008-07-24 18:49:32 UTC (rev 785)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/IActionFactory.java 2008-07-24 18:50:03 UTC (rev 786)
@@ -1,47 +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.factory;
-
-import jaxx.runtime.JAXXObject;
-import org.codelutin.jaxx.action.MyAbstractAction;
-
-import javax.swing.JComponent;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/** @author chemit */
-public interface IActionFactory {
- void resetCache();
-
- MyAbstractAction get(String actionKey);
-
- MyAbstractAction[] loadActions(JAXXObject ui);
-
- MyAbstractAction newAction(String actionKey, JComponent component);
-
- String[] getActionNames();
-
- Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
-
- Set<Entry<String, MyAbstractAction>> cacheEntrySet();
-
- void fireAction(String actionKey, Object source, JComponent component);
-
- void fireAction(String actionKey, Object source);
-
- MyAbstractAction getActionFromCache(String actionKey);
-
- void dispose();
-}
1
0
r785 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org July 24, 2008
by tchemit@users.labs.libre-entreprise.org July 24, 2008
July 24, 2008
Author: tchemit
Date: 2008-07-24 18:49:32 +0000 (Thu, 24 Jul 2008)
New Revision: 785
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
Log:
introduction ActionFactory interface
Modified: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-07-24 18:49:25 UTC (rev 784)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactoryFromProvider.java 2008-07-24 18:49:32 UTC (rev 785)
@@ -25,7 +25,7 @@
import java.util.TreeMap;
/**
- * A simple implementation of {@link ActionFactory} using a properties file to
+ * A simple implementation of {@link AbstractActionFactory} using a properties file to
* load action mapping.
* <p/>
* An entry is in that form : <code>action.actionName=fqn</code> where
@@ -35,7 +35,7 @@
*
* @author chemit
*/
-public class ActionFactoryFromProvider<A extends MyAbstractAction> extends ActionFactory<A> {
+public class ActionFactoryFromProvider<A extends MyAbstractAction> extends AbstractActionFactory<A> {
public static <A extends MyAbstractAction> ActionFactoryFromProvider<A> newInstance(Class<A> klazz) {
return new ActionFactoryFromProvider<A>(klazz);
1
0
r784 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org July 24, 2008
by tchemit@users.labs.libre-entreprise.org July 24, 2008
July 24, 2008
Author: tchemit
Date: 2008-07-24 18:49:25 +0000 (Thu, 24 Jul 2008)
New Revision: 784
Added:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java
Removed:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
Log:
introduction ActionFactory interface
Copied: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java (from rev 783, 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/AbstractActionFactory.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/AbstractActionFactory.java 2008-07-24 18:49:25 UTC (rev 784)
@@ -0,0 +1,386 @@
+/*
+* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 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.factory;
+
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.JAXXToggleButton;
+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 javax.swing.AbstractAction;
+import javax.swing.AbstractButton;
+import javax.swing.Action;
+import javax.swing.Icon;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import java.awt.event.ActionEvent;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * Action factory using the ActionConfig annotations to configure the action.
+ * <p/>
+ * The factory is abstract, implements method {@link #init()} to fill the
+ * dictonary of known action implementations.
+ * <p/>
+ * Use after the {@link #loadActions(jaxx.runtime.JAXXObject)} to instanciate
+ * actions in ui with id equals a known action...
+ * <p/>
+ * TODO Finish doc
+ *
+ * @author chemit
+ */
+public abstract class AbstractActionFactory<A extends MyAbstractAction> implements IActionFactory {
+
+ protected static Log log = LogFactory.getLog(AbstractActionFactory.class);
+
+ /** class of encapsuling action */
+ protected Class<A> baseImpl;
+
+ /** dictionary of known actions implementations */
+ private Map<String, Class<? extends MyAbstractAction>> impls;
+
+ /** dictionary of instanciated actions */
+ private Map<String, MyAbstractAction> cache;
+
+ protected final ActionConfigInitializer actionConfigInitializer;
+ protected final ToggleActionConfigInitializer toggleActionConfigInitializer;
+ protected final SelectActionConfigInitializer selectActionConfigInitializer;
+
+ /**
+ * Method to init the dictionary of knwon action implementations.
+ *
+ * @return the dictionary of known action implementations
+ */
+ protected abstract Map<String, Class<? extends MyAbstractAction>> init();
+
+ protected List<AbstractActionInitializer> registredInitializers;
+
+
+ protected AbstractActionFactory(Class<A> baseImpl) {
+ this.baseImpl = baseImpl;
+ this.impls = init();
+ this.cache = new TreeMap<String, MyAbstractAction>();
+ this.registredInitializers = new java.util.ArrayList<AbstractActionInitializer>();
+
+ this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigInitializer.class);
+ this.actionConfigInitializer = registerInitializer(ActionConfigInitializer.class);
+ this.selectActionConfigInitializer = registerInitializer(SelectActionConfigInitializer.class);
+ }
+
+ public void resetCache() {
+ cache.clear();
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ resetCache();
+ impls.clear();
+ }
+
+ public MyAbstractAction get(String actionKey) {
+ return cache.get(actionKey);
+ }
+
+ public MyAbstractAction[] loadActions(JAXXObject ui) {
+ if (log.isDebugEnabled()) {
+ log.debug("for ui " + ui.getClass());
+ }
+ List<MyAbstractAction> result = new ArrayList<MyAbstractAction>();
+ for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
+ String actionKey = entry.getKey();
+ Object comp = ui.getObjectById(actionKey);
+ if (comp == null || !(comp instanceof AbstractButton || comp instanceof JComboBox)) {
+ // nothing to do
+ continue;
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("detect action " + actionKey);
+ }
+ if (comp instanceof AbstractButton) {
+ AbstractButton component = (AbstractButton) comp;
+ MyAbstractAction action = newAction(actionKey, component);
+
+ component.setAction(action);
+
+ if (component instanceof JAXXToggleButton) {
+ JAXXToggleButton glueComponent = (JAXXToggleButton) component;
+ glueComponent.setIcon((Icon) action.getValue(Action.SMALL_ICON));
+ Integer integer = (Integer) action.getValue(Action.MNEMONIC_KEY);
+ if (integer != null) {
+ glueComponent.setNormalMnemonic(integer);
+ }
+ glueComponent.setSelectedIcon((Icon) action.getValue(Action.SMALL_ICON + 2));
+ integer = (Integer) action.getValue(Action.MNEMONIC_KEY + 2);
+ if (integer != null) {
+ glueComponent.setGlueMnemonic(integer);
+ }
+ glueComponent.setGlueText((String) action.getValue(Action.NAME + 2));
+ glueComponent.setGlueTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION + 2));
+
+ glueComponent.setNormalText((String) action.getValue(Action.NAME));
+ glueComponent.setNormalTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION));
+ }
+
+ Boolean value = (Boolean) action.getValue("hideActionText");
+ component.setHideActionText(value != null && value);
+ action.setEnabled(true);
+ result.add(action);
+ continue;
+ }
+ // is JComboBox
+ JComboBox component = (JComboBox) comp;
+ MyAbstractAction action = newAction(actionKey, component);
+
+ component.setAction(action);
+ Integer val = (Integer) action.getValue("selectedIndex");
+ if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
+ component.setSelectedIndex(val);
+ }
+ result.add(action);
+ }
+ return result.toArray(new MyAbstractAction[result.size()]);
+ }
+
+ /**
+ * @param actionKey le nom de l'action tel que d�finie dans le fichier
+ * de mapping (sans le prefix action.)
+ * @param component le button o� rattacher l'action
+ * @return une nouvelle instance de l'action associ�e � sa clef.
+ */
+ public MyAbstractAction newAction(String actionKey, JComponent component) {
+ // try first in cache
+ MyAbstractAction result = getActionFromCache(actionKey);
+ if (result != null) {
+ return result;
+ }
+
+ try {
+ result = newActionInstance(actionKey);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("create <" + actionKey + " : " + result + ">");
+ }
+
+ // recherche de l'annotation de configuration
+ ActionInitializer<?, ?> initializer = findInitializer(result.getClass());
+
+ if (initializer != null) {
+ initializer.initAction(component, result);
+ }
+
+ try {
+
+ if (initializer != null) {
+ if (AbstractButton.class.isAssignableFrom(initializer.getComponentImpl())) {
+ finalizeNewAction((AbstractButton) component, result, initializer);
+ }
+
+ if (JComboBox.class.isAssignableFrom(initializer.getComponentImpl())) {
+ finalizeNewAction((JComboBox) component, result, initializer);
+ }
+
+ return result;
+ }
+
+ if (component == null || component instanceof AbstractButton) {
+ finalizeNewAction((AbstractButton) component, result, initializer);
+ return result;
+ }
+
+ if (component instanceof JComboBox) {
+ finalizeNewAction((JComboBox) component, result, initializer);
+ }
+ } finally {
+ // save result in cache
+ cache.put(actionKey, result);
+ }
+
+ return result;
+ }
+
+ public String[] getActionNames() {
+ return impls.keySet().toArray(new String[impls.size()]);
+ }
+
+ public Set<Map.Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet() {
+ return impls.entrySet();
+ }
+
+ public Set<Map.Entry<String, MyAbstractAction>> cacheEntrySet() {
+ return cache.entrySet();
+ }
+
+ public void fireAction(String actionKey, Object source, JComponent component) {
+ AbstractAction action = newAction(actionKey, component);
+ fireAction0(actionKey, source, action);
+ }
+
+ public void fireAction(String actionKey, Object source) {
+ fireAction(actionKey, source, null);
+ }
+
+ /**
+ * @param actionKey la clef de l'action
+ * @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouv�e.
+ */
+ public MyAbstractAction getActionFromCache(String actionKey) {
+ // on v�rifie que l'action existe bien
+ checkRegistredAction(actionKey);
+
+ // try in cache
+ if (cache.containsKey(actionKey)) {
+ // use cached action
+ MyAbstractAction action = cache.get(actionKey);
+ if (log.isDebugEnabled()) {
+ log.debug("use cache action " + action);
+ }
+ return action;
+ }
+ return null;
+ }
+
+ public void dispose() {
+ if (log.isInfoEnabled()) {
+ log.info(this);
+ }
+ for (String actionKey : getActionNames()) {
+ MyAbstractAction action = getActionFromCache(actionKey);
+ if (action != null) {
+ action.disposeUI();
+ }
+ }
+ resetCache();
+ }
+
+ /**
+ * @param component le button o� rattacher l'action
+ * @param action action
+ * @param initializer initializer
+ */
+ protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionInitializer<?, ?> initializer) {
+
+ if (initializer == null) {
+ // no initializer matching,
+ if (component != null) {
+ action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
+ action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
+ action.putValue(Action.SMALL_ICON, component.getIcon());
+ action.putValue(Action.NAME, component.getText());
+ action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
+ action.putValue("hideActionText", component.getHideActionText());
+ if (component instanceof JAXXToggleButton) {
+ JAXXToggleButton glueComponent = (JAXXToggleButton) component;
+ action.putValue(Action.SHORT_DESCRIPTION, glueComponent.getNormalTooltipText());
+ action.putValue(Action.NAME, glueComponent.getNormalText());
+ action.putValue(Action.SMALL_ICON, glueComponent.getIcon());
+ action.putValue(Action.MNEMONIC_KEY, glueComponent.getNormalMnemonic());
+ action.putValue(Action.SHORT_DESCRIPTION + 2, glueComponent.getGlueTooltipText());
+ action.putValue(Action.NAME + 2, glueComponent.getGlueText());
+ action.putValue(Action.SMALL_ICON + 2, glueComponent.getSelectedIcon());
+ action.putValue(Action.MNEMONIC_KEY + 2, glueComponent.getGlueMnemonic());
+ }
+ }
+
+ }
+
+ String text = (String) action.getValue(Action.NAME);
+ Integer mnemo = (Integer) action.getValue(Action.MNEMONIC_KEY);
+ if (mnemo != null && mnemo != '\0') {
+ int pos = text.indexOf((char) mnemo.intValue());
+ if (pos == -1) {
+ pos = text.indexOf(Character.toLowerCase((char) mnemo.intValue()));
+ }
+ action.putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, pos);
+ }
+
+ }
+
+ /**
+ * @param component le select box o� rattacher l'action
+ * @param action action
+ * @param initializer initializer
+ */
+ protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionInitializer<?, ?> initializer) {
+
+ if (initializer == null) {
+ action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
+ action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
+ //result.putValue("selectedIndex", component.getSelectedIndex());
+ }
+
+ }
+
+ protected ActionInitializer findInitializer(Class<? extends AbstractAction> action) {
+ for (ActionInitializer registredInitializer : registredInitializers) {
+ if (registredInitializer.getAnnotation(action) != null) {
+ return registredInitializer;
+ }
+ }
+ return null;
+ }
+
+ protected <I extends AbstractActionInitializer> I registerInitializer(Class<I> initizalizer) {
+ try {
+ I instance = initizalizer.newInstance();
+ registredInitializers.add(instance);
+ return instance;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected void fireAction0(String actionKey, Object source, AbstractAction action) {
+ if (action == null) {
+ log.warn("could not find action " + actionKey);
+ return;
+ }
+ ActionEvent event = new ActionEvent(source, ActionEvent.ACTION_FIRST, actionKey);
+ action.actionPerformed(event);
+ }
+
+ protected void checkRegistredAction(String actionKey) {
+ if (!impls.containsKey(actionKey)) {
+ throw new IllegalStateException("can not find a registered action for key " + actionKey);
+ }
+ }
+
+
+ protected MyAbstractAction newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
+ Class<? extends MyAbstractAction> klazz = impls.get(actionKey);
+ MyAbstractAction result;
+ result = klazz.getConstructor(String.class).newInstance(actionKey);
+ result.putValue(Action.ACTION_COMMAND_KEY, actionKey);
+ return result;
+ }
+}
\ No newline at end of file
Deleted: 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-24 18:48:55 UTC (rev 783)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-24 18:49:25 UTC (rev 784)
@@ -1,386 +0,0 @@
-/*
-* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 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.factory;
-
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.swing.JAXXToggleButton;
-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 javax.swing.AbstractAction;
-import javax.swing.AbstractButton;
-import javax.swing.Action;
-import javax.swing.Icon;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import java.awt.event.ActionEvent;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-/**
- * Action factory using the ActionConfig annotations to configure the action.
- * <p/>
- * The factory is abstract, implements method {@link #init()} to fill the
- * dictonary of known action implementations.
- * <p/>
- * Use after the {@link #loadActions(jaxx.runtime.JAXXObject)} to instanciate
- * actions in ui with id equals a known action...
- * <p/>
- * TODO Finish doc
- *
- * @author chemit
- */
-public abstract class ActionFactory<A extends MyAbstractAction> implements IActionFactory {
-
- protected static Log log = LogFactory.getLog(ActionFactory.class);
-
- /** class of encapsuling action */
- protected Class<A> baseImpl;
-
- /** dictionary of known actions implementations */
- private Map<String, Class<? extends MyAbstractAction>> impls;
-
- /** dictionary of instanciated actions */
- private Map<String, MyAbstractAction> cache;
-
- protected final ActionConfigInitializer actionConfigInitializer;
- protected final ToggleActionConfigInitializer toggleActionConfigInitializer;
- protected final SelectActionConfigInitializer selectActionConfigInitializer;
-
- /**
- * Method to init the dictionary of knwon action implementations.
- *
- * @return the dictionary of known action implementations
- */
- protected abstract Map<String, Class<? extends MyAbstractAction>> init();
-
- protected List<AbstractActionInitializer> registredInitializers;
-
-
- protected ActionFactory(Class<A> baseImpl) {
- this.baseImpl = baseImpl;
- this.impls = init();
- this.cache = new TreeMap<String, MyAbstractAction>();
- this.registredInitializers = new java.util.ArrayList<AbstractActionInitializer>();
-
- this.toggleActionConfigInitializer = registerInitializer(ToggleActionConfigInitializer.class);
- this.actionConfigInitializer = registerInitializer(ActionConfigInitializer.class);
- this.selectActionConfigInitializer = registerInitializer(SelectActionConfigInitializer.class);
- }
-
- public void resetCache() {
- cache.clear();
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- resetCache();
- impls.clear();
- }
-
- public MyAbstractAction get(String actionKey) {
- return cache.get(actionKey);
- }
-
- public MyAbstractAction[] loadActions(JAXXObject ui) {
- if (log.isDebugEnabled()) {
- log.debug("for ui " + ui.getClass());
- }
- List<MyAbstractAction> result = new ArrayList<MyAbstractAction>();
- for (Map.Entry<String, Class<? extends MyAbstractAction>> entry : implsEntrySet()) {
- String actionKey = entry.getKey();
- Object comp = ui.getObjectById(actionKey);
- if (comp == null || !(comp instanceof AbstractButton || comp instanceof JComboBox)) {
- // nothing to do
- continue;
- }
- if (log.isTraceEnabled()) {
- log.trace("detect action " + actionKey);
- }
- if (comp instanceof AbstractButton) {
- AbstractButton component = (AbstractButton) comp;
- MyAbstractAction action = newAction(actionKey, component);
-
- component.setAction(action);
-
- if (component instanceof JAXXToggleButton) {
- JAXXToggleButton glueComponent = (JAXXToggleButton) component;
- glueComponent.setIcon((Icon) action.getValue(Action.SMALL_ICON));
- Integer integer = (Integer) action.getValue(Action.MNEMONIC_KEY);
- if (integer != null) {
- glueComponent.setNormalMnemonic(integer);
- }
- glueComponent.setSelectedIcon((Icon) action.getValue(Action.SMALL_ICON + 2));
- integer = (Integer) action.getValue(Action.MNEMONIC_KEY + 2);
- if (integer != null) {
- glueComponent.setGlueMnemonic(integer);
- }
- glueComponent.setGlueText((String) action.getValue(Action.NAME + 2));
- glueComponent.setGlueTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION + 2));
-
- glueComponent.setNormalText((String) action.getValue(Action.NAME));
- glueComponent.setNormalTooltipText((String) action.getValue(Action.SHORT_DESCRIPTION));
- }
-
- Boolean value = (Boolean) action.getValue("hideActionText");
- component.setHideActionText(value != null && value);
- action.setEnabled(true);
- result.add(action);
- continue;
- }
- // is JComboBox
- JComboBox component = (JComboBox) comp;
- MyAbstractAction action = newAction(actionKey, component);
-
- component.setAction(action);
- Integer val = (Integer) action.getValue("selectedIndex");
- if (val != null && val != -1 && val < component.getItemCount() && val != component.getSelectedIndex()) {
- component.setSelectedIndex(val);
- }
- result.add(action);
- }
- return result.toArray(new MyAbstractAction[result.size()]);
- }
-
- /**
- * @param actionKey le nom de l'action tel que d�finie dans le fichier
- * de mapping (sans le prefix action.)
- * @param component le button o� rattacher l'action
- * @return une nouvelle instance de l'action associ�e � sa clef.
- */
- public MyAbstractAction newAction(String actionKey, JComponent component) {
- // try first in cache
- MyAbstractAction result = getActionFromCache(actionKey);
- if (result != null) {
- return result;
- }
-
- try {
- result = newActionInstance(actionKey);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("create <" + actionKey + " : " + result + ">");
- }
-
- // recherche de l'annotation de configuration
- ActionInitializer<?, ?> initializer = findInitializer(result.getClass());
-
- if (initializer != null) {
- initializer.initAction(component, result);
- }
-
- try {
-
- if (initializer != null) {
- if (AbstractButton.class.isAssignableFrom(initializer.getComponentImpl())) {
- finalizeNewAction((AbstractButton) component, result, initializer);
- }
-
- if (JComboBox.class.isAssignableFrom(initializer.getComponentImpl())) {
- finalizeNewAction((JComboBox) component, result, initializer);
- }
-
- return result;
- }
-
- if (component == null || component instanceof AbstractButton) {
- finalizeNewAction((AbstractButton) component, result, initializer);
- return result;
- }
-
- if (component instanceof JComboBox) {
- finalizeNewAction((JComboBox) component, result, initializer);
- }
- } finally {
- // save result in cache
- cache.put(actionKey, result);
- }
-
- return result;
- }
-
- public String[] getActionNames() {
- return impls.keySet().toArray(new String[impls.size()]);
- }
-
- public Set<Map.Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet() {
- return impls.entrySet();
- }
-
- public Set<Map.Entry<String, MyAbstractAction>> cacheEntrySet() {
- return cache.entrySet();
- }
-
- public void fireAction(String actionKey, Object source, JComponent component) {
- AbstractAction action = newAction(actionKey, component);
- fireAction0(actionKey, source, action);
- }
-
- public void fireAction(String actionKey, Object source) {
- fireAction(actionKey, source, null);
- }
-
- /**
- * @param actionKey la clef de l'action
- * @return l'action deja stockee dans le cache d'action, ou <code>null</code> si non trouv�e.
- */
- public MyAbstractAction getActionFromCache(String actionKey) {
- // on v�rifie que l'action existe bien
- checkRegistredAction(actionKey);
-
- // try in cache
- if (cache.containsKey(actionKey)) {
- // use cached action
- MyAbstractAction action = cache.get(actionKey);
- if (log.isDebugEnabled()) {
- log.debug("use cache action " + action);
- }
- return action;
- }
- return null;
- }
-
- public void dispose() {
- if (log.isInfoEnabled()) {
- log.info(this);
- }
- for (String actionKey : getActionNames()) {
- MyAbstractAction action = getActionFromCache(actionKey);
- if (action != null) {
- action.disposeUI();
- }
- }
- resetCache();
- }
-
- /**
- * @param component le button o� rattacher l'action
- * @param action action
- * @param initializer initializer
- */
- protected void finalizeNewAction(AbstractButton component, MyAbstractAction action, ActionInitializer<?, ?> initializer) {
-
- if (initializer == null) {
- // no initializer matching,
- if (component != null) {
- action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
- action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
- action.putValue(Action.SMALL_ICON, component.getIcon());
- action.putValue(Action.NAME, component.getText());
- action.putValue(Action.MNEMONIC_KEY, component.getMnemonic());
- action.putValue("hideActionText", component.getHideActionText());
- if (component instanceof JAXXToggleButton) {
- JAXXToggleButton glueComponent = (JAXXToggleButton) component;
- action.putValue(Action.SHORT_DESCRIPTION, glueComponent.getNormalTooltipText());
- action.putValue(Action.NAME, glueComponent.getNormalText());
- action.putValue(Action.SMALL_ICON, glueComponent.getIcon());
- action.putValue(Action.MNEMONIC_KEY, glueComponent.getNormalMnemonic());
- action.putValue(Action.SHORT_DESCRIPTION + 2, glueComponent.getGlueTooltipText());
- action.putValue(Action.NAME + 2, glueComponent.getGlueText());
- action.putValue(Action.SMALL_ICON + 2, glueComponent.getSelectedIcon());
- action.putValue(Action.MNEMONIC_KEY + 2, glueComponent.getGlueMnemonic());
- }
- }
-
- }
-
- String text = (String) action.getValue(Action.NAME);
- Integer mnemo = (Integer) action.getValue(Action.MNEMONIC_KEY);
- if (mnemo != null && mnemo != '\0') {
- int pos = text.indexOf((char) mnemo.intValue());
- if (pos == -1) {
- pos = text.indexOf(Character.toLowerCase((char) mnemo.intValue()));
- }
- action.putValue(Action.DISPLAYED_MNEMONIC_INDEX_KEY, pos);
- }
-
- }
-
- /**
- * @param component le select box o� rattacher l'action
- * @param action action
- * @param initializer initializer
- */
- protected void finalizeNewAction(JComboBox component, MyAbstractAction action, ActionInitializer<?, ?> initializer) {
-
- if (initializer == null) {
- action.putValue(Action.ACTION_COMMAND_KEY, component.getName());
- action.putValue(Action.SHORT_DESCRIPTION, component.getToolTipText());
- //result.putValue("selectedIndex", component.getSelectedIndex());
- }
-
- }
-
- protected ActionInitializer findInitializer(Class<? extends AbstractAction> action) {
- for (ActionInitializer registredInitializer : registredInitializers) {
- if (registredInitializer.getAnnotation(action) != null) {
- return registredInitializer;
- }
- }
- return null;
- }
-
- protected <I extends AbstractActionInitializer> I registerInitializer(Class<I> initizalizer) {
- try {
- I instance = initizalizer.newInstance();
- registredInitializers.add(instance);
- return instance;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- protected void fireAction0(String actionKey, Object source, AbstractAction action) {
- if (action == null) {
- log.warn("could not find action " + actionKey);
- return;
- }
- ActionEvent event = new ActionEvent(source, ActionEvent.ACTION_FIRST, actionKey);
- action.actionPerformed(event);
- }
-
- protected void checkRegistredAction(String actionKey) {
- if (!impls.containsKey(actionKey)) {
- throw new IllegalStateException("can not find a registered action for key " + actionKey);
- }
- }
-
-
- protected MyAbstractAction newActionInstance(String actionKey) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
- Class<? extends MyAbstractAction> klazz = impls.get(actionKey);
- MyAbstractAction result;
- result = klazz.getConstructor(String.class).newInstance(actionKey);
- result.putValue(Action.ACTION_COMMAND_KEY, actionKey);
- return result;
- }
-}
\ No newline at end of file
1
0
r783 - trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory
by tchemit@users.labs.libre-entreprise.org July 24, 2008
by tchemit@users.labs.libre-entreprise.org July 24, 2008
July 24, 2008
Author: tchemit
Date: 2008-07-24 18:48:55 +0000 (Thu, 24 Jul 2008)
New Revision: 783
Added:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/IActionFactory.java
Modified:
trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java
Log:
introduction ActionFactory interface
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-24 18:47:27 UTC (rev 782)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/ActionFactory.java 2008-07-24 18:48:55 UTC (rev 783)
@@ -56,7 +56,7 @@
*
* @author chemit
*/
-public abstract class ActionFactory<A extends MyAbstractAction> {
+public abstract class ActionFactory<A extends MyAbstractAction> implements IActionFactory {
protected static Log log = LogFactory.getLog(ActionFactory.class);
Added: trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/IActionFactory.java
===================================================================
--- trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/IActionFactory.java (rev 0)
+++ trunk/lutinjaxx/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/factory/IActionFactory.java 2008-07-24 18:48:55 UTC (rev 783)
@@ -0,0 +1,47 @@
+/**
+ * # #% 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.factory;
+
+import jaxx.runtime.JAXXObject;
+import org.codelutin.jaxx.action.MyAbstractAction;
+
+import javax.swing.JComponent;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/** @author chemit */
+public interface IActionFactory {
+ void resetCache();
+
+ MyAbstractAction get(String actionKey);
+
+ MyAbstractAction[] loadActions(JAXXObject ui);
+
+ MyAbstractAction newAction(String actionKey, JComponent component);
+
+ String[] getActionNames();
+
+ Set<Entry<String, Class<? extends MyAbstractAction>>> implsEntrySet();
+
+ Set<Entry<String, MyAbstractAction>> cacheEntrySet();
+
+ void fireAction(String actionKey, Object source, JComponent component);
+
+ void fireAction(String actionKey, Object source);
+
+ MyAbstractAction getActionFromCache(String actionKey);
+
+ void dispose();
+}
1
0