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
r1285 - in jaxx/trunk: . jaxx-compiler-validator jaxx-my-example maven-jaxx-plugin maven-jaxx-plugin/src/main/java/org/codelutin/jaxx
by kmorin@users.labs.libre-entreprise.org April 2, 2009
by kmorin@users.labs.libre-entreprise.org April 2, 2009
April 2, 2009
Author: kmorin
Date: 2009-04-02 12:27:34 +0000 (Thu, 02 Apr 2009)
New Revision: 1285
Added:
jaxx/trunk/jaxx-my-example/
jaxx/trunk/jaxx-my-example/pom.xml
Modified:
jaxx/trunk/jaxx-compiler-validator/pom.xml
jaxx/trunk/maven-jaxx-plugin/pom.xml
jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
jaxx/trunk/pom.xml
Log:
Modified: jaxx/trunk/jaxx-compiler-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-04-02 12:21:55 UTC (rev 1284)
+++ jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-04-02 12:27:34 UTC (rev 1285)
@@ -32,12 +32,24 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-gwt</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jaxx-runtime-validator-swing</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-validator-gwt</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jaxx-compiler-api</artifactId>
Added: jaxx/trunk/jaxx-my-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-my-example/pom.xml (rev 0)
+++ jaxx/trunk/jaxx-my-example/pom.xml 2009-04-02 12:27:34 UTC (rev 1285)
@@ -0,0 +1,324 @@
+<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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.3-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-my-example</artifactId>
+
+<repositories>
+ <repository>
+ <id>gwt-maven</id>
+ <url>http://gwt-maven.googlecode.com/svn/trunk/mavenrepo/</url>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-servlet</artifactId>
+ <version>${gwtVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-user</artifactId>
+ <version>${gwtVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-dev</artifactId>
+ <version>${gwtVersion}</version>
+ <classifier>${platform}-libs</classifier>
+ <type>zip</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.gwt</groupId>
+ <artifactId>gwt-dev</artifactId>
+ <version>${gwtVersion}</version>
+ <classifier>${platform}</classifier>
+ <scope>provided</scope>
+ </dependency>
+ <!-- sibiling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-gwt</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-validator-gwt</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx My Examples</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+<gwtVersion>1.5.3</gwtVersion>
+ <maven.jar.main.class>jaxx.demo.JAXXMyDemo</maven.jar.main.class>
+
+ <!-- jnlp -->
+ <keystorepath>${codelutin.keystorepath}</keystorepath>
+ <keystorealias>CodeLutin</keystorealias>
+ <keystorepass>codelutin</keystorepass>
+
+ <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory>
+
+ </properties>
+
+ <build>
+
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.jaxx</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <pluginManagement>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>./lib/</classpathPrefix>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </pluginManagement>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <configuration>
+ <entries>
+ <entry>
+ <basedir>${maven.gen.dir}/java/</basedir>
+ <includes>
+ <param>**\/**.java</param>
+ </includes>
+ </entry>
+ </entries>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-example</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-example</developerConnection>
+ </scm>
+
+ <profiles>
+ <profile>
+ <id>gwt-dev-linux</id>
+ <properties>
+ <platform>linux</platform>
+ </properties>
+ <activation>
+ <os>
+ <name>Linux</name>
+ </os>
+ </activation>
+ </profile>
+ <!-- by default jnlp is only perform on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
+ <execution>
+ <id>JnlpSun</id>
+ <phase>verify</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${jnlp.build.directory}" />
+ <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <filterset>
+ <filter token="lib" value="javahelp-2.0.02.jar" />
+ <filter token="url" value="${project.url}" />
+ </filterset>
+ </copy>
+ <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <filterset>
+ <filter token="lib" value="jxlayer-3.0.1.jar" />
+ <filter token="url" value="${project.url}" />
+ </filterset>
+ </copy>
+ <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
+ <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>JnlpToSite</id>
+ <phase>pre-site</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${maven.site.gen.dir}/resources" />
+ <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}" failonerror="false" overwrite="false">
+ <fileset dir="${jnlp.build.directory}">
+ <include name="**" />
+ </fileset>
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo.webstart</groupId>
+ <artifactId>webstart-maven-plugin</artifactId>
+ <version>1.0-alpha-2-cl_20081018</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>jnlp-inline</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <force>false</force>
+ <dependencies>
+ <excludes>
+ <exclude>javax.help:javahelp</exclude>
+ <exclude>org.swinglabs:jxlayer</exclude>
+ </excludes>
+ </dependencies>
+ <libPath>lib</libPath>
+ <extensions>
+ <sun>sun.jnlp</sun>
+ <jxlayer>jxlayer.jnlp</jxlayer>
+ </extensions>
+ <jnlp>
+ <outputFile>launch-demo.jnlp</outputFile>
+ <mainClass>${maven.jar.main.class}</mainClass>
+ <allPermissions>true</allPermissions>
+ <offlineAllowed>true</offlineAllowed>
+ </jnlp>
+
+ <sign>
+ <keystore>${keystorepath}</keystore>
+ <keypass />
+ <storepass>${keystorepass}</storepass>
+ <storetype />
+ <alias>${keystorealias}</alias>
+ <validity />
+ <dnameCn />
+ <dnameOu />
+ <dnameO />
+ <dnameL />
+ <dnameSt />
+ <dnameC />
+ <verify>true</verify>
+ <keystoreConfig>
+ <delete>false</delete>
+ <gen>false</gen>
+ </keystoreConfig>
+ </sign>
+
+ <pack200>false</pack200>
+ <gzip>true</gzip>
+ <verbose>false</verbose>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
Modified: jaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-04-02 12:21:55 UTC (rev 1284)
+++ jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-04-02 12:27:34 UTC (rev 1285)
@@ -44,6 +44,18 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-compiler-gwt</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-gwt-action</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- maven plugin project dependencies -->
<dependency>
@@ -150,4 +162,4 @@
<developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/maven-jaxx-plugin</developerConnection>
</scm>
-</project>
\ No newline at end of file
+</project>
Modified: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-04-02 12:21:55 UTC (rev 1284)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-04-02 12:27:34 UTC (rev 1285)
@@ -61,13 +61,13 @@
/**
* Le compilateur à utiliser (par défaut celui de Swing)
*
- * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.SwingCompiler"
+ * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.GWTCompiler"
*/
protected String compilerFQN;
/**
* Le compilateur à utiliser (par défaut celui de Swing)
*
- * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
+ * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.gwt.GWTValidator"
*/
protected String validatorFQN;
/**
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-04-02 12:21:55 UTC (rev 1284)
+++ jaxx/trunk/pom.xml 2009-04-02 12:27:34 UTC (rev 1285)
@@ -14,22 +14,26 @@
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.3-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<modules>
<module>jaxx-runtime-api</module>
<module>jaxx-runtime-swing</module>
+ <module>jaxx-runtime-gwt</module>
<module>jaxx-runtime-validator</module>
<module>jaxx-runtime-validator-swing</module>
+ <module>jaxx-runtime-validator-gwt</module>
<module>jaxx-compiler-api</module>
<module>jaxx-compiler-swing</module>
+ <module>jaxx-compiler-gwt</module>
<module>jaxx-compiler-validator</module>
<module>jaxx-swing-action</module>
+ <module>jaxx-gwt-action</module>
<module>maven-jaxx-plugin</module>
- <module>jaxx-example</module>
+ <module>jaxx-my-example</module>
</modules>
<dependencies>
@@ -262,4 +266,4 @@
</profile>
</profiles>
-</project>
\ No newline at end of file
+</project>
1
0
Author: kmorin
Date: 2009-04-02 12:21:55 +0000 (Thu, 02 Apr 2009)
New Revision: 1284
Added:
jaxx/tags/1.3/
Removed:
jaxx/tags/trunk/
Log:
Copied: jaxx/tags/1.3 (from rev 1283, jaxx/tags/trunk)
1
0
Author: kmorin
Date: 2009-04-02 12:20:32 +0000 (Thu, 02 Apr 2009)
New Revision: 1283
Added:
jaxx/tags/trunk/
Log:
Copied: jaxx/tags/trunk (from rev 1282, jaxx/trunk)
1
0
r1282 - jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing
by sletellier@users.labs.libre-entreprise.org March 30, 2009
by sletellier@users.labs.libre-entreprise.org March 30, 2009
March 30, 2009
Author: sletellier
Date: 2009-03-30 13:42:57 +0000 (Mon, 30 Mar 2009)
New Revision: 1282
Modified:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
Log:
Adding blocking color
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2009-03-29 13:36:44 UTC (rev 1281)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2009-03-30 13:42:57 UTC (rev 1282)
@@ -1,5 +1,7 @@
package jaxx.runtime.swing;
+import java.awt.AlphaComposite;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.Point;
@@ -51,6 +53,10 @@
*/
protected BufferedImage acceptIcon;
/**
+ * Optinal color to put fill background when blocking
+ */
+ protected Color blockingColor;
+ /**
* Internal state to known when we can accept click
*/
protected boolean canClick;
@@ -85,6 +91,10 @@
super.setDirty(isDirty);
}
+ public void setBlockingColor(Color blockingColor) {
+ this.blockingColor = blockingColor;
+ }
+
public void setBlockIcon(BufferedImage blockIcon) {
this.blockIcon = blockIcon;
}
@@ -107,22 +117,19 @@
clone.acceptAction = acceptAction;
clone.acceptIcon = acceptIcon;
clone.blockIcon = blockIcon;
+ clone.blockingColor = blockingColor;
clone.setCanClick(false);
return clone;
}
@Override
protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) {
-
e.consume();
-
}
@Override
protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) {
-
e.consume();
-
}
@Override
@@ -140,25 +147,29 @@
}
break;
}
- e.consume();
+ e.consume();
}
@Override
protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
super.paintLayer(g2, l);
-
- // to be in sync with the view if the layer has a border
+ if (blockingColor != null) {
+ // to be in sync with the view if the layer has a border
/*Insets layerInsets = l.getInsets();
- g2.translate(layerInsets.left, layerInsets.top);
+ g2.translate(layerInsets.left, layerInsets.top);
- JComponent view = l.getView();
- // To prevent painting on view's border
- Insets insets = view.getInsets();
- g2.clip(new Rectangle(insets.left, insets.top,
- view.getWidth() - insets.left - insets.right,
- view.getHeight() - insets.top - insets.bottom));
- */
+ JComponent view = l.getView();
+ // To prevent painting on view's border
+ Insets insets = view.getInsets();
+ g2.clip(new Rectangle(insets.left, insets.top,
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
+ */
+ g2.setColor(blockingColor);
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .1f));
+ g2.fillRect(0, 0, l.getWidth(), l.getHeight());
+ }
if (getCurrentIcon() != null) {
g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null);
}
1
0
r1281 - in jaxx/trunk/maven-jaxx-plugin: . src/main/java/org/codelutin/jaxx src/main/resources src/test/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org March 29, 2009
by tchemit@users.labs.libre-entreprise.org March 29, 2009
March 29, 2009
Author: tchemit
Date: 2009-03-29 13:36:44 +0000 (Sun, 29 Mar 2009)
New Revision: 1281
Added:
jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java
jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxHelpGeneratorMojo.java
jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/NodeItem.java
jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/TemplateGenerator.java
jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm
jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultI18n.java.vm
jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultIndex.xml.vm
jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultMap.jhm.vm
jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultToc.xml.vm
jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/NodeItemTest.java
Modified:
jaxx/trunk/maven-jaxx-plugin/changelog.txt
jaxx/trunk/maven-jaxx-plugin/pom.xml
jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
jaxx/trunk/maven-jaxx-plugin/src/main/resources/log4j.properties
Log:
add generate-help goal
Modified: jaxx/trunk/maven-jaxx-plugin/changelog.txt
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-03-29 13:36:21 UTC (rev 1280)
+++ jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-03-29 13:36:44 UTC (rev 1281)
@@ -1,4 +1,5 @@
1.3 chemit 20090321
+ * 20090327 [chemit] - add javax help mecanism
* 20090301 [chemit] - add a profile mode (-Djaxx.profile)
1.2 letelier 2009022?
Modified: jaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-03-29 13:36:21 UTC (rev 1280)
+++ jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-03-29 13:36:44 UTC (rev 1281)
@@ -1,3 +1,4 @@
+
<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">
<modelVersion>4.0.0</modelVersion>
@@ -87,6 +88,16 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity</artifactId>
+ <version>1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.1</version>
+ </dependency>
</dependencies>
Added: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,170 @@
+/* *##%
+ * 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.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+import java.io.File;
+
+/**
+ * Abract Jaxx Mojo.
+ *
+ * @author chemit
+ *
+ * @since 1.3
+ */
+public abstract class AbstractJaxxMojo extends AbstractMojo {
+
+ /**
+ * Dépendance du projet.
+ *
+ * @parameter default-value="${project}"
+ * @required
+ * @readonly
+ */
+ protected MavenProject project;
+ /**
+ * Repertoire de destination des fichiers java a generer.
+ *
+ * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
+ */
+ protected File outJava;
+ /**
+ * verbose flag
+ *
+ * @parameter expression="${jaxx.verbose}" default-value="false"
+ *
+ * @since 1.3
+ */
+ protected boolean verbose;
+ /**
+ * to make compiler i18nable, says add the {@link org.codelutin.i18n.I18n#_(String, Object[])} method
+ * invocation on {@link jaxx.compiler.I18nHelper#I18N_ATTRIBUTES} attributes.
+ *
+ * @parameter expression="${jaxx.i18nable}" default-value="true"
+ * @see jaxx.compiler.I18nHelper
+ */
+ protected boolean i18nable;
+ /**
+ * The store of helpIds generated by {@link JaxxGeneratorMojo}.
+ * <p/>
+ *
+ * @parameter expression="${jaxx.helpIdStore}" default-value="target/helpIds.properties"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File helpIdStore;
+ /**
+ * The name of the helpset to generate.
+ *
+ * @parameter expression="${jaxx.helpSetName}" default-value="${project.artifactId}"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String helpSetName;
+ /**
+ * The prefix to add to i18n key for any help i18n key.
+ *
+ * @parameter expression="${jaxx.helpsetI18nPrefix}" default-value="${jaxx.helpSetName}.help."
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String helpsetI18nPrefix;
+ /**
+ * The suffix to add to i18n key for an help Id.
+ *
+ * @parameter expression="${jaxx.helpsetTitleI18nSuffix}" default-value=".title"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String helpsetTitleI18nSuffix;
+ /**
+ * The suffix to add to i18n key for an toc Id.
+ *
+ * @parameter expression="${jaxx.helpsetTocI18nSuffix}" default-value=".toc"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String helpsetTocI18nSuffix;
+ /**
+ * The suffix to add to i18n key for an toc Id.
+ *
+ * @parameter expression="${jaxx.helpsetIndexI18nSuffix}" default-value=".index"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String helpsetIndexI18nSuffix;
+ protected boolean skip = true;
+ protected ClassLoader cl;
+
+ public abstract void init() throws Exception;
+
+ public abstract void doAction() throws Exception;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ try {
+ init();
+ } catch (Exception e) {
+ if (e instanceof MojoFailureException) {
+ throw (MojoFailureException) e;
+ }
+ if (e instanceof MojoExecutionException) {
+ throw (MojoExecutionException) e;
+ }
+ throw new MojoExecutionException("error in init : " + e.getMessage(), e);
+ }
+
+ if (skip) {
+ if (verbose) {
+ getLog().info("jaxx - skip!");
+ }
+ return;
+ }
+
+ try {
+
+ doAction();
+
+ } catch (Exception e) {
+ //getLog().error(e);
+ Throwable e2 = e;
+ while (e2.getCause() != null) {
+ e2 = e.getCause();
+ }
+ getLog().error(e2);
+
+ throw new MojoExecutionException(e2.getMessage(), e2);
+ } finally {
+ System.gc();
+ }
+
+ }
+
+}
\ No newline at end of file
Modified: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-03-29 13:36:21 UTC (rev 1280)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-03-29 13:36:44 UTC (rev 1281)
@@ -16,7 +16,6 @@
* 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 jaxx.beaninfos.BeanInfoUtil;
@@ -25,17 +24,14 @@
import jaxx.compiler.JAXXCompilerLaunchor;
import jaxx.runtime.JAXXContext;
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 org.codelutin.util.FileUpdaterHelper;
import org.codelutin.util.MirroredFileUpdater;
import java.io.File;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.net.MalformedURLException;
@@ -44,8 +40,12 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Properties;
import java.util.Set;
import jaxx.compiler.CompiledObjectDecorator;
+import jaxx.compiler.HelpRootCompiledObjectDecorator;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.project.MavenProject;
/**
* Classe permettant de transformer des sources jaxx vers du source java.
@@ -56,112 +56,79 @@
* @requiresDependencyResolution compile
* @requiresProject
*/
-public class JaxxGeneratorMojo extends AbstractMojo {
+public class JaxxGeneratorMojo extends AbstractJaxxMojo {
/**
- * Dépendance du projet.
- *
- * @parameter default-value="${project}"
- * @required
- * @readonly
- */
- protected MavenProject project;
-
- /**
* Le compilateur à utiliser (par défaut celui de Swing)
*
* @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.SwingCompiler"
*/
protected String compilerFQN;
-
/**
* Le compilateur à utiliser (par défaut celui de Swing)
*
* @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
*/
protected String validatorFQN;
-
/**
- * Repertoire de destination des fichiers java a generer.
- *
- * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
- */
- protected File outJava;
- /**
- * flag to include in compiler classpath the java sources directories (src and outJava).
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addSourcesToClassPath}" default-value="false"
- */
- protected boolean addSourcesToClassPath;
-
- /**
- * flag to include in compiler classpath the project compile classpath.
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addProjectClassPath}" default-value="false"
- */
- protected boolean addProjectClassPath;
-
- /**
* chemin du repertoire de generation des resources.
*
* @parameter expression="${jaxx.outResource}" default-value="${basedir}/target/generated-sources/resources"
*/
protected File outResource;
-
/**
* chemin du repertoire de compilation des resources.
*
* @parameter expression="${jaxx.outClass}" default-value="${basedir}/target/classes"
*/
protected File outClass;
-
/**
- * verbose flag
- *
- * @parameter expression="${jaxx.verbose}" default-value="false"
- */
- protected boolean verbose;
-
- /**
* Repertoire sources des fichiers jaxx a generer.
*
* @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java"
*/
protected File src;
-
/**
* pour optimizer le code compile ou genere ?
*
* @parameter expression="${jaxx.optimize}" default-value="false"
*/
protected boolean optimize;
-
/**
* les options de la compilation
*
* @parameter expression="${jaxx.javaOpts}"
*/
protected String javaOpts = null;
-
/**
* pour filter les fichiers a traiter
*
* @parameter expression="${jaxx.includes}"
*/
protected String[] includes;
-
/**
* pour filter les fichiers a ne pas traiter
*
* @parameter expression="${jaxx.excludes}"
*/
protected String[] excludes;
-
/**
+ * flag to include in compiler classpath the java sources directories (src and outJava).
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addSourcesToClassPath}" default-value="false"
+ */
+ protected boolean addSourcesToClassPath;
+ /**
+ * flag to include in compiler classpath the project compile classpath.
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addProjectClassPath}" default-value="false"
+ */
+ protected boolean addProjectClassPath;
+ /**
* to force generation of java source for any jaxx files with no timestamp checking.
* <p/>
* By default, never force generation.
@@ -169,18 +136,7 @@
* @parameter expression="${jaxx.force}" default-value="false"
*/
protected boolean force;
-
/**
- * to make compiler i18nable, says add the {@link org.codelutin.i18n.I18n#_(String, Object[])} method
- * invocation on {@link jaxx.compiler.I18nHelper#I18N_ATTRIBUTES} attributes.
- *
- * @parameter expression="${jaxx.i18nable}" default-value="true"
- * @see jaxx.compiler.I18nHelper
- */
- protected boolean i18nable;
-
-
- /**
* flag to add logger to each generated jaxx file.
* <p/>
* By default, always add it.
@@ -196,7 +152,6 @@
* @parameter expression="${jaxx.resetAfterCompile}" default-value="true"
*/
protected boolean resetAfterCompile;
-
/**
* the name of implementation of {@link jaxx.runtime.JAXXContext}
* to be used on {@link jaxx.runtime.JAXXObject}.
@@ -207,7 +162,6 @@
* @required
*/
protected String jaxxContextImplementorClass;
-
/**
* extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(String[])}.
* <p/>
@@ -221,15 +175,22 @@
* @parameter expression="${jaxx.beanInfoSearchPath}"
*/
protected String[] beanInfoSearchPath;
-
/**
* list of fqn of class toimport for all generated jaxx files
*
* @parameter expression="${jaxx.extraImports}"
+ *
+ * @deprecated Prefer use of extraImportList as a string, so
+ * could be use in properties section.
*/
protected String[] extraImports;
-
/**
+ * list of fqn of class toimport for all generated jaxx files
+ *
+ * @parameter expression="${jaxx.extraImportList}"
+ */
+ protected String extraImportList;
+ /**
* the FQN of the ui to use for error notification.
* <p/>
* If not given, will use the one defined in validator
@@ -238,8 +199,7 @@
* @see jaxx.runtime.validator.swing.SwingValidator#DEFAULT_UI_CLASS
*/
protected String defaultErrorUIFQN;
-
- /**
+ /**
* the FQN of the ui to use for error notification.
* <p/>
* If not given, will use the one defined in validator
@@ -249,7 +209,6 @@
* @see jaxx.compiler.CompiledObjectDecorator
*/
protected String defaultDecoratorFQN;
-
/**
* a flag to use UIManager to retreave icons.
*
@@ -264,25 +223,37 @@
* @parameter expression="${jaxx.profile}" default-value="false"
*/
protected boolean profile;
-
+ /**
+ * flag to activate help generation process.
+ * <p/>
+ * By default, not active.
+ *
+ * @parameter expression="${jaxx.generateHelp}" default-value="false"
+ *
+ * @since 1.3
+ */
+ private boolean generateHelp;
+ /**
+ * the FQN of help broker
+ * <p/>
+ * By default, none.
+ *
+ * @parameter expression="${jaxx.helpBrokerFQN}"
+ *
+ * @since 1.3
+ */
+ private String helpBrokerFQN;
protected String[] files;
-
private static final String[] INCLUDES = {"**\\/*.jaxx"};
-
protected CompilerOptions options;
-
protected MirroredFileUpdater updater;
-
- protected boolean skip = true;
-
private Class<?> defaultErrorUIClass;
private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
-
- protected ClassLoader cl;
private Class<? extends JAXXCompiler> compilerClass;
@SuppressWarnings("unchecked")
- protected void init() throws ClassNotFoundException, MalformedURLException {
+ @Override
+ public void init() throws Exception {
if (project != null && ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging()))) {
// nothing to be done for this type of packaging
@@ -291,12 +262,19 @@
return;
}
+ if (generateHelp) {
+ // check there is some bundle
+ if (helpIdStore == null) {
+ throw new MojoFailureException("you must set the helpIdStore property.");
+ }
+ }
+
compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN);
- defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN);
-
+ defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN);
+
// check the validator class is correct
Class.forName(validatorFQN);
-
+
if (defaultErrorUIFQN != null && !defaultErrorUIFQN.trim().isEmpty()) {
defaultErrorUIClass = Class.forName(defaultErrorUIFQN);
}
@@ -362,7 +340,18 @@
this.files = listFiles.toArray(new String[listFiles.size()]);
}
+ if (extraImportList != null && !extraImportList.isEmpty()) {
+ String[] imports = extraImportList.split(",");
+ int i = 0;
+ for (String importS : imports) {
+ imports[i++] = importS.trim();
+ }
+ if (verbose) {
+ getLog().info("extra imports " + java.util.Arrays.toString(imports));
+ }
+ extraImports = imports;
+ }
options = toCompilerOptions();
if (verbose) {
@@ -371,6 +360,43 @@
}
+ @Override
+ public void doAction() throws MojoExecutionException {
+ getLog().info("jaxx - detects " + this.files.length + " modify jaxx file(s). ");
+
+ try {
+
+ // force compiler init from here, not in a static block
+ TagManager.reset(verbose);
+
+ JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, options);
+ boolean success = launchor.compile();
+ getLog().info("jaxx - generate " + launchor.getCompilerCount() + " file(s). ");
+
+ if (!success) {
+ throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
+ }
+
+ if (generateHelp) {
+ // generate help
+ generateHelp();
+ }
+
+ } catch (MojoExecutionException e) {
+ getLog().error(e);
+ throw e;
+ } catch (Exception e) {
+ //getLog().error(e);
+ Throwable e2 = e;
+ while (e2.getCause() != null) {
+ e2 = e.getCause();
+ }
+ getLog().error(e2);
+
+ throw new MojoExecutionException(e2.getMessage(), e2);
+ }
+ }
+
public CompilerOptions toCompilerOptions() {
CompilerOptions result = new CompilerOptions();
result.setClassPath(src.getPath());
@@ -393,86 +419,116 @@
result.setDefaultErrorUI(defaultErrorUIClass);
result.setUseUIManagerForIcon(useUIManagerForIcon);
result.setDefaultDecoratorClass(defaultDecoratorClass);
+ result.setGenerateHelp(generateHelp);
+ result.setHelpBrokerFQN(helpBrokerFQN);
+ result.setHelpsetTitleI18nSuffix(helpsetTitleI18nSuffix);
+ result.setHelpsetIndexI18nSuffix(helpsetIndexI18nSuffix);
+ result.setHelpsetTocI18nSuffix(helpsetTocI18nSuffix);
+ result.setHelpSetName(helpSetName);
+ result.setHelpsetI18nPrefix(helpsetI18nPrefix);
+
if (cl != null) {
result.setClassLoader(cl);
}
return result;
}
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
+ protected void fixCompileSourceRoots() {
+ //fixme should remove this silly test when we will make real maven plugin tests :)
+ if (project != null) {
+ if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
+ project.addCompileSourceRoot(outJava.getPath());
+ }
+ }
+ }
- try {
- init();
- } catch (ClassNotFoundException e) {
- throw new MojoExecutionException("error in init : " + e.getMessage(), e);
- } catch (MalformedURLException e) {
- throw new MojoExecutionException("error in init : " + e.getMessage(), e);
+ protected void printInit() {
+ getLog().info(options.toString());
+ getLog().info("includes : " + Arrays.toString(includes));
+ for (String file : files) {
+ getLog().info("will generate " + file);
}
- if (skip) {
- if (verbose) {
- getLog().info("jaxx - skip!");
+ ClassLoader threadLoader = Thread.currentThread().getContextClassLoader();
+ getLog().info(threadLoader.toString());
+ if (threadLoader.getClass().getSimpleName().equals("RealmClassLoader")) {
+ try {
+ java.lang.reflect.Method m = threadLoader.getClass().getDeclaredMethod("getURLs");
+ m.setAccessible(true);
+ URL[] urls = (URL[]) m.invoke(threadLoader);
+
+ for (URL url : urls) {
+ getLog().info("url in class loader " + url);
+ }
+ } catch (Exception e) {
+ getLog().warn("??? : " + e.getMessage(), e);
}
- return;
}
- if (files.length == 0) {
- getLog().info("jaxx - no jaxx file to treate. ");
- return;
+ //fixme should remove this silly test when we will make real maven plugin tests :)
+ if (getPluginContext() != null) {
+ for (Object e : getPluginContext().keySet()) {
+ getLog().info("pluginContext " + e + " : " + getPluginContext().get(e));
+ }
}
+ }
+ protected void checkJaxxContextImplementorClass() {
+ if (jaxxContextImplementorClass == null) {
+ throw new IllegalArgumentException("jaxxContextImplementor can not be null");
+ }
try {
- doAction();
- } finally {
- System.gc();
+ Class jaxxContextImplementor = Class.forName(jaxxContextImplementorClass);
+ if (!JAXXContext.class.isAssignableFrom(jaxxContextImplementor)) {
+ throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' does not implements " + JAXXContext.class);
+ }
+ if (Modifier.isAbstract(jaxxContextImplementor.getModifiers())) {
+ throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' can not be abstract.");
+
+ }
+ } catch (ClassNotFoundException e) {
+ throw new IllegalArgumentException("could not find jaxxContextImplementor class : " + jaxxContextImplementorClass);
}
-
}
- public void doAction() throws MojoExecutionException {
- getLog().info("jaxx - detects " + this.files.length + " modify jaxx file(s). ");
+ protected void generateHelp() throws IOException {
+ Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
+ if (helpIds.isEmpty()) {
+ if (verbose) {
+ // no ids detected in this compilation round
+ getLog().info("no helpIds detected.");
+ }
+ return;
+ }
- try {
+ if (!helpIdStore.getParentFile().exists()) {
+ helpIdStore.getParentFile().mkdirs();
+ }
- // force compiler init from here, not in a static block
- TagManager.reset(verbose);
+ Properties p = new Properties();
- JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, options);
- boolean success = launchor.compile();
- getLog().info("jaxx - generate " + launchor.getCompilerCount() + " file(s). ");
+ for (String helpId : helpIds) {
+ String path = helpId.replaceAll("\\.", File.separator);
+ path = removeQuote(path) + ".html";
+ p.put(removeQuote(helpId), path);
+ }
- if (!success) {
- throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
- }
+ FileOutputStream w = new FileOutputStream(helpIdStore);
- } catch (MojoExecutionException e) {
- getLog().error(e);
- throw e;
- } catch (Exception e) {
- //getLog().error(e);
- Throwable e2 = e;
- while (e2.getCause() != null) {
- e2 = e.getCause();
- }
- getLog().error(e2);
-
- throw new MojoExecutionException(e2.getMessage(), e2);
+ try {
+ p.store(w, null);
+ } finally {
+ w.close();
}
- }
- protected void fixCompileSourceRoots() {
- //fixme should remove this silly test when we will make real maven plugin tests :)
- if (project != null) {
- if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
- project.addCompileSourceRoot(outJava.getPath());
- }
- }
+ getLog().info("helpIdStore generated in " + helpIdStore);
+
+ helpIds.clear();
}
@SuppressWarnings({"unchecked"})
- protected URLClassLoader initClassLoader(MavenProject project, Log log) throws MalformedURLException {
- URLClassLoader loader;
+ protected URLClassLoader initClassLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
+ URLClassLoader loader = null;
if (project != null) {
URLClassLoader result;
@@ -499,7 +555,7 @@
result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
} catch (IOException e) {
- throw new RuntimeException("Can't create ClassLoader for script, bad directory: " + outClass + " for reason " + e.getMessage(), e);
+ throw new RuntimeException("Can't create ClassLoader for reason " + e.getMessage(), e);
}
loader = result;
} else {
@@ -517,53 +573,13 @@
return loader;
}
- protected void printInit() {
- getLog().info(options.toString());
- getLog().info("includes : " + Arrays.toString(includes));
- for (String file : files) {
- getLog().info("will generate " + file);
+ protected String removeQuote(String txt) {
+ if (txt.startsWith("\"")) {
+ txt = txt.substring(1);
}
-
- ClassLoader threadLoader = Thread.currentThread().getContextClassLoader();
- getLog().info(threadLoader.toString());
- if (threadLoader.getClass().getSimpleName().equals("RealmClassLoader")) {
- try {
- java.lang.reflect.Method m = threadLoader.getClass().getDeclaredMethod("getURLs");
- m.setAccessible(true);
- URL[] urls = (URL[]) m.invoke(threadLoader);
-
- for (URL url : urls) {
- getLog().info("url in class loader " + url);
- }
- } catch (Exception e) {
- getLog().warn("??? : " + e.getMessage(), e);
- }
+ if (txt.endsWith("\"")) {
+ txt = txt.substring(0, txt.length() - 1);
}
-
- //fixme should remove this silly test when we will make real maven plugin tests :)
- if (getPluginContext() != null) {
- for (Object e : getPluginContext().keySet()) {
- getLog().info("pluginContext " + e + " : " + getPluginContext().get(e));
- }
- }
+ return txt;
}
-
- protected void checkJaxxContextImplementorClass() {
- if (jaxxContextImplementorClass == null) {
- throw new IllegalArgumentException("jaxxContextImplementor can not be null");
- }
- try {
- Class jaxxContextImplementor = Class.forName(jaxxContextImplementorClass);
- if (!JAXXContext.class.isAssignableFrom(jaxxContextImplementor)) {
- throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' does not implements " + JAXXContext.class);
- }
- if (Modifier.isAbstract(jaxxContextImplementor.getModifiers())) {
- throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' can not be abstract.");
-
- }
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("could not find jaxxContextImplementor class : " + jaxxContextImplementorClass);
- }
- }
-
}
\ No newline at end of file
Added: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxHelpGeneratorMojo.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxHelpGeneratorMojo.java (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxHelpGeneratorMojo.java 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,792 @@
+/* *##%
+ * 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.apache.maven.plugin.MojoFailureException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import java.util.Stack;
+import org.apache.maven.model.Resource;
+import org.codelutin.i18n.I18n;
+import org.codelutin.util.FileUtil;
+import org.codelutin.util.SortedProperties;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+import static org.codelutin.i18n.I18n._;
+
+/**
+ * Mojo to generate javax help stuff for your project.
+ *
+ * HelpIds should have been discovered by the JaxxMojo.
+ *
+ * @author chemit
+ * @goal generate-help
+ * @phase process-sources
+ *
+ * @requiresProject
+ * @requiresDependencyResolution compile
+ * @since 1.3
+ */
+public class JaxxHelpGeneratorMojo extends AbstractJaxxMojo {
+
+ /**
+ * The directory where to generate javaHelp skeleton files.
+ * <p/>
+ * Is required if generateHelp is on.
+ *
+ * @parameter expression="${jaxx.helpTarget}" alias="target" default-value="${maven.src.dir}/main/help"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File target;
+ /**
+ * The locale to generate for help.
+ *
+ * By default, stay in France.
+ *
+ * @parameter expression="${jaxx.locale}" default-value="fr"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String locale;
+ /**
+ * The package where to generate i18n java file.
+ *
+ * @parameter expression="${jaxx.packageName}" default-value="${project.groupId}"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String packageName;
+ /**
+ * The file name of the helpset to generate.
+ *
+ * @parameter expression="${jaxx.helpSetFileName}" default-value="${jaxx.helpSetName}.hs"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String helpsetFileName;
+ /**
+ * The file name of the helpset map to generate.
+ *
+ * @parameter expression="${jaxx.mapFileName}" default-value="${jaxx.helpSetName}Map.jhm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String mapFileName;
+ /**
+ * The file name of the helpset index to generate.
+ *
+ * @parameter expression="${jaxx.indexFileName}" default-value="${jaxx.helpSetName}Index.xml"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String indexFileName;
+ /**
+ * The file name of the helpset toc to generate.
+ *
+ * @parameter expression="${jaxx.tocFileName}" default-value="${jaxx.helpSetName}TOC.xml"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String tocFileName;
+ /**
+ * The file name of the i18n java file to generate.
+ *
+ * @parameter expression="${jaxx.i8nFileName}" default-value="${jaxx.helpSetName}I18n.java"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String i8nFileName;
+ /**
+ * The template used to generate helpset file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.helpSetTemplate}" default-value="/defaultHelpSet.hs.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File helpSetTemplate;
+ /**
+ * The template used to generate helpset map file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File mapTemplate;
+ /**
+ * The template used to generate helpset index file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File indexTemplate;
+ /**
+ * The template used to generate helpset toc file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File tocTemplate;
+ /**
+ * The template used to generate helpset content file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File contentTemplate;
+ /**
+ * The template used to generate helpset content file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.i18nTemplate}" default-value="/defaultI18n.java.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File i18nTemplate;
+ /**
+ * The help ids discovered by Jaxx compilation
+ */
+ protected Properties helpIds;
+ private static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
+
+ @Override
+ public void init() throws Exception {
+
+ if (project != null && ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging()))) {
+ // nothing to be done for this type of packaging
+ skip = true;
+ getLog().info("skip generate goal for packaging " + project.getPackaging());
+ return;
+ }
+
+ if (!helpIdStore.exists()) {
+ skip = true;
+ getLog().info("no helpIdStore to react at " + helpIdStore);
+ return;
+ }
+
+ // check there is some bundle
+ if (locale == null) {
+ throw new MojoFailureException("you must set the bundles property.");
+ }
+ // check there is some bundle
+ if (target == null) {
+ throw new MojoFailureException("you must set the target property.");
+ }
+ // check ressources
+ checkResource(helpSetTemplate);
+ checkResource(mapTemplate);
+ checkResource(indexTemplate);
+ checkResource(tocTemplate);
+ checkResource(contentTemplate);
+
+ if (!target.exists()) {
+ getLog().info("mkdir " + target);
+ target.mkdirs();
+ }
+
+
+ helpIds = new SortedProperties();
+
+ InputStream stream = new FileInputStream(helpIdStore);
+
+ helpIds.load(stream);
+
+ stream.close();
+
+ if (helpIds.isEmpty()) {
+
+ // no ids detected
+ getLog().warn("no helpIds detected, will skip.");
+ skip = true;
+ return;
+ }
+
+ skip = false;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ if (i18nable) {
+
+ List<URL> lUrls = new java.util.ArrayList<URL>();
+ List resources = project.getResources();
+ for (Object o : resources) {
+ Resource resource = (Resource) o;
+ lUrls.add(new File(resource.getDirectory()).toURI().toURL());
+ }
+ I18n.setExtraURL(lUrls.toArray(new URL[lUrls.size()]));
+ I18n.init(locale, null);
+ }
+
+ File file;
+
+ Properties env = new Properties();
+
+ env.put("helpSetName", helpSetName);
+ env.put("helpSetFileName", helpsetFileName);
+ env.put("mapFileName", mapFileName);
+ env.put("indexFileName", indexFileName);
+ env.put("tocFileName", tocFileName);
+ env.put("separator", " ");
+ env.put("autoremoveLine", AUTOREMOVE_LINE);
+
+
+ int touchedFiles = 0;
+
+ // ---------------------------------------------------------------
+ // --- main helpset file -----------------------------------------
+ // ---------------------------------------------------------------
+
+
+ file = new File(target, helpsetFileName);
+
+ boolean doCreate = generateHelSetFile(file, env);
+
+ if (doCreate) {
+ touchedFiles++;
+ }
+
+ // ---------------------------------------------------------------
+ // --- helpset map file ------------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(target, mapFileName);
+
+ Properties mergedHelpIds = generateMapFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset index file ----------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(target, indexFileName);
+
+ NodeItem indexRootItem = generateIndexFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset toc file ------------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(target, tocFileName);
+
+ NodeItem tocRootItem = generateTocFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset content files -------------------------------------
+ // ---------------------------------------------------------------
+
+ TemplateGenerator gen = prepareGenerator(contentTemplate);
+
+ Enumeration keys = helpIds.keys();
+
+ while (keys.hasMoreElements()) {
+ String key = (String) keys.nextElement();
+ String url = (String) helpIds.get(key);
+ url = helpSetName + File.separator + url;
+
+ File f = new File(target, url);
+
+ boolean exist = f.exists();
+
+ if (exist) {
+ // check if there is a autoremoveLine in content
+ String content = FileUtil.readAsString(f);
+ if (!content.contains(AUTOREMOVE_LINE)) {
+ // no regenerate marker detected, so skip this file
+ if (verbose) {
+ getLog().debug("skip existing file " + f);
+ }
+ continue;
+ }
+ }
+
+ f.getParentFile().mkdirs();
+
+ if (verbose) {
+ if (exist) {
+ getLog().info("regenerate content file " + f);
+ } else {
+ getLog().info("generate content file " + f);
+ }
+ }
+
+ env.put("helpId", key);
+ String i18n = helpsetI18nPrefix + key + helpsetTitleI18nSuffix;
+ env.put("helpIdTitle", _(i18n));
+ env.put("helpIdUrl", url);
+
+ gen.generate(env, f);
+ touchedFiles++;
+ }
+
+ // ---------------------------------------------------------------
+ // --- i18n file -------------------------------------------------
+ // ---------------------------------------------------------------
+
+ String path = packageName.replaceAll("\\.", File.separator);
+ path += File.separator + i8nFileName;
+ file = new File(outJava, path);
+ generateI18nFile(file, env, mergedHelpIds, indexRootItem, tocRootItem);
+ touchedFiles++;
+
+ getLog().info(touchedFiles + " file(s) treated.");
+ }
+
+ protected void generateI18nFile(File file, Properties env, Properties mergedHelpIds, NodeItem indexRootItem, NodeItem tocRootItem) throws Exception {
+
+ boolean create = !file.exists();
+
+ if (!file.getParentFile().exists()) {
+ file.getParentFile().mkdirs();
+ }
+
+ Set<String> keys = new java.util.HashSet<String>();
+
+ for (Object k : mergedHelpIds.keySet()) {
+ String key = helpsetI18nPrefix + k + helpsetTitleI18nSuffix;
+ keys.add(key);
+ }
+ indexRootItem.extractI18n(keys, helpsetI18nPrefix, helpsetIndexI18nSuffix);
+ tocRootItem.extractI18n(keys, helpsetI18nPrefix, helpsetTocI18nSuffix);
+
+ env.put("keys", keys);
+ env.put("packageName", packageName);
+ String className = file.getName();
+ int index = className.lastIndexOf(".");
+ className = className.substring(0, index);
+ env.put("className", className);
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate i18n java file " + file);
+ } else {
+ getLog().info("udpate i18n java file " + file);
+ }
+ }
+
+ doGen(i18nTemplate, file, env);
+
+ }
+
+ protected boolean generateHelSetFile(File file, Properties env) throws Exception {
+
+ if (file.exists()) {
+ // check the auto removeline presence
+ String content = FileUtil.readAsString(file);
+ if (!content.contains(AUTOREMOVE_LINE)) {
+ // no regenerate marker detected, so skip this file
+ if (verbose) {
+ getLog().info("skip existing helpset main file " + file);
+ }
+ return false;
+ }
+ }
+
+ if (verbose) {
+ if (file.exists()) {
+ getLog().info("regenerate helpset main file " + file);
+ } else {
+ getLog().info("generate helpset main file " + file);
+ }
+ }
+ doGen(helpSetTemplate, file, env);
+ return true;
+ }
+
+ protected Properties generateMapFile(File file, Properties env) throws Exception {
+
+ boolean create;
+
+ Properties mergedHelpIds = null;
+ if (file.exists()) {
+
+ // get back the exisiting data and merge it with incoming ones
+
+ if (verbose) {
+ getLog().info("loading existing helpset map file " + file);
+ }
+
+ mergedHelpIds = getExistingHelpIds(file);
+ create = false;
+
+ } else {
+
+ mergedHelpIds = new SortedProperties();
+ create = true;
+ }
+
+ // inject new helpIds
+
+ for (Object k : helpIds.keySet()) {
+ mergedHelpIds.put(k, helpSetName + "/" + helpIds.get(k));
+ }
+
+ if (!mergedHelpIds.contains("top")) {
+ // on ajoute une entree vers le root du helpset
+
+ String topUrl = helpSetName + ".html";
+ helpIds.put("top", topUrl);
+ mergedHelpIds.put("top", helpSetName + "/" + topUrl);
+ if (verbose) {
+ getLog().debug("add top entry with url " + topUrl);
+ }
+ }
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate helpset map file " + file);
+ } else {
+ getLog().info("udpate helpset map file " + file);
+ }
+ }
+
+ env.put("helpIds", mergedHelpIds);
+ doGen(mapTemplate, file, env);
+ env.remove("helpIds");
+ return mergedHelpIds;
+ }
+
+ protected NodeItem generateIndexFile(File file, Properties env) throws Exception {
+ NodeItem rootItem = null;
+
+ boolean create;
+
+ if (file.exists()) {
+
+ create = false;
+
+ rootItem = getExistingItems("indexitem", file);
+ } else {
+ create = true;
+ }
+
+ if (rootItem == null) {
+ rootItem = new NodeItem("top", helpSetName);
+ }
+
+ // inject new index entries
+
+ for (Object k : helpIds.keySet()) {
+ NodeItem toc = rootItem.findChild(k + "");
+ if (verbose) {
+ getLog().debug("index " + k + " : " + toc);
+ }
+ }
+
+ //String prefix = helpsetI18nPrefix;
+ //String prefix = helpsetI18nPrefix + helpSetName + ".";
+ rootItem.applyI18n(helpsetI18nPrefix, helpsetIndexI18nSuffix);
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate helpset index file " + file);
+ } else {
+ getLog().info("udpate helpset index file " + file);
+ }
+ }
+
+ env.put("rootItem", rootItem);
+ doGen(indexTemplate, file, env);
+ env.remove("rootItem");
+ return rootItem;
+ }
+
+ protected NodeItem generateTocFile(File file, Properties env) throws Exception {
+ NodeItem rootItem = null;
+
+ boolean create;
+
+ if (file.exists()) {
+
+ create = false;
+
+ rootItem = getExistingItems("tocitem", file);
+ } else {
+ create = true;
+ }
+
+ if (rootItem == null) {
+ rootItem = new NodeItem("top", helpSetName);
+ }
+ // inject new toc entries
+
+ for (Object k : helpIds.keySet()) {
+ NodeItem toc = rootItem.findChild(k + "");
+ if (verbose) {
+ getLog().debug("toc " + k + " : " + toc);
+ }
+ }
+
+ //String prefix = helpsetI18nPrefix + helpSetName + ".";
+ rootItem.applyI18n(helpsetI18nPrefix, helpsetTocI18nSuffix);
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate helpset toc file " + file);
+ } else {
+ getLog().info("udpate helpset toc file " + file);
+ }
+ }
+
+ env.put("rootItem", rootItem);
+ doGen(tocTemplate, file, env);
+ env.remove("rootItem");
+ return rootItem;
+ }
+
+ protected void doGen(File template, File f, Properties env) throws Exception {
+ TemplateGenerator gen = prepareGenerator(template);
+ gen.generate(env, f);
+ }
+
+ protected TemplateGenerator prepareGenerator(File template) throws Exception {
+ URL templateURL = getTemplate(template);
+
+ if (verbose) {
+ getLog().info("using template " + templateURL);
+ }
+ TemplateGenerator gen = new TemplateGenerator(project, templateURL);
+ return gen;
+ }
+
+ protected URL getTemplate(File f) throws IOException {
+ URL r = null;
+ InputStream s = null;
+ if (f.exists()) {
+ r = f.toURI().toURL();
+ } else {
+ r = getClass().getResource(f.toString());
+ }
+ return r;
+ }
+
+ protected void checkResource(File f) throws MojoFailureException {
+ if (!f.exists()) {
+ // test in classPath
+ InputStream r = getClass().getResourceAsStream(f.toString());
+ if (r == null) {
+ throw new MojoFailureException("could not find ressource " + f);
+ }
+ }
+ }
+
+ protected Properties getExistingHelpIds(File file) throws SAXException, IOException {
+
+ final Properties result = new SortedProperties();
+
+ XMLReader parser = XMLReaderFactory.createXMLReader();
+
+ parser.setContentHandler(new ContentHandlerAdapter() {
+
+ String target;
+ String url;
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ if ("mapID".equals(localName)) {
+ target = atts.getValue("target");
+ url = atts.getValue("url");
+ if (verbose) {
+ getLog().debug("detect map entry : " + target + " : " + url);
+ }
+ result.put(target, url);
+ }
+ }
+ });
+
+ InputStream s = new FileInputStream(file);
+ try {
+ parser.parse(new InputSource(s));
+ } finally {
+ s.close();
+ }
+ return result;
+ }
+
+ protected NodeItem getExistingItems(String tagName, File file) throws SAXException, IOException {
+
+ XMLReader parser = XMLReaderFactory.createXMLReader();
+ NodeItemHandler handler = new NodeItemHandler(tagName);
+
+ parser.setContentHandler(handler);
+
+ NodeItem rootItem = null;
+ InputStream s = new FileInputStream(file);
+ try {
+ parser.parse(new InputSource(s));
+ rootItem = handler.rootItem;
+ } finally {
+ s.close();
+ }
+ return rootItem;
+ }
+
+ static class NodeItemHandler extends ContentHandlerAdapter {
+
+ NodeItem rootItem;
+ NodeItem currentItem;
+ final Stack<NodeItem> stack;
+ final String tagName;
+
+ public NodeItemHandler(String tagName) {
+ this.tagName = tagName;
+ this.stack = new Stack<NodeItem>();
+ }
+
+ @Override
+ public void startDocument() throws SAXException {
+ rootItem = new NodeItem("top", null);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ if (tagName.equals(localName)) {
+
+ String target = atts.getValue("target");
+ String text = atts.getValue("text");
+
+ // debut d'un item
+ if (currentItem == null) {
+ // premier item
+ if (rootItem.getTarget().equals(target)) {
+ // le premier item est bien top
+ //rootItem.setText(text);
+ currentItem = rootItem;
+ } else {
+ // le premier noeud n'est pas top
+ // en l'encapsule
+ stack.push(rootItem);
+ currentItem = new NodeItem(target, text);
+ rootItem.addChild(currentItem);
+ }
+ } else {
+ NodeItem newItem = new NodeItem(target, text);
+ currentItem.addChild(newItem);
+ currentItem = newItem;
+ }
+ currentItem.adjustTarget();
+ stack.push(currentItem);
+
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ if (tagName.equals(localName)) {
+ // fin d'un item
+ stack.pop();
+ if (!stack.isEmpty()) {
+ currentItem = stack.peek();
+ }
+ }
+ }
+ }
+
+ static class ContentHandlerAdapter implements ContentHandler {
+
+ @Override
+ public void setDocumentLocator(Locator locator) {
+ }
+
+ @Override
+ public void startDocument() throws SAXException {
+ }
+
+ @Override
+ public void endDocument() throws SAXException {
+ }
+
+ @Override
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ }
+
+ @Override
+ public void endPrefixMapping(String prefix) throws SAXException {
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ }
+
+ @Override
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+ }
+
+ @Override
+ public void processingInstruction(String target, String data) throws SAXException {
+ }
+
+ @Override
+ public void skippedEntity(String name) throws SAXException {
+ }
+ }
+}
\ No newline at end of file
Added: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/NodeItem.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/NodeItem.java (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/NodeItem.java 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,137 @@
+package org.codelutin.jaxx;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import static org.codelutin.i18n.I18n._;
+
+public class NodeItem {
+
+ String absoluteTarget;
+ private String target;
+ private String text;
+ private List<NodeItem> childs;
+
+ public NodeItem(String target, String text) {
+ this.target = target;
+ this.absoluteTarget = target;
+
+ this.text = text;
+ }
+
+ public String getTarget() {
+ return target;
+ }
+
+ public String getAbsoluteTarget() {
+ return absoluteTarget;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public List<NodeItem> getChilds() {
+ return childs;
+ }
+
+ public NodeItem findChild(String path) {
+ NodeItem result = null;
+ String[] paths = path.split("\\.");
+ for (int i = 0, j = paths.length; i < j; i++) {
+ String p = paths[i];
+ if (result == null) {
+
+ // first node
+ if (target.equals(p)) {
+ result = this;
+ continue;
+ }
+ result = getChild(p);
+ if (result == null) {
+ result = new NodeItem(p, null);
+ addChild(result);
+ adjutsAbsoluteTarget(result);
+ }
+ continue;
+ }
+ NodeItem child = result.getChild(p);
+ if (child == null) {
+ child = new NodeItem(p, null);
+ result.addChild(child);
+ result.adjutsAbsoluteTarget(child);
+ result = child;
+ } else {
+ result = child;
+ }
+ }
+ return result;
+ }
+
+ public NodeItem getChild(int index) {
+ return childs.get(index);
+ }
+
+ public NodeItem getChild(String target) {
+ if (isLeaf()) {
+ return null;
+ }
+ for (NodeItem i : childs) {
+ if (i.target.equals(target)) {
+ return i;
+ }
+ }
+ return null;
+ }
+
+ public void addChild(NodeItem child) {
+ if (childs == null) {
+ childs = new ArrayList<NodeItem>();
+ }
+
+ childs.add(child);
+ }
+
+ public void adjutsAbsoluteTarget(NodeItem child) {
+ if (!"top".equals(target)) {
+ // on ne prefixe pas les fils direct du root
+ child.absoluteTarget = absoluteTarget + "." + child.target;
+ }
+ }
+
+ public void adjustTarget() {
+ int index = target.lastIndexOf(".");
+ if (index > -1) {
+ target = target.substring(index + 1);
+ }
+ }
+
+ public boolean isLeaf() {
+ return childs == null || childs.isEmpty();
+ }
+
+ public void applyI18n(String prefix, String suffix) {
+ String key = prefix + getAbsoluteTarget() + suffix;
+ text = _(key);
+ if (!isLeaf()) {
+ for (NodeItem i : getChilds()) {
+ i.applyI18n(prefix, suffix);
+ }
+ }
+ }
+
+ public void extractI18n(Set<String> keys, String prefix, String suffix) {
+ String key = prefix + getAbsoluteTarget() + suffix;
+ keys.add(key);
+ if (!isLeaf()) {
+ for (NodeItem i : getChilds()) {
+ i.extractI18n(keys, prefix, suffix);
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<target:" + target + ", text:" + text + ", nbChilds:" + (isLeaf() ? 0 : childs.size()) + ">";
+ }
+}
Added: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/TemplateGenerator.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/TemplateGenerator.java (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/TemplateGenerator.java 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License" );
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.codelutin.jaxx;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Properties;
+
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+
+/**
+ * Generator of template base on velocity.
+ *
+ * @author chemit
+ * @since 1.3
+ *
+ */
+public class TemplateGenerator {
+
+ protected VelocityEngine engine;
+ protected final MavenProject mavenProject;
+ protected Template velocityTemplate;
+
+ protected TemplateGenerator(MavenProject mavenProject, URL template) throws URISyntaxException {
+
+ if (mavenProject == null) {
+ throw new IllegalArgumentException("mavenProject must not be null");
+ }
+
+ if (template == null) {
+ throw new IllegalArgumentException("template must not be null");
+ }
+
+ this.mavenProject = mavenProject;
+
+ Properties props = new Properties();
+
+ String templateName;
+
+ if (template.toURI().isOpaque()) {
+
+ // template is in a jar
+
+ props = new Properties();
+ props.setProperty("resource.loader", "jar");
+ props.setProperty("jar.resource.loader.description", "Jar resource loader for default webstart templates");
+ props.setProperty("jar.resource.loader.class", "org.apache.velocity.runtime.resource.loader.JarResourceLoader");
+
+ // obtain the jar url
+
+ String url = template.toString();
+ int i = url.indexOf("!");
+ templateName = url.substring(i + 2);
+
+ props.setProperty("jar.resource.loader.path", url.substring(0, i + 2));
+
+ } else {
+
+
+ templateName = new File(template.getFile()).getName();
+
+ //props.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.NullLogSystem");
+ props.setProperty("file.resource.loader.path", template.getFile());
+
+ }
+
+ try {
+ engine = new VelocityEngine();
+ //engine.setProperty("runtime.log.logsystem", new NullLogSystem());
+ engine.init(props);
+ } catch (Exception e) {
+ IllegalArgumentException iae = new IllegalArgumentException("Could not initialise Velocity");
+ iae.initCause(e);
+ throw iae;
+ }
+
+ try {
+ this.velocityTemplate = engine.getTemplate(templateName);
+ } catch (Exception e) {
+ IllegalArgumentException iae =
+ new IllegalArgumentException("Could not load the template file from '" + template + "'");
+ iae.initCause(e);
+ throw iae;
+ }
+ }
+
+ public void generate(Properties context, File outputFile) throws Exception {
+
+
+ VelocityContext vcontext = new VelocityContext();
+
+ // Note: properties that contain dots will not be properly parsed by Velocity. Should we replace dots with underscores ?
+ addPropertiesToContext(System.getProperties(), vcontext);
+
+ addPropertiesToContext(mavenProject.getProperties(), vcontext);
+ addPropertiesToContext(context, vcontext);
+
+ vcontext.put("project", mavenProject.getModel());
+
+ vcontext.put("outputFile", outputFile.getName());
+
+ FileWriter writer = new FileWriter(outputFile);
+
+ try {
+ velocityTemplate.merge(vcontext, writer);
+ writer.flush();
+ } catch (Exception e) {
+ throw new Exception("Could not generate the template " + velocityTemplate.getName() + ": " + e.getMessage(), e);
+ } finally {
+ writer.close();
+ }
+ }
+
+ protected void addPropertiesToContext(Properties properties, VelocityContext context) {
+
+ for (Iterator iter = properties.keySet().iterator(); iter.hasNext();) {
+ String key = (String) iter.next();
+ Object value = properties.get(key);
+ context.put(key, value);
+ }
+
+ }
+}
Added: jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+<TITLE>
+$helpIdTitle
+</TITLE>
+</HEAD>
+<BODY BGCOLOR="#ffffff">
+<H1>$helpIdTitle</H1>
+
+<!-- $autoremoveLine -->
+
+</BODY>
+</HTML>
Added: jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,44 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE helpset
+ PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN"
+ "http://java.sun.com/products/javahelp/helpset_1_0.dtd">
+
+<helpset version="1.0">
+
+ <!-- $autoremoveLine -->
+
+ <!-- title -->
+ <title>${helpSetTitle}</title>
+
+ <!-- maps -->
+ <maps>
+ <homeID>top</homeID>
+ <mapref location="$mapFileName"/>
+ </maps>
+
+ <!-- views -->
+ <view>
+ <name>TOC</name>
+ <label>Table Of Contents</label>
+ <type>javax.help.TOCView</type>
+ <data>$tocFileName</data>
+ </view>
+
+ <view>
+ <name>Index</name>
+ <label>Index</label>
+ <type>javax.help.IndexView</type>
+ <data>$indexFileName</data>
+ </view>
+
+#if ( $!searchData != "" )
+ <view>
+ <name>Search</name>
+ <label>Search</label>
+ <type>javax.help.SearchView</type>
+ <data engine="com.sun.java.help.search.DefaultSearchEngine">
+ $searchData
+ </data>
+ </view>
+#end
+</helpset>
Added: jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultI18n.java.vm
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultI18n.java.vm (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultI18n.java.vm 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,16 @@
+package $packageName;
+
+$!commentaire
+public class $className { // $className
+
+{
+// BEGIN DO NOT REMOVE : used to detect helper i18n keys
+//
+#foreach( $key in $keys )
+// _("$key");
+#end
+//
+// END DO NOT REMOVE : used to detect helper i18n keys
+}
+
+} // $className
\ No newline at end of file
Added: jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultIndex.xml.vm
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultIndex.xml.vm (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultIndex.xml.vm 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,21 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE index
+ PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Index Version 1.0//EN"
+ "http://buix.labs.libre-entreprise.org/javahelp/index_1_0.dtd">
+
+## pour afficher un org.codelutin.jaxx.NodeItem
+#macro ( renderItem $item $prefix )
+#if ( $item.isLeaf() )
+$prefix<indexitem target="$item.absoluteTarget" text="$!item.text"/>
+#else
+$prefix<indexitem target="$item.absoluteTarget" text="$!item.text">
+#foreach( $child in $item.getChilds() )
+#renderItem( $child "$prefix$separator" )
+#end
+$prefix</indexitem>
+#end
+#end
+
+<index version="1.0">
+#renderItem( $rootItem $separator )
+</index>
Added: jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultMap.jhm.vm
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultMap.jhm.vm (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultMap.jhm.vm 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,16 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE map
+ PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN"
+ "http://java.sun.com/products/javahelp/map_1_0.dtd">
+<map version="1.0">
+
+#if ( !$helpIds.get("toplevelfolder"))
+ <!-- use this entry to go up in navigation -->
+ <!--mapID target="toplevelfolder" url="images/toplevel.gif" /-->
+#end
+
+#foreach( $key in $helpIds.keys() )
+ <mapID target="$key" url="$helpIds.get($key)" />
+#end
+
+</map>
Added: jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultToc.xml.vm
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultToc.xml.vm (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/resources/defaultToc.xml.vm 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,20 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!DOCTYPE toc
+ PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp TOC Version 1.0//EN"
+ "http://buix.labs.libre-entreprise.org/javahelp/toc_1_0.dtd">
+
+## pour afficher un org.codelutin.jaxx.NodeItem
+#macro ( renderItem $item $prefix )
+#if ( $item.isLeaf() )
+$prefix<tocitem target="$item.absoluteTarget" text="$!item.text"/>
+#else
+$prefix<tocitem target="$item.absoluteTarget" text="$!item.text">
+#foreach( $child in $item.getChilds() )
+#renderItem( $child "$prefix$separator" )
+#end
+$prefix</tocitem>
+#end
+#end
+<toc version="1.0">
+#renderItem( $rootItem $separator )
+</toc>
Modified: jaxx/trunk/maven-jaxx-plugin/src/main/resources/log4j.properties
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/resources/log4j.properties 2009-03-29 13:36:21 UTC (rev 1280)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/resources/log4j.properties 2009-03-29 13:36:44 UTC (rev 1281)
@@ -5,5 +5,5 @@
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-#log4j.logger.org.codelutin.jaxx=DEBUG
+log4j.logger.org.codelutin.i18n=ERROR
#log4j.logger.jaxx=DEBUG
Added: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/NodeItemTest.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/NodeItemTest.java (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/NodeItemTest.java 2009-03-29 13:36:44 UTC (rev 1281)
@@ -0,0 +1,54 @@
+package org.codelutin.jaxx;
+
+import org.junit.Assert;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author tony
+ */
+public class NodeItemTest {
+
+ @Test
+ public void testFindChild() {
+ System.out.println("findChild");
+ String path = "a";
+ NodeItem instance = new NodeItem("a", "rootItem text");
+ NodeItem expResult = new NodeItem("a", "rootItem text");
+ NodeItem result = instance.findChild(path);
+ assertTocItemEquals(expResult, result);
+
+ path = "a.b";
+ expResult = new NodeItem("b", null);
+ result = instance.findChild(path);
+ assertTocItemEquals(expResult, result);
+ assertTrue(instance.getChild("b") == result);
+ assertTrue(instance.findChild("b") == result);
+
+ NodeItem b = result;
+
+ path = "ab";
+ expResult = new NodeItem("ab", null);
+ result = instance.findChild(path);
+ assertTocItemEquals(expResult, result);
+ assertTrue(instance.getChild("ab") == result);
+ assertTrue(instance.findChild("ab") == result);
+
+ path = "a.b.cd";
+ expResult = new NodeItem("cd", null);
+ result = instance.findChild(path);
+ assertTocItemEquals(expResult, result);
+ assertTrue(b.getChild("cd") == result);
+ assertTrue(b.findChild("b.cd") == result);
+ assertTrue(b.findChild("cd") == result);
+ assertTrue(instance.findChild("b.cd") == result);
+ assertTrue(instance.findChild("a.b.cd") == result);
+ }
+
+ protected void assertTocItemEquals(NodeItem t, NodeItem t2) {
+ Assert.assertEquals(t.getTarget(), t2.getTarget());
+ Assert.assertEquals(t.getText(), t2.getText());
+
+ }
+}
\ No newline at end of file
1
0
r1280 - in jaxx/trunk: . jaxx-compiler-api jaxx-compiler-api/src/main/java/jaxx/compiler jaxx-compiler-api/src/main/java/jaxx/tags jaxx-compiler-swing jaxx-compiler-swing/src/main/java/jaxx jaxx-compiler-swing/src/main/java/jaxx/compiler jaxx-runtime-swing jaxx-runtime-swing/src/main/java/jaxx/runtime jaxx-runtime-swing/src/main/java/jaxx/runtime/swing
by tchemit@users.labs.libre-entreprise.org March 29, 2009
by tchemit@users.labs.libre-entreprise.org March 29, 2009
March 29, 2009
Author: tchemit
Date: 2009-03-29 13:36:21 +0000 (Sun, 29 Mar 2009)
New Revision: 1280
Added:
jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/JaxxHelpUI.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
Modified:
jaxx/trunk/changelog.txt
jaxx/trunk/jaxx-compiler-api/changelog.txt
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java
jaxx/trunk/jaxx-compiler-swing/changelog.txt
jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/SwingInitializer.java
jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java
jaxx/trunk/jaxx-runtime-swing/changelog.txt
Log:
add generate-help goal
Modified: jaxx/trunk/changelog.txt
===================================================================
--- jaxx/trunk/changelog.txt 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/changelog.txt 2009-03-29 13:36:21 UTC (rev 1280)
@@ -1,4 +1,5 @@
1.3 chemit 20090320
+ * 20090329 [chemit] - add java help mojo
* 20090313 [chemit] - use i18n 0.10
1.2 ??? 2009????
Modified: jaxx/trunk/jaxx-compiler-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-29 13:36:21 UTC (rev 1280)
@@ -1,4 +1,7 @@
1.3 chemit 20090321
+ * 20090327 [chemit] - refactor clientProperties (no more generation in handler but in decorator)
+ - add javax help mecanism
+
* 20090321 [chemit] - add compilerCount in launchro to known how mush files where generated
* 20090313 [chemit] - can now use geneticType on javaBean object
- add an extra method $afterCompleteSetup method to be included if find in script at last statement of $completeSetup method
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java 2009-03-29 13:36:21 UTC (rev 1280)
@@ -72,6 +72,10 @@
* the decorator (if null will use {@link DefaultCompiledObjectDecorator}).
*/
private CompiledObjectDecorator decorator;
+ /**
+ * client properties
+ */
+ private Map<String,String> clientProperties;
public class ChildRef {
@@ -433,6 +437,29 @@
properties.put(property, value);
}
+ public boolean hasClientProperties() {
+ return clientProperties != null && !clientProperties.isEmpty();
+ }
+
+ public void addClientProperty(String property, String value) {
+ getClientProperties().put(property, value);
+ }
+
+ public String getClientProperty(String key) {
+ if (!hasClientProperties()) {
+ return null;
+ }
+ return clientProperties.get(key);
+ }
+
+ public Map<String, String> getClientProperties() {
+ if (clientProperties == null) {
+ clientProperties = new HashMap<String, String>();
+ }
+ return clientProperties;
+ }
+
+
/**
* Returns all properties which have been set for this object.
*
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java 2009-03-29 13:36:21 UTC (rev 1280)
@@ -44,6 +44,40 @@
/** a flag to use {@link javax.swing.UIManager} to retreave icons. */
private boolean useUIManagerForIcon;
+ /** a flag to generate javax help for any */
+ private boolean generateHelp;
+
+ private String helpBrokerFQN;
+ /**
+ * The prefix to add to i18n key for any help i18n key.
+ *
+ * @since 1.3
+ */
+ protected String helpsetI18nPrefix;
+ /**
+ * The suffix to add to i18n key for an help Id.
+ *
+ * @since 1.3
+ */
+ protected String helpsetTitleI18nSuffix;
+ /**
+ * The suffix to add to i18n key for an toc Id.
+ *
+ * @since 1.3
+ */
+ protected String helpsetTocI18nSuffix;
+ /**
+ * The suffix to add to i18n key for an toc Id.
+ *
+ * @since 1.3
+ */
+ protected String helpsetIndexI18nSuffix;
+ /**
+ * The helpset name
+ *
+ * @since 1.3
+ */
+ protected String helpSetName;
/** the default compiled object decorator to use if none specifed via decorator attribute */
private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
@@ -291,5 +325,61 @@
this.profile = profile;
}
+ public boolean isGenerateHelp() {
+ return generateHelp;
+ }
+
+ public void setGenerateHelp(boolean generateHelp) {
+ this.generateHelp = generateHelp;
+ }
+
+ public String getHelpBrokerFQN() {
+ return helpBrokerFQN;
+ }
+
+ public void setHelpBrokerFQN(String helpBrokerFQN) {
+ this.helpBrokerFQN = helpBrokerFQN;
+ }
+
+ public String getHelpsetIndexI18nSuffix() {
+ return helpsetIndexI18nSuffix;
+ }
+
+ public void setHelpsetIndexI18nSuffix(String helpsetIndexI18nSuffix) {
+ this.helpsetIndexI18nSuffix = helpsetIndexI18nSuffix;
+ }
+
+ public String getHelpsetTitleI18nSuffix() {
+ return helpsetTitleI18nSuffix;
+ }
+
+ public void setHelpsetTitleI18nSuffix(String helpsetTitleI18nSuffix) {
+ this.helpsetTitleI18nSuffix = helpsetTitleI18nSuffix;
+ }
+
+ public String getHelpsetTocI18nSuffix() {
+ return helpsetTocI18nSuffix;
+ }
+
+ public void setHelpsetTocI18nSuffix(String helpsetTocI18nSuffix) {
+ this.helpsetTocI18nSuffix = helpsetTocI18nSuffix;
+ }
+
+ public String getHelpSetName() {
+ return helpSetName;
+ }
+
+ public void setHelpSetName(String helpSetName) {
+ this.helpSetName = helpSetName;
+ }
+
+ public String getHelpsetI18nPrefix() {
+ return helpsetI18nPrefix;
+ }
+
+ public void setHelpsetI18nPrefix(String helpsetI18nPrefix) {
+ this.helpsetI18nPrefix = helpsetI18nPrefix;
+ }
+
}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-03-29 13:36:21 UTC (rev 1280)
@@ -5,6 +5,7 @@
package jaxx.compiler;
import java.lang.reflect.Modifier;
+import java.util.Map.Entry;
import jaxx.CompilerException;
import jaxx.types.TypeManager;
@@ -75,10 +76,18 @@
@Override
public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings) {
StringBuffer code = new StringBuffer();
+ //TC-20090327 generate client properties
+ if (object.hasClientProperties()) {
+ // generate putClientProperty invocations
+ for (Entry<String,String> entry : object.getClientProperties().entrySet()) {
+ object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + entry.getKey() + "\", " + entry.getValue() + ");");
+ }
+
+ }
//TC - 20081017 only generate the method if not empty ?
if (object.getId().startsWith("$")) {
code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
- } else {
+ } else {
String additionCode = object.getAdditionCode();
if (additionCode.length() > 0) {
code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-03-29 13:36:21 UTC (rev 1280)
@@ -204,7 +204,9 @@
if (stringValue.startsWith("{")) {
stringValue = stringValue.substring(1, stringValue.length() - 1);
}
- object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + propertyName.substring(1) + "\", " + stringValue + ");");
+ object.addClientProperty(propertyName.substring(1), stringValue);
+ //TC-20090327 rather not generating code here
+ //object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + propertyName.substring(1) + "\", " + stringValue + ");");
return;
}
if ("icon".equals(propertyName)) {
Modified: jaxx/trunk/jaxx-compiler-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/changelog.txt 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/jaxx-compiler-swing/changelog.txt 2009-03-29 13:36:21 UTC (rev 1280)
@@ -1,6 +1,7 @@
1.3 chemit 20090320
+ * 20090327 [chemit] - introduce javax help decorator
-1.1 chemit 20090220
+1.1 chemit 20090220
* 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...)
1.0 chemit 20090111
Modified: jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/SwingInitializer.java
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/SwingInitializer.java 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/SwingInitializer.java 2009-03-29 13:36:21 UTC (rev 1280)
@@ -31,6 +31,7 @@
import java.awt.Insets;
import jaxx.compiler.BoxedCompiledObjectDecorator;
import jaxx.compiler.CompiledObjectDecorator;
+import jaxx.compiler.HelpRootCompiledObjectDecorator;
public class SwingInitializer implements Initializer {
@@ -89,5 +90,6 @@
TypeManager.registerTypeConverter(KeyStroke.class, new KeyStrokeConverter());
CompiledObjectDecorator.registerDecorator("boxed", BoxedCompiledObjectDecorator.class);
+ CompiledObjectDecorator.registerDecorator("help", HelpRootCompiledObjectDecorator.class);
}
}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java 2009-03-29 13:36:21 UTC (rev 1280)
@@ -1,6 +1,7 @@
package jaxx.compiler;
import jaxx.compiler.CompiledObject.ChildRef;
+import jaxx.runtime.SwingUtil;
/**
* A decorator to surround a compiled object (should be a component at least)
@@ -17,7 +18,7 @@
for (ChildRef child : parent.getChilds()) {
if (child.getChild() == object) {
String javaCode = child.getChildJavaCode();
- child.setChildJavaCode("jaxx.runtime.SwingUtil.boxComponentWithJxLayer(" + javaCode + ")");
+ child.setChildJavaCode(SwingUtil.class.getName()+".boxComponentWithJxLayer(" + javaCode + ")");
break;
}
}
Added: jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java (rev 0)
+++ jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java 2009-03-29 13:36:21 UTC (rev 1280)
@@ -0,0 +1,93 @@
+package jaxx.compiler;
+
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * A decorator to place on a root compiled object to process javaHelp on the file.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class HelpRootCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
+
+ /**
+ * the list of discovered helpId
+ */
+ protected static Set<String> helpIds = new java.util.HashSet<String>();
+
+ protected String getBrokerFQN(JAXXCompiler compiler) {
+ String helpBrokerFQN = compiler.getOptions().getHelpBrokerFQN();
+ return helpBrokerFQN;
+ }
+
+ protected String getHelpId(CompiledObject o) {
+ String helpID = null;
+ if (o.hasClientProperties()) {
+ helpID = o.getClientProperty("help");
+ }
+ return helpID;
+ }
+
+ @Override
+ public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
+ super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
+ CompilerOptions options = compiler.getOptions();
+
+ if (options.isGenerateHelp()) {
+
+ // add JaxxHelpUI interface
+ Class<?> validatorInterface = jaxx.runtime.JaxxHelpUI.class;
+ String helpBrokerFQN = getBrokerFQN(compiler);
+ javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">");
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "registerHelpId",
+ "broker.installUI(component, helpId);",
+ new JavaArgument(helpBrokerFQN, "broker"),
+ new JavaArgument("Component", "component"),
+ new JavaArgument("String", "helpId")));
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "showHelp",
+ "getBroker().showHelp(this, helpId);",
+ new JavaArgument("String", "helpId")));
+
+ StringBuilder buffer = new StringBuilder();
+
+ String lineSeparator = JAXXCompiler.getLineSeparator();
+
+ if (options.isGenerateHelp()) {
+
+ // add code to init javax help system
+ Iterator<CompiledObject> itr = compiler.getObjectCreationOrder();
+
+ for (; itr.hasNext();) {
+ CompiledObject o = itr.next();
+ String helpID = getHelpId(o);
+ if (helpID != null) {
+ buffer.append(lineSeparator);
+ // detects a helpId to register
+ buffer.append("registerHelpId(_broker, " + o.getJavaCode() + ", " + helpID + ");");
+ //keep the helpID for helpSet generation
+ helpIds.add(helpID);
+ }
+ }
+ }
+ if (buffer.length() > 0) {
+
+ StringBuilder extraCode = new StringBuilder(helpBrokerFQN).append(" _broker = getBroker();");
+
+ buffer.append(lineSeparator).append("_broker.prepareUI(this);");
+ buffer.append(lineSeparator);
+
+ // add the calls
+ compiler.appendLateInitializer(extraCode.toString());
+ compiler.appendLateInitializer(buffer.toString());
+ }
+ }
+ }
+
+ public static Set<String> getHelpIds() {
+ return helpIds;
+ }
+}
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-24 14:37:47 UTC (rev 1279)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-29 13:36:21 UTC (rev 1280)
@@ -1,4 +1,5 @@
1.3 chemit 20090321
+ * 20090327 [chemit] - add javax help mecanism
* 20090318 [chemit] - introduce the BlockingLayerUI2 class (should be merge with BlockingLayerUI)
* 20090318 [chemit] - introduce the CardLayout2Ext class
* 20090312 [chemit] - add some usefull code from ObServe (load Nimbus L&F, load ui configuration)
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/JaxxHelpUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/JaxxHelpUI.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/JaxxHelpUI.java 2009-03-29 13:36:21 UTC (rev 1280)
@@ -0,0 +1,23 @@
+package jaxx.runtime;
+
+import java.awt.Component;
+import jaxx.runtime.swing.JaxxHelpBroker;
+
+/**
+ *
+ * Contract to be added on JAXXObject wihch wants to use javax help.
+ *
+ * @param <B> type of broker.
+ *
+ * @author tony
+ * @since 1.3
+ * @see JaxxHelpBroker
+ */
+public interface JaxxHelpUI<B extends JaxxHelpBroker> {
+
+ B getBroker();
+
+ void registerHelpId(B broker, Component component, String helpId);
+
+ void showHelp(String helpId);
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-03-29 13:36:21 UTC (rev 1280)
@@ -0,0 +1,510 @@
+package jaxx.runtime.swing;
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+import javax.help.CSH;
+import javax.help.CSH.DisplayHelpFromSource;
+import javax.help.HelpBroker;
+import javax.help.HelpSet;
+import javax.swing.AbstractButton;
+import javax.swing.JComponent;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * La classe pour encapsuler l'aide de l'application.
+ *
+ * @param <B> le type de broker
+ * @author tony
+ * @since 1.4
+ */
+public abstract class JaxxHelpBroker<B extends JaxxHelpBroker> {
+
+ public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(JaxxHelpBroker.class);
+ protected final String helpsetName;
+ protected final String defaultID;
+ protected final String helpKey;
+ // Main HelpSet & Broker
+ protected final HelpSet helpset;
+ protected final HelpBroker helpBroker;
+ protected ActionListener showHelpAction;
+ protected Hashtable<Component, Cursor> cursors;
+ protected Cursor onItemCursor;
+
+ protected JaxxHelpBroker(String helpsetName, String helpKey, String defaultID) {
+ if (helpsetName == null) {
+ throw new NullPointerException("parameter helpsetName can not be null!");
+ }
+ this.helpsetName = helpsetName;
+ this.helpKey = helpKey;
+ this.defaultID = defaultID;
+ try {
+ ClassLoader cl = getClass().getClassLoader();
+ URL url = HelpSet.findHelpSet(cl, helpsetName);
+ helpset = new HelpSet(cl, url);
+ helpBroker = helpset.createHelpBroker();
+ } catch (Exception ee) {
+ throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
+ }
+ }
+
+ public AbstractButton getShowHelperButton(JAXXObject c) {
+ return (AbstractButton) c.getObjectById("showHelp");
+ }
+
+ public void prepareUI(JAXXObject c) {
+ if (c == null) {
+ throw new NullPointerException("parameter c can not be null!");
+ }
+
+ // l'ui doit avoir un boutton showHelp
+ AbstractButton help = getShowHelperButton(c);
+
+ if (help == null) {
+ log.warn("no showButton detected for " + c.getClass());
+ } else {
+ boolean needListener = true;
+ for (ActionListener a : help.getActionListeners()) {
+ if (a instanceof DisplayHelpFromSource) {
+ needListener = false;
+ break;
+ }
+ }
+ if (needListener) {
+ // attach context to button
+ help.putClientProperty(JAXX_CONTEXT_ENTRY, c.getDelegateContext());
+ help.addActionListener(getShowHelpAction(c));
+ }
+
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("for " + c);
+ }
+
+ //installUI(c, new java.util.ArrayList<String>());
+ }
+
+ public HelpBroker getHelpBroker() {
+ return helpBroker;
+ }
+
+ public String getHelpKey() {
+ return helpKey;
+ }
+
+ public HelpSet getHelpset() {
+ return helpset;
+ }
+
+ public String getHelpsetName() {
+ return helpsetName;
+ }
+
+ public String getDefaultID() {
+ return defaultID;
+ }
+
+ public void showHelpSet() {
+ log.info(this);
+ new CSH.DisplayHelpFromSource(helpBroker);
+ }
+
+ public void showHelp(JAXXContext context, String helpId) {
+ }
+
+ public void installUI(Component comp, String helpId) {
+ CSH.setHelpIDString(comp, helpId);
+ }
+
+ protected void installUI(Object comp, List<String> scanned) {
+ //log.info(comp);
+ if (comp instanceof JComponent) {
+ JComponent c = (JComponent) comp;
+ if (scanned.contains(c.getName())) {
+ return;
+ } else {
+ scanned.add(c.getName());
+ }
+ Object id = c.getClientProperty(helpKey);
+ if (id != null && id instanceof String) {
+ String helpId = (String) id;
+
+ CSH.setHelpIDString(c, helpId);
+
+ log.info(c.getName() + " : " + helpId);
+
+ if (log.isDebugEnabled()) {
+ log.debug(c.getName() + " : " + helpId);
+
+ }
+ }
+ }
+
+ if (comp instanceof JAXXObject) {
+ JAXXObject jo = (JAXXObject) comp;
+
+
+ Map<String, Object> $objectMap = jo.get$objectMap();
+ for (String key : $objectMap.keySet()) {
+
+ if (scanned.contains(key)) {
+ continue;
+ }
+
+ Object o = $objectMap.get(key);
+
+ if (o == comp) {
+ continue;
+ }
+
+ if (o instanceof JAXXObject) {
+ installUI(o, scanned);
+ scanned.add(key);
+ continue;
+ }
+ if (o instanceof JComponent) {
+ installUI(o, scanned);
+ continue;
+ }
+ }
+ }
+ }
+
+ protected ActionListener getShowHelpAction(JAXXContext context) {
+ if (showHelpAction == null) {
+ showHelpAction = addShowHelpAction(context);
+ }
+ return showHelpAction;
+ }
+
+ protected ActionListener addShowHelpAction(JAXXContext context) {
+ return new CSH.DisplayHelpAfterTracking(helpBroker);
+ }
+
+ protected String getHelpID(Component source) {
+ String helpID = null;
+
+ // It is necessery for UIManager.get("HelpOnItemCursor");
+
+ // Get the onItemCursor
+ onItemCursor = (Cursor) UIManager.get("HelpOnItemCursor");
+ if (onItemCursor == null) {
+ return null;
+ }
+
+ // change all the cursors on all windows
+ Vector topComponents = null;
+ cursors = null;
+
+ if (onItemCursor != null) {
+ cursors = new Hashtable<Component, Cursor>();
+ topComponents = getTopContainers(source);
+ Enumeration enums = topComponents.elements();
+ while (enums.hasMoreElements()) {
+ setAndStoreCursors((Container) enums.nextElement(), onItemCursor);
+ }
+ }
+ /*MouseEvent event = getMouseEvent();
+
+ if (event != null) {
+ Component comp = (Component)event.getSource();
+ log.info("component traking!!!!!!!! " + comp.getName()+" : "+comp.getClass().getName());
+ }*/
+
+
+ Object o = CSH.trackCSEvents();
+
+ if (o instanceof Component) {
+
+ helpID = CSH.getHelpIDString((Component) o);
+
+ log.info("component traking " + ((Component) o).getName() + " : " + helpID);
+
+ if (log.isDebugEnabled()) {
+ log.debug("component traking " + ((Component) o).getName() + " : " + helpID);
+ }
+ }
+
+ /*HelpSet objHS = getHelpset();
+ try {
+ ID id = ID.create(helpID, objHS);
+ if (id == null) {
+ id = objHS.getHomeID();
+ }
+
+ } catch (Exception e2) {
+ e2.printStackTrace();
+ }
+ if (helpID == null) {
+ helpID = getDefaultID();
+ }*/
+
+ // restore the old cursors
+ if (topComponents != null) {
+ Enumeration containers = topComponents.elements();
+ while (containers.hasMoreElements()) {
+ resetAndRestoreCursors((Container) containers.nextElement());
+ }
+ }
+ cursors = null;
+
+ return helpID;
+ }
+
+ /*
+ * Get all top level containers to change it's cursors
+ */
+ protected Vector getTopContainers(Object source) {
+ // This method is used to obtain all top level components of application
+ // for which the changing of cursor to question mark is wanted.
+ // Method Frame.getFrames() is used to get list of Frames and
+ // Frame.getOwnedWindows() method on elements of the list
+ // returns all Windows, Dialogs etc. It works correctly in application.
+ // Problem is in applets. There is no way how to get reference to applets
+ // from elsewhere than applet itself. So, if request for CSH (this means
+ // pressing help button or select help menu item) does't come from component
+ // in a Applet, cursor for applets is not changed to question mark. Only for
+ // Frames, Windows and Dialogs is cursor changed properly.
+
+ Vector<Component> containers = new Vector<Component>();
+ Component topComponent = null;
+ topComponent = getRoot(source);
+ if (topComponent instanceof Applet) {
+ try {
+ Enumeration<Applet> applets = ((Applet) topComponent).getAppletContext().getApplets();
+ while (applets.hasMoreElements()) {
+ containers.add(applets.nextElement());
+ }
+ } catch (NullPointerException npe) {
+ containers.add(topComponent);
+ }
+ }
+ Frame frames[] = Frame.getFrames();
+ for (int i = 0; i < frames.length; i++) {
+ Window[] windows = frames[i].getOwnedWindows();
+ for (int j = 0; j < windows.length; j++) {
+ containers.add(windows[j]);
+ }
+ if (!containers.contains(frames[i])) {
+ containers.add(frames[i]);
+ }
+ }
+ return containers;
+ }
+
+ protected Component getRoot(Object comp) {
+ Object parent = comp;
+ while (parent != null) {
+ comp = parent;
+ if (comp instanceof MenuComponent) {
+ parent = ((MenuComponent) comp).getParent();
+ } else if (comp instanceof Component) {
+ if (comp instanceof Window) {
+ break;
+ }
+ if (comp instanceof Applet) {
+ break;
+ }
+ parent = ((Component) comp).getParent();
+ } else {
+ break;
+ }
+ }
+ if (comp instanceof Component) {
+ return ((Component) comp);
+ }
+ return null;
+ }
+
+
+ /*
+ * Set the cursor for a component and its children.
+ * Store the old cursors for future resetting
+ */
+ protected void setAndStoreCursors(Component comp, Cursor cursor) {
+ if (comp == null) {
+ return;
+ }
+ Cursor compCursor = comp.getCursor();
+ if (compCursor != cursor) {
+ cursors.put(comp, compCursor);
+ log.debug("set cursor on " + comp);
+ comp.setCursor(cursor);
+ }
+ if (comp instanceof Container) {
+ Component component[] = ((Container) comp).getComponents();
+ for (int i = 0; i < component.length; i++) {
+ setAndStoreCursors(component[i], cursor);
+ }
+ }
+ }
+
+ /*
+ * Actually restore the cursor for a component and its children
+ */
+ protected void resetAndRestoreCursors(Component comp) {
+ if (comp == null) {
+ return;
+ }
+ Cursor oldCursor = cursors.get(comp);
+ if (oldCursor != null) {
+ log.debug("restored cursor " + oldCursor + " on " + comp);
+ comp.setCursor(oldCursor);
+ }
+ if (comp instanceof Container) {
+ Component component[] = ((Container) comp).getComponents();
+ for (int i = 0; i < component.length; i++) {
+ resetAndRestoreCursors(component[i]);
+ }
+ }
+ }
+
+ /**
+ * Context Sensitive Event Tracking
+ *
+ * Creates a new EventDispatchThread from which to dispatch events. This
+ * method returns when stopModal is invoked.
+ *
+ * @return MouseEvent The mouse event occurred. Null if
+ * cancelled on an undetermined object.
+ */
+ public static MouseEvent getMouseEvent() {
+ // Should the cursor change to a quesiton mark here or
+ // require the user to change the cursor externally to this method?
+ // The problem is that each component can have it's own cursor.
+ // For that reason it might be better to have the user change the
+ // cusor rather than us.
+
+ // To track context-sensitive events get the event queue and process
+ // the events the same way EventDispatchThread does. Filter out
+ // ContextSensitiveEvents SelectObject & Cancel (MouseDown & ???).
+ // Note: This code only handles mouse events. Accessiblity might
+ // require additional functionality or event trapping
+
+ // If the eventQueue can't be retrieved, the thread gets interrupted,
+ // or the thread isn't a instanceof EventDispatchThread then return
+ // a null as we won't be able to trap events.
+ try {
+ if (EventQueue.isDispatchThread()) {
+ EventQueue eq = null;
+
+ // Find the eventQueue. If we can't get to it then just return
+ // null since we won't be able to trap any events.
+
+ try {
+ eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ } catch (Exception ee) {
+ log.debug(ee);
+ }
+
+ // Safe guard
+ if (eq == null) {
+ return null;
+ }
+
+ int eventNumber = -1;
+
+ // Process the events until an object has been selected or
+ // the context-sensitive search has been canceled.
+ while (true) {
+ // This is essentially the body of EventDispatchThread
+ // modified to trap context-senstive events and act
+ // appropriately
+ eventNumber++;
+ AWTEvent event = eq.getNextEvent();
+ Object src = event.getSource();
+ // can't call eq.dispatchEvent
+ // so I pasted it's body here
+
+ // debug(event);
+
+ // Not sure if I should suppress ActiveEvents or not
+ // Modal dialogs do. For now we will not suppress the
+ // ActiveEvent events
+
+ if (event instanceof ActiveEvent) {
+ ((ActiveEvent) event).dispatch();
+ continue;
+ }
+
+ if (src instanceof Component) {
+ // Trap the context-sensitive events here
+ if (event instanceof KeyEvent) {
+ KeyEvent e = (KeyEvent) event;
+ // if this is the cancel key then exit
+ // otherwise pass all other keys up
+ if (e.getKeyCode() == KeyEvent.VK_CANCEL ||
+ e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ e.consume();
+ return null;
+ } else {
+ e.consume();
+ // dispatchEvent(event);
+ }
+ } else if (event instanceof MouseEvent) {
+ MouseEvent e = (MouseEvent) event;
+ int eID = e.getID();
+ if ((eID == MouseEvent.MOUSE_CLICKED ||
+ eID == MouseEvent.MOUSE_PRESSED ||
+ eID == MouseEvent.MOUSE_RELEASED) &&
+ SwingUtilities.isLeftMouseButton(e)) {
+ if (eID == MouseEvent.MOUSE_CLICKED) {
+ if (eventNumber == 0) {
+ dispatchEvent(event);
+ continue;
+ }
+ }
+ e.consume();
+ return e;
+ } else {
+ e.consume();
+ }
+ } else {
+ dispatchEvent(event);
+ }
+ } else if (src instanceof MenuComponent) {
+ if (event instanceof InputEvent) {
+ ((InputEvent) event).consume();
+ }
+ } else {
+ System.err.println("unable to dispatch event: " + event);
+ }
+ }
+ }
+ } catch (InterruptedException e) {
+ log.debug(e);
+ }
+ log.debug("Fall Through code");
+ return null;
+ }
+
+ private static void dispatchEvent(AWTEvent event) {
+ Object src = event.getSource();
+ if (event instanceof ActiveEvent) {
+ // This could become the sole method of dispatching in time.
+ ((ActiveEvent) event).dispatch();
+ } else if (src instanceof Component) {
+ ((Component) src).dispatchEvent(event);
+ } else if (src instanceof MenuComponent) {
+ ((MenuComponent) src).dispatchEvent(event);
+ } else {
+ System.err.println("unable to dispatch event: " + event);
+ }
+ }
+}
1
0
r1279 - in jaxx/trunk/jaxx-runtime-swing/src/main: java/jaxx/runtime java/jaxx/runtime/swing/wizard resources resources/icons
by tchemit@users.labs.libre-entreprise.org March 24, 2009
by tchemit@users.labs.libre-entreprise.org March 24, 2009
March 24, 2009
Author: tchemit
Date: 2009-03-24 14:37:47 +0000 (Tue, 24 Mar 2009)
New Revision: 1279
Added:
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed-16.png
jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed.png
Modified:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
Log:
add default icons for wizard framework
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-24 00:58:12 UTC (rev 1278)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-24 14:37:47 UTC (rev 1279)
@@ -31,8 +31,10 @@
import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.Properties;
+import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
+import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
@@ -461,4 +463,20 @@
this.reverse = reverse;
}
}
+
+ public static JLabel newLabel(String text, Object iconKey, int aligment) {
+ Icon icon = null;
+ if (iconKey instanceof Icon) {
+ icon = (Icon) iconKey;
+ } else if (iconKey instanceof String) {
+ icon = jaxx.runtime.Util.getUIManagerActionIcon((String) iconKey);
+ }
+ JLabel result;
+ if (icon == null) {
+ result = new JLabel(text, aligment);
+ } else {
+ result = new JLabel(text, icon, aligment);
+ }
+ return result;
+ }
}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-03-24 00:58:12 UTC (rev 1278)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-03-24 14:37:47 UTC (rev 1279)
@@ -14,25 +14,81 @@
*/
public interface WizardUI<E extends WizardStep, M extends WizardModel<E>> {
+ /**
+ * @return le modèle de wizard
+ */
M getModel();
+ /**
+ *
+ * @return l'étape courante
+ */
E getSelectedStep();
+ /**
+ *
+ * @return l'ui de l'étape courante
+ */
WizardStepUI<E, M> getSelectedStepUI();
+ /**
+ *
+ * @param step l'étape donnée
+ * @return l'ui de l'étape donnée
+ */
WizardStepUI<E, M> getStepUI(E step);
-
+
+ /**
+ *
+ * @param stepIndex la position de l'étape
+ * @return l'ui de l'étape donée
+ */
WizardStepUI<E, M> getStepUI(int stepIndex);
+ /**
+ * démarre le wizard
+ */
void start();
+ /**
+ * //TODO il faudrait supprimer cette méthode
+ * @return le conteneur d'ui d'étapes
+ */
JTabbedPane getTabs();
+ /**
+ * Méthode invoqué lorsque la première opération du modèlé a été démarrée.
+ */
+ void onWasStarted();
+
+ /**
+ * Méthode invoquée lorsque l'univers des étapes a été modifié dans le
+ * modèle.
+ *
+ * @param steps les nouvelles étapes
+ */
void onStepsChanged(E[] steps);
-
+
+ /**
+ * Méthode invoquée lorsque l'étape courante a changé dans le modèle.
+ *
+ * @param newStep la nouvelle étape courante
+ */
void onStepChanged(E newStep);
+ /**
+ * Méthode invoquée lorsque l'état interne du modèle a changé.
+ *
+ * @param newState le nouvelle état du modèle de wizard
+ */
void onModelStateChanged(WizardOperationState newState);
+ /**
+ * Méthode invoqué lorsque l'état d'une opération a changé.
+ *
+ * @param step l'étape dont l'état a changé
+ * @param newState le nouvel état pour l'étape donné
+ */
void onOperationStateChanged(E step,WizardOperationState newState) ;
+
}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2009-03-24 00:58:12 UTC (rev 1278)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2009-03-24 14:37:47 UTC (rev 1279)
@@ -47,7 +47,7 @@
}
}
- public static void addTraceLogListener(final Log log,WizardModel model) {
+ public static void addTraceLogListener(final Log log, WizardModel model) {
if (log.isTraceEnabled()) {
model.addPropertyChangeListener(new PropertyChangeListener() {
@@ -65,7 +65,11 @@
@Override
@SuppressWarnings("unchecked")
public void propertyChange(PropertyChangeEvent evt) {
- String propertyName = evt.getPropertyName();
+ String propertyName = evt.getPropertyName();
+ if (WizardOperationModel.WAS_STARTED_PROPERTY_NAME.equals(propertyName)) {
+ ui.onWasStarted();
+ return;
+ }
if (WizardModel.STEPS_PROPERTY_NAME.equals(propertyName)) {
java.util.List<E> steps = (java.util.List<E>) evt.getNewValue();
ui.onStepsChanged(steps.toArray((E[]) Array.newInstance(ui.getModel().stepClass, steps.size())));
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-config.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-message.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-next.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-pause.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-previous.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-refresh.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-start.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-canceled.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-failed.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-need_fix.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-pending.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-running.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed-16.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed-16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/resources/icons/action-wizard-state-successed.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
1
0
r1278 - jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator
by tchemit@users.labs.libre-entreprise.org March 24, 2009
by tchemit@users.labs.libre-entreprise.org March 24, 2009
March 24, 2009
Author: tchemit
Date: 2009-03-24 00:58:12 +0000 (Tue, 24 Mar 2009)
New Revision: 1278
Modified:
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
Log:
add scopes getter on BeanValidator
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-03-23 11:34:36 UTC (rev 1277)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-03-24 00:58:12 UTC (rev 1278)
@@ -106,6 +106,10 @@
return fields;
}
+ public Set<BeanValidatorScope> getScopes() {
+ return new java.util.HashSet< BeanValidatorScope>(validators.keySet());
+ }
+
/**
* Retourne vrai si l'objet bean a ete modifie depuis le dernier
* {@link #setBean}
1
0
r1277 - jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing
by tchemit@users.labs.libre-entreprise.org March 23, 2009
by tchemit@users.labs.libre-entreprise.org March 23, 2009
March 23, 2009
Author: tchemit
Date: 2009-03-23 11:34:36 +0000 (Mon, 23 Mar 2009)
New Revision: 1277
Modified:
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
Log:
can clear the validator models
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-03-23 00:02:52 UTC (rev 1276)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-03-23 11:34:36 UTC (rev 1277)
@@ -44,6 +44,14 @@
validator.addBeanValidatorListener(this);
}
+ public void clear() {
+ int i = data.size();
+ if (i > 0) {
+ data.clear();
+ fireIntervalRemoved(this, 0, i - 1);
+ }
+ }
+
@Override
public int getSize() {
return data.size();
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-03-23 00:02:52 UTC (rev 1276)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-03-23 11:34:36 UTC (rev 1277)
@@ -93,6 +93,14 @@
removeMessages(validator, field, scope, true, messages);
}
+ public void clear() {
+ int i = data.size();
+ if (i > 0) {
+ data.clear();
+ fireTableRowsDeleted(0, i - 1);
+ }
+ }
+
/**
* Obtain the message for a given row.
*
@@ -307,7 +315,7 @@
for (int i = getRowCount() - 1; i > -1; i--) {
SwingValidatorMessage error = data.get(i);
- if (error.getEditor() == editor && (scope==null || error.getScope() == scope) && error.getFieldName().equals(fieldName)) {
+ if (error.getEditor() == editor && (scope == null || error.getScope() == scope) && error.getFieldName().equals(fieldName)) {
// remove the message
data.remove(i);
if (notify) {
1
0
r1276 - jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime
by tchemit@users.labs.libre-entreprise.org March 23, 2009
by tchemit@users.labs.libre-entreprise.org March 23, 2009
March 23, 2009
Author: tchemit
Date: 2009-03-23 00:02:52 +0000 (Mon, 23 Mar 2009)
New Revision: 1276
Modified:
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java
Log:
when using validatorLabel, do not translate it immedialty
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java 2009-03-21 16:13:18 UTC (rev 1275)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java 2009-03-23 00:02:52 UTC (rev 1276)
@@ -134,7 +134,7 @@
public static String getMessage(SwingValidatorMessage model) {
String text = model.getMessage();
- if (model.getField()!=null) {
+ if (model.getField() != null) {
text = model.getField().getI18nError(text);
}
return text;
@@ -144,12 +144,12 @@
String text = null;
JComponent editor = model.getEditor();
if (editor != null) {
- String l = (String) editor.getClientProperty("validatorLabel");
- if (l != null) {
+ text = (String) editor.getClientProperty("validatorLabel");
+ /*if (l != null) {
text = I18n._(l);
} else {
// TODO should try the text
- }
+ }*/
}
if (text == null) {
text = value;
1
0
r1275 - in jaxx/trunk: jaxx-compiler-api jaxx-compiler-api/src/main/java/jaxx/compiler jaxx-compiler-validator jaxx-compiler-validator/src/main/java/jaxx/compiler jaxx-compiler-validator/src/main/java/jaxx/tags/validator jaxx-example jaxx-example/src/main/java/jaxx/demo jaxx-example/src/main/resources/i18n jaxx-runtime-swing jaxx-runtime-validator jaxx-runtime-validator/src/main/java/jaxx/runtime jaxx-runtime-validator/src/main/java/jaxx/runtime/validator jaxx-runtime-validator/src/test/java/
by tchemit@users.labs.libre-entreprise.org March 21, 2009
by tchemit@users.labs.libre-entreprise.org March 21, 2009
March 21, 2009
Author: tchemit
Date: 2009-03-21 16:13:18 +0000 (Sat, 21 Mar 2009)
New Revision: 1275
Added:
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/BeanValidatorUtil.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
Removed:
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/SwingValidationUtil.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator2.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java
Modified:
jaxx/trunk/jaxx-compiler-api/changelog.txt
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
jaxx/trunk/jaxx-compiler-validator/changelog.txt
jaxx/trunk/jaxx-compiler-validator/pom.xml
jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/compiler/ValidatorGenerator.java
jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
jaxx/trunk/jaxx-example/changelog.txt
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
jaxx/trunk/jaxx-runtime-swing/changelog.txt
jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt
jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
jaxx/trunk/jaxx-runtime-validator/changelog.txt
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/JAXXValidator.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java
jaxx/trunk/maven-jaxx-plugin/changelog.txt
jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
Log:
validator refactor end
Modified: jaxx/trunk/jaxx-compiler-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,4 +1,5 @@
-1.3 chemit 20090320
+1.3 chemit 20090321
+ * 20090321 [chemit] - add compilerCount in launchro to known how mush files where generated
* 20090313 [chemit] - can now use geneticType on javaBean object
- add an extra method $afterCompleteSetup method to be included if find in script at last statement of $completeSetup method
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -141,6 +141,7 @@
protected LifeCycle currentPass;
protected int errorCount;
protected int warningCount;
+ protected int compilerCount;
protected JAXXProfile profiler;
protected JAXXCompilerLaunchor(File[] files, String[] classNames, CompilerOptions options) {
@@ -233,6 +234,7 @@
*/
public synchronized boolean compile() {
//reset(); // just to be safe...
+ compilerCount = 0;
jaxxFiles.addAll(Arrays.asList(files));
jaxxFileClassNames.addAll(Arrays.asList(classNames));
try {
@@ -375,6 +377,7 @@
e.printStackTrace();
return false;
} finally {
+ compilerCount = compilers.size();
//TC - 20081018 only reset when no error was detected
if (options.isResetAfterCompile() && errorCount == 0) {
reset();
@@ -382,6 +385,10 @@
}
}
+ public int getCompilerCount() {
+ return compilerCount;
+ }
+
protected JAXXCompiler getCompiler(String className, String message) {
JAXXCompiler compiler = compilers.get(className);
if (compiler == null) {
@@ -441,5 +448,4 @@
System.out.println();
System.out.println("See http://www.jaxxframework.org/ for full documentation.");
}
-
}
Modified: jaxx/trunk/jaxx-compiler-validator/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/changelog.txt 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-compiler-validator/changelog.txt 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,4 +1,4 @@
-1.3 chemit 20090320
+1.3 chemit 20090321
1.1 chemit 20090220
* 20090202 [chemit] - refactor validators (this module will soon disappear to jaxx-compiler-swing-validator)
Modified: jaxx/trunk/jaxx-compiler-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-03-21 16:13:18 UTC (rev 1275)
@@ -28,6 +28,12 @@
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>jaxx-runtime-validator-swing</artifactId>
<version>${project.version}</version>
</dependency>
Modified: jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/compiler/ValidatorGenerator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -34,7 +34,7 @@
boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId());
if (found) {
// box the child component in a JxLayer
- child.setChildJavaCode("jaxx.runtime.SwingUtil.boxComponentWithJxLayer(" + javaCode + ")");
+ child.setChildJavaCode(jaxx.runtime.SwingUtil.class.getName()+".boxComponentWithJxLayer(" + javaCode + ")");
}
}
}
@@ -45,7 +45,8 @@
compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
compiler.appendLateInitializer("getValidator(" + id + ").installUIs();");
compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
- compiler.appendLateInitializer("getValidator(" + id + ").validate();");
+ compiler.appendLateInitializer("getValidator(" + id + ").reloadBean();");
+ //compiler.appendLateInitializer("getValidator(" + id + ").validate();");
compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
}
compiler.appendLateInitializer("validatorIds = java.util.Collections.unmodifiableList(validatorIds);");
Modified: jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -11,7 +11,7 @@
import jaxx.introspection.JAXXPropertyDescriptor;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.validator.SwingValidationUtil;
+import jaxx.runtime.SwingValidatorUtil;
import jaxx.runtime.validator.swing.SwingValidator;
import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
import jaxx.tags.DefaultObjectHandler;
@@ -35,33 +35,23 @@
public static final String BEAN_ATTRIBUTE = "bean";
public static final String BEAN_CLASS_ATTRIBUTE = "beanClass";
public static final String BEAN_INITIALIZER_ATTRIBUTE = "beanInitializer";
-
public static final String ERROR_LIST_MODEL_ATTRIBUTE = "errorListModel";
public static final String ERROR_TABLE_MODEL_ATTRIBUTE = "errorTableModel";
public static final String ERROR_LIST_ATTRIBUTE = "errorList";
public static final String ERROR_TABLE_ATTRIBUTE = "errorTable";
-
public static final String ERROR_LIST_MODEL_DEFAULT = "errors";
public static final String ERROR_TABLE_MODEL_DEFAULT = "errors2";
-
public static final String ERROR_LIST_DEFAULT = "errorList";
public static final String ERROR_TABLE_DEFAULT = "errorTable";
-
public static final String AUTOFIELD_ATTRIBUTE = "autoField";
public static final String UI_CLASS_ATTRIBUTE = "uiClass";
public static final String STRICT_MODE_ATTRIBUTE = "strictMode";
-
public static final String CONTEXT_NAME_ATTRIBUTE = "contextName";
-
//public static final String SCOPE_ATTRIBUTE = "scope";
-
public static final String PARENT_VALIDATOR_ATTRIBUTE = "parentValidator";
-
/** to use log facility, just put in your code: log.info(\"...\"); */
static Log log = LogFactory.getLog(BeanValidatorHandler.class);
-
protected static Map<JAXXCompiler, List<CompiledBeanValidator>> validators = new HashMap<JAXXCompiler, List<CompiledBeanValidator>>();
-
protected static Map<JAXXCompiler, List<String>> validatedComponents = new HashMap<JAXXCompiler, List<String>>();
public BeanValidatorHandler(ClassDescriptor beanClass) {
@@ -116,11 +106,11 @@
}
/*if (!error) {
- error = info.addContextName(this, compiler);
+ error = info.addContextName(this, compiler);
}*/
/*if (!error) {
- error = info.addScope(this, compiler);
+ error = info.addScope(this, compiler);
}*/
if (!error) {
@@ -317,13 +307,13 @@
//TC-20090111 beanClass is mandatory
// get the real bean class name (from bean or beanClass)
/*if (beanClass != null) {
- beanClassName = beanClass;
+ beanClassName = beanClass;
} else {
- beanClassName = compiler.getSymbolTable().getClassTagIds().get(bean);
- if (beanClassName == null) {
- compiler.reportError("could not find class of the bean '" + bean + "'");
- return null;
- }
+ beanClassName = compiler.getSymbolTable().getClassTagIds().get(bean);
+ if (beanClassName == null) {
+ compiler.reportError("could not find class of the bean '" + bean + "'");
+ return null;
+ }
}*/
ClassDescriptor beanClassDescriptor = ClassDescriptorLoader.getClassDescriptor(beanClass);
beanDescriptor = DefaultObjectHandler.getJAXXBeanInfo(beanClassDescriptor);
@@ -419,21 +409,20 @@
}
/*protected boolean addContextName(BeanValidatorHandler handler, JAXXCompiler compiler) {
- if (contextName != null) {
- String code = handler.getSetPropertyCode(getJavaCode(), CONTEXT_NAME_ATTRIBUTE, TypeManager.getJavaCode(contextName), compiler);
- appendAdditionCode(code);
- }
- return false;
+ if (contextName != null) {
+ String code = handler.getSetPropertyCode(getJavaCode(), CONTEXT_NAME_ATTRIBUTE, TypeManager.getJavaCode(contextName), compiler);
+ appendAdditionCode(code);
+ }
+ return false;
}*/
/*protected boolean addScope(BeanValidatorHandler handler, JAXXCompiler compiler) {
- if (scope != null) {
- String code = handler.getSetPropertyCode(getJavaCode(), SCOPE_ATTRIBUTE, TypeManager.getJavaCode(scope), compiler);
- appendAdditionCode(code);
- }
- return false;
+ if (scope != null) {
+ String code = handler.getSetPropertyCode(getJavaCode(), SCOPE_ATTRIBUTE, TypeManager.getJavaCode(scope), compiler);
+ appendAdditionCode(code);
+ }
+ return false;
}*/
-
protected boolean addParentValidator(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) {
if (parentValidator != null) {
String initializer;
@@ -470,7 +459,7 @@
}
}
- String code = SwingValidationUtil.class.getName() + ".registerErrorListMouseListener(" + errorList + ");";
+ String code = SwingValidatorUtil.class.getName() + ".registerErrorListMouseListener(" + errorList + ");";
appendAdditionCode(code);
return false;
@@ -490,7 +479,7 @@
}
}
- String code = SwingValidationUtil.class.getName() + ".registerErrorTableMouseListener(" + errorTable + ");";
+ String code = SwingValidatorUtil.class.getName() + ".registerErrorTableMouseListener(" + errorTable + ");";
appendAdditionCode(code);
return false;
@@ -541,7 +530,7 @@
}
/*if (beanInitializer != null) {
- compiler.reportWarning("tag '" + tag + "' found a 'bean' and a 'beanInitializer' attributes, 'beanInitializer' is skipped");
+ compiler.reportWarning("tag '" + tag + "' found a 'bean' and a 'beanInitializer' attributes, 'beanInitializer' is skipped");
}*/
beanInitializer = bean;
}
@@ -603,9 +592,9 @@
continue;
}
/*if (compiler.isComponentUsedByValidator(component)) {
- // component is already used by another validator
- compiler.reportError("component '" + component + "' is already used by another validator.");
- continue;
+ // component is already used by another validator
+ compiler.reportError("component '" + component + "' is already used by another validator.");
+ continue;
}*/
String keyCode = TypeManager.getJavaCode(propertyName);
appendAdditionCode(getJavaCode() + ".setFieldRepresentation(" + keyCode + ", " + component + ");");
Modified: jaxx/trunk/jaxx-example/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-example/changelog.txt 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-example/changelog.txt 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,4 +1,4 @@
-1.3 chemit 20090320
+1.3 chemit 20090321
* 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
* 20090313 [chemit] - improve demo
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,15 +1,10 @@
<DemoPanel>
<style source="Validation.css"/>
-<script>
-void $afterCompleteSetup() {
- validator.setBean(null);
- validator2.setBean(null);
- validator3.setBean(null);
- validator.setBean(model1);
- validator2.setBean(model2);
- validator3.setBean(identity);
-}
+<script><![CDATA[
+import static org.codelutin.i18n.I18n.n_;
+void $afterCompleteSetup() {
+}]]>
</script>
<!-- models -->
<Model id='model1'/>
@@ -48,6 +43,7 @@
</cell>
<cell weightx='1'>
<JTextField id='text' text='{model1.getText()}'
+ _validatorLabel='{n_("form.text")}'
onKeyReleased='model1.setText(text.getText())'/>
</cell>
</row>
@@ -57,6 +53,7 @@
</cell>
<cell weightx='1'>
<JTextField id='text2' text='{model1.getText2()}'
+ _validatorLabel='{n_("form.text2")}'
onKeyReleased='model1.setText2(text2.getText())'/>
</cell>
</row>
@@ -66,7 +63,9 @@
<JLabel text='Ratio:'/>
</cell>
<cell>
- <JSlider id='ratio' minimum='0' maximum='100' value='{model1.getRatio()}'
+ <JSlider id='ratio' minimum='0' maximum='100'
+ value='{model1.getRatio()}'
+ _validatorLabel='{n_("form.ratio")}'
onStateChanged='model1.setRatio(ratio.getValue())'/>
</cell>
</row>
@@ -117,6 +116,7 @@
</cell>
<cell weightx='1'>
<JTextField id='_text' text='{model2.getText()}'
+ _validatorLabel='{n_("form2.text")}'
onKeyReleased='model2.setText(_text.getText())'/>
</cell>
</row>
@@ -126,6 +126,7 @@
</cell>
<cell weightx='1'>
<JTextField id='_text2' text='{model2.getText2()}'
+ _validatorLabel='{n_("form2.text2")}'
onKeyReleased='model2.setText2(_text2.getText())'/>
</cell>
</row>
@@ -135,7 +136,9 @@
<JLabel text='Ratio:'/>
</cell>
<cell>
- <JSlider id='_ratio' minimum='0' maximum='100' value='{model2.getRatio()}'
+ <JSlider id='_ratio' minimum='0' maximum='100'
+ value='{model2.getRatio()}'
+ _validatorLabel='{n_("form2.ratio")}'
onStateChanged='model2.setRatio(_ratio.getValue())'/>
</cell>
</row>
@@ -296,10 +299,11 @@
</row>
<row>
<cell columns='2' fill="both">
- <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200'
+ <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
width='500'>
<JScrollPane>
- <JList id='errorList' model='{errors}'/>
+ <JList id='errorList' model='{errors}'
+ cellRenderer='{new jaxx.runtime.validator.swing.SwingValidatorMessageListRenderer()}'/>
</JScrollPane>
</JPanel>
</cell>
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx 2009-03-21 16:13:18 UTC (rev 1275)
@@ -32,15 +32,9 @@
void $afterCompleteSetup() {
errorTable.setDefaultRenderer(Object.class, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer());
+ errorTable.getRowSorter().setSortKeys(java.util.Arrays.asList(new RowSorter.SortKey(0, SortOrder.ASCENDING)));
SwingUtil.setI18nTableHeaderRenderer(errorTable, n_("validator.scope"), n_("validator.scope.tip"), n_("validator.field"), n_("validator.field.tip"), n_("validator.message"), n_("validator.message.tip"));
SwingUtil.fixTableColumnWidth(errorTable, 0, 25);
-
- validator.setBean(null);
- validator2.setBean(null);
- validator3.setBean(null);
- validator.setBean(model1);
- validator2.setBean(model2);
- validator3.setBean(identity);
}
]]></script>
@@ -56,7 +50,9 @@
</cell>
<cell weightx='1'>
<JTextField id='text' text='{model1.getText()}'
- onKeyReleased='model1.setText(text.getText())'/>
+ onKeyReleased='model1.setText(text.getText())'
+ _validatorLabel='{n_("form.text")}'
+ />
</cell>
</row>
<row>
@@ -65,7 +61,9 @@
</cell>
<cell weightx='1'>
<JTextField id='text2' text='{model1.getText2()}'
- onKeyReleased='model1.setText2(text2.getText())'/>
+ onKeyReleased='model1.setText2(text2.getText())'
+ _validatorLabel='{n_("form.text2")}'
+ />
</cell>
</row>
@@ -74,7 +72,9 @@
<JLabel text='Ratio:'/>
</cell>
<cell>
- <JSlider id='ratio' minimum='0' maximum='100' value='{model1.getRatio()}'
+ <JSlider id='ratio' minimum='0' maximum='100'
+ value='{model1.getRatio()}'
+ _validatorLabel='{n_("form.ratio")}'
onStateChanged='model1.setRatio(ratio.getValue())'/>
</cell>
</row>
@@ -125,6 +125,7 @@
</cell>
<cell weightx='1'>
<JTextField id='_text' text='{model2.getText()}'
+ _validatorLabel='{n_("form2.text")}'
onKeyReleased='model2.setText(_text.getText())'/>
</cell>
</row>
@@ -134,6 +135,7 @@
</cell>
<cell weightx='1'>
<JTextField id='_text2' text='{model2.getText2()}'
+ _validatorLabel='{n_("form2.text2")}'
onKeyReleased='model2.setText2(_text2.getText())'/>
</cell>
</row>
@@ -143,7 +145,9 @@
<JLabel text='Ratio:'/>
</cell>
<cell>
- <JSlider id='_ratio' minimum='0' maximum='100' value='{model2.getRatio()}'
+ <JSlider id='_ratio' minimum='0' maximum='100'
+ value='{model2.getRatio()}'
+ _validatorLabel='{n_("form2.ratio")}'
onStateChanged='model2.setRatio(_ratio.getValue())'/>
</cell>
</row>
@@ -304,10 +308,10 @@
</row>
<row>
<cell columns='2' fill="both">
- <JPanel border='{BorderFactory.createTitledBorder("Errors")}' layout='{new GridLayout()}' height='200'
+ <JPanel border='{BorderFactory.createTitledBorder("Messages")}' layout='{new GridLayout()}' height='200'
width='500'>
<JScrollPane columnHeaderView='{errorTable.getTableHeader()}'>
- <JTable id='errorTable' model='{errors2}' rowSelectionAllowed='true'
+ <JTable id='errorTable' model='{errors2}' rowSelectionAllowed='true' autoCreateRowSorter='true'
autoResizeMode='2' cellSelectionEnabled='false' selectionMode='0'/>
</JScrollPane>
</JPanel>
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-03-21 16:13:18 UTC (rev 1275)
@@ -99,6 +99,12 @@
edit2=
edit3=
emptyNode=< empty node >
+form.ratio=Form \: ratio
+form.text=Form \: text
+form.text2=Form \: text2
+form2.ratio=Form2 \: ratio
+form2.text=Form2 \: text
+form2.text2=Form2 \: text2
no\ layer=
valid=
validator.field=Champ
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-03-21 16:13:18 UTC (rev 1275)
@@ -99,6 +99,12 @@
edit2=
edit3=
emptyNode=< empty node >
+form.ratio=Form \: ratio
+form.text=Form \: text
+form.text2=Form \: text2
+form2.ratio=Form2 \: ratio
+form2.text=Form2 \: text
+form2.text2=Form2 \: text2
no\ layer=
valid=
validator.field=Champ
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,4 +1,4 @@
-1.3 chemit 20090320
+1.3 chemit 20090321
* 20090318 [chemit] - introduce the BlockingLayerUI2 class (should be merge with BlockingLayerUI)
* 20090318 [chemit] - introduce the CardLayout2Ext class
* 20090312 [chemit] - add some usefull code from ObServe (load Nimbus L&F, load ui configuration)
Modified: jaxx/trunk/jaxx-runtime-validator/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,5 +1,6 @@
-1.3 chemit 20090320
- * 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
+1.3 chemit 20090321
+ * 20090320 [chemit] - rename and move ValidationUtil to jaxx.runtime.BeanValidatorUtil
+ * 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
1.1 chemit 20090220
* 20090203 [chemit] - move swing specific code to jaxx-runtime-validator-swing module
Added: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/BeanValidatorUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/BeanValidatorUtil.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/BeanValidatorUtil.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -0,0 +1,152 @@
+package jaxx.runtime;
+
+import jaxx.runtime.validator.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The helper class for validation module.
+ *
+ * @author chemit
+ */
+public class BeanValidatorUtil {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(BeanValidatorUtil.class);
+
+ protected BeanValidatorUtil() {
+ // no instance
+ }
+
+ /**
+ * Convinient method to attach a bean to all validators of an JAXXObject.
+ * <p/>
+ * It is possible to exclude some validator to be treated.
+ *
+ * @param ui the ui containing the validatros to treate
+ * @param bean the bean to attach in validators (can be null)
+ * @param excludeIds the list of validator id to exclude
+ */
+ @SuppressWarnings({"unchecked"})
+ public static void setValidatorBean(JAXXObject ui, Object bean, String... excludeIds) {
+ if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
+ return;
+ }
+ JAXXValidator jaxxValidator = (JAXXValidator) ui;
+ List<String> validatorIds = jaxxValidator.getValidatorIds();
+ if (excludeIds.length > 0) {
+ validatorIds = new ArrayList<String>(validatorIds);
+ for (String excludeId : excludeIds) {
+ validatorIds.remove(excludeId);
+ }
+ }
+ for (String validatorId : validatorIds) {
+ BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
+ if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) {
+ // touch validator, only if fits the bean type (or bean is null)
+ beanValidator.setBean(bean);
+ }
+ }
+ }
+
+ /**
+ * Convinient method to set the changed property to all validators of an JAXXObject.
+ * <p/>
+ * It is possible to exclude some validator to be treated.
+ *
+ * @param ui the ui containing the validatros to treate
+ * @param newValue the new value to set in changed validator property
+ * @param excludeIds the list of validator id to exclude
+ */
+ @SuppressWarnings({"unchecked"})
+ public static void setValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds) {
+ if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
+ return;
+ }
+ JAXXValidator jaxxValidator = (JAXXValidator) ui;
+ List<String> validatorIds = jaxxValidator.getValidatorIds();
+ if (excludeIds.length > 0) {
+ validatorIds = new ArrayList<String>(validatorIds);
+ for (String excludeId : excludeIds) {
+ validatorIds.remove(excludeId);
+ }
+ }
+ for (String validatorId : validatorIds) {
+ BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
+ beanValidator.setChanged(newValue);
+ }
+ }
+
+ /**
+ * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator.
+ *
+ * @param validator validator to be involved
+ * @param fieldName the name of the bean property
+ * @param value the actual value to convert
+ * @param valueClass the type of the conversion
+ */
+ public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) {
+
+ Object result = validator.convert(fieldName, value, valueClass);
+ if (result != null) {
+ try {
+ BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass());
+
+ for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
+ if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) {
+
+ descriptor.getWriteMethod().invoke(validator.getBean(), result);
+ break;
+ }
+ }
+ } catch (IntrospectionException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
+ }
+ } else {
+ //fixme : conversion failed, we should be able to notify ui that values has changed ?
+ // otherwise, bean value has not changed,...
+ }
+ }
+
+ public static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) {
+ try {
+ // check that the bean is listenable, otherwise, can't use
+ // the validator on it
+ BeanInfo infos = Introspector.getBeanInfo(beanClass);
+ EventSetDescriptor[] events = infos.getEventSetDescriptors();
+ for (EventSetDescriptor event : events) {
+ if ("propertyChange".equals(event.getName())) {
+
+ if (event.getAddListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass);
+ }
+ if (event.getRemoveListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass);
+ }
+ return event;
+ }
+ }
+
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass);
+ } catch (IntrospectionException ex) {
+ throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex);
+ }
+ }
+
+}
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/JAXXValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/JAXXValidator.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/JAXXValidator.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -2,7 +2,7 @@
import java.util.List;
-import jaxx.runtime.validator.BeanValidator2;
+import jaxx.runtime.validator.BeanValidator;
/**
* The contract of a validator-able object.
@@ -17,7 +17,7 @@
* @param validatorId validator id
* @return the associated validator, or <code>null</code> if not find
*/
- BeanValidator2<?> getValidator(String validatorId);
+ BeanValidator<?> getValidator(String validatorId);
/** @return the list of ids of all registred validator */
List<String> getValidatorIds();
Copied: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java (from rev 1273, jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator2.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -0,0 +1,459 @@
+package jaxx.runtime.validator;
+
+import jaxx.runtime.BeanValidatorUtil;
+import java.beans.EventSetDescriptor;
+import org.apache.commons.beanutils.ConversionException;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ConverterUtil;
+
+import java.beans.Introspector;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+import javax.swing.event.EventListenerList;
+
+/**
+ *
+ * A customized validator for a given bean.
+ *
+ * <b>Note:</b> The bean must be listenable on properyChange events (means
+ * must have public addPropertychangeListener and removePropertyChangeListener methods).
+ *
+ * @param <B> type of the bean to validate.
+ *
+ * @author chemit
+ */
+public class BeanValidator<B> {
+
+ /** la nom de la propriété bean */
+ static public final String BEAN_PROERTY = "bean";
+ /** la nom de la propriété contextName */
+ static public final String CONTEXT_NAME_PROPERTY = "contextName";
+ /** la nom de l'état valid */
+ static public final String VALID_PROERTY = "valid";
+ /** la nom de l'état changed */
+ static public final String CHANGED_PROERTY = "changed";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static protected final Log log = LogFactory.getLog(BeanValidator.class);
+ /** the type of bean to watch */
+ protected final Class<B> beanClass;
+ /** the validation named context (can be null) */
+ protected String contextName;
+ /** to chain to a prent validator */
+ protected BeanValidator<?> parentValidator;
+ /** state to indicate that validator has changed since the last time bean was setted */
+ protected boolean changed = false;
+ /** state of the validator (is true if no errors of error scope is found) */
+ protected boolean valid = true;
+ /** bean to be watched */
+ protected B bean = null;
+ /** to add and remove PropertyChangeListener on watched beans */
+ protected EventSetDescriptor beanEventDescriptor;
+ /** list of fields watched by this validator */
+ protected Set<BeanValidatorField<B>> fields;
+ /** map of conversion errors detected by this validator */
+ protected Map<String, String> conversionErrors;
+ /** xworks scope validator **/
+ protected EnumMap<BeanValidatorScope, XWorkBeanValidator<B>> validators;
+ /** listener that listens on bean modification */
+ protected PropertyChangeListener l;
+ /** delegate property change support */
+ protected PropertyChangeSupport pcs;
+ /** A list of event listeners for this validators */
+ protected EventListenerList listenerList = new EventListenerList();
+
+ public BeanValidator(Class<B> beanClass, String contextName) {
+ this.beanClass = beanClass;
+ this.pcs = new PropertyChangeSupport(this);
+ this.conversionErrors = new TreeMap<String, String>();
+ this.validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(BeanValidatorScope.class);
+
+ setContextName(contextName);
+
+ l = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ validate();
+ setValid(!hasErrors());
+ setChanged(true);
+ }
+ };
+ }
+
+ public Class<B> getBeanClass() {
+ return beanClass;
+ }
+
+ public BeanValidator<?> getParentValidator() {
+ return parentValidator;
+ }
+
+ public String getContextName() {
+ return contextName;
+ }
+
+ public Set<BeanValidatorField<B>> getFields() {
+ return fields;
+ }
+
+ /**
+ * Retourne vrai si l'objet bean a ete modifie depuis le dernier
+ * {@link #setBean}
+ *
+ * @return <code>true</code> if bean was modify since last {@link #setBean(Object)} invocation
+ */
+ public boolean isChanged() {
+ return changed;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public B getBean() {
+ return bean;
+ }
+
+ public BeanValidatorField<B> getField(String fieldName) {
+ for (BeanValidatorField<B> field : fields) {
+ if (fieldName.equals(field.getName())) {
+ return field;
+ }
+ }
+ return null;
+ }
+
+ public boolean hasErrors() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasErrors()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasWarnings() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasWarnings()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasInfos() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasInfos()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Test a the validator contains the field given his name
+ *
+ * @param fieldName the name of the searched field
+ * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise
+ */
+ public boolean containsField(String fieldName) {
+ BeanValidatorField<B> field = getField(fieldName);
+ return field != null;
+ }
+
+ public boolean isValid(String fieldName) {
+ BeanValidatorField<B> field = getField(fieldName);
+ if (field == null) {
+ throw new IllegalArgumentException("could not find a validator field " + fieldName);
+ }
+ return field.isValid();
+ }
+
+ /**
+ * Permet de force la remise a false de l'etat de changement du bean
+ *
+ * @param changed flag to force reset of property {@link #changed}
+ */
+ public void setChanged(boolean changed) {
+ this.changed = changed;
+ // force the property to be fired (never pass the older value)
+ pcs.firePropertyChange(CHANGED_PROERTY, null, changed);
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
+ // force the property to be fired (never pass the older value)
+ pcs.firePropertyChange(VALID_PROERTY, null, valid);
+ }
+
+ public void setBean(B bean) {
+ B oldBean = this.bean;
+ if (log.isDebugEnabled()) {
+ log.debug(this + " : " + bean);
+ }
+
+ // clean conversions of previous bean
+ conversionErrors.clear();
+
+ if (oldBean != null) {
+ try {
+ getBeanEventDescriptor(oldBean).getRemoveListenerMethod().invoke(oldBean, l);
+ } catch (Exception eee) {
+ log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
+ }
+ }
+ this.bean = bean;
+
+ if (bean == null) {
+
+ // remove all messages for all fields of the validator
+
+ for (BeanValidatorField<B> f : fields) {
+
+ f.updateMessages(this, null, null);
+ }
+
+ } else {
+ try {
+ getBeanEventDescriptor(bean).getAddListenerMethod().invoke(bean, l);
+ } catch (Exception eee) {
+ log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
+ }
+ validate();
+ }
+ setChanged(false);
+ setValid(!hasErrors());
+ pcs.firePropertyChange(BEAN_PROERTY, oldBean, bean);
+ }
+
+ public void setContextName(String contextName) {
+ String oldValidationContextName = this.contextName;
+ this.contextName = contextName;
+ // changing contextName could change fields definition
+ // so dettach bean, must rebuild the fields
+ if (bean != null) {
+ setBean(null);
+ }
+ // rebuild the fields
+ initFields();
+ pcs.firePropertyChange(CONTEXT_NAME_PROPERTY, oldValidationContextName, contextName);
+ }
+
+ public void setParentValidator(BeanValidator<?> parentValidator) {
+ this.parentValidator = parentValidator;
+ }
+
+ /**
+ * Convert a value.
+ * <p/>
+ * If an error occurs, then add an error in validator.
+ *
+ * @param <T> the type of conversion
+ * @param fieldName the name of the bean property
+ * @param value the value to convert
+ * @param valueClass the type of converted value
+ * @return the converted value, or null if conversion was not ok
+ */
+ @SuppressWarnings({"unchecked"})
+ public <T> T convert(String fieldName, String value, Class<T> valueClass) {
+ if (fieldName == null) {
+ throw new IllegalArgumentException("fieldName can not be null");
+ }
+ if (valueClass == null) {
+ throw new IllegalArgumentException("valueClass can not be null");
+ }
+
+ // on ne convertit pas si il y a un bean et que le resultat de la validation
+ // pourra etre affiche quelque part
+ if (!canValidate() || value == null) {
+ return null;
+ }
+
+ // remove the previous conversion error for the field
+ conversionErrors.remove(fieldName);
+
+ T result;
+ try {
+ Converter converter = ConverterUtil.getConverter(valueClass);
+ if (converter == null) {
+ throw new RuntimeException("could not find converter for the type " + valueClass);
+ }
+ result = (T) converter.convert(valueClass, value);
+ /* Why this test ? if (result != null && !value.equals(result.toString())) {
+ conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
+ result = null;
+ validate();
+ }*/
+ } catch (ConversionException e) {
+ // get
+ conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
+ result = null;
+ validate();
+ }
+ return result;
+ }
+
+ /**
+ * il faut eviter le code re-intrant (durant une validation, une autre est
+ * demandee). Pour cela on fait la validation dans un thread, et tant
+ * que la premiere validation n'est pas fini, on ne repond pas aux
+ * solicitations.
+ * Cette method est public pour permettre de force une validation par
+ * programmation, ce qui est utile par exemple si le bean ne supporte
+ * pas les {@link PropertyChangeListener}
+ */
+ public void validate() {
+
+ // on ne valide que si il y a un bean et que le resultat de la validation
+ // pourra etre affiche quelque part
+ if (!canValidate()) {
+ return;
+ }
+
+ for (BeanValidatorScope scope : validators.keySet()) {
+
+ XWorkBeanValidator<B> validator = validators.get(scope);
+
+ Map<String, List<String>> newMessages = validator.validate(bean);
+
+ if (scope == BeanValidatorScope.ERROR) {
+ // treate conversion errors
+ // reinject them
+ for (Entry<String, String> entry : conversionErrors.entrySet()) {
+ // remove from validation, errors occurs on this field
+ List<String> errors = newMessages.get(entry.getKey());
+ String conversionError = entry.getValue();
+ if (errors != null) {
+ errors.clear();
+ errors.add(conversionError);
+ } else {
+ errors = java.util.Collections.singletonList(conversionError);
+ // add the concrete conversion error
+ newMessages.put(entry.getKey(), errors);
+ }
+ }
+ }
+
+ // for each field, update his list of messages
+ for (BeanValidatorField<B> field : fields) {
+ List<String> messagesForField = newMessages.get(field.getName());
+ if (field.getScopes().contains(scope)) {
+ field.updateMessages(this, scope, messagesForField);
+ }
+ }
+ }
+
+ if (parentValidator != null) {
+ // chained validation
+ parentValidator.l.propertyChange(null);
+ }
+
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">";
+ }
+
+ public void addBeanValidatorListener(BeanValidatorListener listener) {
+ listenerList.add(BeanValidatorListener.class, listener);
+ }
+
+ public void removeBeanValidatorListener(BeanValidatorListener listener) {
+ listenerList.remove(BeanValidatorListener.class, listener);
+ }
+
+ public BeanValidatorListener[] getBeanValidatorListeners() {
+ return listenerList.getListeners(BeanValidatorListener.class);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ /** @return <code>true</code> if validation is enabled, <code>false</code> otherwise. */
+ protected boolean canValidate() {
+ return !(bean == null || fields.isEmpty());
+ }
+
+ protected void fireFieldChanged(BeanValidatorField<B> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
+
+ BeanValidatorEvent evt = new BeanValidatorEvent(this, field, scope, toAdd, toDelete);
+
+ for (BeanValidatorListener listener : listenerList.getListeners(BeanValidatorListener.class)) {
+ listener.onFieldChanged(evt);
+ }
+ }
+
+ protected synchronized void initFields() {
+
+ Set<String> detectedFieldNames = new java.util.HashSet<String>();
+ EnumMap<BeanValidatorScope, Set<String>> tmp = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class);
+ Set<BeanValidatorField<B>> detectedFields = new java.util.HashSet<BeanValidatorField<B>>();
+
+ validators.clear();
+
+ for (BeanValidatorScope scope : BeanValidatorScope.values()) {
+ String scopeContext = (contextName == null ? "" : contextName + "-") + scope.name().toLowerCase();
+
+ XWorkBeanValidator<B> newValidator = new XWorkBeanValidator<B>(beanClass, scopeContext, false);
+ Set<String> fieldNames = newValidator.getFieldNames();
+ if (log.isDebugEnabled()) {
+ log.debug("detected validators for scope " + scopeContext + " : " + fieldNames);
+ }
+ if (!fieldNames.isEmpty()) {
+ // fields detected in this validator, keep it
+ validators.put(scope, newValidator);
+ detectedFieldNames.addAll(fieldNames);
+ tmp.put(scope, fieldNames);
+ }
+ }
+
+ List<BeanValidatorScope> scopes = new ArrayList<BeanValidatorScope>();
+ for (String fieldName : detectedFieldNames) {
+ scopes.clear();
+ // detect scopes for the field
+ for (BeanValidatorScope scope : BeanValidatorScope.values()) {
+ if (tmp.containsKey(scope) && tmp.get(scope).contains(fieldName)) {
+ scopes.add(scope);
+ }
+ }
+ BeanValidatorField<B> f = new BeanValidatorField<B>(beanClass, fieldName, scopes);
+ detectedFields.add(f);
+ }
+ tmp.clear();
+ detectedFieldNames.clear();
+
+ this.fields = java.util.Collections.unmodifiableSet(detectedFields);
+ }
+
+ protected EventSetDescriptor getBeanEventDescriptor(B bean) {
+ if (beanEventDescriptor == null) {
+ // check that the bean is listenable, otherwise, can't use the validator on it
+ this.beanEventDescriptor = BeanValidatorUtil.getPropertyChangeListenerDescriptor(bean.getClass());
+ }
+ return beanEventDescriptor;
+ }
+}
Property changes on: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator2.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator2.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator2.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,458 +0,0 @@
-package jaxx.runtime.validator;
-
-import java.beans.EventSetDescriptor;
-import org.apache.commons.beanutils.ConversionException;
-import org.apache.commons.beanutils.Converter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.util.ConverterUtil;
-
-import java.beans.Introspector;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.TreeMap;
-import javax.swing.event.EventListenerList;
-
-/**
- *
- * A customized validator for a given bean.
- *
- * <b>Note:</b> The bean must be listenable on properyChange events (means
- * must have public addPropertychangeListener and removePropertyChangeListener methods).
- *
- * @param <B> type of the bean to validate.
- *
- * @author chemit
- */
-public class BeanValidator2<B> {
-
- /** la nom de la propriété bean */
- static public final String BEAN_PROERTY = "bean";
- /** la nom de la propriété contextName */
- static public final String CONTEXT_NAME_PROPERTY = "contextName";
- /** la nom de l'état valid */
- static public final String VALID_PROERTY = "valid";
- /** la nom de l'état changed */
- static public final String CHANGED_PROERTY = "changed";
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static protected final Log log = LogFactory.getLog(BeanValidator2.class);
- /** the type of bean to watch */
- protected final Class<B> beanClass;
- /** the validation named context (can be null) */
- protected String contextName;
- /** to chain to a prent validator */
- protected BeanValidator2<?> parentValidator;
- /** state to indicate that validator has changed since the last time bean was setted */
- protected boolean changed = false;
- /** state of the validator (is true if no errors of error scope is found) */
- protected boolean valid = true;
- /** bean to be watched */
- protected B bean = null;
- /** to add and remove PropertyChangeListener on watched beans */
- protected EventSetDescriptor beanEventDescriptor;
- /** list of fields watched by this validator */
- protected Set<BeanValidatorField<B>> fields;
- /** map of conversion errors detected by this validator */
- protected Map<String, String> conversionErrors;
- /** xworks scope validator **/
- protected EnumMap<BeanValidatorScope, XWorkBeanValidator<B>> validators;
- /** listener that listens on bean modification */
- protected PropertyChangeListener l;
- /** delegate property change support */
- protected PropertyChangeSupport pcs;
- /** A list of event listeners for this validators */
- protected EventListenerList listenerList = new EventListenerList();
-
- public BeanValidator2(Class<B> beanClass, String contextName) {
- this.beanClass = beanClass;
- this.pcs = new PropertyChangeSupport(this);
- this.conversionErrors = new TreeMap<String, String>();
- this.validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(BeanValidatorScope.class);
-
- setContextName(contextName);
-
- l = new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- validate();
- setValid(!hasErrors());
- setChanged(true);
- }
- };
- }
-
- public Class<B> getBeanClass() {
- return beanClass;
- }
-
- public BeanValidator2<?> getParentValidator() {
- return parentValidator;
- }
-
- public String getContextName() {
- return contextName;
- }
-
- public Set<BeanValidatorField<B>> getFields() {
- return fields;
- }
-
- /**
- * Retourne vrai si l'objet bean a ete modifie depuis le dernier
- * {@link #setBean}
- *
- * @return <code>true</code> if bean was modify since last {@link #setBean(Object)} invocation
- */
- public boolean isChanged() {
- return changed;
- }
-
- public boolean isValid() {
- return valid;
- }
-
- public B getBean() {
- return bean;
- }
-
- public BeanValidatorField<B> getField(String fieldName) {
- for (BeanValidatorField<B> field : fields) {
- if (fieldName.equals(field.getName())) {
- return field;
- }
- }
- return null;
- }
-
- public boolean hasErrors() {
- for (BeanValidatorField<B> field : fields) {
- if (field.hasErrors()) {
- return true;
- }
- }
- return false;
- }
-
- public boolean hasWarnings() {
- for (BeanValidatorField<B> field : fields) {
- if (field.hasWarnings()) {
- return true;
- }
- }
- return false;
- }
-
- public boolean hasInfos() {
- for (BeanValidatorField<B> field : fields) {
- if (field.hasInfos()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Test a the validator contains the field given his name
- *
- * @param fieldName the name of the searched field
- * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise
- */
- public boolean containsField(String fieldName) {
- BeanValidatorField<B> field = getField(fieldName);
- return field != null;
- }
-
- public boolean isValid(String fieldName) {
- BeanValidatorField<B> field = getField(fieldName);
- if (field == null) {
- throw new IllegalArgumentException("could not find a validator field " + fieldName);
- }
- return field.isValid();
- }
-
- /**
- * Permet de force la remise a false de l'etat de changement du bean
- *
- * @param changed flag to force reset of property {@link #changed}
- */
- public void setChanged(boolean changed) {
- this.changed = changed;
- // force the property to be fired (never pass the older value)
- pcs.firePropertyChange(CHANGED_PROERTY, null, changed);
- }
-
- public void setValid(boolean valid) {
- this.valid = valid;
- // force the property to be fired (never pass the older value)
- pcs.firePropertyChange(VALID_PROERTY, null, valid);
- }
-
- public void setBean(B bean) {
- B oldBean = this.bean;
- if (log.isDebugEnabled()) {
- log.debug(this + " : " + bean);
- }
-
- // clean conversions of previous bean
- conversionErrors.clear();
-
- if (oldBean != null) {
- try {
- getBeanEventDescriptor(oldBean).getRemoveListenerMethod().invoke(oldBean, l);
- } catch (Exception eee) {
- log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
- }
- }
- this.bean = bean;
-
- if (bean == null) {
-
- // remove all messages for all fields of the validator
-
- for (BeanValidatorField<B> f : fields) {
-
- f.updateMessages(this, null, null);
- }
-
- } else {
- try {
- getBeanEventDescriptor(bean).getAddListenerMethod().invoke(bean, l);
- } catch (Exception eee) {
- log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
- }
- validate();
- }
- setChanged(false);
- setValid(!hasErrors());
- pcs.firePropertyChange(BEAN_PROERTY, oldBean, bean);
- }
-
- public void setContextName(String contextName) {
- String oldValidationContextName = this.contextName;
- this.contextName = contextName;
- // changing contextName could change fields definition
- // so dettach bean, must rebuild the fields
- if (bean != null) {
- setBean(null);
- }
- // rebuild the fields
- initFields();
- pcs.firePropertyChange(CONTEXT_NAME_PROPERTY, oldValidationContextName, contextName);
- }
-
- public void setParentValidator(BeanValidator2<?> parentValidator) {
- this.parentValidator = parentValidator;
- }
-
- /**
- * Convert a value.
- * <p/>
- * If an error occurs, then add an error in validator.
- *
- * @param <T> the type of conversion
- * @param fieldName the name of the bean property
- * @param value the value to convert
- * @param valueClass the type of converted value
- * @return the converted value, or null if conversion was not ok
- */
- @SuppressWarnings({"unchecked"})
- public <T> T convert(String fieldName, String value, Class<T> valueClass) {
- if (fieldName == null) {
- throw new IllegalArgumentException("fieldName can not be null");
- }
- if (valueClass == null) {
- throw new IllegalArgumentException("valueClass can not be null");
- }
-
- // on ne convertit pas si il y a un bean et que le resultat de la validation
- // pourra etre affiche quelque part
- if (!canValidate() || value == null) {
- return null;
- }
-
- // remove the previous conversion error for the field
- conversionErrors.remove(fieldName);
-
- T result;
- try {
- Converter converter = ConverterUtil.getConverter(valueClass);
- if (converter == null) {
- throw new RuntimeException("could not find converter for the type " + valueClass);
- }
- result = (T) converter.convert(valueClass, value);
- /* Why this test ? if (result != null && !value.equals(result.toString())) {
- conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
- result = null;
- validate();
- }*/
- } catch (ConversionException e) {
- // get
- conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
- result = null;
- validate();
- }
- return result;
- }
-
- /**
- * il faut eviter le code re-intrant (durant une validation, une autre est
- * demandee). Pour cela on fait la validation dans un thread, et tant
- * que la premiere validation n'est pas fini, on ne repond pas aux
- * solicitations.
- * Cette method est public pour permettre de force une validation par
- * programmation, ce qui est utile par exemple si le bean ne supporte
- * pas les {@link PropertyChangeListener}
- */
- public void validate() {
-
- // on ne valide que si il y a un bean et que le resultat de la validation
- // pourra etre affiche quelque part
- if (!canValidate()) {
- return;
- }
-
- for (BeanValidatorScope scope : validators.keySet()) {
-
- XWorkBeanValidator<B> validator = validators.get(scope);
-
- Map<String, List<String>> newMessages = validator.validate(bean);
-
- if (scope == BeanValidatorScope.ERROR) {
- // treate conversion errors
- // reinject them
- for (Entry<String, String> entry : conversionErrors.entrySet()) {
- // remove from validation, errors occurs on this field
- List<String> errors = newMessages.get(entry.getKey());
- String conversionError = entry.getValue();
- if (errors != null) {
- errors.clear();
- errors.add(conversionError);
- } else {
- errors = java.util.Collections.singletonList(conversionError);
- // add the concrete conversion error
- newMessages.put(entry.getKey(), errors);
- }
- }
- }
-
- // for each field, update his list of messages
- for (BeanValidatorField<B> field : fields) {
- List<String> messagesForField = newMessages.get(field.getName());
- if (field.getScopes().contains(scope)) {
- field.updateMessages(this, scope, messagesForField);
- }
- }
- }
-
- if (parentValidator != null) {
- // chained validation
- parentValidator.l.propertyChange(null);
- }
-
- }
-
- @Override
- public String toString() {
- return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">";
- }
-
- public void addBeanValidatorListener(BeanValidatorListener listener) {
- listenerList.add(BeanValidatorListener.class, listener);
- }
-
- public void removeBeanValidatorListener(BeanValidatorListener listener) {
- listenerList.remove(BeanValidatorListener.class, listener);
- }
-
- public BeanValidatorListener[] getBeanValidatorListeners() {
- return listenerList.getListeners(BeanValidatorListener.class);
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- /** @return <code>true</code> if validation is enabled, <code>false</code> otherwise. */
- protected boolean canValidate() {
- return !(bean == null || fields.isEmpty());
- }
-
- protected void fireFieldChanged(BeanValidatorField<B> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
-
- BeanValidatorEvent evt = new BeanValidatorEvent(this, field, scope, toAdd, toDelete);
-
- for (BeanValidatorListener listener : listenerList.getListeners(BeanValidatorListener.class)) {
- listener.onFieldChanged(evt);
- }
- }
-
- protected synchronized void initFields() {
-
- Set<String> detectedFieldNames = new java.util.HashSet<String>();
- EnumMap<BeanValidatorScope, Set<String>> tmp = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class);
- Set<BeanValidatorField<B>> detectedFields = new java.util.HashSet<BeanValidatorField<B>>();
-
- validators.clear();
-
- for (BeanValidatorScope scope : BeanValidatorScope.values()) {
- String scopeContext = (contextName == null ? "" : contextName + "-") + scope.name().toLowerCase();
-
- XWorkBeanValidator<B> newValidator = new XWorkBeanValidator<B>(beanClass, scopeContext, false);
- Set<String> fieldNames = newValidator.getFieldNames();
- if (log.isDebugEnabled()) {
- log.debug("detected validators for scope " + scopeContext + " : " + fieldNames);
- }
- if (!fieldNames.isEmpty()) {
- // fields detected in this validator, keep it
- validators.put(scope, newValidator);
- detectedFieldNames.addAll(fieldNames);
- tmp.put(scope, fieldNames);
- }
- }
-
- List<BeanValidatorScope> scopes = new ArrayList<BeanValidatorScope>();
- for (String fieldName : detectedFieldNames) {
- scopes.clear();
- // detect scopes for the field
- for (BeanValidatorScope scope : BeanValidatorScope.values()) {
- if (tmp.containsKey(scope) && tmp.get(scope).contains(fieldName)) {
- scopes.add(scope);
- }
- }
- BeanValidatorField<B> f = new BeanValidatorField<B>(beanClass, fieldName, scopes);
- detectedFields.add(f);
- }
- tmp.clear();
- detectedFieldNames.clear();
-
- this.fields = java.util.Collections.unmodifiableSet(detectedFields);
- }
-
- protected EventSetDescriptor getBeanEventDescriptor(B bean) {
- if (beanEventDescriptor == null) {
- // check that the bean is listenable, otherwise, can't use the validator on it
- this.beanEventDescriptor = ValidationUtil.getPropertyChangeListenerDescriptor(bean.getClass());
- }
- return beanEventDescriptor;
- }
-}
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -17,7 +17,7 @@
String[] messagestoAdd;
String[] messagestoDelete;
- public BeanValidatorEvent(BeanValidator2 source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
+ public BeanValidatorEvent(BeanValidator source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
super(source);
this.field = field;
this.scope = scope;
@@ -26,8 +26,8 @@
}
@Override
- public BeanValidator2 getSource() {
- return (BeanValidator2) super.getSource();
+ public BeanValidator getSource() {
+ return (BeanValidator) super.getSource();
}
public String getFieldName() {
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -107,7 +107,7 @@
return messages.get(scope);
}
- public void updateMessages(BeanValidator2<B> validator, BeanValidatorScope scope, List<String> messages) {
+ public void updateMessages(BeanValidator<B> validator, BeanValidatorScope scope, List<String> messages) {
if (scope == null) {
@@ -220,7 +220,7 @@
return sb.toString();
}
- protected void clearMessages(BeanValidatorScope scope, BeanValidator2<B> validator) {
+ protected void clearMessages(BeanValidatorScope scope, BeanValidator<B> validator) {
// remove all messages
Set<String> toDelete = getMessages(scope);
Added: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -0,0 +1,72 @@
+package jaxx.runtime.validator;
+
+/**
+ * The object to box a validation message.
+ *
+ * @param <E> type of message (use for override {@link #compareTo(E)} method.
+ *
+ * @author chemit
+ * @since 1.3
+ */
+public class BeanValidatorMessage<E extends BeanValidatorMessage> implements Comparable<E> {
+
+ /**
+ * the validator that produce the message
+ */
+ protected BeanValidator validator;
+ /**
+ * the field thatproduce the message
+ */
+ protected BeanValidatorField field;
+ /**
+ * the label of the message (to be displayed somewhere)
+ */
+ protected String message;
+ /**
+ * the scope of the message
+ */
+ protected BeanValidatorScope scope;
+
+ public BeanValidatorMessage(BeanValidator validator, BeanValidatorField field, String message, BeanValidatorScope scope) {
+ this.field = field;
+ this.validator = validator;
+ this.message = message;
+ this.scope = scope;
+ }
+
+ public BeanValidator getValidator() {
+ return validator;
+ }
+
+ public BeanValidatorField getField() {
+ return field;
+ }
+
+ public BeanValidatorScope getScope() {
+ return scope;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ @Override
+ public int compareTo(E o) {
+ // sort on scope
+ int result = getScope().compareTo(o.getScope());
+ if (result == 0) {
+ // sort on field name
+ result = field.getName().compareTo(o.field.getName());
+ if (result == 0) {
+ // sort on message
+ result = message.compareTo(o.message);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return scope + " - " + field.getI18nError(message);
+ }
+}
Deleted: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,153 +0,0 @@
-package jaxx.runtime.validator;
-
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.JAXXValidator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.beans.BeanInfo;
-import java.beans.EventSetDescriptor;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The helper class for validation module.
- *
- * @author chemit
- */
-public class ValidationUtil {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(ValidationUtil.class);
-
- protected ValidationUtil() {
- // no instance
- }
-
- /**
- * Convinient method to attach a bean to all validators of an JAXXObject.
- * <p/>
- * It is possible to exclude some validator to be treated.
- *
- * @param ui the ui containing the validatros to treate
- * @param bean the bean to attach in validators (can be null)
- * @param excludeIds the list of validator id to exclude
- */
- @SuppressWarnings({"unchecked"})
- public static void setValidatorBean(JAXXObject ui, Object bean, String... excludeIds) {
- if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
- return;
- }
- JAXXValidator jaxxValidator = (JAXXValidator) ui;
- List<String> validatorIds = jaxxValidator.getValidatorIds();
- if (excludeIds.length > 0) {
- validatorIds = new ArrayList<String>(validatorIds);
- for (String excludeId : excludeIds) {
- validatorIds.remove(excludeId);
- }
- }
- for (String validatorId : validatorIds) {
- BeanValidator2 beanValidator = jaxxValidator.getValidator(validatorId);
- if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) {
- // touch validator, only if fits the bean type (or bean is null)
- beanValidator.setBean(bean);
- }
- }
- }
-
- /**
- * Convinient method to set the changed property to all validators of an JAXXObject.
- * <p/>
- * It is possible to exclude some validator to be treated.
- *
- * @param ui the ui containing the validatros to treate
- * @param newValue the new value to set in changed validator property
- * @param excludeIds the list of validator id to exclude
- */
- @SuppressWarnings({"unchecked"})
- public static void setValidatorChanged(JAXXObject ui, boolean newValue, String... excludeIds) {
- if (!JAXXValidator.class.isAssignableFrom(ui.getClass())) {
- return;
- }
- JAXXValidator jaxxValidator = (JAXXValidator) ui;
- List<String> validatorIds = jaxxValidator.getValidatorIds();
- if (excludeIds.length > 0) {
- validatorIds = new ArrayList<String>(validatorIds);
- for (String excludeId : excludeIds) {
- validatorIds.remove(excludeId);
- }
- }
- for (String validatorId : validatorIds) {
- BeanValidator2 beanValidator = jaxxValidator.getValidator(validatorId);
- beanValidator.setChanged(newValue);
- }
- }
-
- /**
- * Convert a value to a given type and then if was succesffull try to set it in the bean manage by the validator.
- *
- * @param validator validator to be involved
- * @param fieldName the name of the bean property
- * @param value the actual value to convert
- * @param valueClass the type of the conversion
- */
- public static void convert(BeanValidator2<?> validator, String fieldName, String value, Class<?> valueClass) {
-
- Object result = validator.convert(fieldName, value, valueClass);
- if (result != null) {
- try {
- BeanInfo info = Introspector.getBeanInfo(validator.getBean().getClass());
-
- for (PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
- if (fieldName.equals(descriptor.getName()) && descriptor.getWriteMethod() != null) {
-
- descriptor.getWriteMethod().invoke(validator.getBean(), result);
- break;
- }
- }
- } catch (IntrospectionException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- } catch (InvocationTargetException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- } catch (IllegalAccessException e) {
- log.error("could not obtain beanInfo for " + valueClass.getClass() + ", reason : " + e.getMessage(), e);
- }
- } else {
- //fixme : conversion failed, we should be able to notify ui that values has changed ?
- // otherwise, bean value has not changed,...
- }
- }
-
- static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) {
- try {
- // check that the bean is listenable, otherwise, can't use
- // the validator on it
- BeanInfo infos = Introspector.getBeanInfo(beanClass);
- EventSetDescriptor[] events = infos.getEventSetDescriptors();
- for (EventSetDescriptor event : events) {
- if ("propertyChange".equals(event.getName())) {
-
- if (event.getAddListenerMethod() == null) {
- // no property event listener, so can not use the validator
- throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass);
- }
- if (event.getRemoveListenerMethod() == null) {
- // no property event listener, so can not use the validator
- throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass);
- }
- return event;
- }
- }
-
- // no property event listener, so can not use the validator
- throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass);
- } catch (IntrospectionException ex) {
- throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex);
- }
- }
-
-}
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -15,8 +15,8 @@
public class BeanValidatorTest {
/** to use log facility, just put in your code: log.info(\"...\"); */
- static protected final Log log = LogFactory.getLog(BeanValidator2.class);
- protected BeanValidator2<SimpleBean> validator;
+ static protected final Log log = LogFactory.getLog(BeanValidator.class);
+ protected BeanValidator<SimpleBean> validator;
protected SimpleBean bean;
BeanValidatorListenerImpl errorListener;
BeanValidatorListenerImpl warningListener;
@@ -25,7 +25,7 @@
@Before
public void setUp() {
bean = new SimpleBean();
- validator = new BeanValidator2<SimpleBean>(SimpleBean.class, null);
+ validator = new BeanValidator<SimpleBean>(SimpleBean.class, null);
validator.addBeanValidatorListener(errorListener = new BeanValidatorListenerImpl(BeanValidatorScope.ERROR));
validator.addBeanValidatorListener(warningListener = new BeanValidatorListenerImpl(BeanValidatorScope.WARNING));
validator.addBeanValidatorListener(infoListener = new BeanValidatorListenerImpl(BeanValidatorScope.INFO));
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,7 +1,7 @@
package jaxx.runtime.validator.field;
import java.io.File;
-import jaxx.runtime.validator.BeanValidator2;
+import jaxx.runtime.validator.BeanValidator;
import jaxx.runtime.validator.BeanValidatorField;
import jaxx.runtime.validator.ValidatorBean;
import org.apache.commons.logging.Log;
@@ -23,7 +23,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(AbstractFieldValidatorTest.class);
- static protected BeanValidator2<ValidatorBean> validator;
+ static protected BeanValidator<ValidatorBean> validator;
static protected File basedir;
protected ValidatorBean bean;
@@ -53,7 +53,7 @@
b = new File("").getAbsolutePath();
}
basedir = new File(b);
- validator = new BeanValidator2<ValidatorBean>(ValidatorBean.class, null);
+ validator = new BeanValidator<ValidatorBean>(ValidatorBean.class, null);
}
protected void assertFieldInError(String fieldName, String error, boolean required) {
Modified: jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,4 +1,5 @@
-1.3 chemit 20090320
+1.3 chemit 20090321
+ * 20090320 [chemit] - rename and move SwingValidationUtil to jaxx.runtime.SwingValidatorUtil
* 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
1.1 chemit 20090220
Modified: jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-03-21 16:13:18 UTC (rev 1275)
@@ -25,6 +25,11 @@
<artifactId>jaxx-runtime-validator</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
Added: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/SwingValidatorUtil.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -0,0 +1,175 @@
+package jaxx.runtime;
+
+import jaxx.runtime.validator.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JList;
+import javax.swing.JTable;
+import java.awt.event.MouseListener;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableMouseListener;
+import jaxx.runtime.validator.swing.SwingValidatorMessageListMouseListener;
+import jaxx.runtime.validator.swing.SwingValidatorMessage;
+import org.codelutin.i18n.I18n;
+
+/**
+ * The helper class for validation module.
+ *
+ * @author chemit
+ */
+public class SwingValidatorUtil extends BeanValidatorUtil {
+
+ static ImageIcon errorIcon;
+ static ImageIcon warningIcon;
+ static ImageIcon infoIcon;
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(SwingValidatorUtil.class);
+
+ public static ImageIcon getErrorIcon() {
+ if (errorIcon == null) {
+ errorIcon = jaxx.runtime.Util.createImageIcon("error.png");
+ }
+ return errorIcon;
+ }
+
+ public static ImageIcon getInfoIcon() {
+ if (infoIcon == null) {
+ infoIcon = jaxx.runtime.Util.createImageIcon("info.png");
+ }
+ return infoIcon;
+ }
+
+ public static ImageIcon getWarningIcon() {
+ if (warningIcon == null) {
+ warningIcon = jaxx.runtime.Util.createImageIcon("warning.png");
+ }
+ return warningIcon;
+ }
+
+ protected SwingValidatorUtil() {
+ // no instance
+ }
+
+ /**
+ * Register for a given validator list ui a validator mouse listener.
+ *
+ * Note: there is only one listener registred for a given list model, so
+ * invoking this method tiwce or more will have no effect.
+ *
+ * @param list the validation ui list
+ * @return the listener instanciate or found
+ * @see SwingValidatorMessageListMouseListener
+ */
+ public static SwingValidatorMessageListMouseListener registerErrorListMouseListener(JList list) {
+ SwingValidatorMessageListMouseListener listener = getErrorListMouseListener(list);
+
+ if (listener != null) {
+ return listener;
+ }
+ listener = new SwingValidatorMessageListMouseListener();
+ if (log.isDebugEnabled()) {
+ log.debug(listener.toString());
+ }
+ list.addMouseListener(listener);
+ return listener;
+ }
+
+ /**
+ * Register for a given validator table ui a validator mouse listener
+ *
+ * Note: there is onlt one listener registred for a givne table model, so
+ * invokin this method twice or more will have no effect.
+ *
+ * @param table the validator table ui
+ * @return the listener instanciate or found
+ * @see SwingValidatorMessageTableMouseListener
+ */
+ public static SwingValidatorMessageTableMouseListener registerErrorTableMouseListener(JTable table) {
+ SwingValidatorMessageTableMouseListener listener = getErrorTableMouseListener(table);
+
+ if (listener != null) {
+ return listener;
+ }
+ listener = new SwingValidatorMessageTableMouseListener();
+ if (log.isDebugEnabled()) {
+ log.debug(listener.toString());
+ }
+ table.addMouseListener(listener);
+ return listener;
+ }
+
+ /**
+ * @param list the validator list ui
+ * @return the validator list mouse listener, or <code>null</code> if not found
+ * @see SwingValidatorMessageListMouseListener
+ */
+ public static SwingValidatorMessageListMouseListener getErrorListMouseListener(JList list) {
+ if (list != null) {
+ for (MouseListener listener : list.getMouseListeners()) {
+ if (listener instanceof SwingValidatorMessageTableMouseListener) {
+ return (SwingValidatorMessageListMouseListener) listener;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @param table the validator table ui
+ * @return the validator table mouse listener, or <code>null</code> if not found
+ * @see SwingValidatorMessageTableMouseListener
+ */
+ public static SwingValidatorMessageTableMouseListener getErrorTableMouseListener(JTable table) {
+ if (table != null) {
+ for (MouseListener listener : table.getMouseListeners()) {
+ if (listener instanceof SwingValidatorMessageTableMouseListener) {
+ return (SwingValidatorMessageTableMouseListener) listener;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String getMessage(SwingValidatorMessage model) {
+ String text = model.getMessage();
+ if (model.getField()!=null) {
+ text = model.getField().getI18nError(text);
+ }
+ return text;
+ }
+
+ public static String getFieldName(SwingValidatorMessage model, String value) {
+ String text = null;
+ JComponent editor = model.getEditor();
+ if (editor != null) {
+ String l = (String) editor.getClientProperty("validatorLabel");
+ if (l != null) {
+ text = I18n._(l);
+ } else {
+ // TODO should try the text
+ }
+ }
+ if (text == null) {
+ text = value;
+ }
+ return text;
+ }
+
+ public static ImageIcon getIcon(BeanValidatorScope scope) {
+ ImageIcon icon = null;
+ switch (scope) {
+ case ERROR:
+ icon = getErrorIcon();
+ break;
+ case WARNING:
+ icon = getWarningIcon();
+ break;
+ case INFO:
+ icon = getInfoIcon();
+ break;
+ }
+ return icon;
+ }
+}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/SwingValidationUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/SwingValidationUtil.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/SwingValidationUtil.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,65 +0,0 @@
-package jaxx.runtime.validator;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JList;
-import javax.swing.JTable;
-import java.awt.event.MouseListener;
-import jaxx.runtime.validator.swing.SwingValidatorMessageTableMouseListener;
-import jaxx.runtime.validator.swing.SwingValidatorMessageListMouseListener;
-
-/**
- * The helper class for validation module.
- *
- * @author chemit
- */
-public class SwingValidationUtil extends ValidationUtil {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(SwingValidationUtil.class);
-
- protected SwingValidationUtil() {
- // no instance
- }
-
- public static void registerErrorListMouseListener(JList list) {
- if (list == null) {
- return;
- }
- for (MouseListener listener : list.getMouseListeners()) {
- if (listener instanceof SwingValidatorMessageListMouseListener) {
- // already have a such listener
- log.info("already registered a such MouseListener : " + listener);
- return;
- }
- }
- list.addMouseListener(new SwingValidatorMessageListMouseListener());
- }
-
- public static void registerErrorTableMouseListener(JTable table) {
- if (table == null) {
- return;
- }
- for (MouseListener listener : table.getMouseListeners()) {
- if (listener instanceof SwingValidatorMessageTableMouseListener) {
- // already have a such listener
- log.info("already registered a such MouseListener : " + listener);
- return;
- }
- }
- table.addMouseListener(new SwingValidatorMessageTableMouseListener());
- }
-
- public SwingValidatorMessageTableMouseListener getErrorTableMouseListener(JTable table) {
- if (table != null) {
- for (MouseListener listener : table.getMouseListeners()) {
- if (listener instanceof SwingValidatorMessageTableMouseListener) {
- return (SwingValidatorMessageTableMouseListener) listener;
- }
- }
- }
- return null;
- }
-}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,6 +1,5 @@
package jaxx.runtime.validator.swing;
-
import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
import jaxx.runtime.validator.swing.ui.IconValidationUI;
import org.apache.commons.logging.Log;
@@ -15,10 +14,9 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import jaxx.runtime.validator.BeanValidator2;
+import jaxx.runtime.validator.BeanValidator;
import jaxx.runtime.validator.BeanValidatorField;
-
/**
* La surcharge de {@link jaxx.runtime.validator.BeanValidator} pour les ui swing
* <p/>
@@ -96,31 +94,40 @@
* @author chemit
* @version 1.0
*/
-public class SwingValidator<B> extends BeanValidator2<B> {
+public class SwingValidator<B> extends BeanValidator<B> {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(SwingValidator.class);
-
static private final Class<? extends AbstractBeanValidatorUI> DEFAULT_UI_CLASS = IconValidationUI.class;
-
/** permet de faire le lien en un champs du bean et l'objet qui permet de l'editer */
protected Map<String, JComponent> fieldRepresentation;
-
/** Object servant a contenir la liste des erreurs */
protected SwingValidatorMessageListModel errorListModel;
-
/** Object servant a contenir la liste des erreurs */
protected SwingValidatorMessageTableModel errorTableModel;
-
/** ui renderer class */
protected Class<? extends AbstractBeanValidatorUI> uiClass;
-
public SwingValidator(Class<B> beanClass, String contextName) {
super(beanClass, contextName);
fieldRepresentation = new HashMap<String, JComponent>();
}
+ /**
+ * To reload a bean in the validator.
+ *
+ * This method is used to reload ui, since some editors
+ * could not exist when validator is init, so some messages
+ * should not be attached to an editor.
+ */
+ public void reloadBean() {
+ B b = getBean();
+ if (b != null) {
+ setBean(null);
+ setBean(b);
+ }
+ }
+
public JComponent getFieldRepresentation(String fieldname) {
return fieldRepresentation.get(fieldname);
}
@@ -154,27 +161,27 @@
/*Map<ValidatorField<B>, List<ValidatorErrorListener>> oldListeners = new HashMap<ValidatorField<B>, List<ValidatorErrorListener>>();
for (ValidatorField<B> field : fields) {
- ValidatorErrorListener[] listeners = field.getValidatorErrorListeners();
- List<ValidatorErrorListener> toReinject = new ArrayList<ValidatorErrorListener>();
- for (ValidatorErrorListener listener : listeners) {
- if (listener instanceof AbstractBeanValidatorUI) {
- // this listener will be reinject via installUIs method
- continue;
- }
- toReinject.add(listener);
- }
- oldListeners.put(field, toReinject);
+ ValidatorErrorListener[] listeners = field.getValidatorErrorListeners();
+ List<ValidatorErrorListener> toReinject = new ArrayList<ValidatorErrorListener>();
+ for (ValidatorErrorListener listener : listeners) {
+ if (listener instanceof AbstractBeanValidatorUI) {
+ // this listener will be reinject via installUIs method
+ continue;
+ }
+ toReinject.add(listener);
+ }
+ oldListeners.put(field, toReinject);
}*/
super.setContextName(contextName);
// must reinstall ui
installUIs();
// reinject none ui listeners
/*for (Entry<ValidatorField<B>, List<ValidatorErrorListener>> entry : oldListeners.entrySet()) {
- ValidatorField<B> field = getField(entry.getKey().getName());
- for (ValidatorErrorListener listener : entry.getValue()) {
- field.addValidatorErrorListener(listener);
- }
+ ValidatorField<B> field = getField(entry.getKey().getName());
+ for (ValidatorErrorListener listener : entry.getValue()) {
+ field.addValidatorErrorListener(listener);
}
+ }
oldListeners.clear();*/
}
@@ -213,6 +220,7 @@
/** install ui on required components */
public void installUIs() {
SwingUtilities.invokeLater(new Runnable() {
+
@Override
public void run() {
if (uiClass == null) {
@@ -249,9 +257,9 @@
JXLayer<?> jx = (JXLayer<?>) container;
Object ui = jx.getUI();
if (ui != null && ui instanceof AbstractBeanValidatorUI) {
- removeBeanValidatorListener((AbstractBeanValidatorUI)ui);
+ removeBeanValidatorListener((AbstractBeanValidatorUI) ui);
}
-
+
jx.setUI(null);
}
}
@@ -268,6 +276,4 @@
}
}
}
-
-
}
Copied: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (from rev 1274, jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessage.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -0,0 +1,66 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.JComponent;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorMessage;
+import jaxx.runtime.validator.BeanValidatorScope;
+
+/**
+ * The object to box a validation message within an u.
+ *
+ * @author chemit
+ * @since 1.3
+ * @see BeanValidatorMessage
+ */
+public class SwingValidatorMessage extends BeanValidatorMessage<SwingValidatorMessage> {
+
+ /**
+ * the optional field's editor
+ */
+ protected JComponent editor;
+ protected String fieldName;
+
+ public SwingValidatorMessage(SwingValidator validator, BeanValidatorField field, String message, BeanValidatorScope scope, JComponent editor) {
+ super(validator, field, message, scope);
+ this.fieldName = field.getName();
+ this.editor = editor;
+ }
+
+ public SwingValidatorMessage(SwingValidator validator, String fieldName, String message, BeanValidatorScope scope, JComponent editor) {
+ super(validator, null, message, scope);
+ this.fieldName = fieldName;
+ this.editor = editor;
+ }
+
+ public JComponent getEditor() {
+ return editor;
+ }
+
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ @Override
+ public int compareTo(SwingValidatorMessage o) {
+ // sort on scope
+ int result = getScope().compareTo(o.getScope());
+ if (result == 0) {
+ // sort on field name
+ result = fieldName.compareTo(o.getFieldName());
+ if (result == 0) {
+ // sort on message
+ result = message.compareTo(o.getMessage());
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ String s = scope + " - " + (field == null ? message : field.getI18nError(message));
+ if (editor == null) {
+ return s;
+ }
+ return editor.getName() + " : " + s;
+ }
+}
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -2,13 +2,10 @@
import jaxx.runtime.validator.BeanValidatorEvent;
-import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.List;
import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorListener;
import jaxx.runtime.validator.BeanValidatorScope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -18,18 +15,27 @@
*
* @author chemit
*/
-public class SwingValidatorMessageListModel extends DefaultListModel implements BeanValidatorListener {
+public class SwingValidatorMessageListModel
+ extends javax.swing.AbstractListModel
+ implements jaxx.runtime.validator.BeanValidatorListener {
+ private static final long serialVersionUID = 1L;
/** to use log facility, just put in your code: log.info(\"...\"); */
private static Log log = LogFactory.getLog(SwingValidatorMessageListModel.class);
- private static final long serialVersionUID = 1L;
/** list of registred validators */
protected transient List<SwingValidator<?>> validators;
+ /** list of messages actual displayed */
+ protected List<SwingValidatorMessage> data;
public SwingValidatorMessageListModel() {
validators = new ArrayList<SwingValidator<?>>();
+ data = new java.util.ArrayList<SwingValidatorMessage>();
}
+ public boolean isEmpty() {
+ return getSize() == 0;
+ }
+
public void registerValidator(SwingValidator<?> validator) {
if (validators.contains(validator)) {
throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
@@ -39,97 +45,90 @@
}
@Override
+ public int getSize() {
+ return data.size();
+ }
+
+ @Override
+ public Object getElementAt(int index) {
+ ensureRowIndex(index);
+ return data.get(index);
+ }
+
+ @Override
public void onFieldChanged(BeanValidatorEvent event) {
String[] toDelete = event.getMessagesToDelete();
String[] toAdd = event.getMessagesToAdd();
- BeanValidatorScope scope = event.getScope();
- SwingValidator validator = (SwingValidator) event.getSource();
BeanValidatorField field = event.getField();
+ BeanValidatorScope scope = event.getScope();
+ boolean mustAdd = toAdd != null && toAdd.length > 0;
+ boolean mustDel = toDelete != null && toDelete.length > 0;
if (log.isTraceEnabled()) {
log.trace("----------------------------------------------------------");
- log.trace(field + " - (" + getSize() + ") toAdd " + (toAdd == null ? null : toAdd.length));
- log.trace(field + " - (" + getSize() + ") toDelete " + (toDelete == null ? null : toDelete.length));
+ log.trace(field + " - (" + getSize() + ") toAdd " + mustAdd);
+ log.trace(field + " - (" + getSize() + ") toDelete " + mustDel);
}
- if ((toAdd == null || toAdd.length == 0) && (toDelete == null || toDelete.length == 0)) {
- // no data to add nor remove, so nothing to do
- return;
- }
+ SwingValidator validator = (SwingValidator) event.getSource();
- if (toAdd == null || toAdd.length == 0) {
+ if (mustDel) {
- if (log.isTraceEnabled()) {
- log.trace(field + " - toDelete : just delete some datas!");
- }
+ // removes datas and notify if no messages to add
+ removeMessages(validator, field, scope, !mustAdd, toDelete);
+ }
- // no add, no need to resort the datas, can direclty delete
- // messages we do not want any longer
+ if (mustAdd) {
- // delete some messages for the given field and given scope
- List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
- List<Integer> indexs = new java.util.ArrayList<Integer>(toDelete.length);
+ // add new messages, sort datas and notify
+ addMessages(validator, field, scope, true, toAdd);
+ }
+ }
- Enumeration enumeration = elements();
- int index = 0;
- while (enumeration.hasMoreElements()) {
- SwingValidatorMessageModel error = (SwingValidatorMessageModel) enumeration.nextElement();
+ protected void ensureRowIndex(int index) throws ArrayIndexOutOfBoundsException {
+ if (index < -1 || index >= getSize()) {
+ throw new ArrayIndexOutOfBoundsException("the rowIndex was " + index + ", but should be int [0," + (getSize() - 1) + "]");
+ }
+ }
- if (error.getValidator() == validator && error.getField() == field && ids.contains(error.getMessage())) {
- indexs.add(index);
- }
- index++;
- }
+ protected void addMessages(SwingValidator validator, BeanValidatorField field, BeanValidatorScope scope, boolean sort, String... messages) {
- java.util.Collections.reverse(indexs);
-
- for (Integer i : indexs) {
- removeElementAt(i);
+ JComponent editor = validator.getFieldRepresentation(field.getName());
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireIntervalAdded(this, data.size() - 1, data.size() - 1);
}
-
- return;
}
- if (log.isTraceEnabled()) {
- log.trace(field + " - add and delete !");
- }
+ if (sort) {
- List<SwingValidatorMessageModel> newMessages = new ArrayList<SwingValidatorMessageModel>();
+ // resort datas
+ java.util.Collections.sort(data);
+ // notify
+ fireContentsChanged(this, 0, getSize() - 1);
+ }
+ }
+ protected void removeMessages(SwingValidator validator, BeanValidatorField field, BeanValidatorScope scope, boolean notify, String... messages) {
- // obtain all messages not to delete
+ List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
- List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
- Enumeration enumeration = elements();
- while (enumeration.hasMoreElements()) {
- SwingValidatorMessageModel error = (SwingValidatorMessageModel) enumeration.nextElement();
-
- if (error.getValidator() != validator || error.getField() != field || !ids.contains(error.getMessage())) {
- // keep this row
- newMessages.add(error);
+ for (int i = getSize() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getValidator() == validator && error.getScope() == scope && error.getField() == field && messagesToDel.contains(error.getMessage())) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireIntervalRemoved(this, i, i);
+ }
}
}
-
- if (toAdd != null && toAdd.length > 0) {
- JComponent editor = validator.getFieldRepresentation(field.getName());
- // add new messages
- for (String error : toAdd) {
- newMessages.add(new SwingValidatorMessageModel(validator, field, error, editor));
- }
- }
-
- // sort datas
-
- java.util.Collections.sort(newMessages);
-
- // clean model and reinject new errors
- removeAllElements();
-
- // reinject in list model, all the errors
- for (SwingValidatorMessageModel error : newMessages) {
- addElement(error);
- }
- }
+ }
}
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -25,7 +25,7 @@
super.mouseClicked(e);
if (e.getClickCount() == 2) {
- SwingValidatorMessageModel entry = getSelectedError(e);
+ SwingValidatorMessage entry = getSelectedMessage(e);
if (entry == null) {
// no entry found
return;
@@ -37,8 +37,7 @@
}
}
-
- protected SwingValidatorMessageModel getSelectedError(MouseEvent e) {
+ protected SwingValidatorMessage getSelectedMessage(MouseEvent e) {
JList list = (JList) e.getSource();
if (!(list.getModel() instanceof SwingValidatorMessageListModel)) {
log.warn("model must be a " + SwingValidatorMessageListModel.class + ", but was " + list.getModel());
@@ -51,7 +50,7 @@
// nothing is selected
return null;
}
- SwingValidatorMessageModel entry = (SwingValidatorMessageModel) model.getElementAt(index);
+ SwingValidatorMessage entry = (SwingValidatorMessage) model.getElementAt(index);
if (log.isDebugEnabled()) {
log.debug("selected index: " + index + " : error: " + entry);
}
Added: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListRenderer.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -0,0 +1,80 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import java.awt.Component;
+import javax.swing.DefaultListCellRenderer;
+import jaxx.runtime.validator.BeanValidatorScope;
+import jaxx.runtime.SwingValidatorUtil;
+
+/**
+ * A simple render of a table of validator's messages, says a table that use
+ * a {@link SwingValidatorMessageTableModel} model.
+ *
+ * @author chemit
+ * @since 1.3
+ * @see SwingValidatorMessageTableModel
+ */
+public class SwingValidatorMessageListRenderer extends DefaultListCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+ protected String format = "%1$-20s - %2$s";
+
+ public SwingValidatorMessageListRenderer() {
+ }
+
+ public SwingValidatorMessageListRenderer(String format) {
+ this.format = format;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public void setFormat(String format) {
+ this.format = format;
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+
+ JLabel rendererComponent = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+
+ SwingValidatorMessage model = (SwingValidatorMessage) value;
+
+ // scope
+ ImageIcon icon = SwingValidatorUtil.getIcon(model.getScope());
+
+ // field name
+ String fieldName = getFieldName(list, model.getField().getName(), index);
+
+ // message
+ String message = getMessage(model);
+
+ // text to display
+ String text = String.format(format, fieldName, message);
+
+ rendererComponent.setText(text);
+ rendererComponent.setIcon(icon);
+
+ return rendererComponent;
+ }
+
+ public ImageIcon getIcon(BeanValidatorScope scope) {
+ ImageIcon icon = SwingValidatorUtil.getIcon(scope);
+ return icon;
+ }
+
+ public String getMessage(SwingValidatorMessage model) {
+ String text = SwingValidatorUtil.getMessage(model);
+ return text;
+ }
+
+ public String getFieldName(JList list, String value, int row) {
+ SwingValidatorMessageListModel tableModel = (SwingValidatorMessageListModel) list.getModel();
+ SwingValidatorMessage model = (SwingValidatorMessage) tableModel.getElementAt(row);
+ String fieldName = SwingValidatorUtil.getFieldName(model, value);
+ return fieldName;
+ }
+}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,75 +0,0 @@
-package jaxx.runtime.validator.swing;
-
-import javax.swing.JComponent;
-import jaxx.runtime.validator.BeanValidatorField;
-
-/**
- * The object to box a validation message within an u.
- *
- * @author chemit
- * @since 1.3
- */
-public class SwingValidatorMessageModel implements Comparable<SwingValidatorMessageModel> {
-
- /**
- * the validator that produce the message
- */
- protected SwingValidator validator;
- /**
- * the field thatproduce the message
- */
- protected BeanValidatorField field;
- /**
- * the label of the message (to be displayed somewhere)
- */
- protected String message;
- /**
- * the optional field's editor
- */
- protected JComponent editor;
-
- public SwingValidatorMessageModel(SwingValidator validator, BeanValidatorField field, String message, JComponent editor) {
- this.field = field;
- this.validator = validator;
- this.message = message;
- this.editor = editor;
- }
-
- public JComponent getEditor() {
- return editor;
- }
-
- public SwingValidator getValidator() {
- return validator;
- }
-
- public BeanValidatorField getField() {
- return field;
- }
-
- public String getMessage() {
- return message;
- }
-
- @Override
- public int compareTo(SwingValidatorMessageModel o) {
- int result = field.getScope().compareTo(o.field.getScope());
- if (result != 0) {
- return result;
- }
- result = field.getName().compareTo(o.field.getName());
- if (result != 0) {
- return result;
- }
- result = message.compareTo(o.message);
- return result;
- }
-
- @Override
- public String toString() {
- if (editor == null) {
- return field.getI18nError(message);
- }
- return editor.getName() + " : " + field.getI18nError(message);
- }
-}
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -3,156 +3,317 @@
import jaxx.runtime.validator.BeanValidatorEvent;
import javax.swing.JComponent;
-import javax.swing.table.DefaultTableModel;
import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Enumeration;
import java.util.List;
-import java.util.Vector;
import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorListener;
+import jaxx.runtime.validator.BeanValidatorScope;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
- * The model of the list of errors
+ * The model of the table of errors.
*
+ * The model listens validators messages and update his internal model from it.
+ *
* @author chemit
+ * @since 1.3
*/
-public class SwingValidatorMessageTableModel extends DefaultTableModel implements BeanValidatorListener {
+public class SwingValidatorMessageTableModel
+ extends javax.swing.table.AbstractTableModel
+ implements jaxx.runtime.validator.BeanValidatorListener {
+ private static final long serialVersionUID = 1L;
/** to use log facility, just put in your code: log.info(\"...\"); */
private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
- private static final long serialVersionUID = 1L;
public static final String[] columnNames = {"validator.scope", "validator.field", "validator.message"};
+ public static final Class<?>[] columnClasses = {BeanValidatorScope.class, String.class, String.class};
/** list of registred validators */
protected transient List<SwingValidator<?>> validators;
- /** comporator of errors */
- protected transient Comparator<SwingValidatorMessageModel> comparator;
+ /** list of messages actual displayed */
+ protected List<SwingValidatorMessage> data;
public SwingValidatorMessageTableModel() {
- super(columnNames, 0);
+ super();
validators = new ArrayList<SwingValidator<?>>();
+ data = new java.util.ArrayList<SwingValidatorMessage>();
}
- public int getErrorColumn() {
- return findColumn(columnNames[2]);
+ /**
+ * Register a validator for this model.
+ *
+ *
+ * Note: a validator can not be register twice in the same model.
+ *
+ * @param validator the validator to register
+ */
+ public void registerValidator(SwingValidator<?> validator) {
+ if (validators.contains(validator)) {
+ throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
+ }
+ validators.add(validator);
+ validator.addBeanValidatorListener(this);
}
+ public void addMessages(SwingValidator validator, String fieldName, BeanValidatorScope scope, String... messages) {
+ addMessages(validator, fieldName, scope, true, messages);
+ }
+
+ public void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, String... messages) {
+ addMessages(editor, fieldName, scope, true, messages);
+ }
+
+ public void addMessages(SwingValidator validator, BeanValidatorField field, BeanValidatorScope scope, String... messages) {
+ addMessages(validator, field, scope, true, messages);
+ }
+
+ public void removeMessages(JComponent editor, BeanValidatorScope scope) {
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getEditor() == editor && (scope == null || error.getScope() == scope)) {
+ // remove the message
+ data.remove(i);
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
+
+ public void removeMessages(SwingValidator validator, String fieldName, BeanValidatorScope scope, String... messages) {
+ removeMessages(validator, fieldName, scope, true, messages);
+ }
+
+ public void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope) {
+ removeMessages(editor, fieldName, scope, true);
+ }
+
+ public void removeMessages(SwingValidator validator, BeanValidatorField field, BeanValidatorScope scope, String... messages) {
+ removeMessages(validator, field, scope, true, messages);
+ }
+
+ /**
+ * Obtain the message for a given row.
+ *
+ * @param rowIndex the row index
+ * @return the message for the given row index
+ */
+ public SwingValidatorMessage getRow(int rowIndex) {
+ ensureRowIndex(rowIndex);
+ return data.get(rowIndex);
+ }
+
@Override
public boolean isCellEditable(int row, int column) {
// cells are never editable in this model
return false;
}
- public void registerValidator(SwingValidator<?> validator) {
- if (validators.contains(validator)) {
- throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
- }
- validators.add(validator);
- validator.addBeanValidatorListener(this);
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ ensureColumnIndex(columnIndex);
+ return columnClasses[columnIndex];
}
@Override
+ public String getColumnName(int column) {
+ ensureColumnIndex(column);
+ return columnNames[column];
+ }
+
+ @Override
public void onFieldChanged(BeanValidatorEvent event) {
String[] toDelete = event.getMessagesToDelete();
String[] toAdd = event.getMessagesToAdd();
BeanValidatorField field = event.getField();
+ BeanValidatorScope scope = event.getScope();
+ boolean mustAdd = toAdd != null && toAdd.length > 0;
+ boolean mustDel = toDelete != null && toDelete.length > 0;
if (log.isTraceEnabled()) {
log.trace("----------------------------------------------------------");
- log.trace(field + " - (" + getRowCount() + ") toAdd " + (toAdd == null ? null : toAdd.length));
- log.trace(field + " - (" + getRowCount() + ") toDelete " + (toDelete == null ? null : toDelete.length));
+ log.trace(field + " - (" + getRowCount() + ") toAdd " + mustAdd);
+ log.trace(field + " - (" + getRowCount() + ") toDelete " + mustDel);
}
- if ((toAdd == null || toAdd.length == 0) && (toDelete == null || toDelete.length == 0)) {
- // no data to add nor remove, so nothing to do
- return;
- }
SwingValidator validator = (SwingValidator) event.getSource();
+ if (mustDel) {
- int errorColumn = getErrorColumn();
+ // removes datas and notify if no messages to add
+ removeMessages(validator, field, scope, !mustAdd, toDelete);
+ }
- if (toAdd == null || toAdd.length == 0) {
+ if (mustAdd) {
+ // add new messages, sort datas and notify
+ addMessages(validator, field, scope, true, toAdd);
+ }
+ }
- if (log.isTraceEnabled()) {
- log.trace(field + " - toDelete : just delete some datas!");
- }
+ @Override
+ public int getRowCount() {
+ return data.size();
+ }
- // no add, no need to resort the datas, can direclty delete
- // messages we do not want any longer
+ @Override
+ public int getColumnCount() {
+ return columnNames.length;
+ }
- // delete some messages for the given field and given scope
- List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
- List<Integer> indexs = new java.util.ArrayList<Integer>(toDelete.length);
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ ensureColumnIndex(columnIndex);
+ ensureRowIndex(rowIndex);
- Enumeration enumeration = getDataVector().elements();
+ SwingValidatorMessage row = data.get(rowIndex);
+ if (columnIndex == 0) {
+ // the icon
+ return row.getScope();
+ }
+ if (columnIndex == 1) {
+ // the field
+ return row.getFieldName();
+ }
+ if (columnIndex == 2) {
+ // the message
+ return row.getMessage();
+ }
- int index = 0;
- while (enumeration.hasMoreElements()) {
- Vector row = (Vector) enumeration.nextElement();
- SwingValidatorMessageModel error = (SwingValidatorMessageModel) row.get(errorColumn);
- if (error.getValidator() == validator && error.getField() == field && ids.contains(error.getMessage())) {
- // remo the message
- indexs.add(index);
- }
- index++;
- }
- java.util.Collections.reverse(indexs);
+ // should never come here
+ return null;
+ }
- for (Integer i : indexs) {
- removeRow(i);
+ protected void ensureRowIndex(int rowIndex) throws ArrayIndexOutOfBoundsException {
+ if (rowIndex < -1 || rowIndex >= getRowCount()) {
+ throw new ArrayIndexOutOfBoundsException("the rowIndex was " + rowIndex + ", but should be int [0," + (getRowCount() - 1) + "]");
+ }
+ }
+
+ protected void ensureColumnIndex(int index) throws ArrayIndexOutOfBoundsException {
+ if (index < -1 || index >= getColumnCount()) {
+ throw new ArrayIndexOutOfBoundsException("the columnIndex was " + index + ", but should be int [0," + (getColumnCount() - 1) + "]");
+ }
+ }
+
+ protected void addMessages(SwingValidator validator, BeanValidatorField field, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ JComponent editor = validator == null ? null : validator.getFieldRepresentation(field.getName());
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(validator, field, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireTableRowsInserted(data.size() - 1, data.size() - 1);
}
+ }
- return;
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireTableDataChanged();
}
+ }
- if (log.isTraceEnabled()) {
- log.trace(field + " - add and delete !");
+ protected void addMessages(SwingValidator validator, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) {
+
+ JComponent editor = validator == null ? null : validator.getFieldRepresentation(fieldName);
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(validator, fieldName, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireTableRowsInserted(data.size() - 1, data.size() - 1);
+ }
}
- // rebuild all the data (since we are some adding data and we ensure
- // an order on datas)
+ if (sort) {
- List<SwingValidatorMessageModel> newMessages = new ArrayList<SwingValidatorMessageModel>();
+ // resort datas
+ java.util.Collections.sort(data);
- // delete some messages for the given field and given scope
- List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+ // notify
+ fireTableDataChanged();
+ }
+ }
- Enumeration enumeration = getDataVector().elements();
+ protected void addMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean sort, String... messages) {
- while (enumeration.hasMoreElements()) {
- Vector row = (Vector) enumeration.nextElement();
- SwingValidatorMessageModel error = (SwingValidatorMessageModel) row.get(errorColumn);
- if (error.getValidator() != validator || error.getField() != field || !ids.contains(error.getMessage())) {
- // keep this row
- newMessages.add(error);
+ // add new errors
+ for (String error : messages) {
+ SwingValidatorMessage row = new SwingValidatorMessage(null, fieldName, error, scope, editor);
+ data.add(row);
+ if (!sort) {
+ fireTableRowsInserted(data.size() - 1, data.size() - 1);
}
}
- if (toAdd != null && toAdd.length > 0) {
- JComponent editor = validator.getFieldRepresentation(field.getName());
- // add new errors
- for (String error : toAdd) {
- SwingValidatorMessageModel errorModel = new SwingValidatorMessageModel(validator, field, error, editor);
- newMessages.add(errorModel);
+ if (sort) {
+
+ // resort datas
+ java.util.Collections.sort(data);
+
+ // notify
+ fireTableDataChanged();
+ }
+ }
+
+ protected void removeMessages(SwingValidator validator, BeanValidatorField field, BeanValidatorScope scope, boolean notify, String... messages) {
+
+ List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(field.getName()) && messagesToDel.contains(error.getMessage())) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireTableRowsDeleted(i, i);
+ }
}
}
+ }
- // sort datas
+ protected void removeMessages(SwingValidator validator, String fieldName, BeanValidatorScope scope, boolean notify, String... messages) {
- java.util.Collections.sort(newMessages);
+ List<String> messagesToDel = new java.util.ArrayList<String>(java.util.Arrays.asList(messages));
- // clean table model and reinject new messages
- getDataVector().clear();
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
- // reinject in list model, all the errors
- for (SwingValidatorMessageModel error : newMessages) {
- addRow(new Object[]{error.getField().getScope(), error.getField().getName(), error});
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getValidator() == validator && error.getScope() == scope && error.getFieldName().equals(fieldName) && messagesToDel.contains(error.getMessage())) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireTableRowsDeleted(i, i);
+ }
+ }
}
+ }
- fireTableDataChanged();
+ protected void removeMessages(JComponent editor, String fieldName, BeanValidatorScope scope, boolean notify) {
+
+ // do it in reverse mode (only one pass in that way since index
+ // will stay coherent while removing them)
+
+ for (int i = getRowCount() - 1; i > -1; i--) {
+ SwingValidatorMessage error = data.get(i);
+ if (error.getEditor() == editor && (scope==null || error.getScope() == scope) && error.getFieldName().equals(fieldName)) {
+ // remove the message
+ data.remove(i);
+ if (notify) {
+ fireTableRowsDeleted(i, i);
+ }
+ }
+ }
}
}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -36,7 +36,7 @@
super.mouseClicked(e);
if (e.getClickCount() == 2) {
- SwingValidatorMessageModel entry = getSelectedError(e);
+ SwingValidatorMessage entry = getSelectedMessage(e);
if (entry == null) {
// no entry found
return;
@@ -52,7 +52,7 @@
}
- protected SwingValidatorMessageModel getSelectedError(MouseEvent e) {
+ protected SwingValidatorMessage getSelectedMessage(MouseEvent e) {
JTable table = (JTable) e.getSource();
if (!(table.getModel() instanceof SwingValidatorMessageTableModel)) {
log.warn("model must be a " + SwingValidatorMessageTableModel.class + ", but was " + table.getModel());
@@ -65,8 +65,10 @@
// nothing is selected
return null;
}
- int col = model.getErrorColumn();
- SwingValidatorMessageModel entry = (SwingValidatorMessageModel) model.getValueAt(index, col);
+ if (table.getRowSorter() != null) {
+ index = table.getRowSorter().convertRowIndexToModel(index);
+ }
+ SwingValidatorMessage entry = model.getRow(index);
if (log.isDebugEnabled()) {
log.debug("selected index: " + index + " : error: " + entry);
}
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -6,56 +6,70 @@
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.Component;
import jaxx.runtime.validator.BeanValidatorScope;
+import jaxx.runtime.SwingValidatorUtil;
-/** @author chemit */
+/**
+ * A simple render of a table of validator's messages, says a table that use
+ * a {@link SwingValidatorMessageTableModel} model.
+ *
+ * @author chemit
+ * @since 1.3
+ * @see SwingValidatorMessageTableModel
+ */
public class SwingValidatorMessageTableRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 1L;
- ImageIcon errorIcon;
- ImageIcon warningIcon;
- ImageIcon infoIcon;
- public SwingValidatorMessageTableRenderer() {
- errorIcon = jaxx.runtime.Util.createImageIcon("error.png");
- warningIcon = jaxx.runtime.Util.createImageIcon("warning.png");
- infoIcon = jaxx.runtime.Util.createImageIcon("info.png");
- }
-
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel rendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
ImageIcon icon = null;
String text = null;
- if (value instanceof BeanValidatorScope) {
- BeanValidatorScope scope = (BeanValidatorScope) value;
- switch (scope) {
- case ERROR:
- icon = errorIcon;
- break;
- case WARNING:
- icon = warningIcon;
- break;
- case INFO:
- icon = infoIcon;
- break;
- }
- } else if (value instanceof SwingValidatorMessageModel) {
- SwingValidatorMessageModel model = (SwingValidatorMessageModel) value;
- String error = model.getMessage();
- text = model.getField().getI18nError(error);
- } else {
- // keep text rendered
- text = rendererComponent.getText();
+ column = table.convertColumnIndexToModel(column);
+ if (table.getRowSorter() != null) {
+ row = table.getRowSorter().convertRowIndexToModel(row);
}
+
+ switch (column) {
+ case 0:
+ // scope
+ icon = SwingValidatorUtil.getIcon((BeanValidatorScope) value);
+ break;
+
+ case 1:
+ // field name
+ text = getFieldName(table, (String) value, row);
+ break;
+
+ case 2:
+ // message
+ text = getMessage(table, (String) value, row);
+ break;
+ }
+
rendererComponent.setText(text);
rendererComponent.setIcon(icon);
return rendererComponent;
}
- @Override
- protected void setValue(Object value) {
- super.setValue(value);
+ public ImageIcon getIcon(BeanValidatorScope scope) {
+ ImageIcon icon = SwingValidatorUtil.getIcon(scope);
+ return icon;
}
+
+ public String getMessage(JTable table, String value, int row) {
+ SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel();
+ SwingValidatorMessage model = tableModel.getRow(row);
+ String text = SwingValidatorUtil.getMessage(model);
+ return text;
+ }
+
+ public String getFieldName(JTable table, String value, int row) {
+ SwingValidatorMessageTableModel tableModel = (SwingValidatorMessageTableModel) table.getModel();
+ SwingValidatorMessage model = tableModel.getRow(row);
+ String fieldName = SwingValidatorUtil.getFieldName(model, value);
+ return fieldName;
+ }
}
\ No newline at end of file
Modified: jaxx/trunk/maven-jaxx-plugin/changelog.txt
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-03-21 16:13:18 UTC (rev 1275)
@@ -1,4 +1,4 @@
-1.3 chemit 20090320
+1.3 chemit 20090321
* 20090301 [chemit] - add a profile mode (-Djaxx.profile)
1.2 letelier 2009022?
Modified: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-03-21 08:22:03 UTC (rev 1274)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-03-21 16:13:18 UTC (rev 1275)
@@ -281,6 +281,7 @@
protected ClassLoader cl;
private Class<? extends JAXXCompiler> compilerClass;
+ @SuppressWarnings("unchecked")
protected void init() throws ClassNotFoundException, MalformedURLException {
if (project != null && ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging()))) {
@@ -353,7 +354,7 @@
}
} else {
if (verbose) {
- getLog().info("jaxx - will generate file [" + file + "].");
+ getLog().info("jaxx - detect modify file [" + file + "].");
}
listFiles.add(file);
}
@@ -430,7 +431,7 @@
}
public void doAction() throws MojoExecutionException {
- getLog().info("jaxx - will generate " + this.files.length + " jaxx file(s). ");
+ getLog().info("jaxx - detects " + this.files.length + " modify jaxx file(s). ");
try {
@@ -438,8 +439,10 @@
TagManager.reset(verbose);
JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, options);
+ boolean success = launchor.compile();
+ getLog().info("jaxx - generate " + launchor.getCompilerCount() + " file(s). ");
- if (!launchor.compile()) {
+ if (!success) {
throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
}
1
0
r1274 - in jaxx/trunk: jaxx-example/src/main/java/jaxx/demo jaxx-runtime-validator/src/main/java/jaxx/runtime/validator jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing maven-jaxx-plugin/src/test/resources/testcases/validator/errors maven-jaxx-plugin/src/test/resources/testcas
by tchemit@users.labs.libre-entreprise.org March 21, 2009
by tchemit@users.labs.libre-entreprise.org March 21, 2009
March 21, 2009
Author: tchemit
Date: 2009-03-21 08:22:03 +0000 (Sat, 21 Mar 2009)
New Revision: 1274
Added:
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-error-validation.xml
Removed:
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListMouseListener.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableMouseListener.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableRenderer.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorEvent.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorListener.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorField.java
jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-validation.xml
Modified:
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/SwingValidationUtil.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedErrorListModel.jaxx
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedErrorTableModel.jaxx
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/ok/Validation.jaxx
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/ok/ValidationBeanClass.jaxx
Log:
remplacement des classes swingValidatorError* en SwingValidatorMessage*
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx 2009-03-21 08:22:03 UTC (rev 1274)
@@ -17,7 +17,7 @@
<Identity id='identity'/>
<!-- errors model -->
- <jaxx.runtime.validator.swing.SwingValidatorErrorListModel id='errors'
+ <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'
onContentsChanged='ok.setEnabled(errors.isEmpty())'/>
<!-- validators -->
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx 2009-03-21 08:22:03 UTC (rev 1274)
@@ -7,7 +7,7 @@
<Identity id='identity'/>
<!-- errors model -->
- <jaxx.runtime.validator.swing.SwingValidatorErrorTableModel id='errors2'
+ <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errors2'
onTableChanged='ok.setEnabled(errors2.getRowCount()==0)'/>
<!-- validators -->
@@ -31,7 +31,7 @@
import jaxx.runtime.SwingUtil;
void $afterCompleteSetup() {
- errorTable.setDefaultRenderer(Object.class, new jaxx.runtime.validator.swing.SwingValidatorErrorTableRenderer());
+ errorTable.setDefaultRenderer(Object.class, new jaxx.runtime.validator.swing.SwingValidatorMessageTableRenderer());
SwingUtil.setI18nTableHeaderRenderer(errorTable, n_("validator.scope"), n_("validator.scope.tip"), n_("validator.field"), n_("validator.field.tip"), n_("validator.message"), n_("validator.message.tip"));
SwingUtil.fixTableColumnWidth(errorTable, 0, 25);
Deleted: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,476 +0,0 @@
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ValidationAwareSupport;
-import com.opensymphony.xwork2.config.Configuration;
-import com.opensymphony.xwork2.config.ConfigurationManager;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
-import com.opensymphony.xwork2.validator.ActionValidatorManager;
-import com.opensymphony.xwork2.validator.DelegatingValidatorContext;
-import com.opensymphony.xwork2.validator.FieldValidator;
-import com.opensymphony.xwork2.validator.ValidationException;
-import com.opensymphony.xwork2.validator.Validator;
-import com.opensymphony.xwork2.validator.ValidatorScope;
-import java.beans.EventSetDescriptor;
-import org.apache.commons.beanutils.ConversionException;
-import org.apache.commons.beanutils.Converter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.util.ConverterUtil;
-
-import java.beans.Introspector;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
-/**
- *
- * A customized validator for a given bean.
- *
- * <b>Note:</b> The bean must be listenable on properyChange events (means
- * must have public addPropertychangeListener and removePropertyChangeListener methods).
- *
- * @param <B> type of the bean to validate.
- *
- * @author chemit
- */
-@Deprecated
-public class BeanValidator<B> {
-
- /** la nom de la propriété bean */
- static public final String BEAN_PROERTY = "bean";
-
- /** la nom de la propriété contextName */
- static public final String CONTEXT_NAME_PROPERTY = "contextName";
-
- /** la nom de l'état valid */
- static public final String VALID_PROERTY = "valid";
-
- /** la nom de l'état changed */
- static public final String CHANGED_PROERTY = "changed";
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static protected final Log log = LogFactory.getLog(BeanValidator.class);
-
- /** the type of bean to watch */
- protected final Class<B> beanClass;
-
- /** the validation named context (can be null) */
- protected String contextName;
-
- /** to chain to a prent validator */
- protected BeanValidator<?> parentValidator;
-
- /** state to indicate that validator has changed since the last time bean was setted */
- protected boolean changed = false;
-
- /** state of the validator (is true if no errors of error scope is found) */
- protected boolean valid = true;
-
- /** bean to be watched */
- protected B bean = null;
-
- /**
- * map of fields by scope
- * TODO use this and remove fields property and xworks patch :)
- */
- protected EnumMap<ValidatorScope, List<ValidatorField<B>>> fieldsByScope;
-
- /** list of fields watched by this validator */
- protected List<ValidatorField<B>> fields;
-
- /** map of conversion errors detected by this validator */
- protected Map<String, String> conversionErrors;
-
- /** delgate property change support */
- protected PropertyChangeSupport pcs;
-
- /** listener that listens on bean modification */
- protected PropertyChangeListener l;
-
- protected ValidationAwareSupport validationSupport;
- protected DelegatingValidatorContext validationContext;
- protected transient ActionValidatorManager validator;
- protected ActionContext context;
-
- protected EventSetDescriptor beanEventDescriptor;
-
- public BeanValidator(Class<B> beanClass, String contextName) {
- // check that the bean is listenable, otherwise, can't use the validator on it
- beanEventDescriptor = ValidationUtil.getPropertyChangeListenerDescriptor(beanClass);
-
- this.beanClass = beanClass;
- this.contextName = contextName;
- pcs = new PropertyChangeSupport(this);
- validationSupport = new ValidationAwareSupport();
- validationContext = new DelegatingValidatorContext(validationSupport);
-
- // init context
- ConfigurationManager confManager = new ConfigurationManager();
- Configuration conf = confManager.getConfiguration();
-
- ValueStackFactory vsf = conf.getContainer().getInstance(
- ValueStackFactory.class);
- ValueStack vs = vsf.createValueStack();
- context = new ActionContext(vs.getContext());
- ActionContext.setContext(context);
-
- // init validator
- validator = conf.getContainer().getInstance(ActionValidatorManager.class, "no-annotations");
- initFields();
-
- conversionErrors = new TreeMap<String, String>();
-
- l = new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- validate();
- setValid(!hasErrors());
- setChanged(true);
- }
- };
- }
-
- protected void initFields() {
- // init fields from detected fieldValidator in XWorks framework
- fields = new ArrayList<ValidatorField<B>>();
- for (Validator v : validator.getValidators(beanClass, contextName)) {
- // we only work on FieldValidator at the moment
- if (v instanceof FieldValidator) {
- FieldValidator fieldValidator = (FieldValidator) v;
- String fName = fieldValidator.getFieldName();
- ValidatorScope fScope = fieldValidator.getValidatorScope();
- ValidatorField<B> field = new ValidatorField<B>(beanClass, fName, fScope);
- if (!fields.contains(field)) {
- fields.add(field);
- }
- }
- }
-
- fields = Collections.unmodifiableList(fields);
- }
-
- public Class<B> getBeanClass() {
- return beanClass;
- }
-
- public BeanValidator<?> getParentValidator() {
- return parentValidator;
- }
-
- public String getContextName() {
- return contextName;
- }
-
- public List<ValidatorField<B>> getFields() {
- return fields;
- }
-
- public ValidatorField<B> getField(String fieldName) {
- for (ValidatorField<B> field : fields) {
- if (fieldName.equals(field.getName())) {
- return field;
- }
- }
- return null;
- }
-
- /**
- * Retourne vrai si l'objet bean a ete modifie depuis le dernier
- * {@link #setBean}
- *
- * @return <code>true</code> if bean was modify since last {@link #setBean(Object)} invocation
- */
- public boolean isChanged() {
- return changed;
- }
-
- public boolean isValid() {
- return valid;
- }
-
- public B getBean() {
- return bean;
- }
-
- /**
- * Permet de force la remise a false de l'etat de changement du bean
- *
- * @param changed flag to force reset of property {@link #changed}
- */
- public void setChanged(boolean changed) {
- this.changed = changed;
- // force the property to be fired (never pass the older value)
- pcs.firePropertyChange(CHANGED_PROERTY, null, changed);
- }
-
- public void setValid(boolean valid) {
- this.valid = valid;
- // force the property to be fired (never pass the older value)
- pcs.firePropertyChange(VALID_PROERTY, null, valid);
- }
-
- public void setBean(B bean) {
- B oldBean = this.bean;
- if (log.isDebugEnabled()) {
- log.debug(this + " : " + bean);
- }
- // clean conversions of previous bean
- conversionErrors.clear();
-
- if (oldBean != null) {
- try {
- beanEventDescriptor.getRemoveListenerMethod().invoke(oldBean, l);
- //Method method = this.bean.getClass().getMethod("removePropertyChangeListener", PropertyChangeListener.class);
- //method.invoke(oldBean, l);
- } catch (Exception eee) {
- log.info("Can't register as listener for bean "+beanClass+" for reason "+eee.getMessage(), eee);
- }
- }
- this.bean = bean;
-
- if (bean == null) {
- // must remove all errors from this validator on errorListModel
- validationSupport.clearErrorsAndMessages();
-
- // dispatch in each field the new errors
- dispatchErrorsToFields();
- } else {
- try {
- beanEventDescriptor.getAddListenerMethod().invoke(bean, l);
- //Method method = this.bean.getClass().getMethod("addPropertyChangeListener", PropertyChangeListener.class);
- //method.invoke(bean, l);
- } catch (Exception eee) {
- log.info("Can't register as listener for bean "+beanClass+" for reason "+eee.getMessage(), eee);
- }
- validate();
- }
- setChanged(false);
- setValid(!hasErrors());
- pcs.firePropertyChange(BEAN_PROERTY, oldBean, bean);
- }
-
- //FIXME At the moment we do not allow to change contextName, but we should be able to do it
- public void setContextName(String contextName) {
- String oldValidationContextName = this.contextName;
- this.contextName = contextName;
- // changing contextName could change fields definition
- // so dettach bean, must rebuild the fields
- setBean(null);
- initFields();
- pcs.firePropertyChange(CONTEXT_NAME_PROPERTY, oldValidationContextName, contextName);
- }
-
- public void setParentValidator(BeanValidator<?> parentValidator) {
- this.parentValidator = parentValidator;
- }
-
- /** @return <code>true</code> if errors are detected, <code>false</code> otherwise */
- public boolean hasErrors() {
- for (ValidatorField<B> field : fields) {
- if (field.hasErrors()) {
- return true;
- }
- }
- return false;
- }
-
- public boolean hasWarnings() {
- for (ValidatorField<B> field : fields) {
- if (field.hasWarnings()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Test a the validator contains the field given his name
- *
- * @param fieldName the name of the searched field
- * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise
- */
- public boolean containsField(String fieldName) {
- ValidatorField<B> field = getField(fieldName);
- return field != null;
- }
-
- public boolean isValid(String fieldName) {
- ValidatorField<B> field = getField(fieldName);
- if (field == null) {
- throw new IllegalArgumentException("could not find a validator field " + fieldName);
- }
- return field.isValid();
- }
-
- /**
- * Convert a value.
- * <p/>
- * If an error occurs, then add an error in validator.
- *
- * @param <T> the type of conversion
- * @param fieldName the name of the bean property
- * @param value the value to convert
- * @param valueClass the type of converted value
- * @return the converted value, or null if conversion was not ok
- */
- @SuppressWarnings({"unchecked"})
- public <T> T convert(String fieldName, String value, Class<T> valueClass) {
- if (fieldName == null) {
- throw new IllegalArgumentException("fieldName can not be null");
- }
- if (valueClass == null) {
- throw new IllegalArgumentException("valueClass can not be null");
- }
-
- // on ne convertit pas si il y a un bean et que le resultat de la validation
- // pourra etre affiche quelque part
- if (!canValidate() || value == null) {
- return null;
- }
-
- // remove the previous conversion error for the field
- conversionErrors.remove(fieldName);
-
- T result;
- try {
- Converter converter = ConverterUtil.getConverter(valueClass);
- if (converter == null) {
- throw new RuntimeException("could not find converter for the type " + valueClass);
- }
- result = (T) converter.convert(valueClass, value);
- /* Why this test ? if (result != null && !value.equals(result.toString())) {
- conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
- result = null;
- validate();
- }*/
- } catch (ConversionException e) {
- // get
- conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
- result = null;
- validate();
- }
- return result;
- }
-
- /**
- * il faut eviter le code re-intrant (durant une validation, une autre est
- * demandee). Pour cela on fait la validation dans un thread, et tant
- * que la premiere validation n'est pas fini, on ne repond pas aux
- * solicitations.
- * Cette method est public pour permettre de force une validation par
- * programmation, ce qui est utile par exemple si le bean ne supporte
- * pas les {@link PropertyChangeListener}
- */
- public void validate() {
- // on ne valide que si il y a un bean et que le resultat de la validation
- // pourra etre affiche quelque part
- if (!canValidate()) {
- return;
- }
-
- try {
-
- validationSupport.clearErrorsAndMessages();
-
- //TC - 20081024 : since context is in a ThreadLocal variable, we must do the check
- if (ActionContext.getContext() == null) {
- ActionContext.setContext(context);
- }
-
- validator.validate(bean, contextName, validationContext);
-
- // add the registred conversion errors
- transfertConversionErrorsToFieldErrors();
-
- if (log.isTraceEnabled()) {
- log.trace("Action errors: " + validationContext.getActionErrors());
- log.trace("Action messages: " + validationContext.getActionMessages());
- log.trace("Field errors: " + validationContext.getFieldErrors());
- }
-
- if (log.isDebugEnabled()) {
- log.debug(this + " : " + validationContext.getFieldErrors());
- }
-
- // dispatch in each field the new errors
- dispatchErrorsToFields();
-
- if (parentValidator != null) {
- // chained validation
- parentValidator.l.propertyChange(null);
- }
- } catch (ValidationException eee) {
- log.warn("Error during validation", eee);
- }
- }
-
- @Override
- public String toString() {
- return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">";
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- /** @return <code>true</code> if validation is enabled, <code>false</code> otherwise. */
- protected boolean canValidate() {
- return !(bean == null || fields.isEmpty());
- }
-
- /**
- * Transfer the registred conversion errors to fieldErrors.
- * <p/>
- * The previously filed errors of a given field where a conversion error occurs will be removed.
- */
- @SuppressWarnings({"unchecked"})
- protected void transfertConversionErrorsToFieldErrors() {
- Map map = validationContext.getFieldErrors();
- for (Entry<String, String> entry : conversionErrors.entrySet()) {
- // remove from validation, errors occurs on this field
- List errors = (List) map.get(entry.getKey());
- if (errors != null) {
- errors.clear();
- errors.add(entry.getValue());
- } else {
- errors = Collections.singletonList(entry.getValue());
- }
- // add the concrete conversion error
- map.put(entry.getKey(), errors);
- }
- validationContext.setFieldErrors(map);
- }
-
- /** synchronize the errors found in this validator to each field. */
- protected void dispatchErrorsToFields() {
-
- Map map = validationContext.getFieldErrors();
- for (ValidatorField<B> field : fields) {
- String fieldName = field.getName();
- boolean detectedErrors = map.containsKey(fieldName);
- field.addErrors(this, detectedErrors ? (List) map.get(fieldName) : null);
- }
- }
-
-}
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -14,19 +14,4 @@
* @param event the event
*/
void onFieldChanged(BeanValidatorEvent event);
-
- /**
- * Invoked when a validator detects a new message on a field.
- *
- * @param event the event
- */
- //void onNewMessages(BeanValidatorEvent event);
-
- /**
- * Invoked when a validator detetcs that a previously message is
- * no more exisitng.
- *
- * @param event the event
- */
- //void onResolvedMessages(BeanValidatorEvent event);
}
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -95,7 +95,7 @@
* @param value the actual value to convert
* @param valueClass the type of the conversion
*/
- public static void convert(BeanValidator<?> validator, String fieldName, String value, Class<?> valueClass) {
+ public static void convert(BeanValidator2<?> validator, String fieldName, String value, Class<?> valueClass) {
Object result = validator.convert(fieldName, value, valueClass);
if (result != null) {
Deleted: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorEvent.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorEvent.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorEvent.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,46 +0,0 @@
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.validator.ValidatorScope;
-
-import java.util.Set;
-
-/**
- * The definition of an event on {@link ValidatorErrorListener}
- * to be fired by a {@link BeanValidator}.
- *
- * @author chemit
- */
-@Deprecated
-public class ValidatorErrorEvent {
-
- /** the source of the event */
- BeanValidator source;
-
- /** the field impacted by the validator */
- ValidatorField<?> field;
-
- public ValidatorErrorEvent(BeanValidator source, ValidatorField<?> field) {
- this.source = source;
- this.field = field;
- }
-
- public BeanValidator getSource() {
- return source;
- }
-
- public String getFieldName() {
- return field.getName();
- }
-
- public Set<String> getErrors() {
- return field.getErrors();
- }
-
- public ValidatorScope getScope() {
- return field.getScope();
- }
-
- public ValidatorField getField() {
- return field;
- }
-}
Deleted: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorListener.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorListener.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorListener.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,25 +0,0 @@
-package jaxx.runtime.validator;
-
-/**
- * The listener contract to be used on {@link BeanValidator]
- *
- * @author chemit
- */
-@Deprecated
-public interface ValidatorErrorListener extends java.util.EventListener {
- /**
- * Invoked when a validator detects a error on a field.
- *
- * @param event the event
- */
- void onNewError(ValidatorErrorEvent event);
-
- /**
- * Invoked when a validator detetcs that a previously error is
- * no more exisitng.
- *
- * @param event the event
- */
- void onResolvedError(ValidatorErrorEvent event);
-
-}
Deleted: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorField.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorField.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorField.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,187 +0,0 @@
-package jaxx.runtime.validator;
-
-import com.opensymphony.xwork2.validator.ValidatorScope;
-import static org.codelutin.i18n.I18n._;
-
-import javax.swing.event.EventListenerList;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-/**
- * Definition of a field to be handled in a {@link BeanValidator].
- * <p/>
- * <p/>
- * A such class is only registred in {@link BeanValidator } when the field of the bean
- * was found in validator xml configuration file for a {@link com.opensymphony.xwork2.validator.FieldValidator} only.
- * <p/>
- * This class use properties {@link #beanClass}, {@link #name} to define
- * his naturel order.
- *
- * @author chemit
- * @param <B> the type of the bean handled by the validator and this field of validation.
- */
-@Deprecated
-public class ValidatorField<B> {
-
- /** the class of bean */
- protected final Class<B> beanClass;
-
- /** name of field in bean */
- protected String name;
-
- /** the scope of the field */
- protected ValidatorScope scope;
-
- /** the list of error for this field */
- protected Set<String> errors;
-
- /** A list of event listeners for this validators */
- protected EventListenerList listenerList = new EventListenerList();
-
- public ValidatorField(Class<B> beanClass, String name, ValidatorScope scope) {
- this.beanClass = beanClass;
- this.name = name;
- this.scope = scope;
- this.errors = new HashSet<String>();
- }
-
- public String getName() {
- return name;
- }
-
- public ValidatorScope getScope() {
- return scope;
- }
-
- public Class<B> getBeanClass() {
- return beanClass;
- }
-
- public Set<String> getErrors() {
- return errors;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setScope(ValidatorScope scope) {
- this.scope = scope;
- }
-
- /**
- * @return <code>true</code> if this field is valid (says is in error
- * scope and has errors), <code>false</code> otherwise.
- */
- public boolean isValid() {
- return hasErrors();
- }
-
- public boolean hasErrors() {
- return scope == ValidatorScope.ERROR && !errors.isEmpty();
- }
-
- public boolean hasWarnings() {
- return scope == ValidatorScope.WARNING && !errors.isEmpty();
- }
-
- public void addErrors(BeanValidator<B> validator, List errors) {
- boolean hasPreviousError = !this.errors.isEmpty();
-
- // reset errors for this field
- this.errors.clear();
-
- if (errors == null) {
- // no error to assign to this field
- if (hasPreviousError) {
- // there were previously errors, but any longer
- // so fire a resolvedErrorEvent for this field
- fireResolvedError(validator);
- }
- return;
- }
-
- for (Object error : errors) {
- this.errors.add(error.toString());
- }
- // fire a newErrorEvent for this field
- fireNewError(validator);
- }
-
- public String getI18nError(String error) {
- String text;
- if (error.indexOf("##") == -1) {
- text = _(error);
- } else {
- StringTokenizer stk = new StringTokenizer(error, "##");
- String errorName = stk.nextToken();
- List<String> args = new ArrayList<String>();
- while (stk.hasMoreTokens()) {
- args.add(stk.nextToken());
- }
- text = _(errorName, args.toArray());
- }
- return text;
- }
-
- public void addValidatorErrorListener(ValidatorErrorListener listener) {
- listenerList.add(ValidatorErrorListener.class, listener);
- }
-
- public void removeValidatorErrorListener(ValidatorErrorListener listener) {
- listenerList.remove(ValidatorErrorListener.class, listener);
- }
-
- public ValidatorErrorListener[] getValidatorErrorListeners() {
- return listenerList.getListeners(ValidatorErrorListener.class);
- }
-
- protected void fireNewError(BeanValidator<B> validator) {
- ValidatorErrorEvent evt = new ValidatorErrorEvent(validator, this);
- for (ValidatorErrorListener listener : listenerList.getListeners(ValidatorErrorListener.class)) {
- listener.onNewError(evt);
- }
- }
-
- protected void fireResolvedError(BeanValidator<B> validator) {
- ValidatorErrorEvent evt = new ValidatorErrorEvent(validator, this);
- for (ValidatorErrorListener listener : listenerList.getListeners(ValidatorErrorListener.class)) {
- listener.onResolvedError(evt);
- }
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof ValidatorField)) {
- return false;
- }
-
- ValidatorField that = (ValidatorField) o;
- return beanClass.equals(that.beanClass) && name.equals(that.name);
- }
-
- @Override
- public int hashCode() {
- int result = beanClass.hashCode();
- result = 31 * result + name.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("<").append(super.toString());
- sb.append(" beanClass:").append(beanClass);
- sb.append(", name:").append(name);
- sb.append(", scope:").append(scope);
- sb.append(", errors:").append(errors);
- sb.append('>');
- return sb.toString();
- }
-}
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,9 +1,9 @@
package jaxx.runtime.validator.field;
import java.io.File;
-import jaxx.runtime.validator.BeanValidator;
+import jaxx.runtime.validator.BeanValidator2;
+import jaxx.runtime.validator.BeanValidatorField;
import jaxx.runtime.validator.ValidatorBean;
-import jaxx.runtime.validator.ValidatorField;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
@@ -23,7 +23,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(AbstractFieldValidatorTest.class);
- static protected BeanValidator<ValidatorBean> validator;
+ static protected BeanValidator2<ValidatorBean> validator;
static protected File basedir;
protected ValidatorBean bean;
@@ -53,16 +53,17 @@
b = new File("").getAbsolutePath();
}
basedir = new File(b);
- validator = new BeanValidator<ValidatorBean>(ValidatorBean.class, null);
+ validator = new BeanValidator2<ValidatorBean>(ValidatorBean.class, null);
}
protected void assertFieldInError(String fieldName, String error, boolean required) {
- ValidatorField<ValidatorBean> field = validator.getField(fieldName);
-
- for (String o : field.getErrors()) {
- if (o.equals(error)) {
- assertTrue(required);
- return;
+ BeanValidatorField<ValidatorBean> field = validator.getField(fieldName);
+ if (field !=null && field.getErrors() != null) {
+ for (String o : field.getErrors()) {
+ if (o.equals(error)) {
+ assertTrue(required);
+ return;
+ }
}
}
// error was not found
Copied: jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-error-validation.xml (from rev 1273, jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-validation.xml)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-error-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-error-validation.xml 2009-03-21 08:22:03 UTC (rev 1274)
@@ -0,0 +1,95 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="stringValue">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>stringValue.required</message>
+ </field-validator>
+ </field>
+
+ <field name="existingFile">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>existingFile.required</message>
+ </field-validator>
+ <field-validator type="existingFile" short-circuit="true">
+ <message>existingFile.not.exist</message>
+ </field-validator>
+ </field>
+
+ <field name="notExistingFile">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>notExistingFile.required</message>
+ </field-validator>
+ <field-validator type="notExistingFile" short-circuit="true">
+ <message>notExistingFile.exist</message>
+ </field-validator>
+ </field>
+
+ <field name="existingDirectory">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>existingDirectory.required</message>
+ </field-validator>
+
+ <field-validator type="existingDirectory" short-circuit="true">
+ <message>existingDirectory.not.exist</message>
+ </field-validator>
+ </field>
+
+ <field name="notExistingDirectory">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>notExistingDirectory.required</message>
+ </field-validator>
+
+ <field-validator type="notExistingDirectory" short-circuit="true">
+ <message>notExistingDirectory.exist</message>
+ </field-validator>
+ </field>
+
+ <field name="entries">
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">AT_LEAST_ONE</param>
+ <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]></param>
+ <message>collectionFieldExpression.atLeastOne</message>
+ </field-validator>
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">EXACTLY_ONE</param>
+ <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]></param>
+ <message>collectionFieldExpression.exactlyOne</message>
+ </field-validator>
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">ALL</param>
+ <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]></param>
+ <message>collectionFieldExpression.all</message>
+ </field-validator>
+ <field-validator type="collectionFieldExpression">
+ <param name="mode">NONE</param>
+ <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]></param>
+ <message>collectionFieldExpression.none</message>
+ </field-validator>
+
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">intValue</param>
+ <message>collectionUniqueKey.one.failed</message>
+ </field-validator>
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">stringValue</param>
+ <message>collectionUniqueKey.two.failed</message>
+ </field-validator>
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">intValue,stringValue</param>
+ <message>collectionUniqueKey.three.failed</message>
+ </field-validator>
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">intValue,stringValue,stringValue2</param>
+ <message>collectionUniqueKey.four.failed</message>
+ </field-validator>
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">stringValue</param>
+ <param name="againstProperty">entry</param>
+ <message>collectionUniqueKey.five.failed</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-validation.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-validation.xml 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-validation.xml 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,95 +0,0 @@
-<!DOCTYPE validators PUBLIC
- "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
- "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-<validators>
-
- <field name="stringValue">
- <field-validator type="requiredstring" short-circuit="true">
- <message>stringValue.required</message>
- </field-validator>
- </field>
-
- <field name="existingFile">
- <field-validator type="requiredFile" short-circuit="true" validatorScope="ERROR">
- <message>existingFile.required</message>
- </field-validator>
- <field-validator type="existingFile" short-circuit="true">
- <message>existingFile.not.exist</message>
- </field-validator>
- </field>
-
- <field name="notExistingFile">
- <field-validator type="requiredFile" short-circuit="true">
- <message>notExistingFile.required</message>
- </field-validator>
- <field-validator type="notExistingFile" short-circuit="true">
- <message>notExistingFile.exist</message>
- </field-validator>
- </field>
-
- <field name="existingDirectory">
- <field-validator type="requiredFile" short-circuit="true">
- <message>existingDirectory.required</message>
- </field-validator>
-
- <field-validator type="existingDirectory" short-circuit="true">
- <message>existingDirectory.not.exist</message>
- </field-validator>
- </field>
-
- <field name="notExistingDirectory">
- <field-validator type="requiredFile" short-circuit="true">
- <message>notExistingDirectory.required</message>
- </field-validator>
-
- <field-validator type="notExistingDirectory" short-circuit="true">
- <message>notExistingDirectory.exist</message>
- </field-validator>
- </field>
-
- <field name="entries">
- <field-validator type="collectionFieldExpression">
- <param name="mode">AT_LEAST_ONE</param>
- <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]></param>
- <message>collectionFieldExpression.atLeastOne</message>
- </field-validator>
- <field-validator type="collectionFieldExpression">
- <param name="mode">EXACTLY_ONE</param>
- <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]></param>
- <message>collectionFieldExpression.exactlyOne</message>
- </field-validator>
- <field-validator type="collectionFieldExpression">
- <param name="mode">ALL</param>
- <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]></param>
- <message>collectionFieldExpression.all</message>
- </field-validator>
- <field-validator type="collectionFieldExpression">
- <param name="mode">NONE</param>
- <param name="expression"><![CDATA[ intValue == 0 && stringValue == "stringValue" ]]></param>
- <message>collectionFieldExpression.none</message>
- </field-validator>
-
- <field-validator type="collectionUniqueKey">
- <param name="keys">intValue</param>
- <message>collectionUniqueKey.one.failed</message>
- </field-validator>
- <field-validator type="collectionUniqueKey">
- <param name="keys">stringValue</param>
- <message>collectionUniqueKey.two.failed</message>
- </field-validator>
- <field-validator type="collectionUniqueKey">
- <param name="keys">intValue,stringValue</param>
- <message>collectionUniqueKey.three.failed</message>
- </field-validator>
- <field-validator type="collectionUniqueKey">
- <param name="keys">intValue,stringValue,stringValue2</param>
- <message>collectionUniqueKey.four.failed</message>
- </field-validator>
- <field-validator type="collectionUniqueKey">
- <param name="keys">stringValue</param>
- <param name="againstProperty">entry</param>
- <message>collectionUniqueKey.five.failed</message>
- </field-validator>
- </field>
-
-</validators>
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/SwingValidationUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/SwingValidationUtil.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/SwingValidationUtil.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,13 +1,14 @@
package jaxx.runtime.validator;
-import jaxx.runtime.validator.swing.SwingValidatorErrorListMouseListener;
-import jaxx.runtime.validator.swing.SwingValidatorErrorTableMouseListener;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.swing.JList;
import javax.swing.JTable;
import java.awt.event.MouseListener;
+import jaxx.runtime.validator.swing.SwingValidatorMessageTableMouseListener;
+import jaxx.runtime.validator.swing.SwingValidatorMessageListMouseListener;
/**
* The helper class for validation module.
@@ -28,13 +29,13 @@
return;
}
for (MouseListener listener : list.getMouseListeners()) {
- if (listener instanceof SwingValidatorErrorListMouseListener) {
+ if (listener instanceof SwingValidatorMessageListMouseListener) {
// already have a such listener
log.info("already registered a such MouseListener : " + listener);
return;
}
}
- list.addMouseListener(new SwingValidatorErrorListMouseListener());
+ list.addMouseListener(new SwingValidatorMessageListMouseListener());
}
public static void registerErrorTableMouseListener(JTable table) {
@@ -42,20 +43,20 @@
return;
}
for (MouseListener listener : table.getMouseListeners()) {
- if (listener instanceof SwingValidatorErrorTableMouseListener) {
+ if (listener instanceof SwingValidatorMessageTableMouseListener) {
// already have a such listener
log.info("already registered a such MouseListener : " + listener);
return;
}
}
- table.addMouseListener(new SwingValidatorErrorTableMouseListener());
+ table.addMouseListener(new SwingValidatorMessageTableMouseListener());
}
- public static SwingValidatorErrorTableMouseListener getErrorTableMouseListener(JTable table) {
+ public SwingValidatorMessageTableMouseListener getErrorTableMouseListener(JTable table) {
if (table != null) {
for (MouseListener listener : table.getMouseListeners()) {
- if (listener instanceof SwingValidatorErrorTableMouseListener) {
- return (SwingValidatorErrorTableMouseListener) listener;
+ if (listener instanceof SwingValidatorMessageTableMouseListener) {
+ return (SwingValidatorMessageTableMouseListener) listener;
}
}
}
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -107,10 +107,10 @@
protected Map<String, JComponent> fieldRepresentation;
/** Object servant a contenir la liste des erreurs */
- protected SwingValidatorErrorListModel errorListModel;
+ protected SwingValidatorMessageListModel errorListModel;
/** Object servant a contenir la liste des erreurs */
- protected SwingValidatorErrorTableModel errorTableModel;
+ protected SwingValidatorMessageTableModel errorTableModel;
/** ui renderer class */
protected Class<? extends AbstractBeanValidatorUI> uiClass;
@@ -129,7 +129,7 @@
return uiClass;
}
- public void setErrorListModel(SwingValidatorErrorListModel errorListModel) {
+ public void setErrorListModel(SwingValidatorMessageListModel errorListModel) {
this.errorListModel = errorListModel;
if (errorListModel != null) {
// register the validator in the model list
@@ -137,7 +137,7 @@
}
}
- public void setErrorTableModel(SwingValidatorErrorTableModel errorTableModel) {
+ public void setErrorTableModel(SwingValidatorMessageTableModel errorTableModel) {
this.errorTableModel = errorTableModel;
if (errorTableModel != null) {
// register the validator in the model table
@@ -221,7 +221,7 @@
}
for (Entry<String, JComponent> entry : fieldRepresentation.entrySet()) {
try {
- setErrorRepresentation(entry.getKey(), null, entry.getValue(), uiClass);
+ setMessageRepresentation(entry.getKey(), null, entry.getValue(), uiClass);
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -230,7 +230,7 @@
});
}
- protected void setErrorRepresentation(String fieldname, JComponent old, JComponent c, Class<? extends AbstractBeanValidatorUI> uiClass)
+ protected void setMessageRepresentation(String fieldname, JComponent old, JComponent c, Class<? extends AbstractBeanValidatorUI> uiClass)
throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
if (old == c) {
// same component, nothing to do
@@ -250,7 +250,6 @@
Object ui = jx.getUI();
if (ui != null && ui instanceof AbstractBeanValidatorUI) {
removeBeanValidatorListener((AbstractBeanValidatorUI)ui);
- //field.removeValidatorErrorListener((AbstractBeanValidatorUI) ui);
}
jx.setUI(null);
@@ -265,7 +264,6 @@
ui.setEnabled(true);
JXLayer<JComponent> jx = (JXLayer<JComponent>) container;
addBeanValidatorListener(ui);
- //field.addValidatorErrorListener(ui);
jx.setUI(ui);
}
}
Deleted: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListModel.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListModel.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,231 +0,0 @@
-package jaxx.runtime.validator.swing;
-
-import jaxx.runtime.validator.BeanValidatorEvent;
-
-import javax.swing.DefaultListModel;
-import javax.swing.JComponent;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorListener;
-import jaxx.runtime.validator.BeanValidatorScope;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * The model of the list of errors
- *
- * @author chemit
- */
-public class SwingValidatorErrorListModel extends DefaultListModel implements BeanValidatorListener {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static Log log = LogFactory.getLog(SwingValidatorErrorListModel.class);
- private static final long serialVersionUID = 1L;
- /** list of registred validators */
- protected transient List<SwingValidator<?>> validators;
-
- public SwingValidatorErrorListModel() {
- validators = new ArrayList<SwingValidator<?>>();
- }
-
- public void registerValidator(SwingValidator<?> validator) {
- if (validators.contains(validator)) {
- throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
- }
- validators.add(validator);
- validator.addBeanValidatorListener(this);
- // the model listen on each field of the validator
- /*for (ValidatorField<?> field : validator.getFields()) {
- field.addValidatorErrorListener(this);
- }*/
- }
-
- @Override
- public void onFieldChanged(BeanValidatorEvent event) {
- String[] toDelete = event.getMessagesToDelete();
- String[] toAdd = event.getMessagesToAdd();
- BeanValidatorScope scope = event.getScope();
- SwingValidator validator = (SwingValidator) event.getSource();
- BeanValidatorField field = event.getField();
-
- if (log.isTraceEnabled()) {
- log.trace("----------------------------------------------------------");
- log.trace(field + " - (" + getSize() + ") toAdd " + (toAdd == null ? null : toAdd.length));
- log.trace(field + " - (" + getSize() + ") toDelete " + (toDelete == null ? null : toDelete.length));
- }
-
- if ((toAdd == null || toAdd.length == 0) && (toDelete == null || toDelete.length == 0)) {
- // no data to add nor remove, so nothing to do
- return;
- }
-
- if (toAdd == null || toAdd.length == 0) {
-
- if (log.isTraceEnabled()) {
- log.trace(field + " - toDelete : just delete some datas!");
- }
-
- // no add, no need to resort the datas, can direclty delete
- // messages we do not want any longer
-
- // delete some messages for the given field and given scope
- List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
- List<Integer> indexs = new java.util.ArrayList<Integer>(toDelete.length);
-
- Enumeration enumeration = elements();
- int index = 0;
- while (enumeration.hasMoreElements()) {
- SwingValidatorErrorModel error = (SwingValidatorErrorModel) enumeration.nextElement();
-
- if (error.getValidator() == validator && error.getField() == field && ids.contains(error.getError())) {
- indexs.add(index);
- }
- index++;
- }
-
- java.util.Collections.reverse(indexs);
-
- for (Integer i : indexs) {
- removeElementAt(i);
- }
-
- return;
- }
-
- if (log.isTraceEnabled()) {
- log.trace(field + " - add and delete !");
- }
-
- List<SwingValidatorErrorModel> newMessages = new ArrayList<SwingValidatorErrorModel>();
-
-
-
- // obtain all messages not to delete
-
- List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
-
- Enumeration enumeration = elements();
- while (enumeration.hasMoreElements()) {
- SwingValidatorErrorModel error = (SwingValidatorErrorModel) enumeration.nextElement();
-
- if (error.getValidator() != validator || error.getField() != field || !ids.contains(error.getError())) {
- // keep this row
- newMessages.add(error);
- }
- }
-
- if (toAdd != null && toAdd.length > 0) {
- JComponent editor = validator.getFieldRepresentation(field.getName());
- // add new messages
- for (String error : toAdd) {
- newMessages.add(new SwingValidatorErrorModel(validator, field, error, editor));
- }
- }
-
- // sort datas
-
- java.util.Collections.sort(newMessages);
-
- // clean model and reinject new errors
- removeAllElements();
-
- // reinject in list model, all the errors
- for (SwingValidatorErrorModel error : newMessages) {
- addElement(error);
- }
-
- /*
- List<SwingValidatorErrorModel> newErrors = new ArrayList<SwingValidatorErrorModel>();
-
- JComponent editor = validator.getFieldRepresentation(field.getName());
- // add new errors
- for (String error : toAdd) {
- newErrors.add(new SwingValidatorErrorModel(validator, field, error, editor));
- }
-
-
- java.util.Collections.sort(newErrors);
-
- // clean model and reinject new errors
- removeAllElements();
-
- // reinject in list model, all the errors
- for (SwingValidatorErrorModel error : newErrors) {
- addElement(error);
- }*/
- }
- /**
- * Invoked when a validator detects a error on a field.
- *
- * @param event the event
- */
- /*@Override
- public void onNewError(ValidatorErrorEvent event) {
- ValidatorField field = event.getField();
- SwingValidator validator = (SwingValidator) event.getSource();
- Set<String> errors = event.getErrors();
-
- // must remove all previously error for this field and validator
- List<SwingValidatorErrorModel> newErrors = new ArrayList<SwingValidatorErrorModel>();
- JComponent editor = validator.getFieldRepresentation(field.getName());
- Enumeration enumeration = elements();
- while (enumeration.hasMoreElements()) {
- SwingValidatorErrorModel error = (SwingValidatorErrorModel) enumeration.nextElement();
- if (error.getValidator() == validator && error.getField() == field) {
- // this error can be skipped
- continue;
- }
- newErrors.add(error);
- }
- // add new errors
- for (String error : errors) {
- newErrors.add(new SwingValidatorErrorModel(validator, field, error, editor));
- }
- java.util.Collections.sort(newErrors);
-
- // clean model and reinject new errors
- removeAllElements();
-
- // reinject in list model, all the errors
- for (SwingValidatorErrorModel error : newErrors) {
- addElement(error);
- }
- //FIXME, this is not performant, prefer use a isValueAdjusting property on SwingValidator
- // notify that the model has changed
- }*/
- /**
- * Invoked when a validator detetcs that a previously error is
- * no more exisitng.
- *
- * @param event the event
- */
- /*@Override
- public void onResolvedError(ValidatorErrorEvent event) {
- SwingValidator validator = (SwingValidator) event.getSource();
- ValidatorField field = event.getField();
- // must remove all previously error for this field
-
- boolean somethingChange = false;
- Enumeration enumeration = elements();
- List<SwingValidatorErrorModel> newList = new ArrayList<SwingValidatorErrorModel>();
- while (enumeration.hasMoreElements()) {
- SwingValidatorErrorModel error = (SwingValidatorErrorModel) enumeration.nextElement();
- if (error.getValidator() == validator && error.getField() == field) {
- // this error can be skipped
- somethingChange = true;
- } else {
- newList.add(error);
- }
- }
- // clean model and reinject new errors
- removeAllElements();
-
- if (somethingChange) {
- for (SwingValidatorErrorModel errorModel : newList) {
- addElement(errorModel);
- }
- }
- }*/
-}
Deleted: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListMouseListener.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListMouseListener.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListMouseListener.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,61 +0,0 @@
-package jaxx.runtime.validator.swing;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JComponent;
-import javax.swing.JList;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-
-/**
- * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorErrorListModel} as a model.
- * <p/>
- * When a double click occurs, find the selected error in model and then focus to the associated component of error.
- *
- * @author chemit
- */
-public class SwingValidatorErrorListMouseListener extends MouseAdapter {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(SwingValidatorErrorListMouseListener.class);
-
- @Override
- public void mouseClicked(MouseEvent e) {
- super.mouseClicked(e);
- if (e.getClickCount() == 2) {
-
- SwingValidatorErrorModel entry = getSelectedError(e);
- if (entry == null) {
- // no entry found
- return;
- }
- JComponent component = entry.getEditor();
- if (component != null) {
- component.requestFocus();
- }
- }
- }
-
-
- protected SwingValidatorErrorModel getSelectedError(MouseEvent e) {
- JList list = (JList) e.getSource();
- if (!(list.getModel() instanceof SwingValidatorErrorListModel)) {
- log.warn("model must be a " + SwingValidatorErrorListModel.class + ", but was " + list.getModel());
- return null;
- }
-
- SwingValidatorErrorListModel model = (SwingValidatorErrorListModel) list.getModel();
- int index = list.getSelectionModel().getMinSelectionIndex();
- if (index == -1) {
- // nothing is selected
- return null;
- }
- SwingValidatorErrorModel entry = (SwingValidatorErrorModel) model.getElementAt(index);
- if (log.isDebugEnabled()) {
- log.debug("selected index: " + index + " : error: " + entry);
- }
- return entry;
- }
-
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorModel.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorModel.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,58 +0,0 @@
-package jaxx.runtime.validator.swing;
-
-
-import javax.swing.JComponent;
-import jaxx.runtime.validator.BeanValidatorField;
-
-/** @author chemit */
-public class SwingValidatorErrorModel implements Comparable<SwingValidatorErrorModel> {
- protected SwingValidator validator;
- protected BeanValidatorField field;
- protected String error;
- protected JComponent editor;
-
- public SwingValidatorErrorModel(SwingValidator validator, BeanValidatorField field, String error, JComponent editor) {
- this.field = field;
- this.validator = validator;
- this.error = error;
- this.editor = editor;
- }
-
- public JComponent getEditor() {
- return editor;
- }
-
- public SwingValidator getValidator() {
- return validator;
- }
-
- public BeanValidatorField getField() {
- return field;
- }
-
- public String getError() {
- return error;
- }
-
- @Override
- public int compareTo(SwingValidatorErrorModel o) {
- int result = field.getScope().compareTo(o.field.getScope());
- if (result != 0) {
- return result;
- }
- result = field.getName().compareTo(o.field.getName());
- if (result != 0) {
- return result;
- }
- result = error.compareTo(o.error);
- return result;
- }
-
- @Override
- public String toString() {
- if (editor == null) {
- return field.getI18nError(error);
- }
- return editor.getName() + " : " + field.getI18nError(error);
- }
-}
Deleted: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableModel.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableModel.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,158 +0,0 @@
-package jaxx.runtime.validator.swing;
-
-import jaxx.runtime.validator.BeanValidatorEvent;
-
-import javax.swing.JComponent;
-import javax.swing.table.DefaultTableModel;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Vector;
-import jaxx.runtime.validator.BeanValidatorField;
-import jaxx.runtime.validator.BeanValidatorListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * The model of the list of errors
- *
- * @author chemit
- */
-public class SwingValidatorErrorTableModel extends DefaultTableModel implements BeanValidatorListener {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static Log log = LogFactory.getLog(SwingValidatorErrorTableMouseListener.class);
- private static final long serialVersionUID = 1L;
- public static final String[] columnNames = {"validator.scope", "validator.field", "validator.message"};
- /** list of registred validators */
- protected transient List<SwingValidator<?>> validators;
- /** comporator of errors */
- protected transient Comparator<SwingValidatorErrorModel> comparator;
-
- public SwingValidatorErrorTableModel() {
- super(columnNames, 0);
- validators = new ArrayList<SwingValidator<?>>();
- }
-
- public int getErrorColumn() {
- return findColumn(columnNames[2]);
- }
-
- @Override
- public boolean isCellEditable(int row, int column) {
- // cells are never editable in this model
- return false;
- }
-
- public void registerValidator(SwingValidator<?> validator) {
- if (validators.contains(validator)) {
- throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
- }
- validators.add(validator);
- validator.addBeanValidatorListener(this);
- }
-
- @Override
- public void onFieldChanged(BeanValidatorEvent event) {
- String[] toDelete = event.getMessagesToDelete();
- String[] toAdd = event.getMessagesToAdd();
- BeanValidatorField field = event.getField();
-
- if (log.isTraceEnabled()) {
- log.trace("----------------------------------------------------------");
- log.trace(field + " - (" + getRowCount() + ") toAdd " + (toAdd == null ? null : toAdd.length));
- log.trace(field + " - (" + getRowCount() + ") toDelete " + (toDelete == null ? null : toDelete.length));
- }
- if ((toAdd == null || toAdd.length == 0) && (toDelete == null || toDelete.length == 0)) {
- // no data to add nor remove, so nothing to do
- return;
- }
-
- SwingValidator validator = (SwingValidator) event.getSource();
-
-
- int errorColumn = getErrorColumn();
-
- if (toAdd == null || toAdd.length == 0) {
-
-
- if (log.isTraceEnabled()) {
- log.trace(field + " - toDelete : just delete some datas!");
- }
-
- // no add, no need to resort the datas, can direclty delete
- // messages we do not want any longer
-
- // delete some messages for the given field and given scope
- List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
- List<Integer> indexs = new java.util.ArrayList<Integer>(toDelete.length);
-
- Enumeration enumeration = getDataVector().elements();
-
- int index = 0;
- while (enumeration.hasMoreElements()) {
- Vector row = (Vector) enumeration.nextElement();
- SwingValidatorErrorModel error = (SwingValidatorErrorModel) row.get(errorColumn);
- if (error.getValidator() == validator && error.getField() == field && ids.contains(error.getError())) {
- // remo the message
- indexs.add(index);
- }
- index++;
- }
- java.util.Collections.reverse(indexs);
-
- for (Integer i : indexs) {
- removeRow(i);
- }
-
- return;
- }
-
- if (log.isTraceEnabled()) {
- log.trace(field + " - add and delete !");
- }
-
- // rebuild all the data (since we are some adding data and we ensure
- // an order on datas)
-
- List<SwingValidatorErrorModel> newMessages = new ArrayList<SwingValidatorErrorModel>();
-
- // delete some messages for the given field and given scope
- List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
-
- Enumeration enumeration = getDataVector().elements();
-
- while (enumeration.hasMoreElements()) {
- Vector row = (Vector) enumeration.nextElement();
- SwingValidatorErrorModel error = (SwingValidatorErrorModel) row.get(errorColumn);
- if (error.getValidator() != validator || error.getField() != field || !ids.contains(error.getError())) {
- // keep this row
- newMessages.add(error);
- }
- }
-
- if (toAdd != null && toAdd.length > 0) {
- JComponent editor = validator.getFieldRepresentation(field.getName());
- // add new errors
- for (String error : toAdd) {
- SwingValidatorErrorModel errorModel = new SwingValidatorErrorModel(validator, field, error, editor);
- newMessages.add(errorModel);
- }
- }
-
- // sort datas
-
- java.util.Collections.sort(newMessages);
-
- // clean table model and reinject new messages
- getDataVector().clear();
-
- // reinject in list model, all the errors
- for (SwingValidatorErrorModel error : newMessages) {
- addRow(new Object[]{error.getField().getScope(), error.getField().getName(), error});
- }
-
- fireTableDataChanged();
- }
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableMouseListener.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableMouseListener.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableMouseListener.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,92 +0,0 @@
-package jaxx.runtime.validator.swing;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JComponent;
-import javax.swing.JTable;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-
-/**
- * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorErrorTableModel} as a model.
- * <p/>
- * When a double click occurs, find the selected error in model and then focus to the associated component of error.
- *
- * @author chemit
- */
-public class SwingValidatorErrorTableMouseListener extends MouseAdapter {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static Log log = LogFactory.getLog(SwingValidatorErrorTableMouseListener.class);
-
- public static final String HIGHLIGHT_ERROR_PROPERTY = "highlightError";
-
- /** delgate property change support */
- protected PropertyChangeSupport pcs;
-
- public SwingValidatorErrorTableMouseListener() {
- pcs = new PropertyChangeSupport(this);
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- super.mouseClicked(e);
- if (e.getClickCount() == 2) {
-
- SwingValidatorErrorModel entry = getSelectedError(e);
- if (entry == null) {
- // no entry found
- return;
- }
- JComponent component = entry.getEditor();
- if (component != null) {
- pcs.firePropertyChange(HIGHLIGHT_ERROR_PROPERTY, null, entry);
- if (component.isVisible()) {
- component.requestFocus();
- }
- }
- }
- }
-
-
- protected SwingValidatorErrorModel getSelectedError(MouseEvent e) {
- JTable table = (JTable) e.getSource();
- if (!(table.getModel() instanceof SwingValidatorErrorTableModel)) {
- log.warn("model must be a " + SwingValidatorErrorTableModel.class + ", but was " + table.getModel());
- return null;
- }
-
- SwingValidatorErrorTableModel model = (SwingValidatorErrorTableModel) table.getModel();
- int index = table.getSelectionModel().getMinSelectionIndex();
- if (index == -1) {
- // nothing is selected
- return null;
- }
- int col = model.getErrorColumn();
- SwingValidatorErrorModel entry = (SwingValidatorErrorModel) model.getValueAt(index, col);
- if (log.isDebugEnabled()) {
- log.debug("selected index: " + index + " : error: " + entry);
- }
- return entry;
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableRenderer.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableRenderer.java 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableRenderer.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,61 +0,0 @@
-package jaxx.runtime.validator.swing;
-
-import javax.swing.ImageIcon;
-import javax.swing.JLabel;
-import javax.swing.JTable;
-import javax.swing.table.DefaultTableCellRenderer;
-import java.awt.Component;
-import jaxx.runtime.validator.BeanValidatorScope;
-
-/** @author chemit */
-public class SwingValidatorErrorTableRenderer extends DefaultTableCellRenderer {
-
- private static final long serialVersionUID = 1L;
- ImageIcon errorIcon;
- ImageIcon warningIcon;
- ImageIcon infoIcon;
-
- public SwingValidatorErrorTableRenderer() {
- errorIcon = jaxx.runtime.Util.createImageIcon("error.png");
- warningIcon = jaxx.runtime.Util.createImageIcon("warning.png");
- infoIcon = jaxx.runtime.Util.createImageIcon("info.png");
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- JLabel rendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- ImageIcon icon = null;
- String text = null;
- if (value instanceof BeanValidatorScope) {
-
- BeanValidatorScope scope = (BeanValidatorScope) value;
- switch (scope) {
- case ERROR:
- icon = errorIcon;
- break;
- case WARNING:
- icon = warningIcon;
- break;
- case INFO:
- icon = infoIcon;
- break;
- }
- } else if (value instanceof SwingValidatorErrorModel) {
- SwingValidatorErrorModel model = (SwingValidatorErrorModel) value;
- String error = model.getError();
- text = model.getField().getI18nError(error);
- } else {
- // keep text rendered
- text = rendererComponent.getText();
- }
- rendererComponent.setText(text);
- rendererComponent.setIcon(icon);
- return rendererComponent;
- }
-
- @Override
- protected void setValue(Object value) {
- super.setValue(value);
- }
-}
\ No newline at end of file
Copied: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (from rev 1273, jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListModel.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListModel.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -0,0 +1,135 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.validator.BeanValidatorEvent;
+
+import javax.swing.DefaultListModel;
+import javax.swing.JComponent;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
+import jaxx.runtime.validator.BeanValidatorScope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The model of the list of validation's messages
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageListModel extends DefaultListModel implements BeanValidatorListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorMessageListModel.class);
+ private static final long serialVersionUID = 1L;
+ /** list of registred validators */
+ protected transient List<SwingValidator<?>> validators;
+
+ public SwingValidatorMessageListModel() {
+ validators = new ArrayList<SwingValidator<?>>();
+ }
+
+ public void registerValidator(SwingValidator<?> validator) {
+ if (validators.contains(validator)) {
+ throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
+ }
+ validators.add(validator);
+ validator.addBeanValidatorListener(this);
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ String[] toDelete = event.getMessagesToDelete();
+ String[] toAdd = event.getMessagesToAdd();
+ BeanValidatorScope scope = event.getScope();
+ SwingValidator validator = (SwingValidator) event.getSource();
+ BeanValidatorField field = event.getField();
+
+ if (log.isTraceEnabled()) {
+ log.trace("----------------------------------------------------------");
+ log.trace(field + " - (" + getSize() + ") toAdd " + (toAdd == null ? null : toAdd.length));
+ log.trace(field + " - (" + getSize() + ") toDelete " + (toDelete == null ? null : toDelete.length));
+ }
+
+ if ((toAdd == null || toAdd.length == 0) && (toDelete == null || toDelete.length == 0)) {
+ // no data to add nor remove, so nothing to do
+ return;
+ }
+
+ if (toAdd == null || toAdd.length == 0) {
+
+ if (log.isTraceEnabled()) {
+ log.trace(field + " - toDelete : just delete some datas!");
+ }
+
+ // no add, no need to resort the datas, can direclty delete
+ // messages we do not want any longer
+
+ // delete some messages for the given field and given scope
+ List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+ List<Integer> indexs = new java.util.ArrayList<Integer>(toDelete.length);
+
+ Enumeration enumeration = elements();
+ int index = 0;
+ while (enumeration.hasMoreElements()) {
+ SwingValidatorMessageModel error = (SwingValidatorMessageModel) enumeration.nextElement();
+
+ if (error.getValidator() == validator && error.getField() == field && ids.contains(error.getMessage())) {
+ indexs.add(index);
+ }
+ index++;
+ }
+
+ java.util.Collections.reverse(indexs);
+
+ for (Integer i : indexs) {
+ removeElementAt(i);
+ }
+
+ return;
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace(field + " - add and delete !");
+ }
+
+ List<SwingValidatorMessageModel> newMessages = new ArrayList<SwingValidatorMessageModel>();
+
+
+
+ // obtain all messages not to delete
+
+ List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+
+ Enumeration enumeration = elements();
+ while (enumeration.hasMoreElements()) {
+ SwingValidatorMessageModel error = (SwingValidatorMessageModel) enumeration.nextElement();
+
+ if (error.getValidator() != validator || error.getField() != field || !ids.contains(error.getMessage())) {
+ // keep this row
+ newMessages.add(error);
+ }
+ }
+
+ if (toAdd != null && toAdd.length > 0) {
+ JComponent editor = validator.getFieldRepresentation(field.getName());
+ // add new messages
+ for (String error : toAdd) {
+ newMessages.add(new SwingValidatorMessageModel(validator, field, error, editor));
+ }
+ }
+
+ // sort datas
+
+ java.util.Collections.sort(newMessages);
+
+ // clean model and reinject new errors
+ removeAllElements();
+
+ // reinject in list model, all the errors
+ for (SwingValidatorMessageModel error : newMessages) {
+ addElement(error);
+ }
+ }
+}
Copied: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (from rev 1273, jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListMouseListener.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -0,0 +1,61 @@
+package jaxx.runtime.validator.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JComponent;
+import javax.swing.JList;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/**
+ * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageListModel} as a model.
+ * <p/>
+ * When a double click occurs, find the selected error in model and then focus to the associated component of error.
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageListMouseListener extends MouseAdapter {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(SwingValidatorMessageListMouseListener.class);
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ super.mouseClicked(e);
+ if (e.getClickCount() == 2) {
+
+ SwingValidatorMessageModel entry = getSelectedError(e);
+ if (entry == null) {
+ // no entry found
+ return;
+ }
+ JComponent component = entry.getEditor();
+ if (component != null) {
+ component.requestFocus();
+ }
+ }
+ }
+
+
+ protected SwingValidatorMessageModel getSelectedError(MouseEvent e) {
+ JList list = (JList) e.getSource();
+ if (!(list.getModel() instanceof SwingValidatorMessageListModel)) {
+ log.warn("model must be a " + SwingValidatorMessageListModel.class + ", but was " + list.getModel());
+ return null;
+ }
+
+ SwingValidatorMessageListModel model = (SwingValidatorMessageListModel) list.getModel();
+ int index = list.getSelectionModel().getMinSelectionIndex();
+ if (index == -1) {
+ // nothing is selected
+ return null;
+ }
+ SwingValidatorMessageModel entry = (SwingValidatorMessageModel) model.getElementAt(index);
+ if (log.isDebugEnabled()) {
+ log.debug("selected index: " + index + " : error: " + entry);
+ }
+ return entry;
+ }
+
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageListMouseListener.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java (from rev 1273, jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorModel.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -0,0 +1,75 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.JComponent;
+import jaxx.runtime.validator.BeanValidatorField;
+
+/**
+ * The object to box a validation message within an u.
+ *
+ * @author chemit
+ * @since 1.3
+ */
+public class SwingValidatorMessageModel implements Comparable<SwingValidatorMessageModel> {
+
+ /**
+ * the validator that produce the message
+ */
+ protected SwingValidator validator;
+ /**
+ * the field thatproduce the message
+ */
+ protected BeanValidatorField field;
+ /**
+ * the label of the message (to be displayed somewhere)
+ */
+ protected String message;
+ /**
+ * the optional field's editor
+ */
+ protected JComponent editor;
+
+ public SwingValidatorMessageModel(SwingValidator validator, BeanValidatorField field, String message, JComponent editor) {
+ this.field = field;
+ this.validator = validator;
+ this.message = message;
+ this.editor = editor;
+ }
+
+ public JComponent getEditor() {
+ return editor;
+ }
+
+ public SwingValidator getValidator() {
+ return validator;
+ }
+
+ public BeanValidatorField getField() {
+ return field;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ @Override
+ public int compareTo(SwingValidatorMessageModel o) {
+ int result = field.getScope().compareTo(o.field.getScope());
+ if (result != 0) {
+ return result;
+ }
+ result = field.getName().compareTo(o.field.getName());
+ if (result != 0) {
+ return result;
+ }
+ result = message.compareTo(o.message);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ if (editor == null) {
+ return field.getI18nError(message);
+ }
+ return editor.getName() + " : " + field.getI18nError(message);
+ }
+}
Property changes on: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageModel.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (from rev 1273, jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableModel.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableModel.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -0,0 +1,158 @@
+package jaxx.runtime.validator.swing;
+
+import jaxx.runtime.validator.BeanValidatorEvent;
+
+import javax.swing.JComponent;
+import javax.swing.table.DefaultTableModel;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Vector;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The model of the list of errors
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageTableModel extends DefaultTableModel implements BeanValidatorListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
+ private static final long serialVersionUID = 1L;
+ public static final String[] columnNames = {"validator.scope", "validator.field", "validator.message"};
+ /** list of registred validators */
+ protected transient List<SwingValidator<?>> validators;
+ /** comporator of errors */
+ protected transient Comparator<SwingValidatorMessageModel> comparator;
+
+ public SwingValidatorMessageTableModel() {
+ super(columnNames, 0);
+ validators = new ArrayList<SwingValidator<?>>();
+ }
+
+ public int getErrorColumn() {
+ return findColumn(columnNames[2]);
+ }
+
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ // cells are never editable in this model
+ return false;
+ }
+
+ public void registerValidator(SwingValidator<?> validator) {
+ if (validators.contains(validator)) {
+ throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
+ }
+ validators.add(validator);
+ validator.addBeanValidatorListener(this);
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ String[] toDelete = event.getMessagesToDelete();
+ String[] toAdd = event.getMessagesToAdd();
+ BeanValidatorField field = event.getField();
+
+ if (log.isTraceEnabled()) {
+ log.trace("----------------------------------------------------------");
+ log.trace(field + " - (" + getRowCount() + ") toAdd " + (toAdd == null ? null : toAdd.length));
+ log.trace(field + " - (" + getRowCount() + ") toDelete " + (toDelete == null ? null : toDelete.length));
+ }
+ if ((toAdd == null || toAdd.length == 0) && (toDelete == null || toDelete.length == 0)) {
+ // no data to add nor remove, so nothing to do
+ return;
+ }
+
+ SwingValidator validator = (SwingValidator) event.getSource();
+
+
+ int errorColumn = getErrorColumn();
+
+ if (toAdd == null || toAdd.length == 0) {
+
+
+ if (log.isTraceEnabled()) {
+ log.trace(field + " - toDelete : just delete some datas!");
+ }
+
+ // no add, no need to resort the datas, can direclty delete
+ // messages we do not want any longer
+
+ // delete some messages for the given field and given scope
+ List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+ List<Integer> indexs = new java.util.ArrayList<Integer>(toDelete.length);
+
+ Enumeration enumeration = getDataVector().elements();
+
+ int index = 0;
+ while (enumeration.hasMoreElements()) {
+ Vector row = (Vector) enumeration.nextElement();
+ SwingValidatorMessageModel error = (SwingValidatorMessageModel) row.get(errorColumn);
+ if (error.getValidator() == validator && error.getField() == field && ids.contains(error.getMessage())) {
+ // remo the message
+ indexs.add(index);
+ }
+ index++;
+ }
+ java.util.Collections.reverse(indexs);
+
+ for (Integer i : indexs) {
+ removeRow(i);
+ }
+
+ return;
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace(field + " - add and delete !");
+ }
+
+ // rebuild all the data (since we are some adding data and we ensure
+ // an order on datas)
+
+ List<SwingValidatorMessageModel> newMessages = new ArrayList<SwingValidatorMessageModel>();
+
+ // delete some messages for the given field and given scope
+ List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+
+ Enumeration enumeration = getDataVector().elements();
+
+ while (enumeration.hasMoreElements()) {
+ Vector row = (Vector) enumeration.nextElement();
+ SwingValidatorMessageModel error = (SwingValidatorMessageModel) row.get(errorColumn);
+ if (error.getValidator() != validator || error.getField() != field || !ids.contains(error.getMessage())) {
+ // keep this row
+ newMessages.add(error);
+ }
+ }
+
+ if (toAdd != null && toAdd.length > 0) {
+ JComponent editor = validator.getFieldRepresentation(field.getName());
+ // add new errors
+ for (String error : toAdd) {
+ SwingValidatorMessageModel errorModel = new SwingValidatorMessageModel(validator, field, error, editor);
+ newMessages.add(errorModel);
+ }
+ }
+
+ // sort datas
+
+ java.util.Collections.sort(newMessages);
+
+ // clean table model and reinject new messages
+ getDataVector().clear();
+
+ // reinject in list model, all the errors
+ for (SwingValidatorMessageModel error : newMessages) {
+ addRow(new Object[]{error.getField().getScope(), error.getField().getName(), error});
+ }
+
+ fireTableDataChanged();
+ }
+}
\ No newline at end of file
Copied: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (from rev 1273, jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableMouseListener.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -0,0 +1,92 @@
+package jaxx.runtime.validator.swing;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ * A mouse listener to put on a {@link javax.swing.JList} with a {@link SwingValidatorMessageTableModel} as a model.
+ * <p/>
+ * When a double click occurs, find the selected error in model and then focus to the associated component of error.
+ *
+ * @author chemit
+ */
+public class SwingValidatorMessageTableMouseListener extends MouseAdapter {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorMessageTableMouseListener.class);
+
+ public static final String HIGHLIGHT_ERROR_PROPERTY = "highlightError";
+
+ /** delgate property change support */
+ protected PropertyChangeSupport pcs;
+
+ public SwingValidatorMessageTableMouseListener() {
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ super.mouseClicked(e);
+ if (e.getClickCount() == 2) {
+
+ SwingValidatorMessageModel entry = getSelectedError(e);
+ if (entry == null) {
+ // no entry found
+ return;
+ }
+ JComponent component = entry.getEditor();
+ if (component != null) {
+ pcs.firePropertyChange(HIGHLIGHT_ERROR_PROPERTY, null, entry);
+ if (component.isVisible()) {
+ component.requestFocus();
+ }
+ }
+ }
+ }
+
+
+ protected SwingValidatorMessageModel getSelectedError(MouseEvent e) {
+ JTable table = (JTable) e.getSource();
+ if (!(table.getModel() instanceof SwingValidatorMessageTableModel)) {
+ log.warn("model must be a " + SwingValidatorMessageTableModel.class + ", but was " + table.getModel());
+ return null;
+ }
+
+ SwingValidatorMessageTableModel model = (SwingValidatorMessageTableModel) table.getModel();
+ int index = table.getSelectionModel().getMinSelectionIndex();
+ if (index == -1) {
+ // nothing is selected
+ return null;
+ }
+ int col = model.getErrorColumn();
+ SwingValidatorMessageModel entry = (SwingValidatorMessageModel) model.getValueAt(index, col);
+ if (log.isDebugEnabled()) {
+ log.debug("selected index: " + index + " : error: " + entry);
+ }
+ return entry;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableMouseListener.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (from rev 1273, jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableRenderer.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java 2009-03-21 08:22:03 UTC (rev 1274)
@@ -0,0 +1,61 @@
+package jaxx.runtime.validator.swing;
+
+import javax.swing.ImageIcon;
+import javax.swing.JLabel;
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.Component;
+import jaxx.runtime.validator.BeanValidatorScope;
+
+/** @author chemit */
+public class SwingValidatorMessageTableRenderer extends DefaultTableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+ ImageIcon errorIcon;
+ ImageIcon warningIcon;
+ ImageIcon infoIcon;
+
+ public SwingValidatorMessageTableRenderer() {
+ errorIcon = jaxx.runtime.Util.createImageIcon("error.png");
+ warningIcon = jaxx.runtime.Util.createImageIcon("warning.png");
+ infoIcon = jaxx.runtime.Util.createImageIcon("info.png");
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ JLabel rendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ ImageIcon icon = null;
+ String text = null;
+ if (value instanceof BeanValidatorScope) {
+
+ BeanValidatorScope scope = (BeanValidatorScope) value;
+ switch (scope) {
+ case ERROR:
+ icon = errorIcon;
+ break;
+ case WARNING:
+ icon = warningIcon;
+ break;
+ case INFO:
+ icon = infoIcon;
+ break;
+ }
+ } else if (value instanceof SwingValidatorMessageModel) {
+ SwingValidatorMessageModel model = (SwingValidatorMessageModel) value;
+ String error = model.getMessage();
+ text = model.getField().getI18nError(error);
+ } else {
+ // keep text rendered
+ text = rendererComponent.getText();
+ }
+ rendererComponent.setText(text);
+ rendererComponent.setIcon(icon);
+ return rendererComponent;
+ }
+
+ @Override
+ protected void setValue(Object value) {
+ super.setValue(value);
+ }
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorMessageTableRenderer.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedErrorListModel.jaxx
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedErrorListModel.jaxx 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedErrorListModel.jaxx 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,4 +1,4 @@
<Application>
- <jaxx.runtime.validator.swing.SwingValidatorErrorListModel id='errors'/>
+ <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'/>
<BeanValidator beanClass='testcases.validator.errors.Model' errorListModel='errors' errorListModel='fake'/>
</Application>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedErrorTableModel.jaxx
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedErrorTableModel.jaxx 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/errors/DuplicatedErrorTableModel.jaxx 2009-03-21 08:22:03 UTC (rev 1274)
@@ -1,4 +1,4 @@
<Application>
- <jaxx.runtime.validator.swing.SwingValidatorErrorListModel id='errors'/>
+ <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'/>
<BeanValidator beanClass='testcases.validator.errors.Model' errorTableModel='errors' errorTableModel='fake'/>
</Application>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/ok/Validation.jaxx
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/ok/Validation.jaxx 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/ok/Validation.jaxx 2009-03-21 08:22:03 UTC (rev 1274)
@@ -6,7 +6,7 @@
<Identity id='identity'/>
<!-- errors model -->
- <jaxx.runtime.validator.swing.SwingValidatorErrorListModel id='errors'
+ <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'
onContentsChanged='ok.setEnabled(errors.size()==0)'/>
<!-- validators -->
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/ok/ValidationBeanClass.jaxx
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/ok/ValidationBeanClass.jaxx 2009-03-20 13:02:18 UTC (rev 1273)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/validator/ok/ValidationBeanClass.jaxx 2009-03-21 08:22:03 UTC (rev 1274)
@@ -4,7 +4,7 @@
<Identity id='identity'/>
<!-- errors model -->
- <jaxx.runtime.validator.swing.SwingValidatorErrorListModel id='errors'/>
+ <jaxx.runtime.validator.swing.SwingValidatorMessageListModel id='errors'/>
<!-- validators -->
<BeanValidator id='validator3' autoField='true' beanClass='testcases.validator.ok.Identity' errorListModel='errors'>
1
0
r1273 - in jaxx/trunk: . jaxx-compiler-api jaxx-compiler-swing jaxx-compiler-validator jaxx-example jaxx-runtime-api jaxx-runtime-swing jaxx-runtime-validator jaxx-runtime-validator-swing jaxx-swing-action jaxx-util maven-jaxx-plugin
by tchemit@users.labs.libre-entreprise.org March 20, 2009
by tchemit@users.labs.libre-entreprise.org March 20, 2009
March 20, 2009
Author: tchemit
Date: 2009-03-20 13:02:18 +0000 (Fri, 20 Mar 2009)
New Revision: 1273
Modified:
jaxx/trunk/changelog.txt
jaxx/trunk/jaxx-compiler-api/changelog.txt
jaxx/trunk/jaxx-compiler-swing/changelog.txt
jaxx/trunk/jaxx-compiler-validator/changelog.txt
jaxx/trunk/jaxx-example/changelog.txt
jaxx/trunk/jaxx-runtime-api/changelog.txt
jaxx/trunk/jaxx-runtime-swing/changelog.txt
jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt
jaxx/trunk/jaxx-runtime-validator/changelog.txt
jaxx/trunk/jaxx-swing-action/changelog.txt
jaxx/trunk/jaxx-util/changelog.txt
jaxx/trunk/maven-jaxx-plugin/changelog.txt
Log:
release 1.3
Modified: jaxx/trunk/changelog.txt
===================================================================
--- jaxx/trunk/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,5 +1,6 @@
-1.3
+1.3 chemit 20090320
* 20090313 [chemit] - use i18n 0.10
+
1.2 ??? 2009????
* 20090223 [chemit] - move sources from jaxx-util to jaxx-swing-action module
- delete jaxx-util module
Modified: jaxx/trunk/jaxx-compiler-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,4 +1,4 @@
-1.3 ??? 200902??
+1.3 chemit 20090320
* 20090313 [chemit] - can now use geneticType on javaBean object
- add an extra method $afterCompleteSetup method to be included if find in script at last statement of $completeSetup method
Modified: jaxx/trunk/jaxx-compiler-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-compiler-swing/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,3 +1,5 @@
+1.3 chemit 20090320
+
1.1 chemit 20090220
* 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...)
Modified: jaxx/trunk/jaxx-compiler-validator/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-compiler-validator/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,3 +1,5 @@
+1.3 chemit 20090320
+
1.1 chemit 20090220
* 20090202 [chemit] - refactor validators (this module will soon disappear to jaxx-compiler-swing-validator)
* 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...)
Modified: jaxx/trunk/jaxx-example/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-example/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-example/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,4 +1,4 @@
-1.3
+1.3 chemit 20090320
* 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
* 20090313 [chemit] - improve demo
Modified: jaxx/trunk/jaxx-runtime-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,4 +1,4 @@
-1.3 ??? 200903??
+1.3 chemit 20090320
* 20090302 [chemit] - add pcs in ApplicationContext
- add method in Util to filter JAXX property changed listeners
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,4 +1,4 @@
-1.3 ?? 200903??
+1.3 chemit 20090320
* 20090318 [chemit] - introduce the BlockingLayerUI2 class (should be merge with BlockingLayerUI)
* 20090318 [chemit] - introduce the CardLayout2Ext class
* 20090312 [chemit] - add some usefull code from ObServe (load Nimbus L&F, load ui configuration)
Modified: jaxx/trunk/jaxx-runtime-validator/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,4 +1,4 @@
-1.3 ??? 200903??
+1.3 chemit 20090320
* 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
1.1 chemit 20090220
Modified: jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,4 +1,4 @@
-1.3 ??? 200903??
+1.3 chemit 20090320
* 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
1.1 chemit 20090220
Modified: jaxx/trunk/jaxx-swing-action/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-swing-action/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-swing-action/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,3 +1,5 @@
+1.3 chemit 20090320
+
1.1 chemit 20090220
* 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...)
- rename i18n bundles according artifactId
Modified: jaxx/trunk/jaxx-util/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-util/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/jaxx-util/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,3 +1,5 @@
+1.3 chemit 20090320
+
1.1 chemit 20090220
* 20090122 [chemit] - refactor poms (sibling dependencies, pluginsManagment,...)
- rename i18n bundles according artifactId
Modified: jaxx/trunk/maven-jaxx-plugin/changelog.txt
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
+++ jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-03-20 13:02:18 UTC (rev 1273)
@@ -1,4 +1,4 @@
-1.3 ??? 200903??
+1.3 chemit 20090320
* 20090301 [chemit] - add a profile mode (-Djaxx.profile)
1.2 letelier 2009022?
1
0
r1272 - in jaxx/trunk: jaxx-example jaxx-example/src/main/java/jaxx/demo jaxx-example/src/main/resources jaxx-example/src/main/resources/i18n jaxx-example/src/main/resources/jaxx/demo jaxx-runtime-validator jaxx-runtime-validator/src/main/java/jaxx/runtime jaxx-runtime-validator/src/main/java/jaxx/runtime/validator jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field jaxx-runtime-validator/src/test/java/jaxx/runtime/validator jaxx-runtime-validator/src/test/java/jaxx/runtime/vali
by tchemit@users.labs.libre-entreprise.org March 19, 2009
by tchemit@users.labs.libre-entreprise.org March 19, 2009
March 19, 2009
Author: tchemit
Date: 2009-03-19 22:47:05 +0000 (Thu, 19 Mar 2009)
New Revision: 1272
Added:
jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-error-validation.xml
jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-info-validation.xml
jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-warning-validation.xml
jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-error-validation.xml
jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-info-validation.xml
jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-warning-validation.xml
jaxx/trunk/jaxx-runtime-validator-swing/src/main/resources/icons/info.png
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator2.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/SimpleBean.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java
jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml
jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml
jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml
jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml
Removed:
jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-validation.xml
jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-validation.xml
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorScope.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/AbstractValidatorTest.java
Modified:
jaxx/trunk/jaxx-example/changelog.txt
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
jaxx/trunk/jaxx-example/src/main/resources/log4j.properties
jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableModel.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableRenderer.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
jaxx/trunk/jaxx-runtime-validator/changelog.txt
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/JAXXValidator.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorEvent.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorListener.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorField.java
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java
jaxx/trunk/jaxx-runtime-validator/src/test/resources/log4j.properties
Log:
refactor validator, now can deal with scope : one file by scope
no more modification in xworls
improve listener design
TODO remove all classes and bump back the version of xworks
Modified: jaxx/trunk/jaxx-example/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-example/changelog.txt 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-example/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,4 +1,5 @@
1.3
+ * 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
* 20090313 [chemit] - improve demo
1.1 chemit 20090220
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-03-19 22:47:05 UTC (rev 1272)
@@ -3,7 +3,8 @@
org.codelutin.i18n.I18n.init();
-void $afterCompleteSetup() {
+void $afterCompleteSetup() {
+ try { jaxx.runtime.SwingUtil.initNimbusLoookAndFeel(); } catch (Exception e) { log.error(e.getMessage(), e); }
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationListDemo.jaxx 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,6 +1,16 @@
<DemoPanel>
<style source="Validation.css"/>
+<script>
+void $afterCompleteSetup() {
+ validator.setBean(null);
+ validator2.setBean(null);
+ validator3.setBean(null);
+ validator.setBean(model1);
+ validator2.setBean(model2);
+ validator3.setBean(identity);
+}
+</script>
<!-- models -->
<Model id='model1'/>
<Model id='model2'/>
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx 2009-03-19 22:47:05 UTC (rev 1272)
@@ -30,16 +30,17 @@
import static org.codelutin.i18n.I18n.n_;
import jaxx.runtime.SwingUtil;
-static boolean wasinit=false;
-
-errorTable.setDefaultRenderer(Object.class, new jaxx.runtime.validator.swing.SwingValidatorErrorTableRenderer());
-SwingUtil.setI18nTableHeaderRenderer(errorTable, n_("validator.scope"), n_("validator.scope.tip"), n_("validator.field"), n_("validator.field.tip"), n_("validator.message"), n_("validator.message.tip"));
-public void setVisible(boolean value) {
- if (!wasinit) {
- SwingUtil.fixTableColumnWidth(errorTable, 0, 20);
- wasinit=true;
- }
- super.setVisible(value);
+void $afterCompleteSetup() {
+ errorTable.setDefaultRenderer(Object.class, new jaxx.runtime.validator.swing.SwingValidatorErrorTableRenderer());
+ SwingUtil.setI18nTableHeaderRenderer(errorTable, n_("validator.scope"), n_("validator.scope.tip"), n_("validator.field"), n_("validator.field.tip"), n_("validator.message"), n_("validator.message.tip"));
+ SwingUtil.fixTableColumnWidth(errorTable, 0, 25);
+
+ validator.setBean(null);
+ validator2.setBean(null);
+ validator3.setBean(null);
+ validator.setBean(model1);
+ validator2.setBean(model2);
+ validator3.setBean(identity);
}
]]></script>
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-03-19 22:47:05 UTC (rev 1272)
@@ -89,6 +89,7 @@
button\ B=
button\ C=
button\ C\ (full\ block)=
+button\ D\ (full\ block\ 2)=
button\ with\ layer=
cancel=
close=
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-03-19 22:47:05 UTC (rev 1272)
@@ -89,6 +89,7 @@
button\ B=
button\ C=
button\ C\ (full\ block)=
+button\ D\ (full\ block\ 2)=
button\ with\ layer=
cancel=
close=
Added: jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-error-validation.xml
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-error-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-error-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,49 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <field name="firstName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a firstName.</message>
+ </field-validator>
+ </field>
+ <field name="lastName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a lastName.</message>
+ </field-validator>
+ </field>
+
+ <field name="email">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for email.</message>
+ </field-validator>
+ <field-validator type="email" short-circuit="true">
+ <message>Not a valid e-mail.</message>
+ </field-validator>
+ </field>
+
+ <field name="config">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for config.</message>
+ </field-validator>
+ <field-validator type="existingFile" short-circuit="true">
+ <message>The configuration file ${config} does not exist.</message>
+ </field-validator>
+ </field>
+
+ <field name="dir">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for dir.</message>
+ </field-validator>
+ <field-validator type="existingDirectory" short-circuit="true">
+ <message>The directory ${dir} does not exist.</message>
+ </field-validator>
+ </field>
+
+ <field name="age">
+ <field-validator type="int">
+ <param name="min">18</param>
+ <message>Your are too young (min ${min} )</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Copied: jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-info-validation.xml (from rev 1250, jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-validation.xml)
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-info-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-info-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,49 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!--field name="firstName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a firstName.</message>
+ </field-validator>
+ </field>
+ <field name="lastName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a lastName.</message>
+ </field-validator>
+ </field>
+
+ <field name="email">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for email.</message>
+ </field-validator>
+ <field-validator type="email" short-circuit="true">
+ <message>Not a valid e-mail.</message>
+ </field-validator>
+ </field>
+
+ <field name="config">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for config.</message>
+ </field-validator>
+ <field-validator type="existingFile" short-circuit="true">
+ <message>The configuration file ${config} does not exist.</message>
+ </field-validator>
+ </field>
+
+ <field name="dir">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for dir.</message>
+ </field-validator>
+ <field-validator type="existingDirectory" short-circuit="true">
+ <message>The directory ${dir} does not exist.</message>
+ </field-validator>
+ </field-->
+
+ <field name="age">
+ <field-validator type="int">
+ <param name="min">25</param>
+ <message>You are still young ( old ${min} ) </message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-validation.xml
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-validation.xml 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,50 +0,0 @@
-<!DOCTYPE validators PUBLIC
- "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
- "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-<validators>
- <field name="firstName">
- <field-validator type="requiredstring" short-circuit="true">
- <message>You must enter a firstName.</message>
- </field-validator>
- </field>
- <field name="lastName">
- <field-validator type="requiredstring" short-circuit="true">
- <message>You must enter a lastName.</message>
- </field-validator>
- </field>
-
- <field name="email">
- <field-validator type="requiredstring" short-circuit="true">
- <message>You must enter a value for email.</message>
- </field-validator>
- <field-validator type="email" short-circuit="true">
- <message>Not a valid e-mail.</message>
- </field-validator>
- </field>
-
- <field name="config">
- <field-validator type="requiredFile" short-circuit="true">
- <message>You must enter a value for config.</message>
- </field-validator>
- <field-validator type="existingFile" short-circuit="true">
- <message>The configuration file ${config} does not exist.</message>
- </field-validator>
- </field>
-
- <field name="dir">
- <field-validator type="requiredFile" short-circuit="true">
- <message>You must enter a value for dir.</message>
- </field-validator>
- <field-validator type="existingDirectory" short-circuit="true">
- <message>The directory ${dir} does not exist.</message>
- </field-validator>
- </field>
-
- <field name="age">
- <field-validator type="int">
- <param name="min">18</param>
- <param name="max">88</param>
- <message>Age needs to be between ${min} and ${max}</message>
- </field-validator>
- </field>
-</validators>
\ No newline at end of file
Added: jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-warning-validation.xml
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-warning-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Identity-warning-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,49 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!--field name="firstName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a firstName.</message>
+ </field-validator>
+ </field>
+ <field name="lastName">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a lastName.</message>
+ </field-validator>
+ </field>
+
+ <field name="email">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for email.</message>
+ </field-validator>
+ <field-validator type="email" short-circuit="true">
+ <message>Not a valid e-mail.</message>
+ </field-validator>
+ </field>
+
+ <field name="config">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for config.</message>
+ </field-validator>
+ <field-validator type="existingFile" short-circuit="true">
+ <message>The configuration file ${config} does not exist.</message>
+ </field-validator>
+ </field>
+
+ <field name="dir">
+ <field-validator type="requiredFile" short-circuit="true">
+ <message>You must enter a value for dir.</message>
+ </field-validator>
+ <field-validator type="existingDirectory" short-circuit="true">
+ <message>The directory ${dir} does not exist.</message>
+ </field-validator>
+ </field-->
+
+ <field name="age">
+ <field-validator type="int">
+ <param name="max">88</param>
+ <message>Info : Your are older than ${max} !</message>
+ </field-validator>
+ </field>
+</validators>
\ No newline at end of file
Copied: jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-error-validation.xml (from rev 1250, jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-validation.xml)
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-error-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-error-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,35 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!-- Field Validators for email field -->
+ <field name="text">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for text.</message>
+ </field-validator>
+ </field>
+
+ <field name="text2">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for text2.</message>
+ </field-validator>
+ </field>
+
+ <field name="ratio">
+ <field-validator type="int">
+ <param name="min">20</param>
+ <param name="max">50</param>
+ <message>Ratio needs to be between ${min} and ${max}</message>
+ </field-validator>
+ </field>
+
+ <!-- Plain Validator 1 -->
+ <validator type="expression">
+ <param name="expression">text.startsWith("poussin")</param>
+ <message>Email not starts with poussin</message>
+ </validator>
+ <validator type="expression">
+ <param name="expression">text2.startsWith("chemit")</param>
+ <message>Email not starts with chemit</message>
+ </validator>
+</validators>
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-error-validation.xml
___________________________________________________________________
Name: svn:mergeinfo
+
Added: jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-info-validation.xml
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-info-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-info-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,13 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!-- Field Validators for email field -->
+ <field name="text">
+ <field-validator type="fieldexpression">
+ <param name="expression"><![CDATA[ text != null && text.length() > 10]]></param>
+ <message>Text should have more than 10 caracters</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-validation.xml
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-validation.xml 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,41 +0,0 @@
-<!DOCTYPE validators PUBLIC
- "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
- "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
-<validators>
- <!-- Field Validators for email field -->
- <field name="text">
- <field-validator type="requiredstring" short-circuit="true">
- <message>You must enter a value for text.</message>
- </field-validator>
- <field-validator type="email" short-circuit="true">
- <message>Not a valid e-mail for text.</message>
- </field-validator>
- </field>
-
- <field name="text2">
- <field-validator type="requiredstring" short-circuit="true">
- <message>You must enter a value for text2.</message>
- </field-validator>
- <field-validator type="email" short-circuit="true">
- <message>Not a valid e-mail for text2.</message>
- </field-validator>
- </field>
-
- <field name="ratio">
- <field-validator type="int">
- <param name="min">20</param>
- <param name="max">50</param>
- <message>Ratio needs to be between ${min} and ${max}</message>
- </field-validator>
- </field>
-
- <!-- Plain Validator 1 -->
- <validator type="expression">
- <param name="expression">text.startsWith("poussin")</param>
- <message>Email not starts with poussin</message>
- </validator>
- <validator type="expression">
- <param name="expression">text2.startsWith("chemit")</param>
- <message>Email not starts with chemit</message>
- </validator>
-</validators>
\ No newline at end of file
Added: jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-warning-validation.xml
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-warning-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/resources/jaxx/demo/Model-warning-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,18 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+ <!-- Field Validators for email field -->
+ <field name="text">
+ <field-validator type="email" short-circuit="true">
+ <message>Not a valid e-mail for text.</message>
+ </field-validator>
+ </field>
+
+ <field name="text2">
+ <field-validator type="requiredstring" short-circuit="true">
+ <message>You must enter a value for text2.</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Modified: jaxx/trunk/jaxx-example/src/main/resources/log4j.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/log4j.properties 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-example/src/main/resources/log4j.properties 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,9 +1,9 @@
# Global logging configuration
-log4j.rootLogger=INFO, stdout
+log4j.rootLogger=ERROR, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-#log4j.logger.org.codelutin.jaxx=DEBUG
log4j.logger.examples=DEBUG
+log4j.logger.jaxx=INFO
Modified: jaxx/trunk/jaxx-runtime-validator/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,3 +1,6 @@
+1.3 ??? 200903??
+ * 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
+
1.1 chemit 20090220
* 20090203 [chemit] - move swing specific code to jaxx-runtime-validator-swing module
* 20090202 [chemit] - rename Util to ValidationUtil
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/JAXXValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/JAXXValidator.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/JAXXValidator.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,8 +1,8 @@
package jaxx.runtime;
-import jaxx.runtime.validator.BeanValidator;
import java.util.List;
+import jaxx.runtime.validator.BeanValidator2;
/**
* The contract of a validator-able object.
@@ -17,7 +17,7 @@
* @param validatorId validator id
* @return the associated validator, or <code>null</code> if not find
*/
- BeanValidator<?> getValidator(String validatorId);
+ BeanValidator2<?> getValidator(String validatorId);
/** @return the list of ids of all registred validator */
List<String> getValidatorIds();
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -12,6 +12,7 @@
import com.opensymphony.xwork2.validator.ValidationException;
import com.opensymphony.xwork2.validator.Validator;
import com.opensymphony.xwork2.validator.ValidatorScope;
+import java.beans.EventSetDescriptor;
import org.apache.commons.beanutils.ConversionException;
import org.apache.commons.beanutils.Converter;
import org.apache.commons.logging.Log;
@@ -22,7 +23,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
@@ -31,7 +31,18 @@
import java.util.Map.Entry;
import java.util.TreeMap;
-/** @author chemit */
+/**
+ *
+ * A customized validator for a given bean.
+ *
+ * <b>Note:</b> The bean must be listenable on properyChange events (means
+ * must have public addPropertychangeListener and removePropertyChangeListener methods).
+ *
+ * @param <B> type of the bean to validate.
+ *
+ * @author chemit
+ */
+@Deprecated
public class BeanValidator<B> {
/** la nom de la propriété bean */
@@ -90,7 +101,12 @@
protected transient ActionValidatorManager validator;
protected ActionContext context;
+ protected EventSetDescriptor beanEventDescriptor;
+
public BeanValidator(Class<B> beanClass, String contextName) {
+ // check that the bean is listenable, otherwise, can't use the validator on it
+ beanEventDescriptor = ValidationUtil.getPropertyChangeListenerDescriptor(beanClass);
+
this.beanClass = beanClass;
this.contextName = contextName;
pcs = new PropertyChangeSupport(this);
@@ -114,6 +130,7 @@
conversionErrors = new TreeMap<String, String>();
l = new PropertyChangeListener() {
+ @Override
public void propertyChange(PropertyChangeEvent evt) {
validate();
setValid(!hasErrors());
@@ -209,15 +226,17 @@
// clean conversions of previous bean
conversionErrors.clear();
- if (oldBean != null) {
+ if (oldBean != null) {
try {
- Method method = this.bean.getClass().getMethod("removePropertyChangeListener", PropertyChangeListener.class);
- method.invoke(oldBean, l);
+ beanEventDescriptor.getRemoveListenerMethod().invoke(oldBean, l);
+ //Method method = this.bean.getClass().getMethod("removePropertyChangeListener", PropertyChangeListener.class);
+ //method.invoke(oldBean, l);
} catch (Exception eee) {
- log.info("Can't register as listener", eee);
+ log.info("Can't register as listener for bean "+beanClass+" for reason "+eee.getMessage(), eee);
}
}
this.bean = bean;
+
if (bean == null) {
// must remove all errors from this validator on errorListModel
validationSupport.clearErrorsAndMessages();
@@ -226,10 +245,11 @@
dispatchErrorsToFields();
} else {
try {
- Method method = this.bean.getClass().getMethod("addPropertyChangeListener", PropertyChangeListener.class);
- method.invoke(bean, l);
+ beanEventDescriptor.getAddListenerMethod().invoke(bean, l);
+ //Method method = this.bean.getClass().getMethod("addPropertyChangeListener", PropertyChangeListener.class);
+ //method.invoke(bean, l);
} catch (Exception eee) {
- log.info("Can't register as listener", eee);
+ log.info("Can't register as listener for bean "+beanClass+" for reason "+eee.getMessage(), eee);
}
validate();
}
@@ -296,6 +316,7 @@
* <p/>
* If an error occurs, then add an error in validator.
*
+ * @param <T> the type of conversion
* @param fieldName the name of the bean property
* @param value the value to convert
* @param valueClass the type of converted value
Added: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator2.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator2.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidator2.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,458 @@
+package jaxx.runtime.validator;
+
+import java.beans.EventSetDescriptor;
+import org.apache.commons.beanutils.ConversionException;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ConverterUtil;
+
+import java.beans.Introspector;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+import javax.swing.event.EventListenerList;
+
+/**
+ *
+ * A customized validator for a given bean.
+ *
+ * <b>Note:</b> The bean must be listenable on properyChange events (means
+ * must have public addPropertychangeListener and removePropertyChangeListener methods).
+ *
+ * @param <B> type of the bean to validate.
+ *
+ * @author chemit
+ */
+public class BeanValidator2<B> {
+
+ /** la nom de la propriété bean */
+ static public final String BEAN_PROERTY = "bean";
+ /** la nom de la propriété contextName */
+ static public final String CONTEXT_NAME_PROPERTY = "contextName";
+ /** la nom de l'état valid */
+ static public final String VALID_PROERTY = "valid";
+ /** la nom de l'état changed */
+ static public final String CHANGED_PROERTY = "changed";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static protected final Log log = LogFactory.getLog(BeanValidator2.class);
+ /** the type of bean to watch */
+ protected final Class<B> beanClass;
+ /** the validation named context (can be null) */
+ protected String contextName;
+ /** to chain to a prent validator */
+ protected BeanValidator2<?> parentValidator;
+ /** state to indicate that validator has changed since the last time bean was setted */
+ protected boolean changed = false;
+ /** state of the validator (is true if no errors of error scope is found) */
+ protected boolean valid = true;
+ /** bean to be watched */
+ protected B bean = null;
+ /** to add and remove PropertyChangeListener on watched beans */
+ protected EventSetDescriptor beanEventDescriptor;
+ /** list of fields watched by this validator */
+ protected Set<BeanValidatorField<B>> fields;
+ /** map of conversion errors detected by this validator */
+ protected Map<String, String> conversionErrors;
+ /** xworks scope validator **/
+ protected EnumMap<BeanValidatorScope, XWorkBeanValidator<B>> validators;
+ /** listener that listens on bean modification */
+ protected PropertyChangeListener l;
+ /** delegate property change support */
+ protected PropertyChangeSupport pcs;
+ /** A list of event listeners for this validators */
+ protected EventListenerList listenerList = new EventListenerList();
+
+ public BeanValidator2(Class<B> beanClass, String contextName) {
+ this.beanClass = beanClass;
+ this.pcs = new PropertyChangeSupport(this);
+ this.conversionErrors = new TreeMap<String, String>();
+ this.validators = new EnumMap<BeanValidatorScope, XWorkBeanValidator<B>>(BeanValidatorScope.class);
+
+ setContextName(contextName);
+
+ l = new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ validate();
+ setValid(!hasErrors());
+ setChanged(true);
+ }
+ };
+ }
+
+ public Class<B> getBeanClass() {
+ return beanClass;
+ }
+
+ public BeanValidator2<?> getParentValidator() {
+ return parentValidator;
+ }
+
+ public String getContextName() {
+ return contextName;
+ }
+
+ public Set<BeanValidatorField<B>> getFields() {
+ return fields;
+ }
+
+ /**
+ * Retourne vrai si l'objet bean a ete modifie depuis le dernier
+ * {@link #setBean}
+ *
+ * @return <code>true</code> if bean was modify since last {@link #setBean(Object)} invocation
+ */
+ public boolean isChanged() {
+ return changed;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public B getBean() {
+ return bean;
+ }
+
+ public BeanValidatorField<B> getField(String fieldName) {
+ for (BeanValidatorField<B> field : fields) {
+ if (fieldName.equals(field.getName())) {
+ return field;
+ }
+ }
+ return null;
+ }
+
+ public boolean hasErrors() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasErrors()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasWarnings() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasWarnings()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasInfos() {
+ for (BeanValidatorField<B> field : fields) {
+ if (field.hasInfos()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Test a the validator contains the field given his name
+ *
+ * @param fieldName the name of the searched field
+ * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise
+ */
+ public boolean containsField(String fieldName) {
+ BeanValidatorField<B> field = getField(fieldName);
+ return field != null;
+ }
+
+ public boolean isValid(String fieldName) {
+ BeanValidatorField<B> field = getField(fieldName);
+ if (field == null) {
+ throw new IllegalArgumentException("could not find a validator field " + fieldName);
+ }
+ return field.isValid();
+ }
+
+ /**
+ * Permet de force la remise a false de l'etat de changement du bean
+ *
+ * @param changed flag to force reset of property {@link #changed}
+ */
+ public void setChanged(boolean changed) {
+ this.changed = changed;
+ // force the property to be fired (never pass the older value)
+ pcs.firePropertyChange(CHANGED_PROERTY, null, changed);
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
+ // force the property to be fired (never pass the older value)
+ pcs.firePropertyChange(VALID_PROERTY, null, valid);
+ }
+
+ public void setBean(B bean) {
+ B oldBean = this.bean;
+ if (log.isDebugEnabled()) {
+ log.debug(this + " : " + bean);
+ }
+
+ // clean conversions of previous bean
+ conversionErrors.clear();
+
+ if (oldBean != null) {
+ try {
+ getBeanEventDescriptor(oldBean).getRemoveListenerMethod().invoke(oldBean, l);
+ } catch (Exception eee) {
+ log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
+ }
+ }
+ this.bean = bean;
+
+ if (bean == null) {
+
+ // remove all messages for all fields of the validator
+
+ for (BeanValidatorField<B> f : fields) {
+
+ f.updateMessages(this, null, null);
+ }
+
+ } else {
+ try {
+ getBeanEventDescriptor(bean).getAddListenerMethod().invoke(bean, l);
+ } catch (Exception eee) {
+ log.info("Can't register as listener for bean " + beanClass + " for reason " + eee.getMessage(), eee);
+ }
+ validate();
+ }
+ setChanged(false);
+ setValid(!hasErrors());
+ pcs.firePropertyChange(BEAN_PROERTY, oldBean, bean);
+ }
+
+ public void setContextName(String contextName) {
+ String oldValidationContextName = this.contextName;
+ this.contextName = contextName;
+ // changing contextName could change fields definition
+ // so dettach bean, must rebuild the fields
+ if (bean != null) {
+ setBean(null);
+ }
+ // rebuild the fields
+ initFields();
+ pcs.firePropertyChange(CONTEXT_NAME_PROPERTY, oldValidationContextName, contextName);
+ }
+
+ public void setParentValidator(BeanValidator2<?> parentValidator) {
+ this.parentValidator = parentValidator;
+ }
+
+ /**
+ * Convert a value.
+ * <p/>
+ * If an error occurs, then add an error in validator.
+ *
+ * @param <T> the type of conversion
+ * @param fieldName the name of the bean property
+ * @param value the value to convert
+ * @param valueClass the type of converted value
+ * @return the converted value, or null if conversion was not ok
+ */
+ @SuppressWarnings({"unchecked"})
+ public <T> T convert(String fieldName, String value, Class<T> valueClass) {
+ if (fieldName == null) {
+ throw new IllegalArgumentException("fieldName can not be null");
+ }
+ if (valueClass == null) {
+ throw new IllegalArgumentException("valueClass can not be null");
+ }
+
+ // on ne convertit pas si il y a un bean et que le resultat de la validation
+ // pourra etre affiche quelque part
+ if (!canValidate() || value == null) {
+ return null;
+ }
+
+ // remove the previous conversion error for the field
+ conversionErrors.remove(fieldName);
+
+ T result;
+ try {
+ Converter converter = ConverterUtil.getConverter(valueClass);
+ if (converter == null) {
+ throw new RuntimeException("could not find converter for the type " + valueClass);
+ }
+ result = (T) converter.convert(valueClass, value);
+ /* Why this test ? if (result != null && !value.equals(result.toString())) {
+ conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
+ result = null;
+ validate();
+ }*/
+ } catch (ConversionException e) {
+ // get
+ conversionErrors.put(fieldName, "error.convertor." + Introspector.decapitalize(valueClass.getSimpleName()));
+ result = null;
+ validate();
+ }
+ return result;
+ }
+
+ /**
+ * il faut eviter le code re-intrant (durant une validation, une autre est
+ * demandee). Pour cela on fait la validation dans un thread, et tant
+ * que la premiere validation n'est pas fini, on ne repond pas aux
+ * solicitations.
+ * Cette method est public pour permettre de force une validation par
+ * programmation, ce qui est utile par exemple si le bean ne supporte
+ * pas les {@link PropertyChangeListener}
+ */
+ public void validate() {
+
+ // on ne valide que si il y a un bean et que le resultat de la validation
+ // pourra etre affiche quelque part
+ if (!canValidate()) {
+ return;
+ }
+
+ for (BeanValidatorScope scope : validators.keySet()) {
+
+ XWorkBeanValidator<B> validator = validators.get(scope);
+
+ Map<String, List<String>> newMessages = validator.validate(bean);
+
+ if (scope == BeanValidatorScope.ERROR) {
+ // treate conversion errors
+ // reinject them
+ for (Entry<String, String> entry : conversionErrors.entrySet()) {
+ // remove from validation, errors occurs on this field
+ List<String> errors = newMessages.get(entry.getKey());
+ String conversionError = entry.getValue();
+ if (errors != null) {
+ errors.clear();
+ errors.add(conversionError);
+ } else {
+ errors = java.util.Collections.singletonList(conversionError);
+ // add the concrete conversion error
+ newMessages.put(entry.getKey(), errors);
+ }
+ }
+ }
+
+ // for each field, update his list of messages
+ for (BeanValidatorField<B> field : fields) {
+ List<String> messagesForField = newMessages.get(field.getName());
+ if (field.getScopes().contains(scope)) {
+ field.updateMessages(this, scope, messagesForField);
+ }
+ }
+ }
+
+ if (parentValidator != null) {
+ // chained validation
+ parentValidator.l.propertyChange(null);
+ }
+
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">";
+ }
+
+ public void addBeanValidatorListener(BeanValidatorListener listener) {
+ listenerList.add(BeanValidatorListener.class, listener);
+ }
+
+ public void removeBeanValidatorListener(BeanValidatorListener listener) {
+ listenerList.remove(BeanValidatorListener.class, listener);
+ }
+
+ public BeanValidatorListener[] getBeanValidatorListeners() {
+ return listenerList.getListeners(BeanValidatorListener.class);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ /** @return <code>true</code> if validation is enabled, <code>false</code> otherwise. */
+ protected boolean canValidate() {
+ return !(bean == null || fields.isEmpty());
+ }
+
+ protected void fireFieldChanged(BeanValidatorField<B> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
+
+ BeanValidatorEvent evt = new BeanValidatorEvent(this, field, scope, toAdd, toDelete);
+
+ for (BeanValidatorListener listener : listenerList.getListeners(BeanValidatorListener.class)) {
+ listener.onFieldChanged(evt);
+ }
+ }
+
+ protected synchronized void initFields() {
+
+ Set<String> detectedFieldNames = new java.util.HashSet<String>();
+ EnumMap<BeanValidatorScope, Set<String>> tmp = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class);
+ Set<BeanValidatorField<B>> detectedFields = new java.util.HashSet<BeanValidatorField<B>>();
+
+ validators.clear();
+
+ for (BeanValidatorScope scope : BeanValidatorScope.values()) {
+ String scopeContext = (contextName == null ? "" : contextName + "-") + scope.name().toLowerCase();
+
+ XWorkBeanValidator<B> newValidator = new XWorkBeanValidator<B>(beanClass, scopeContext, false);
+ Set<String> fieldNames = newValidator.getFieldNames();
+ if (log.isDebugEnabled()) {
+ log.debug("detected validators for scope " + scopeContext + " : " + fieldNames);
+ }
+ if (!fieldNames.isEmpty()) {
+ // fields detected in this validator, keep it
+ validators.put(scope, newValidator);
+ detectedFieldNames.addAll(fieldNames);
+ tmp.put(scope, fieldNames);
+ }
+ }
+
+ List<BeanValidatorScope> scopes = new ArrayList<BeanValidatorScope>();
+ for (String fieldName : detectedFieldNames) {
+ scopes.clear();
+ // detect scopes for the field
+ for (BeanValidatorScope scope : BeanValidatorScope.values()) {
+ if (tmp.containsKey(scope) && tmp.get(scope).contains(fieldName)) {
+ scopes.add(scope);
+ }
+ }
+ BeanValidatorField<B> f = new BeanValidatorField<B>(beanClass, fieldName, scopes);
+ detectedFields.add(f);
+ }
+ tmp.clear();
+ detectedFieldNames.clear();
+
+ this.fields = java.util.Collections.unmodifiableSet(detectedFields);
+ }
+
+ protected EventSetDescriptor getBeanEventDescriptor(B bean) {
+ if (beanEventDescriptor == null) {
+ // check that the bean is listenable, otherwise, can't use the validator on it
+ this.beanEventDescriptor = ValidationUtil.getPropertyChangeListenerDescriptor(bean.getClass());
+ }
+ return beanEventDescriptor;
+ }
+}
Added: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorEvent.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,52 @@
+package jaxx.runtime.validator;
+
+/**
+ * The definition of an event on {@link BeanValidatorListener}
+ * to be fired by a {@link BeanValidator}.
+ *
+ * @author chemit
+ * @since 1.3
+ */
+public class BeanValidatorEvent extends java.util.EventObject {
+
+ private static final long serialVersionUID = 1L;
+ /** the field impacted by the validator */
+ BeanValidatorField<?> field;
+ /** the scope impacted by the event */
+ BeanValidatorScope scope;
+ String[] messagestoAdd;
+ String[] messagestoDelete;
+
+ public BeanValidatorEvent(BeanValidator2 source, BeanValidatorField<?> field, BeanValidatorScope scope, String[] toAdd, String[] toDelete) {
+ super(source);
+ this.field = field;
+ this.scope = scope;
+ this.messagestoAdd = toAdd;
+ this.messagestoDelete = toDelete;
+ }
+
+ @Override
+ public BeanValidator2 getSource() {
+ return (BeanValidator2) super.getSource();
+ }
+
+ public String getFieldName() {
+ return field.getName();
+ }
+
+ public String[] getMessagesToAdd() {
+ return messagestoAdd;
+ }
+
+ public String[] getMessagesToDelete() {
+ return messagestoDelete;
+ }
+
+ public BeanValidatorScope getScope() {
+ return scope;
+ }
+
+ public BeanValidatorField getField() {
+ return field;
+ }
+}
Added: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorField.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,239 @@
+package jaxx.runtime.validator;
+
+import static org.codelutin.i18n.I18n._;
+
+import javax.swing.event.EventListenerList;
+import java.util.ArrayList;
+import java.util.EnumMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Definition of a field to be handled in a {@link BeanValidator}.
+ * <p/>
+ * A such class is only registred in {@link BeanValidator } when the field of the bean
+ * was found in validator xml configuration file for a {@link com.opensymphony.xwork2.validator.FieldValidator} only.
+ * <p/>
+ * This class use properties {@link #beanClass}, {@link #name} to define
+ * his naturel order.
+ *
+ * @author chemit
+ * @param <B> the type of the bean handled by the validator and this field of validation.
+ * @since 1.3
+ */
+public class BeanValidatorField<B> {
+
+ /** the class of bean */
+ protected final Class<B> beanClass;
+ /** name of field in bean */
+ protected final String name;
+ protected EnumMap<BeanValidatorScope, Set<String>> messages;
+ /** A list of event listeners for this validators */
+ protected EventListenerList listenerList = new EventListenerList();
+
+ public BeanValidatorField(Class<B> beanClass, String name, List<BeanValidatorScope> scopes) {
+ this.beanClass = beanClass;
+ this.name = name;
+ messages = new EnumMap<BeanValidatorScope, Set<String>>(BeanValidatorScope.class);
+ for (BeanValidatorScope scope : scopes) {
+ messages.put(scope, new HashSet<String>());
+ }
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<B> getBeanClass() {
+ return beanClass;
+ }
+
+ /**
+ * @return <code>true</code> if this field is valid (says is in error
+ * scope and has errors), <code>false</code> otherwise.
+ */
+ public boolean isValid() {
+ return !hasErrors();
+ }
+
+ public BeanValidatorScope getScope() {
+ if (hasErrors()) {
+ return BeanValidatorScope.ERROR;
+ }
+ if (hasWarnings()) {
+ return BeanValidatorScope.WARNING;
+ }
+ if (hasInfos()) {
+ return BeanValidatorScope.INFO;
+ }
+ return null;
+ }
+
+ public Set<BeanValidatorScope> getScopes() {
+ return messages.keySet();
+ }
+
+ public boolean hasErrors() {
+ return hasMessages(BeanValidatorScope.ERROR);
+ }
+
+ public boolean hasWarnings() {
+ return hasMessages(BeanValidatorScope.WARNING);
+ }
+
+ public boolean hasInfos() {
+ return hasMessages(BeanValidatorScope.INFO);
+ }
+
+ public Set<String> getErrors() {
+ return getMessages(BeanValidatorScope.ERROR);
+ }
+
+ public Set<String> getWarnings() {
+ return getMessages(BeanValidatorScope.WARNING);
+ }
+
+ public Set<String> getInfos() {
+ return getMessages(BeanValidatorScope.INFO);
+ }
+
+ public boolean hasMessages(BeanValidatorScope scope) {
+ return messages.containsKey(scope) && !getMessages(scope).isEmpty();
+ }
+
+ public Set<String> getMessages(BeanValidatorScope scope) {
+ return messages.get(scope);
+ }
+
+ public void updateMessages(BeanValidator2<B> validator, BeanValidatorScope scope, List<String> messages) {
+
+ if (scope == null) {
+
+ // special case to reset all messages from all scopes
+
+ for (BeanValidatorScope s : getScopes()) {
+
+ clearMessages(s, validator);
+ }
+ return;
+ }
+
+ if (!this.messages.containsKey(scope)) {
+ throw new IllegalArgumentException("the scope " + scope + " was not registred for " + this);
+ }
+
+ if (messages == null || messages.isEmpty()) {
+
+ // no incoming message for this scope
+
+ clearMessages(scope, validator);
+ return;
+ }
+
+ // build the diff of messages (the one to delete, the one to add)
+
+ boolean hasChanged = false;
+
+ Set<String> currentMessages = getMessages(scope);
+
+ // detect messages to delete
+ Set<String> toDelete = new java.util.HashSet<String>(currentMessages);
+ toDelete.removeAll(messages);
+
+ if (!toDelete.isEmpty()) {
+ // apply delete
+ currentMessages.removeAll(toDelete);
+ hasChanged = true;
+ }
+
+ // detect messages to add
+ Set<String> toAdd = new java.util.HashSet<String>(messages);
+ toAdd.removeAll(currentMessages);
+
+ if (!toAdd.isEmpty()) {
+ // apply add
+ currentMessages.addAll(toAdd);
+ hasChanged = true;
+ }
+
+ if (hasChanged) {
+
+ // something has changed, fire notifications
+ String[] del = toDelete.toArray(new String[toDelete.size()]);
+ String[] add = toAdd.toArray(new String[toAdd.size()]);
+
+ validator.fireFieldChanged(this, scope, add, del);
+ }
+ toAdd.clear();
+ toDelete.clear();
+
+ }
+
+ public String getI18nError(String error) {
+ String text;
+ if (error.indexOf("##") == -1) {
+ text = _(error);
+ } else {
+ StringTokenizer stk = new StringTokenizer(error, "##");
+ String errorName = stk.nextToken();
+ List<String> args = new ArrayList<String>();
+ while (stk.hasMoreTokens()) {
+ args.add(stk.nextToken());
+ }
+ text = _(errorName, args.toArray());
+ }
+ return text;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof BeanValidatorField)) {
+ return false;
+ }
+
+ BeanValidatorField that = (BeanValidatorField) o;
+ return beanClass.equals(that.beanClass) && name.equals(that.name);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = beanClass.hashCode();
+ result = 31 * result + name.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("<").append(super.toString());
+ sb.append(" beanClass:").append(beanClass);
+ sb.append(", name:").append(name);
+ sb.append(", scopes:").append(messages == null ? "[]" : messages.keySet());
+ sb.append(", scope:").append(getScope());
+ //sb.append(", errors:").append(errors);
+ sb.append('>');
+ return sb.toString();
+ }
+
+ protected void clearMessages(BeanValidatorScope scope, BeanValidator2<B> validator) {
+ // remove all messages
+ Set<String> toDelete = getMessages(scope);
+
+ if (!toDelete.isEmpty()) {
+
+ // there is some messages to delete
+ String[] toDel = toDelete.toArray(new String[toDelete.size()]);
+
+ // apply deletion
+ toDelete.clear();
+
+ // fire
+ validator.fireFieldChanged(this, scope, null, toDel);
+ }
+ }
+}
Added: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,32 @@
+package jaxx.runtime.validator;
+
+/**
+ * The listener contract to be used on {@link BeanValidator]
+ *
+ * @author chemit
+ * @since 1.3
+ */
+public interface BeanValidatorListener extends java.util.EventListener {
+
+ /**
+ * Invoked when a validator detects some changes on a field.
+ *
+ * @param event the event
+ */
+ void onFieldChanged(BeanValidatorEvent event);
+
+ /**
+ * Invoked when a validator detects a new message on a field.
+ *
+ * @param event the event
+ */
+ //void onNewMessages(BeanValidatorEvent event);
+
+ /**
+ * Invoked when a validator detetcs that a previously message is
+ * no more exisitng.
+ *
+ * @param event the event
+ */
+ //void onResolvedMessages(BeanValidatorEvent event);
+}
Copied: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java (from rev 1250, jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorScope.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,34 @@
+package jaxx.runtime.validator;
+
+/**
+ * The differents levels of messages in validation process.
+ * <p/>
+ * The order of the enum defines the severity of validation.
+ * <p/>
+ * Always begin with error, then if no error found, try warning, then info...
+ *
+ * @author chemit
+ */
+public enum BeanValidatorScope {
+ /**
+ * the error scope level.
+ *
+ * When a message of a such scope is found on a validator, then the validator
+ * is invalid and modified.
+ */
+ ERROR,
+ /**
+ * the warning scope level.
+ *
+ * When a message of a such scope is found on a validator, then the validator
+ * is still valid but modified.
+ */
+ WARNING,
+ /**
+ * the information scope level.
+ *
+ * When a message of a sucg scope is found on a validator, then the
+ * validator is still valid and not modified.
+ */
+ INFO
+}
Property changes on: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/BeanValidatorScope.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidationUtil.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -6,6 +6,7 @@
import org.apache.commons.logging.LogFactory;
import java.beans.BeanInfo;
+import java.beans.EventSetDescriptor;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
@@ -50,7 +51,7 @@
}
}
for (String validatorId : validatorIds) {
- BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
+ BeanValidator2 beanValidator = jaxxValidator.getValidator(validatorId);
if (bean == null || beanValidator.getBeanClass().isAssignableFrom(bean.getClass())) {
// touch validator, only if fits the bean type (or bean is null)
beanValidator.setBean(bean);
@@ -81,7 +82,7 @@
}
}
for (String validatorId : validatorIds) {
- BeanValidator beanValidator = jaxxValidator.getValidator(validatorId);
+ BeanValidator2 beanValidator = jaxxValidator.getValidator(validatorId);
beanValidator.setChanged(newValue);
}
}
@@ -120,4 +121,33 @@
// otherwise, bean value has not changed,...
}
}
+
+ static EventSetDescriptor getPropertyChangeListenerDescriptor(Class beanClass) {
+ try {
+ // check that the bean is listenable, otherwise, can't use
+ // the validator on it
+ BeanInfo infos = Introspector.getBeanInfo(beanClass);
+ EventSetDescriptor[] events = infos.getEventSetDescriptors();
+ for (EventSetDescriptor event : events) {
+ if ("propertyChange".equals(event.getName())) {
+
+ if (event.getAddListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no addPropertyChangeListener method found for " + beanClass);
+ }
+ if (event.getRemoveListenerMethod() == null) {
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no removePropertyChangeListener method found for " + beanClass);
+ }
+ return event;
+ }
+ }
+
+ // no property event listener, so can not use the validator
+ throw new IllegalStateException("no PropertyChangeListener access method found for " + beanClass);
+ } catch (IntrospectionException ex) {
+ throw new IllegalStateException("could not acquire PropertyChangeListener bean info for " + beanClass + " for reason " + ex.getMessage(), ex);
+ }
+ }
+
}
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorEvent.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorEvent.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorEvent.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -10,6 +10,7 @@
*
* @author chemit
*/
+@Deprecated
public class ValidatorErrorEvent {
/** the source of the event */
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorListener.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorListener.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorErrorListener.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -5,6 +5,7 @@
*
* @author chemit
*/
+@Deprecated
public interface ValidatorErrorListener extends java.util.EventListener {
/**
* Invoked when a validator detects a error on a field.
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorField.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorField.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorField.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -23,6 +23,7 @@
* @author chemit
* @param <B> the type of the bean handled by the validator and this field of validation.
*/
+@Deprecated
public class ValidatorField<B> {
/** the class of bean */
Deleted: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorScope.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorScope.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/ValidatorScope.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,16 +0,0 @@
-package jaxx.runtime.validator;
-
-/**
- * The differents levels of validation.
- * <p/>
- * The order of the enum defines the severity of validation.
- * <p/>
- * Always begin with error, then if no error found, try warning, ...
- *
- * @author chemit
- */
-public enum ValidatorScope {
- ERROR,
- WARNING,
- INFO
-}
Added: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/XWorkBeanValidator.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,230 @@
+package jaxx.runtime.validator;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ValidationAwareSupport;
+import com.opensymphony.xwork2.config.Configuration;
+import com.opensymphony.xwork2.config.ConfigurationManager;
+import com.opensymphony.xwork2.util.ValueStack;
+import com.opensymphony.xwork2.util.ValueStackFactory;
+import com.opensymphony.xwork2.validator.ActionValidatorManager;
+import com.opensymphony.xwork2.validator.DelegatingValidatorContext;
+import com.opensymphony.xwork2.validator.FieldValidator;
+import com.opensymphony.xwork2.validator.ValidationException;
+import com.opensymphony.xwork2.validator.Validator;
+import java.util.Collection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * A customized validator for a given bean.
+ *
+ * Use the method {@link #validate(java.lang.Object)} to obtain the messages
+ * detected by the validator for the given bean.
+ *
+ * @param <B> type of the bean to validate.
+ *
+ * @author chemit
+ * @since 1.3
+ */
+public class XWorkBeanValidator<B> {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(XWorkBeanValidator.class);
+ private final static Map<String, List<String>> EMPTY_RESULT = Collections.unmodifiableMap(new HashMap<String, List<String>>());
+ /** the type of bean to validate */
+ protected final Class<B> beanClass;
+ /** the validation named context (can be null) */
+ protected String contextName;
+ /** the list of field names detected for this validator */
+ protected Set<String> fieldNames;
+ /** a flag to include or not the default context validators */
+ protected boolean includeDefaultContext;
+ // --
+ // XWorks fields
+ // --
+ protected ValidationAwareSupport validationSupport;
+ protected DelegatingValidatorContext validationContext;
+ protected transient ActionValidatorManager validator;
+ protected ActionContext context;
+
+ public XWorkBeanValidator(Class<B> beanClass, String contextName) {
+ this(beanClass, contextName, true);
+ }
+
+ public XWorkBeanValidator(Class<B> beanClass, String contextName, boolean includeDefaultContext) {
+
+ this.beanClass = beanClass;
+ this.includeDefaultContext = includeDefaultContext;
+ validationSupport = new ValidationAwareSupport();
+ validationContext = new DelegatingValidatorContext(validationSupport);
+
+ // init context
+ ConfigurationManager confManager = new ConfigurationManager();
+ Configuration conf = confManager.getConfiguration();
+
+ ValueStack vs = conf.getContainer().getInstance(ValueStackFactory.class).createValueStack();
+ context = new ActionContext(vs.getContext());
+ ActionContext.setContext(context);
+
+ // init validator
+ validator = conf.getContainer().getInstance(ActionValidatorManager.class, "no-annotations");
+
+ // init context
+ setContextName(contextName);
+ }
+
+ public boolean isIncludeDefaultContext() {
+ return includeDefaultContext;
+ }
+
+ public Class<B> getBeanClass() {
+ return beanClass;
+ }
+
+ public String getContextName() {
+ return contextName;
+ }
+
+ public Set<String> getFieldNames() {
+ return fieldNames;
+ }
+
+ /**
+ * Test a the validator contains the field given his name
+ *
+ * @param fieldName the name of the searched field
+ * @return <code>true</code> if validator contaisn this field, <code>false</code> otherwise
+ */
+ public boolean containsField(String fieldName) {
+ return fieldNames.contains(fieldName);
+ }
+
+ public void setIncludeDefaultContext(boolean includeDefaultContext) {
+ this.includeDefaultContext = includeDefaultContext;
+ if (contextName != null) {
+ // reload context
+ setContextName(contextName);
+ }
+ }
+
+ public void setContextName(String contextName) {
+ this.contextName = contextName;
+ // changing contextName may change fields definition
+ // so reload fields
+ initFields();
+ }
+
+ /**
+ * Valide le bean donné et retourne les messages produits.
+ *
+ * @param bean le bean a valider (il doit etre non null)
+ *
+ * @return le dictionnaire des messages produits par la validation indexées
+ * par le nom du champs du bean impacté.
+ */
+ public Map<String, List<String>> validate(B bean) {
+
+ if (bean == null) {
+ throw new NullPointerException("bean can not be null in method validate");
+ }
+
+ Map<String, List<String>> result = EMPTY_RESULT;
+
+ // on lance la validation uniquement si des champs sont a valider
+ if (!fieldNames.isEmpty()) {
+
+ try {
+
+ //TC - 20081024 : since context is in a ThreadLocal variable, we must do the check
+ if (ActionContext.getContext() == null) {
+ ActionContext.setContext(context);
+ }
+
+ validator.validate(bean, contextName, validationContext);
+
+ if (log.isTraceEnabled()) {
+ log.trace("Action errors: " + validationContext.getActionErrors());
+ log.trace("Action messages: " + validationContext.getActionMessages());
+ log.trace("Field errors: " + validationContext.getFieldErrors());
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug(this + " : " + validationContext.getFieldErrors());
+ }
+
+ if (validationContext.hasFieldErrors()) {
+ Map messages = validationContext.getFieldErrors();
+ result = new HashMap<String, List<String>>(messages.size());
+ for (Object fieldName : messages.keySet()) {
+ Collection c = (Collection) messages.get(fieldName);
+ List<String> mm = new java.util.ArrayList<String>(c.size());
+ for (Object message : c) {
+ mm.add(message + "");
+ }
+ result.put(fieldName + "", mm);
+ }
+ }
+
+ } catch (ValidationException eee) {
+ log.warn("Error during validation on " + beanClass + " for reason : " + eee.getMessage(), eee);
+
+ } finally {
+ // on nettoye toujours le validateur apres operation
+ validationSupport.clearErrorsAndMessages();
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<beanClass:" + beanClass + ", contextName:" + contextName + ">";
+ }
+
+ /**
+ * update the property {@link #fieldNames}, says search in XWorks
+ */
+ protected synchronized void initFields() {
+
+ if (fieldNames != null) {
+ fieldNames = null;
+ }
+
+ Set<String> detectedFieldNames = new java.util.HashSet<String>();
+
+ int skip = 0;
+ if (contextName != null && !includeDefaultContext) {
+ // count the number of validator to skip
+ for (Validator v : validator.getValidators(beanClass, null)) {
+ // we only work on FieldValidator at the moment
+ if (v instanceof FieldValidator) {
+ skip++;
+ }
+ }
+ }
+
+ for (Validator v : validator.getValidators(beanClass, contextName)) {
+ // we only work on FieldValidator at the moment
+ if (v instanceof FieldValidator) {
+ if (skip > 0) {
+ skip--;
+ continue;
+ }
+ FieldValidator fieldValidator = (FieldValidator) v;
+ log.debug("context " + contextName + " - field " + fieldValidator.getFieldName());
+ String fName = fieldValidator.getFieldName();
+ detectedFieldNames.add(fName);
+ }
+ }
+
+ fieldNames = Collections.unmodifiableSet(detectedFieldNames);
+ }
+}
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionFieldExpressionValidator.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -12,8 +12,8 @@
*/
public class CollectionFieldExpressionValidator extends FieldExpressionValidator {
-
public enum Mode {
+
/** au moins une entrée de la collection doit etre valide */
AT_LEAST_ONE,
/** exactement une entrée dela collection doit être valide */
@@ -23,7 +23,6 @@
/** aucune valeur de la collection doivent etre valides */
NONE
}
-
/** le mode de validation sur la liste */
protected Mode mode;
@@ -35,10 +34,6 @@
this.mode = mode;
}
- public void setMode(String mode) {
- this.mode = Mode.valueOf(mode);
- }
-
@Override
public void validate(Object object) throws ValidationException {
if (mode == null) {
@@ -188,5 +183,4 @@
public String getValidatorType() {
return "collectionFieldExpression";
}
-
}
Deleted: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/AbstractValidatorTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/AbstractValidatorTest.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/AbstractValidatorTest.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,44 +0,0 @@
-package jaxx.runtime.validator;
-
-import org.junit.Assert;
-import org.junit.BeforeClass;
-
-import java.io.File;
-
-/**
- * Abstract class of this module.
- *
- * @author chemit
- */
-public abstract class AbstractValidatorTest extends Assert {
-
- static protected BeanValidator<ValidatorBean> validator;
-
- static protected File basedir;
-
- protected ValidatorBean bean;
-
- @BeforeClass
- public static void initValidator() throws Exception {
-
- String b = System.getenv("basedir");
- if (b == null) {
- b = new File("").getAbsolutePath();
- }
- basedir = new File(b);
- validator = new BeanValidator<ValidatorBean>(ValidatorBean.class, null);
- }
-
- protected void assertFieldInError(String fieldName, String error, boolean required) {
- ValidatorField<ValidatorBean> field = validator.getField(fieldName);
-
- for (String o : field.getErrors()) {
- if (o.equals(error)) {
- assertTrue(required);
- return;
- }
- }
- // error was not found
- assertFalse(required);
- }
-}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/BeanValidatorTest.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,33 +1,198 @@
package jaxx.runtime.validator;
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
/**
- * Une classe pour tester {@link BeanValidator}
*
- * @author chemit
+ * @author tony
*/
-public class BeanValidatorTest extends AbstractValidatorTest {
+public class BeanValidatorTest {
- //TODO do other tests :)
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static protected final Log log = LogFactory.getLog(BeanValidator2.class);
+ protected BeanValidator2<SimpleBean> validator;
+ protected SimpleBean bean;
+ BeanValidatorListenerImpl errorListener;
+ BeanValidatorListenerImpl warningListener;
+ BeanValidatorListenerImpl infoListener;
+ @Before
+ public void setUp() {
+ bean = new SimpleBean();
+ validator = new BeanValidator2<SimpleBean>(SimpleBean.class, null);
+ validator.addBeanValidatorListener(errorListener = new BeanValidatorListenerImpl(BeanValidatorScope.ERROR));
+ validator.addBeanValidatorListener(warningListener = new BeanValidatorListenerImpl(BeanValidatorScope.WARNING));
+ validator.addBeanValidatorListener(infoListener = new BeanValidatorListenerImpl(BeanValidatorScope.INFO));
+ }
+
+ @After
+ public void tearDown() {
+ bean = null;
+ if (validator != null) {
+ validator.setBean(null);
+ validator = null;
+ }
+ }
+ private static final String STRING_VALUE_ERROR = "stringValue.error";
+ private static final String STRING_VALUE_WARNING = "stringValue.warning";
+ private static final String INT_VALUE_ERROR = "intValue.error";
+ private static final String INT_VALUE_INFO = "intValue.info";
+
@Test
- public void testSetBean() {
- bean = new ValidatorBean();
+ public void testValidate() {
- assertNull(bean.getStringValue());
+ assertMessages(errorListener);
+ assertMessages(warningListener);
+ assertMessages(infoListener);
- // no bean on validator
- assertNull(validator.getBean());
- assertTrue(validator.isValid());
+ log.info("-----------------------------------------------");
+ validator.setBean(bean);
- // add bean to validator
+ assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ log.info("-----------------------------------------------");
+ bean.setStringValue("one");
+
+ assertMessages(errorListener, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ log.info("-----------------------------------------------");
+ bean.setStringValue("oneone");
+
+ assertMessages(errorListener, INT_VALUE_ERROR);
+ assertMessages(warningListener);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ log.info("-----------------------------------------------");
+ bean.setIntValue(1);
+
+ assertMessages(errorListener);
+ assertMessages(warningListener);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ log.info("-----------------------------------------------");
+ bean.setIntValue(10);
+
+ assertMessages(errorListener);
+ assertMessages(warningListener);
+ assertMessages(infoListener);
+
+ log.info("-----------------------------------------------");
+
+ bean.setStringValue(null);
+ bean.setIntValue(0);
+
+ assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+
+ log.info("-----------------------------------------------");
+ }
+
+ @Test
+ public void testConvert() {
+
+
+ assertMessages(errorListener);
+ assertMessages(warningListener);
+ assertMessages(infoListener);
+
+ log.info("-----------------------------------------------");
+
validator.setBean(bean);
- assertFieldInError("stringValue", "stringValue.required", true);
- validator.setBean(null);
- // validator is valid, no more errors should be in validator
- assertTrue(validator.isValid());
+ assertMessages(errorListener, STRING_VALUE_ERROR, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+
+ log.info("-----------------------------------------------");
+
+ Object value = validator.convert("intValue", "abc", Class.class);
+
+ Assert.assertNull(value);
+
+ assertMessages(errorListener, STRING_VALUE_ERROR, "error.convertor.class");
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ log.info("-----------------------------------------------");
+ bean.setStringValue("one");
+
+ assertMessages(errorListener, "error.convertor.class");
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ log.info("-----------------------------------------------");
+
+ value = validator.convert("intValue", "3", Integer.class);
+
+ bean.setIntValue((Integer) value);
+
+ assertMessages(errorListener);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ log.info("-----------------------------------------------");
+
+ bean.setIntValue(-1);
+ assertMessages(errorListener, INT_VALUE_ERROR);
+ assertMessages(warningListener, STRING_VALUE_WARNING);
+ assertMessages(infoListener, INT_VALUE_INFO);
+
+ log.info("-----------------------------------------------");
}
-}
+ void assertMessages(BeanValidatorListenerImpl listener, String... expected) {
+ List<String> actual = listener.getMessages();
+ Assert.assertEquals(" shoudl have " + java.util.Arrays.toString(expected) + " but had " + actual, expected.length, actual.size());
+ for (String m : expected) {
+ Assert.assertEquals("could not find " + m + " in " + actual, true, actual.contains(m));
+ }
+ }
+
+ class BeanValidatorListenerImpl implements BeanValidatorListener {
+
+ final BeanValidatorScope scope;
+
+ public BeanValidatorListenerImpl(BeanValidatorScope scope) {
+ this.scope = scope;
+ }
+ java.util.List<String> messages = new java.util.ArrayList<String>();
+
+ public List<String> getMessages() {
+ return messages;
+ }
+
+ @Override
+ public void onFieldChanged(BeanValidatorEvent event) {
+ if (scope != event.getScope()) {
+ return;
+ }
+ String[] messagesToDelete = event.getMessagesToDelete();
+ if (messagesToDelete != null && messagesToDelete.length > 0) {
+ log.info(event.getScope() + " messages to delete : " + java.util.Arrays.toString(messagesToDelete));
+ for (String m : messagesToDelete) {
+ messages.remove(m);
+ }
+ }
+ String[] messagesToAdd = event.getMessagesToAdd();
+ if (messagesToAdd != null && messagesToAdd.length > 0) {
+ log.info(event.getScope() + " messages to add : " + java.util.Arrays.toString(messagesToAdd));
+ for (String m : messagesToAdd) {
+ messages.add(m);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/SimpleBean.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/SimpleBean.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/SimpleBean.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,51 @@
+package jaxx.runtime.validator;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+public class SimpleBean {
+
+ protected int intValue;
+ protected String stringValue;
+ final PropertyChangeSupport p;
+
+ public SimpleBean() {
+ p = new PropertyChangeSupport(this);
+ }
+
+ public int getIntValue() {
+ return intValue;
+ }
+
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ public void setStringValue(String stringValue) {
+ String old = this.stringValue;
+ this.stringValue = stringValue;
+ p.firePropertyChange("stringValue", old, stringValue);
+ }
+
+ public void setIntValue(int intValue) {
+ int old = this.intValue;
+ this.intValue = intValue;
+ p.firePropertyChange("intValue", old, intValue);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ p.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ p.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ p.removePropertyChangeListener(propertyName, listener);
+ }
+}
\ No newline at end of file
Added: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/XWorkBeanValidatorTest.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,156 @@
+package jaxx.runtime.validator;
+
+import java.util.List;
+import java.util.Map;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ * @author tony
+ * @since 1.3
+ */
+public class XWorkBeanValidatorTest {
+
+ protected XWorkBeanValidator<SimpleBean> validator;
+ protected SimpleBean bean;
+ protected Map<String, List<String>> messages;
+
+ @Before
+ public void setUp() {
+ bean = new SimpleBean();
+ validator = new XWorkBeanValidator<SimpleBean>(SimpleBean.class, "simple");
+ }
+
+ @After
+ public void tearDown() {
+ bean = null;
+ messages = null;
+ }
+
+ @Test
+ public void testUnknownField() {
+ Assert.assertEquals(false, validator.containsField("fake_" + System.nanoTime()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testValidateNPE() {
+ validator.validate(null);
+ }
+
+ @Test
+ public void testValidate() {
+
+
+ messages = validator.validate(bean);
+
+ assertFieldInError("stringValue", "stringValue.null", true, messages);
+ assertFieldInError("intValue", "intValue.null", true, messages);
+
+ bean.setStringValue("notnull");
+ messages = validator.validate(bean);
+
+ assertFieldInError("stringValue", "stringValue.null", false, messages);
+ assertFieldInError("intValue", "intValue.null", true, messages);
+
+ bean.setIntValue(1);
+ messages = validator.validate(bean);
+
+ assertFieldInError("stringValue", "stringValue.null", false, messages);
+ assertFieldInError("intValue", "intValue.null", false, messages);
+
+ }
+
+ @Test
+ public void testSetContextName() {
+
+
+ String expected = "simple";
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "error");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "warning");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(false, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "info");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(false, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "fake_" + System.nanoTime());
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(false, validator.containsField("stringValue"));
+ Assert.assertEquals(false, validator.containsField("intValue"));
+
+ }
+
+ @Test
+ public void testSetIncludeDefaultContext() {
+
+ validator.setIncludeDefaultContext(false);
+
+ String expected = "simple";
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "error");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "warning");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(true, validator.containsField("stringValue"));
+ Assert.assertEquals(false, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "info");
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(false, validator.containsField("stringValue"));
+ Assert.assertEquals(true, validator.containsField("intValue"));
+
+ validator.setContextName(expected = "fake_" + System.nanoTime());
+
+ Assert.assertEquals(expected, validator.getContextName());
+ Assert.assertEquals(false, validator.containsField("stringValue"));
+ Assert.assertEquals(false, validator.containsField("intValue"));
+
+ }
+
+ protected void assertFieldInError(String fieldName, String error, boolean required, Map<String, List<String>> messages) {
+
+ Assert.assertEquals(true, validator.containsField(fieldName));
+ List<String> fieldMessages = messages.get(fieldName);
+ //Assert.assertEquals(true,validator.containsField(fieldName));
+ if (fieldMessages != null) {
+ for (String o : fieldMessages) {
+ if (o.equals(error)) {
+ Assert.assertTrue(required);
+ return;
+ }
+ }
+ }
+
+ // error was not found
+ Assert.assertFalse(required);
+ }
+}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/AbstractFieldValidatorTest.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,11 +1,15 @@
package jaxx.runtime.validator.field;
-import jaxx.runtime.validator.AbstractValidatorTest;
+import java.io.File;
+import jaxx.runtime.validator.BeanValidator;
import jaxx.runtime.validator.ValidatorBean;
+import jaxx.runtime.validator.ValidatorField;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
+import org.junit.BeforeClass;
/**
* Abstract class to test a specific validator.
@@ -15,10 +19,13 @@
*
* @author chemit
*/
-public abstract class AbstractFieldValidatorTest extends AbstractValidatorTest {
+public abstract class AbstractFieldValidatorTest extends Assert {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(AbstractFieldValidatorTest.class);
+ static protected BeanValidator<ValidatorBean> validator;
+ static protected File basedir;
+ protected ValidatorBean bean;
/**
* the moethod to implements testing the given validator on the given bean.
@@ -29,7 +36,7 @@
@Before
public void setUp() throws Exception {
- log.info("start test " + getClass().getSimpleName());
+ log.debug("start test " + getClass().getSimpleName());
validator.setBean(bean = new ValidatorBean());
}
@@ -38,4 +45,27 @@
validator.setBean(null);
}
+ @BeforeClass
+ public static void initValidator() throws Exception {
+
+ String b = System.getenv("basedir");
+ if (b == null) {
+ b = new File("").getAbsolutePath();
+ }
+ basedir = new File(b);
+ validator = new BeanValidator<ValidatorBean>(ValidatorBean.class, null);
+ }
+
+ protected void assertFieldInError(String fieldName, String error, boolean required) {
+ ValidatorField<ValidatorBean> field = validator.getField(fieldName);
+
+ for (String o : field.getErrors()) {
+ if (o.equals(error)) {
+ assertTrue(required);
+ return;
+ }
+ }
+ // error was not found
+ assertFalse(required);
+ }
}
\ No newline at end of file
Added: jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-error-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,19 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="stringValue">
+ <field-validator type="requiredstring">
+ <message>stringValue.error</message>
+ </field-validator>
+ </field>
+
+ <field name="intValue">
+ <field-validator type="int">
+ <param name="min">1</param>
+ <message>intValue.error</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Added: jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-info-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,13 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="intValue">
+ <field-validator type="int">
+ <param name="min">10</param>
+ <message>intValue.info</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Added: jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-simple-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,19 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="stringValue">
+ <field-validator type="requiredstring">
+ <message>stringValue.null</message>
+ </field-validator>
+ </field>
+
+ <field name="intValue">
+ <field-validator type="int">
+ <param name="min">1</param>
+ <message>intValue.null</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Added: jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml (rev 0)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/SimpleBean-warning-validation.xml 2009-03-19 22:47:05 UTC (rev 1272)
@@ -0,0 +1,13 @@
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="stringValue">
+ <field-validator type="fieldexpression">
+ <param name="expression"><![CDATA[ stringValue != null && stringValue.length() > 5]]></param>
+ <message>stringValue.warning</message>
+ </field-validator>
+ </field>
+
+</validators>
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/resources/log4j.properties
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/resources/log4j.properties 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/resources/log4j.properties 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,5 +1,5 @@
# Global logging configuration
-log4j.rootLogger=INFO, stdout
+log4j.rootLogger=ERROR, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
Modified: jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/changelog.txt 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,2 +1,5 @@
+1.3 ??? 200903??
+ * 20090319 [chemit] - refactor Validator : now can deal with scopes, improve design
+
1.1 chemit 20090220
* 20090203 [chemit] - introduce this module specific to swing
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,8 +1,6 @@
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.BeanValidator;
-import jaxx.runtime.validator.ValidatorErrorListener;
-import jaxx.runtime.validator.ValidatorField;
+
import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
import jaxx.runtime.validator.swing.ui.IconValidationUI;
import org.apache.commons.logging.Log;
@@ -14,12 +12,13 @@
import java.awt.Container;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import jaxx.runtime.validator.BeanValidator2;
+import jaxx.runtime.validator.BeanValidatorField;
+
/**
* La surcharge de {@link jaxx.runtime.validator.BeanValidator} pour les ui swing
* <p/>
@@ -92,14 +91,12 @@
* }
* </pre>
*
+ * @param <B> le type de bean a valider
* @author poussin
* @author chemit
- * @version 1.0
- * <p/>
- * Last update: $Date: 3 févr. 2009 $
- * By : $Author: chatellier $
+ * @version 1.0
*/
-public class SwingValidator<B> extends BeanValidator<B> {
+public class SwingValidator<B> extends BeanValidator2<B> {
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(SwingValidator.class);
@@ -154,9 +151,8 @@
@Override
public void setContextName(String contextName) {
- Map<ValidatorField<B>, List<ValidatorErrorListener>> oldListeners = new HashMap<ValidatorField<B>, List<ValidatorErrorListener>>();
+ /*Map<ValidatorField<B>, List<ValidatorErrorListener>> oldListeners = new HashMap<ValidatorField<B>, List<ValidatorErrorListener>>();
-
for (ValidatorField<B> field : fields) {
ValidatorErrorListener[] listeners = field.getValidatorErrorListeners();
List<ValidatorErrorListener> toReinject = new ArrayList<ValidatorErrorListener>();
@@ -168,18 +164,18 @@
toReinject.add(listener);
}
oldListeners.put(field, toReinject);
- }
+ }*/
super.setContextName(contextName);
// must reinstall ui
installUIs();
// reinject none ui listeners
- for (Entry<ValidatorField<B>, List<ValidatorErrorListener>> entry : oldListeners.entrySet()) {
+ /*for (Entry<ValidatorField<B>, List<ValidatorErrorListener>> entry : oldListeners.entrySet()) {
ValidatorField<B> field = getField(entry.getKey().getName());
for (ValidatorErrorListener listener : entry.getValue()) {
field.addValidatorErrorListener(listener);
}
}
- oldListeners.clear();
+ oldListeners.clear();*/
}
/**
@@ -190,7 +186,7 @@
* @param c the editor component for the field
*/
public void setFieldRepresentation(String fieldname, JComponent c) {
- ValidatorField<B> field = getField(fieldname);
+ BeanValidatorField<B> field = getField(fieldname);
if (field == null) {
// no field registred in the validator
log.warn("the field '" + fieldname + "' is not defined in validator (no rules on it)");
@@ -240,7 +236,7 @@
// same component, nothing to do
return;
}
- ValidatorField<B> field = getField(fieldname);
+ BeanValidatorField<B> field = getField(fieldname);
if (field == null) {
// this case should not appear since fieldName has already been check in method addFieldRepresentation
@@ -253,8 +249,10 @@
JXLayer<?> jx = (JXLayer<?>) container;
Object ui = jx.getUI();
if (ui != null && ui instanceof AbstractBeanValidatorUI) {
- field.removeValidatorErrorListener((AbstractBeanValidatorUI) ui);
+ removeBeanValidatorListener((AbstractBeanValidatorUI)ui);
+ //field.removeValidatorErrorListener((AbstractBeanValidatorUI) ui);
}
+
jx.setUI(null);
}
}
@@ -262,11 +260,12 @@
// ajout du jxlayer sous ce composant
Container container = c.getParent();
if (container instanceof JXLayer) {
- Constructor<? extends AbstractBeanValidatorUI> cons = uiClass.getConstructor(ValidatorField.class);
+ Constructor<? extends AbstractBeanValidatorUI> cons = uiClass.getConstructor(BeanValidatorField.class);
AbstractBeanValidatorUI ui = cons.newInstance(field);
ui.setEnabled(true);
JXLayer<JComponent> jx = (JXLayer<JComponent>) container;
- field.addValidatorErrorListener(ui);
+ addBeanValidatorListener(ui);
+ //field.addValidatorErrorListener(ui);
jx.setUI(ui);
}
}
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListModel.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorListModel.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,73 +1,151 @@
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.BeanValidator;
-import jaxx.runtime.validator.ValidatorErrorEvent;
-import jaxx.runtime.validator.ValidatorErrorListener;
-import jaxx.runtime.validator.ValidatorField;
+import jaxx.runtime.validator.BeanValidatorEvent;
import javax.swing.DefaultListModel;
import javax.swing.JComponent;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
-import java.util.Set;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
+import jaxx.runtime.validator.BeanValidatorScope;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* The model of the list of errors
*
* @author chemit
*/
-public class SwingValidatorErrorListModel extends DefaultListModel implements ValidatorErrorListener {
+public class SwingValidatorErrorListModel extends DefaultListModel implements BeanValidatorListener {
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorErrorListModel.class);
private static final long serialVersionUID = 1L;
-
/** list of registred validators */
- protected transient List<BeanValidator<?>> validators;
+ protected transient List<SwingValidator<?>> validators;
-
public SwingValidatorErrorListModel() {
- validators = new ArrayList<BeanValidator<?>>();
+ validators = new ArrayList<SwingValidator<?>>();
}
- public void registerValidator(BeanValidator<?> validator) {
+ public void registerValidator(SwingValidator<?> validator) {
if (validators.contains(validator)) {
throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
}
validators.add(validator);
+ validator.addBeanValidatorListener(this);
// the model listen on each field of the validator
- for (ValidatorField<?> field : validator.getFields()) {
- field.addValidatorErrorListener(this);
- }
+ /*for (ValidatorField<?> field : validator.getFields()) {
+ field.addValidatorErrorListener(this);
+ }*/
}
-
- /**
- * Invoked when a validator detects a error on a field.
- *
- * @param event the event
- */
@Override
- public void onNewError(ValidatorErrorEvent event) {
- ValidatorField field = event.getField();
+ public void onFieldChanged(BeanValidatorEvent event) {
+ String[] toDelete = event.getMessagesToDelete();
+ String[] toAdd = event.getMessagesToAdd();
+ BeanValidatorScope scope = event.getScope();
SwingValidator validator = (SwingValidator) event.getSource();
- Set<String> errors = event.getErrors();
+ BeanValidatorField field = event.getField();
- // must remove all previously error for this field and validator
- List<SwingValidatorErrorModel> newErrors = new ArrayList<SwingValidatorErrorModel>();
- JComponent editor = validator.getFieldRepresentation(field.getName());
+ if (log.isTraceEnabled()) {
+ log.trace("----------------------------------------------------------");
+ log.trace(field + " - (" + getSize() + ") toAdd " + (toAdd == null ? null : toAdd.length));
+ log.trace(field + " - (" + getSize() + ") toDelete " + (toDelete == null ? null : toDelete.length));
+ }
+
+ if ((toAdd == null || toAdd.length == 0) && (toDelete == null || toDelete.length == 0)) {
+ // no data to add nor remove, so nothing to do
+ return;
+ }
+
+ if (toAdd == null || toAdd.length == 0) {
+
+ if (log.isTraceEnabled()) {
+ log.trace(field + " - toDelete : just delete some datas!");
+ }
+
+ // no add, no need to resort the datas, can direclty delete
+ // messages we do not want any longer
+
+ // delete some messages for the given field and given scope
+ List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+ List<Integer> indexs = new java.util.ArrayList<Integer>(toDelete.length);
+
+ Enumeration enumeration = elements();
+ int index = 0;
+ while (enumeration.hasMoreElements()) {
+ SwingValidatorErrorModel error = (SwingValidatorErrorModel) enumeration.nextElement();
+
+ if (error.getValidator() == validator && error.getField() == field && ids.contains(error.getError())) {
+ indexs.add(index);
+ }
+ index++;
+ }
+
+ java.util.Collections.reverse(indexs);
+
+ for (Integer i : indexs) {
+ removeElementAt(i);
+ }
+
+ return;
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace(field + " - add and delete !");
+ }
+
+ List<SwingValidatorErrorModel> newMessages = new ArrayList<SwingValidatorErrorModel>();
+
+
+
+ // obtain all messages not to delete
+
+ List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+
Enumeration enumeration = elements();
while (enumeration.hasMoreElements()) {
SwingValidatorErrorModel error = (SwingValidatorErrorModel) enumeration.nextElement();
- if (error.getValidator() == validator && error.getField() == field) {
- // this error can be skipped
- continue;
+
+ if (error.getValidator() != validator || error.getField() != field || !ids.contains(error.getError())) {
+ // keep this row
+ newMessages.add(error);
}
- newErrors.add(error);
}
+
+ if (toAdd != null && toAdd.length > 0) {
+ JComponent editor = validator.getFieldRepresentation(field.getName());
+ // add new messages
+ for (String error : toAdd) {
+ newMessages.add(new SwingValidatorErrorModel(validator, field, error, editor));
+ }
+ }
+
+ // sort datas
+
+ java.util.Collections.sort(newMessages);
+
+ // clean model and reinject new errors
+ removeAllElements();
+
+ // reinject in list model, all the errors
+ for (SwingValidatorErrorModel error : newMessages) {
+ addElement(error);
+ }
+
+ /*
+ List<SwingValidatorErrorModel> newErrors = new ArrayList<SwingValidatorErrorModel>();
+
+ JComponent editor = validator.getFieldRepresentation(field.getName());
// add new errors
- for (String error : errors) {
- newErrors.add(new SwingValidatorErrorModel(validator, field, error, editor));
+ for (String error : toAdd) {
+ newErrors.add(new SwingValidatorErrorModel(validator, field, error, editor));
}
+
+
java.util.Collections.sort(newErrors);
// clean model and reinject new errors
@@ -75,43 +153,79 @@
// reinject in list model, all the errors
for (SwingValidatorErrorModel error : newErrors) {
- addElement(error);
- }
- //FIXME, this is not performant, prefer use a isValueAdjusting property on SwingValidator
- // notify that the model has changed
+ addElement(error);
+ }*/
}
+ /**
+ * Invoked when a validator detects a error on a field.
+ *
+ * @param event the event
+ */
+ /*@Override
+ public void onNewError(ValidatorErrorEvent event) {
+ ValidatorField field = event.getField();
+ SwingValidator validator = (SwingValidator) event.getSource();
+ Set<String> errors = event.getErrors();
+ // must remove all previously error for this field and validator
+ List<SwingValidatorErrorModel> newErrors = new ArrayList<SwingValidatorErrorModel>();
+ JComponent editor = validator.getFieldRepresentation(field.getName());
+ Enumeration enumeration = elements();
+ while (enumeration.hasMoreElements()) {
+ SwingValidatorErrorModel error = (SwingValidatorErrorModel) enumeration.nextElement();
+ if (error.getValidator() == validator && error.getField() == field) {
+ // this error can be skipped
+ continue;
+ }
+ newErrors.add(error);
+ }
+ // add new errors
+ for (String error : errors) {
+ newErrors.add(new SwingValidatorErrorModel(validator, field, error, editor));
+ }
+ java.util.Collections.sort(newErrors);
+
+ // clean model and reinject new errors
+ removeAllElements();
+
+ // reinject in list model, all the errors
+ for (SwingValidatorErrorModel error : newErrors) {
+ addElement(error);
+ }
+ //FIXME, this is not performant, prefer use a isValueAdjusting property on SwingValidator
+ // notify that the model has changed
+ }*/
/**
* Invoked when a validator detetcs that a previously error is
* no more exisitng.
*
* @param event the event
*/
- @Override
+ /*@Override
public void onResolvedError(ValidatorErrorEvent event) {
- SwingValidator validator = (SwingValidator) event.getSource();
- ValidatorField field = event.getField();
- // must remove all previously error for this field
+ SwingValidator validator = (SwingValidator) event.getSource();
+ ValidatorField field = event.getField();
+ // must remove all previously error for this field
- boolean somethingChange = false;
- Enumeration enumeration = elements();
- List<SwingValidatorErrorModel> newList = new ArrayList<SwingValidatorErrorModel>();
- while (enumeration.hasMoreElements()) {
- SwingValidatorErrorModel error = (SwingValidatorErrorModel) enumeration.nextElement();
- if (error.getValidator() == validator && error.getField() == field) {
- // this error can be skipped
- somethingChange = true;
- } else {
- newList.add(error);
- }
- }
- // clean model and reinject new errors
- removeAllElements();
+ boolean somethingChange = false;
+ Enumeration enumeration = elements();
+ List<SwingValidatorErrorModel> newList = new ArrayList<SwingValidatorErrorModel>();
+ while (enumeration.hasMoreElements()) {
+ SwingValidatorErrorModel error = (SwingValidatorErrorModel) enumeration.nextElement();
+ if (error.getValidator() == validator && error.getField() == field) {
+ // this error can be skipped
+ somethingChange = true;
+ } else {
+ newList.add(error);
+ }
+ }
+ // clean model and reinject new errors
+ removeAllElements();
- if (somethingChange) {
- for (SwingValidatorErrorModel errorModel : newList) {
- addElement(errorModel);
- }
- }
+ if (somethingChange) {
+ for (SwingValidatorErrorModel errorModel : newList) {
+ addElement(errorModel);
}
-}
\ No newline at end of file
+ }
+ }*/
+}
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorModel.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorModel.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,17 +1,17 @@
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.ValidatorField;
import javax.swing.JComponent;
+import jaxx.runtime.validator.BeanValidatorField;
/** @author chemit */
public class SwingValidatorErrorModel implements Comparable<SwingValidatorErrorModel> {
protected SwingValidator validator;
- protected ValidatorField field;
+ protected BeanValidatorField field;
protected String error;
protected JComponent editor;
- public SwingValidatorErrorModel(SwingValidator validator, ValidatorField field, String error, JComponent editor) {
+ public SwingValidatorErrorModel(SwingValidator validator, BeanValidatorField field, String error, JComponent editor) {
this.field = field;
this.validator = validator;
this.error = error;
@@ -26,7 +26,7 @@
return validator;
}
- public ValidatorField getField() {
+ public BeanValidatorField getField() {
return field;
}
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableModel.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableModel.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,32 +1,32 @@
package jaxx.runtime.validator.swing;
-import jaxx.runtime.validator.ValidatorErrorEvent;
-import jaxx.runtime.validator.ValidatorErrorListener;
-import jaxx.runtime.validator.ValidatorField;
+import jaxx.runtime.validator.BeanValidatorEvent;
import javax.swing.JComponent;
import javax.swing.table.DefaultTableModel;
import java.util.ArrayList;
import java.util.Comparator;
-import java.util.Iterator;
+import java.util.Enumeration;
import java.util.List;
-import java.util.Set;
import java.util.Vector;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* The model of the list of errors
*
* @author chemit
*/
-public class SwingValidatorErrorTableModel extends DefaultTableModel implements ValidatorErrorListener {
+public class SwingValidatorErrorTableModel extends DefaultTableModel implements BeanValidatorListener {
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static Log log = LogFactory.getLog(SwingValidatorErrorTableMouseListener.class);
private static final long serialVersionUID = 1L;
-
public static final String[] columnNames = {"validator.scope", "validator.field", "validator.message"};
-
/** list of registred validators */
protected transient List<SwingValidator<?>> validators;
-
/** comporator of errors */
protected transient Comparator<SwingValidatorErrorModel> comparator;
@@ -50,80 +50,109 @@
throw new IllegalArgumentException("the validator " + validator + " is already registred in " + this);
}
validators.add(validator);
- // the model listen on each field of the validator
- for (ValidatorField<?> field : validator.getFields()) {
- field.addValidatorErrorListener(this);
- }
+ validator.addBeanValidatorListener(this);
}
- /**
- * Invoked when a validator detects a error on a field.
- *
- * @param event the event
- */
@Override
- public void onNewError(ValidatorErrorEvent event) {
- ValidatorField field = event.getField();
+ public void onFieldChanged(BeanValidatorEvent event) {
+ String[] toDelete = event.getMessagesToDelete();
+ String[] toAdd = event.getMessagesToAdd();
+ BeanValidatorField field = event.getField();
+
+ if (log.isTraceEnabled()) {
+ log.trace("----------------------------------------------------------");
+ log.trace(field + " - (" + getRowCount() + ") toAdd " + (toAdd == null ? null : toAdd.length));
+ log.trace(field + " - (" + getRowCount() + ") toDelete " + (toDelete == null ? null : toDelete.length));
+ }
+ if ((toAdd == null || toAdd.length == 0) && (toDelete == null || toDelete.length == 0)) {
+ // no data to add nor remove, so nothing to do
+ return;
+ }
+
SwingValidator validator = (SwingValidator) event.getSource();
- Set<String> errors = event.getErrors();
- // must remove all previously error for this field and validator
+
+
int errorColumn = getErrorColumn();
- List<SwingValidatorErrorModel> newErrors = new ArrayList<SwingValidatorErrorModel>();
- JComponent editor = validator.getFieldRepresentation(field.getName());
- for (Object o : getDataVector()) {
- Vector row = (Vector) o;
+ if (toAdd == null || toAdd.length == 0) {
+
+
+ if (log.isTraceEnabled()) {
+ log.trace(field + " - toDelete : just delete some datas!");
+ }
+
+ // no add, no need to resort the datas, can direclty delete
+ // messages we do not want any longer
+
+ // delete some messages for the given field and given scope
+ List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+ List<Integer> indexs = new java.util.ArrayList<Integer>(toDelete.length);
+
+ Enumeration enumeration = getDataVector().elements();
+
+ int index = 0;
+ while (enumeration.hasMoreElements()) {
+ Vector row = (Vector) enumeration.nextElement();
+ SwingValidatorErrorModel error = (SwingValidatorErrorModel) row.get(errorColumn);
+ if (error.getValidator() == validator && error.getField() == field && ids.contains(error.getError())) {
+ // remo the message
+ indexs.add(index);
+ }
+ index++;
+ }
+ java.util.Collections.reverse(indexs);
+
+ for (Integer i : indexs) {
+ removeRow(i);
+ }
+
+ return;
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace(field + " - add and delete !");
+ }
+
+ // rebuild all the data (since we are some adding data and we ensure
+ // an order on datas)
+
+ List<SwingValidatorErrorModel> newMessages = new ArrayList<SwingValidatorErrorModel>();
+
+ // delete some messages for the given field and given scope
+ List<String> ids = new java.util.ArrayList<String>(java.util.Arrays.asList(toDelete));
+
+ Enumeration enumeration = getDataVector().elements();
+
+ while (enumeration.hasMoreElements()) {
+ Vector row = (Vector) enumeration.nextElement();
SwingValidatorErrorModel error = (SwingValidatorErrorModel) row.get(errorColumn);
- if (error.getValidator() == validator && error.getField() == field) {
- // this error can be skipped
- continue;
+ if (error.getValidator() != validator || error.getField() != field || !ids.contains(error.getError())) {
+ // keep this row
+ newMessages.add(error);
}
- newErrors.add(error);
}
- // add new errors
- for (String error : errors) {
- newErrors.add(new SwingValidatorErrorModel(validator, field, error, editor));
+
+ if (toAdd != null && toAdd.length > 0) {
+ JComponent editor = validator.getFieldRepresentation(field.getName());
+ // add new errors
+ for (String error : toAdd) {
+ SwingValidatorErrorModel errorModel = new SwingValidatorErrorModel(validator, field, error, editor);
+ newMessages.add(errorModel);
+ }
}
- java.util.Collections.sort(newErrors);
- // clean table model and reinject new errors
+ // sort datas
+
+ java.util.Collections.sort(newMessages);
+
+ // clean table model and reinject new messages
getDataVector().clear();
+
// reinject in list model, all the errors
- for (SwingValidatorErrorModel error : newErrors) {
+ for (SwingValidatorErrorModel error : newMessages) {
addRow(new Object[]{error.getField().getScope(), error.getField().getName(), error});
}
- //FIXME, this is not performant, prefer use a isValueAdjusting property on SwingValidator
- // notify that the model has changed
+
fireTableDataChanged();
}
-
- /**
- * Invoked when a validator detetcs that a previously error is
- * no more exisitng.
- *
- * @param event the event
- */
- @Override
- public void onResolvedError(ValidatorErrorEvent event) {
- SwingValidator validator = (SwingValidator) event.getSource();
- ValidatorField field = event.getField();
- // must remove all previously error for this field
- int errorColumn = getErrorColumn();
- boolean somethingChange = false;
- for (Iterator it = getDataVector().iterator(); it.hasNext();) {
- Object o = it.next();
- Vector row = (Vector) o;
- SwingValidatorErrorModel error = (SwingValidatorErrorModel) row.get(errorColumn);
- if (error.getValidator() == validator && error.getField() == field) {
- // this error can be skipped
- it.remove();
- somethingChange = true;
- }
- }
- if (somethingChange) {
- // notify that the model has changed
- fireTableDataChanged();
- }
- }
-
}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableRenderer.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableRenderer.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidatorErrorTableRenderer.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,32 +1,35 @@
package jaxx.runtime.validator.swing;
-import com.opensymphony.xwork2.validator.ValidatorScope;
-
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.Component;
+import jaxx.runtime.validator.BeanValidatorScope;
/** @author chemit */
public class SwingValidatorErrorTableRenderer extends DefaultTableCellRenderer {
+ private static final long serialVersionUID = 1L;
ImageIcon errorIcon;
ImageIcon warningIcon;
+ ImageIcon infoIcon;
public SwingValidatorErrorTableRenderer() {
errorIcon = jaxx.runtime.Util.createImageIcon("error.png");
warningIcon = jaxx.runtime.Util.createImageIcon("warning.png");
+ infoIcon = jaxx.runtime.Util.createImageIcon("info.png");
}
+ @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JLabel rendererComponent = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
ImageIcon icon = null;
String text = null;
- if (value instanceof ValidatorScope) {
+ if (value instanceof BeanValidatorScope) {
- ValidatorScope scope = (ValidatorScope) value;
+ BeanValidatorScope scope = (BeanValidatorScope) value;
switch (scope) {
case ERROR:
icon = errorIcon;
@@ -34,6 +37,9 @@
case WARNING:
icon = warningIcon;
break;
+ case INFO:
+ icon = infoIcon;
+ break;
}
} else if (value instanceof SwingValidatorErrorModel) {
SwingValidatorErrorModel model = (SwingValidatorErrorModel) value;
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,8 +1,8 @@
package jaxx.runtime.validator.swing.ui;
-import jaxx.runtime.validator.ValidatorErrorEvent;
-import jaxx.runtime.validator.ValidatorErrorListener;
-import jaxx.runtime.validator.ValidatorField;
+import jaxx.runtime.validator.BeanValidatorEvent;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.jxlayer.plaf.AbstractLayerUI;
@@ -12,15 +12,14 @@
*
* @author chemit
*/
-public abstract class AbstractBeanValidatorUI extends AbstractLayerUI<javax.swing.JComponent> implements ValidatorErrorListener {
+public abstract class AbstractBeanValidatorUI extends AbstractLayerUI<javax.swing.JComponent> implements BeanValidatorListener {
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(AbstractBeanValidatorUI.class);
-
/** the field to render */
- protected ValidatorField field;
+ protected BeanValidatorField field;
- public AbstractBeanValidatorUI(ValidatorField field) {
+ public AbstractBeanValidatorUI(BeanValidatorField field) {
this.field = field;
if (log.isDebugEnabled()) {
log.debug("install " + this + "<field:" + field + ">");
@@ -28,22 +27,11 @@
}
@Override
- public void onNewError(ValidatorErrorEvent event) {
- dispatchValidatorErrorEvent(event);
- }
-
- @Override
- public void onResolvedError(ValidatorErrorEvent event) {
- dispatchValidatorErrorEvent(event);
- }
-
- protected void dispatchValidatorErrorEvent(ValidatorErrorEvent event) {
- // check if event occurs to this field
- if (!field.equals(event.getField())) {
- return;
+ public void onFieldChanged(BeanValidatorEvent event) {
+ if (field.equals(event.getField())) {
+ // ask to repaint the layer
+ setDirty(true);
}
- // repaint the layer
- setDirty(true);
}
}
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/IconValidationUI.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,6 +1,5 @@
package jaxx.runtime.validator.swing.ui;
-import jaxx.runtime.validator.ValidatorField;
import org.jdesktop.jxlayer.JXLayer;
import javax.swing.BorderFactory;
@@ -9,6 +8,8 @@
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
/** @author chemit */
public class IconValidationUI extends AbstractBeanValidatorUI {
@@ -16,9 +17,19 @@
// The icon to be shown at the layer's corner
protected static BufferedImage errorIcon;
protected static BufferedImage warningIcon;
+ protected static BufferedImage infoIcon;
- public IconValidationUI(ValidatorField field) {
+ public IconValidationUI(BeanValidatorField field) {
super(field);
+ if (errorIcon == null) {
+ errorIcon = prepareIcon(Color.RED);
+ }
+ if (warningIcon == null) {
+ warningIcon = prepareIcon(Color.ORANGE);
+ }
+ if (infoIcon == null) {
+ infoIcon = prepareIcon(Color.GREEN);
+ }
}
@Override
@@ -37,34 +48,26 @@
protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
super.paintLayer(g2, l);
// There is no need to take insets into account for this painter
- switch (field.getScope()) {
- case ERROR:
- if (field.hasErrors()) {
- g2.drawImage(getErrorIcon(), l.getWidth() - errorIcon.getWidth() - 1, 0, null);
- }
- break;
- case WARNING:
- if (field.hasWarnings()) {
- g2.drawImage(getWarningIcon(), l.getWidth() - warningIcon.getWidth() - 1, 0, null);
- }
- break;
+ BeanValidatorScope scope = field.getScope();
+ if (scope != null) {
+ BufferedImage icon = null;
+ switch (scope) {
+ case ERROR:
+ icon = errorIcon;
+ break;
+ case WARNING:
+ icon = warningIcon;
+ break;
+ case INFO:
+ icon = infoIcon;
+ break;
+ }
+ if (icon != null) {
+ g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
+ }
}
}
- protected static BufferedImage getErrorIcon() {
- if (errorIcon == null) {
- errorIcon = prepareIcon(Color.RED);
- }
- return errorIcon;
- }
-
- protected static BufferedImage getWarningIcon() {
- if (warningIcon == null) {
- warningIcon = prepareIcon(Color.YELLOW);
- }
- return warningIcon;
- }
-
protected static BufferedImage prepareIcon(Color color) {
int width = 7;
int height = 8;
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/ImageValidationUI.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,6 +1,5 @@
package jaxx.runtime.validator.swing.ui;
-import jaxx.runtime.validator.ValidatorField;
import org.jdesktop.jxlayer.JXLayer;
import javax.swing.BorderFactory;
@@ -9,15 +8,27 @@
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
+import jaxx.runtime.validator.BeanValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
/** @author chemit */
public class ImageValidationUI extends AbstractBeanValidatorUI {
protected static BufferedImage errorIcon;
protected static BufferedImage warningIcon;
+ protected static BufferedImage infoIcon;
- public ImageValidationUI(ValidatorField field) {
+ public ImageValidationUI(BeanValidatorField field) {
super(field);
+ if (errorIcon == null) {
+ errorIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("error.png"));
+ }
+ if (warningIcon == null) {
+ warningIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("warning.png"));
+ }
+ if (infoIcon == null) {
+ infoIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("info.png"));
+ }
}
protected static BufferedImage prepareIcon(ImageIcon image) {
@@ -45,31 +56,23 @@
@Override
protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
super.paintLayer(g2, l);
- switch (field.getScope()) {
- case ERROR:
- if (field.hasErrors()) {
- g2.drawImage(getErrorIcon(), l.getWidth() - errorIcon.getWidth() - 1, 0, null);
- }
- break;
- case WARNING:
- if (field.hasWarnings()) {
- g2.drawImage(getWarningIcon(), l.getWidth() - warningIcon.getWidth() - 1, 0, null);
- }
- break;
+ BeanValidatorScope scope = field.getScope();
+ if (scope != null) {
+ BufferedImage icon = null;
+ switch (scope) {
+ case ERROR:
+ icon = errorIcon;
+ break;
+ case WARNING:
+ icon = warningIcon;
+ break;
+ case INFO:
+ icon = infoIcon;
+ break;
+ }
+ if (icon != null) {
+ g2.drawImage(icon, l.getWidth() - icon.getWidth() - 1, 0, null);
+ }
}
}
-
- protected static BufferedImage getErrorIcon() {
- if (errorIcon == null) {
- errorIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("error.png"));
- }
- return errorIcon;
- }
-
- protected static BufferedImage getWarningIcon() {
- if (warningIcon == null) {
- warningIcon = prepareIcon(jaxx.runtime.Util.createImageIcon("warning.png"));
- }
- return warningIcon;
- }
}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2009-03-18 18:17:16 UTC (rev 1271)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/TranslucentValidationUI.java 2009-03-19 22:47:05 UTC (rev 1272)
@@ -1,6 +1,6 @@
package jaxx.runtime.validator.swing.ui;
-import jaxx.runtime.validator.ValidatorField;
+import jaxx.runtime.validator.BeanValidatorScope;
import org.jdesktop.jxlayer.JXLayer;
import javax.swing.JComponent;
@@ -9,17 +9,20 @@
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Rectangle;
+import jaxx.runtime.validator.BeanValidatorField;
/** @author chemit */
public class TranslucentValidationUI extends AbstractBeanValidatorUI {
protected Color errorHightlight;
protected Color warningHightlight;
+ protected Color infoHightlight;
- public TranslucentValidationUI(ValidatorField field) {
+ public TranslucentValidationUI(BeanValidatorField field) {
super(field);
errorHightlight = Color.RED;
warningHightlight = Color.YELLOW;
+ infoHightlight = Color.GREEN;
}
@Override
@@ -38,23 +41,24 @@
view.getWidth() - insets.left - insets.right,
view.getHeight() - insets.top - insets.bottom));
- switch (field.getScope()) {
+ BeanValidatorScope scope = field.getScope();
- case ERROR:
- if (field.hasErrors()) {
+ if (scope == null) {
+ g2.setColor(Color.WHITE);
+ } else {
+ switch (scope) {
+ case ERROR:
g2.setColor(errorHightlight);
- } else {
- g2.setColor(Color.WHITE);
- }
- break;
- case WARNING:
- if (field.hasErrors()) {
+ break;
+ case WARNING:
g2.setColor(warningHightlight);
- } else {
- g2.setColor(Color.WHITE);
- }
- break;
+ break;
+ case INFO:
+ g2.setColor(infoHightlight);
+ break;
+ }
}
+
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .2f));
g2.fillRect(0, 0, l.getWidth(), l.getHeight());
}
Added: jaxx/trunk/jaxx-runtime-validator-swing/src/main/resources/icons/info.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-runtime-validator-swing/src/main/resources/icons/info.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
1
0
r1271 - in jaxx/trunk: jaxx-example/src/main/java/jaxx/demo jaxx-runtime-swing jaxx-runtime-swing/src/main/java/jaxx/runtime/swing
by tchemit@users.labs.libre-entreprise.org March 18, 2009
by tchemit@users.labs.libre-entreprise.org March 18, 2009
March 18, 2009
Author: tchemit
Date: 2009-03-18 18:17:16 +0000 (Wed, 18 Mar 2009)
New Revision: 1271
Added:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
Modified:
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
jaxx/trunk/jaxx-runtime-swing/changelog.txt
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
Log:
introduce BlockingLayerUI2
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-03-18 08:46:51 UTC (rev 1270)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-03-18 18:17:16 UTC (rev 1271)
@@ -11,22 +11,38 @@
accept(e, "from icon of layer");
}
}}' />
+ <jaxx.runtime.swing.BlockingLayerUI2 id='layerUI2'
+ blockIcon='{SwingUtil.createImageIcon("action-block.png")}'
+ acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}'
+ acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L;
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ accept(e, "from icon of layer");
+ }
+ }}' />
<script><![CDATA[
import jaxx.runtime.SwingUtil;
void $afterCompleteSetup() {
for (JComponent boxed : SwingUtil.getLayeredComponents(this)) {
+ if (boxed == d) {
+ SwingUtil.getLayer(boxed).setUI(layerUI2);
+ continue;
+ }
+
jaxx.runtime.swing.BlockingLayerUI ui = layerUI.clone();
if ( boxed == c) {
ui.setBlock(true);
}
SwingUtil.getLayer(boxed).setUI(ui);
- //ui.setDirty(true);
}
}
public void setLayer(boolean active) {
for (JComponent boxed : SwingUtil.getLayeredComponents(this)) {
+ if (boxed == d) {
+ continue;
+ }
jaxx.runtime.swing.BlockingLayerUI ui = (jaxx.runtime.swing.BlockingLayerUI)SwingUtil.getLayer(boxed).getUI();
if ( boxed == c) {
ui.setBlock(active);
@@ -59,6 +75,8 @@
onActionPerformed='accept(event, "from button (no layer)")'/>
<JButton id='c' text='button C (full block)' decorator='boxed' _clickedText='"button C was clicked"'
onActionPerformed='accept(event, "from button (no layer)");'/>
+ <JButton id='d' text='button D (full block 2)' decorator='boxed' _clickedText='"button D was clicked"'
+ onActionPerformed='accept(event, "from button (no layer)");'/>
</JPanel>
</cell>
</row>
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-18 08:46:51 UTC (rev 1270)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-18 18:17:16 UTC (rev 1271)
@@ -1,4 +1,5 @@
1.3 ?? 200903??
+ * 20090318 [chemit] - introduce the BlockingLayerUI2 class (should be merge with BlockingLayerUI)
* 20090318 [chemit] - introduce the CardLayout2Ext class
* 20090312 [chemit] - add some usefull code from ObServe (load Nimbus L&F, load ui configuration)
* 20090309 [chemit] - in BlockingLayerUI, add a new state 'block' to enable/disable blocking mode with a blockingColor
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-03-18 08:46:51 UTC (rev 1270)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-03-18 18:17:16 UTC (rev 1271)
@@ -4,9 +4,7 @@
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
-import java.awt.Insets;
import java.awt.Point;
-import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI2.java 2009-03-18 18:17:16 UTC (rev 1271)
@@ -0,0 +1,206 @@
+package jaxx.runtime.swing;
+
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.RenderingHints;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.image.BufferedImage;
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import org.jdesktop.jxlayer.JXLayer;
+
+/**
+ *
+ * A JXLayer ui implementation that permits to block a component but still
+ * allow an action when clicking everywhere on the layer.
+ *
+ * Moreover, an icon can be added on the right-top icon painted and changed
+ * when the mouse is over the layer.
+ *
+ * You can change the blocking and accepting icon.
+ *
+ * To hook an click on the layer's icon, you can :
+ *
+ * <ul><li>pass an Action via method {@link #setAcceptAction(Action)}</li>
+ * <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li>
+ * </ul>
+ *
+ * @author tony
+ * @since 1.3
+ */
+public class BlockingLayerUI2 extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> {
+
+ public static final String CAN_CLICK_PROPERTY = "canClick";
+ public static final String ACCEPT_ICON_PROPERTY = "acceptIcon";
+ public static final String BLOCK_ICON_PROPERTY = "blockIcon";
+ private static final long serialVersionUID = 1L;
+ /**
+ * Action to be treated when click on icon
+ */
+ protected Action acceptAction;
+ /**
+ * Icon when you can not click
+ */
+ protected BufferedImage blockIcon;
+ /**
+ * Icon when you can click
+ */
+ protected BufferedImage acceptIcon;
+ /**
+ * Internal state to known when we can accept click
+ */
+ protected boolean canClick;
+
+ public void setAcceptAction(Action acceptAction) {
+ this.acceptAction = acceptAction;
+ }
+
+ public void setAcceptIcon(ImageIcon acceptIcon) {
+ this.acceptIcon = prepareIcon(acceptIcon);
+ firePropertyChange(ACCEPT_ICON_PROPERTY, null, acceptIcon);
+ setDirty(true);
+ }
+
+ public void setBlockIcon(ImageIcon blockIcon) {
+ this.blockIcon = prepareIcon(blockIcon);
+ firePropertyChange(BLOCK_ICON_PROPERTY, null, blockIcon);
+ setDirty(true);
+ }
+
+ public void setCanClick(boolean canClick) {
+ boolean oldvalue = this.canClick;
+ this.canClick = canClick;
+ firePropertyChange(CAN_CLICK_PROPERTY, oldvalue, canClick);
+ if (oldvalue != canClick) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void setDirty(boolean isDirty) {
+ super.setDirty(isDirty);
+ }
+
+ public void setBlockIcon(BufferedImage blockIcon) {
+ this.blockIcon = blockIcon;
+ }
+
+ public BufferedImage getBlockIcon() {
+ return blockIcon;
+ }
+
+ protected BufferedImage getAcceptIcon() {
+ return acceptIcon;
+ }
+
+ public boolean isCanClick() {
+ return canClick;
+ }
+
+ @Override
+ public BlockingLayerUI2 clone() {
+ BlockingLayerUI2 clone = new BlockingLayerUI2();
+ clone.acceptAction = acceptAction;
+ clone.acceptIcon = acceptIcon;
+ clone.blockIcon = blockIcon;
+ clone.setCanClick(false);
+ return clone;
+ }
+
+ @Override
+ protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) {
+
+ e.consume();
+
+ }
+
+ @Override
+ protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) {
+
+ e.consume();
+
+ }
+
+ @Override
+ protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) {
+ switch (e.getID()) {
+ case MouseEvent.MOUSE_ENTERED:
+ setCanClick(true);
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ setCanClick(false);
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ if (canClick) {
+ acceptEvent(e, l);
+ }
+ break;
+ }
+ e.consume();
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+
+ // to be in sync with the view if the layer has a border
+ /*Insets layerInsets = l.getInsets();
+ g2.translate(layerInsets.left, layerInsets.top);
+
+ JComponent view = l.getView();
+ // To prevent painting on view's border
+ Insets insets = view.getInsets();
+ g2.clip(new Rectangle(insets.left, insets.top,
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
+ */
+
+ if (getCurrentIcon() != null) {
+ g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null);
+ }
+ }
+
+ protected void acceptEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (acceptAction != null) {
+ acceptAction.putValue("layer", l);
+ Component source = l.getView();
+ acceptAction.actionPerformed(new ActionEvent(source, 0, "accept"));
+ }
+ }
+
+ protected BufferedImage getCurrentIcon() {
+ return canClick ? acceptIcon : blockIcon;
+ }
+
+ protected BufferedImage prepareIcon(ImageIcon image) {
+ BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.drawImage(image.getImage(), 0, 0, null);
+ g2.dispose();
+ return icon;
+ }
+
+ protected void updateCanClickState(JXLayer<JComponent> l, MouseEvent e) {
+ // udpate toolTipText
+ Point layerLocation = l.getView().getLocation();
+ Point mousePoint = e.getPoint();
+ BufferedImage currentIcon = getCurrentIcon();
+ if (currentIcon == null) {
+ setCanClick(false);
+ return;
+ }
+ int minX = (int) layerLocation.getX() + l.getWidth() - currentIcon.getWidth();
+ int maxX = (int) layerLocation.getX() + l.getWidth();
+ int minY = 0;
+ int maxY = currentIcon.getHeight();
+ boolean accept = minX <= mousePoint.getX() && mousePoint.getX() <= maxX;
+ accept &= minY <= mousePoint.getLocation().getY() && mousePoint.getLocation().getY() <= maxY;
+ setCanClick(accept);
+ }
+}
1
0
March 18, 2009
Author: tchemit
Date: 2009-03-18 08:46:51 +0000 (Wed, 18 Mar 2009)
New Revision: 1270
Modified:
jaxx/trunk/jaxx-runtime-swing/changelog.txt
Log:
introduce CardLayout2Ext + improve wizard framework
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-18 08:45:58 UTC (rev 1269)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-18 08:46:51 UTC (rev 1270)
@@ -1,4 +1,5 @@
1.3 ?? 200903??
+ * 20090318 [chemit] - introduce the CardLayout2Ext class
* 20090312 [chemit] - add some usefull code from ObServe (load Nimbus L&F, load ui configuration)
* 20090309 [chemit] - in BlockingLayerUI, add a new state 'block' to enable/disable blocking mode with a blockingColor
* 20090303 [chemit] - in BlockingLayerUI, add a new state 'useIcon' to enable/disable use of the action icon
1
0
r1269 - in jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing: . wizard
by tchemit@users.labs.libre-entreprise.org March 18, 2009
by tchemit@users.labs.libre-entreprise.org March 18, 2009
March 18, 2009
Author: tchemit
Date: 2009-03-18 08:45:58 +0000 (Wed, 18 Mar 2009)
New Revision: 1269
Added:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java
Modified:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
Log:
introduce CardLayout2Ext + improve wizard framework
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/CardLayout2Ext.java 2009-03-18 08:45:58 UTC (rev 1269)
@@ -0,0 +1,99 @@
+package jaxx.runtime.swing;
+
+import java.awt.Container;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Une extension de {@link CardLayout2} pour pouvoir automatiquement afficher un
+ * contenu à partir de la propriété {@link #selected}.
+ *
+ * Ainsi, en changeant cette propriété via la méthode {@link #setSelected(String)},
+ * le contenu sera changé automatiquement, ce qui permet une utilisation direct
+ * dans jaxx sans à avoir à écrire d'écouteur.
+ *
+ * @author tony
+ * @since 1.3
+ * @see CardLayout2
+ */
+public class CardLayout2Ext extends CardLayout2 {
+
+ /** log */
+ static private Log log = LogFactory.getLog(CardLayout2.class);
+ private static final long serialVersionUID = 1L;
+ public static final String SELECTED_PROPERTY_NAME = "selected";
+ /**
+ * pour propager les changements dans le modèle vers l'ui
+ */
+ protected PropertyChangeSupport pcs;
+ /**
+ * le contenu sélectionné
+ */
+ protected String selected;
+ private String containerName;
+ private JAXXObject ui;
+ private Container container;
+
+ public CardLayout2Ext(JAXXObject ui, String containerName) {
+ pcs = new PropertyChangeSupport(this);
+ this.ui = ui;
+ this.containerName = containerName;
+ }
+
+ public String getSelected() {
+ return selected;
+ }
+
+ public String getPreviousSelected() {
+ int index = contexts.indexOf(selected);
+ if (index < 1) {
+ return null;
+ }
+ return contexts.get(index - 1) + "";
+ }
+
+ public String getNextSelected() {
+ int index = contexts.indexOf(selected);
+ if (index >= contexts.size()) {
+ return null;
+ }
+ return contexts.get(index + 1) + "";
+ }
+
+ public void setSelected(String selected) {
+ this.selected = selected;
+ show(getContainer(), selected);
+ }
+
+ public Container getContainer() {
+ if (container == null) {
+ container = (Container) ui.getObjectById(containerName);
+ }
+ return container;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListeners() {
+ for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-03-16 18:44:15 UTC (rev 1268)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-03-18 08:45:58 UTC (rev 1269)
@@ -195,6 +195,17 @@
}
}
+ public void validate() {
+ if (step == null) {
+ // pas de validation quand aucune etape n'est sélectionnée
+ return;
+ }
+ boolean validate = validate(step);
+ this.validStep = validate;
+ // toujours forcer la propagation
+ firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep);
+ }
+
protected Class<E> getStepClass() {
return stepClass;
}
@@ -210,17 +221,6 @@
validate();
}
- protected void validate() {
- if (step == null) {
- // pas de validation quand aucune etape n'est sélectionnée
- return;
- }
- boolean validate = validate(step);
- this.validStep = validate;
- // toujours forcer la propagation
- firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep);
- }
-
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
pcs.firePropertyChange(propertyName, oldValue, newValue);
}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-03-16 18:44:15 UTC (rev 1268)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-03-18 08:45:58 UTC (rev 1269)
@@ -34,6 +34,18 @@
return operation;
}
+ public Exception getError() {
+ return error;
+ }
+
+ public void setError(Exception e) {
+ error = e;
+ }
+
+ public void sendMessage(String msg) {
+ firePropertyChange("message", null, msg);
+ }
+
public abstract void start(JAXXContext context);
public abstract void beforeAction(JAXXContext context, M model) throws Exception;
@@ -44,8 +56,6 @@
public abstract WizardOperationState onCancel(M model, Exception e);
- public abstract void afterAction(M model, WizardOperationState result, Exception error);
-
protected abstract M getModel();
public WizardOperationState getOperationState() {
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-03-16 18:44:15 UTC (rev 1268)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-03-18 08:45:58 UTC (rev 1269)
@@ -49,44 +49,42 @@
}
public void cancel() {
- if (currentAction != null) {
- log.debug("cancel action " + currentAction);
- // on a une action en cours, on l'annule
- currentAction.cancel(true);
- }
- // on annule aussi le modele
+ log.info("cancel " + this);
+ this.canceled = true;
+
+ // on annule le modele
getModel().cancel();
- this.canceled = true;
+
// on rend la main au thread
setWaiting(false);
}
@SuppressWarnings("unchecked")
- public void launchOperation(E operation) {
+ public A launchOperation(E operation) {
- if (currentAction != null) {
+ if (currentAction != null && (!currentAction.isDone() || currentAction.operationState == WizardOperationState.RUNNING)) {
// on ne peut traiter qu'une seule opération à la fois
throw new IllegalStateException("can not add a operation when thread is busy, or has another operation to be done");
}
- try {
- currentAction = (A) operation.getActionClass().newInstance();
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
+ currentAction = (A) getModel().getOperationAction(operation);
+
// on libere le thread pour qu'il execute l'opération
setWaiting(false);
+
+ return currentAction;
}
+ public A getCurrentAction() {
+ return currentAction;
+ }
+
@Override
public void propertyChange(PropertyChangeEvent evt) {
log.trace(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
if ("state".equals(evt.getPropertyName())) {
- //@SuppressWarnings("unchecked")
- //A action = (A) evt.getSource();
StateValue state = (StateValue) evt.getNewValue();
if (state == StateValue.DONE) {
// on rend la main au thread pour qu'il attende une prochaine operation
- //getModel().setOperationState(action.getOperation(), action.getOperationState());
setWaiting(false);
}
}
@@ -137,13 +135,17 @@
// est terminée ou a été annulée, on passera alors
// dans la méthode onPropertyChanged
- getModel().setOperationState(currentAction.getOperationState());
+ if (canceled) {
+ getModel().setOperationState(WizardOperationState.CANCELED);
+ } else {
+ getModel().setOperationState(currentAction.getOperationState());
+ }
// le thread n'écoute plus l'action car elle est terminée
// ou annulée
currentAction.removePropertyChangeListener(this);
// suppression de l'action
- currentAction = null;
+ //currentAction = null;
}
}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-03-16 18:44:15 UTC (rev 1268)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-03-18 08:45:58 UTC (rev 1269)
@@ -1,9 +1,12 @@
package jaxx.runtime.swing.wizard;
+import java.util.Arrays;
import java.util.EnumMap;
import java.util.EnumSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.swing.SwingWorker.StateValue;
/**
* Un modèle de wizard avec des opérations.
@@ -18,11 +21,8 @@
public static final String OPERATION_STATE_PROPERTY_NAME = "operationState";
public static final String MODEL_STATE_PROPERTY_NAME = "modelState";
public static final String WAS_STARTED_PROPERTY_NAME = "wasStarted";
+
/**
- * le type d'une opération
- */
-// protected Class<O> operationClass;
- /**
* La liste des opérations à effectuer
*/
protected Set<E> operations;
@@ -30,6 +30,7 @@
* Pour conserver les états des opérations
*/
protected Map<E, WizardOperationState> operationStates;
+ protected Map<E, WizardOperationAction> operationActions;
/**
* L'état générale du modèle
*/
@@ -45,6 +46,7 @@
Class<T> k = (Class) stepClass;
this.operationStates = (Map) new EnumMap(k);
this.operations = (Set<E>) EnumSet.noneOf(k);
+ this.operationActions = (Map) new EnumMap(k);
}
public Set<E> getOperations() {
@@ -73,6 +75,19 @@
return operationStates.get(operation);
}
+ public WizardOperationAction getOperationAction(E operation) {
+ WizardOperationAction action = operationActions.get(operation);
+ if (action == null) {
+ try {
+ action = operation.getActionClass().newInstance();
+ operationActions.put(operation, action);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ return action;
+ }
+
public void setOperationState(WizardOperationState operationState) {
E operation = getOperation();
setOperationState(operation, operationState);
@@ -90,7 +105,7 @@
boolean[] result = new boolean[getSteps().size()];
int index = getSteps().indexOf(getStep());
if (index != -1) {
-
+
for (int i = 0, j = steps.size(); i < j; i++) {
if (i <= index) {
// tous les onglets inferieur ou egal au courant sont accessibles
@@ -106,7 +121,7 @@
(!previousStep.isOperation() || getOperationState(previousStep) == WizardOperationState.SUCCESSED));
}
}
- System.out.println("accessibles steps -------- " + java.util.Arrays.toString(result));
+ //System.out.println("accessibles steps -------- " + java.util.Arrays.toString(result));
return result;
}
@@ -121,12 +136,24 @@
}
public void cancel() {
+
for (E op : operations) {
if (getOperationState(op) == WizardOperationState.PENDING) {
// on annule l'opération à venir
setOperationState(op, WizardOperationState.CANCELED);
}
}
+ setModelState(WizardOperationState.CANCELED);
+ if (getStep() != null && getStep().isOperation()) {
+ WizardOperationAction action = getOperationAction(getStep());
+ if (action != null) {
+ if (!action.isCancelled() && !action.isDone() && action.getState() == StateValue.STARTED) {
+ System.out.println("cancel action " + action);
+ // on annule l'action
+ action.cancel(true);
+ }
+ }
+ }
}
public WizardOperationModel<E> addOperation(E operation) {
@@ -152,6 +179,10 @@
super.setSteps(steps);
// on force la propagation de la nouvelle liste
firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ updateOperationStates(Arrays.asList(steps));
+ }
+
+ public void updateOperationStates(List<E> steps) {
int index = 0;
for (E e : steps) {
fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, index++, null, getOperationState(e));
@@ -185,7 +216,7 @@
case CANCELED:
//le modele devient annulé
setModelState(WizardOperationState.CANCELED);
- break;
+ return;
case PENDING:
//le modele est en attente
setModelState(WizardOperationState.PENDING);
@@ -210,6 +241,7 @@
}
break;
}
+ updateOperationStates(steps);
}
@Override
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-03-16 18:44:15 UTC (rev 1268)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-03-18 08:45:58 UTC (rev 1269)
@@ -1,6 +1,7 @@
package jaxx.runtime.swing.wizard;
-import javax.swing.JFrame;
+import java.awt.Window;
+import javax.swing.ImageIcon;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXInitialContext;
import jaxx.runtime.JAXXObject;
@@ -20,85 +21,37 @@
protected UI ui;
- @SuppressWarnings("unchecked")
- public WizardUILancher(JAXXContext context, JFrame mainUI, Class<UI> uiClass, M model) {
- super();
+ public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, String title, String tip, ImageIcon icon) {
+ this(context, uiClass, modelClass, null, title, tip, icon);
+ }
+
+ public WizardUILancher(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) {
try {
- // instanciate ui parent context
- JAXXInitialContext uiContext = new JAXXInitialContext();
- uiContext.add(mainUI == null ? context : mainUI);
- // parent context model
- uiContext.add(model);
- // apply action
- uiContext.add("apply", new Runnable() {
-
- @Override
- public void run() {
- doAction(ui);
- }
- });
- // cancel action
- uiContext.add("cancel", new Runnable() {
-
- @Override
- public void run() {
- doCancel(ui);
- }
- });
-
- // instanciate ui
- ui = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{JFrame.class, JAXXContext.class});
-
+ ui = createUI(context, uiClass, modelClass, model, title, tip, icon);
} catch (Exception ex) {
throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
}
}
- @SuppressWarnings("unchecked")
- public WizardUILancher(JAXXContext context, JFrame mainUI, Class<UI> uiClass, Class<M> modelClass) {
- super();
+ public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) {
try {
- // instanciate ui parent context
- JAXXInitialContext uiContext = new JAXXInitialContext();
- uiContext.add(mainUI == null ? context : mainUI);
- // parent context model
- uiContext.add(modelClass.newInstance());
- // apply action
- uiContext.add("apply", new Runnable() {
-
- @Override
- public void run() {
- doAction(ui);
- }
- });
- // cancel action
- uiContext.add("cancel", new Runnable() {
-
- @Override
- public void run() {
- doCancel(ui);
- }
- });
-
- // instanciate ui
- ui = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{JFrame.class, JAXXContext.class});
-
+ ui = createUI(context, mainUI, uiClass, modelClass, model);
} catch (Exception ex) {
throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
}
}
+ public WizardUILancher(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass) {
+ this(context, mainUI, uiClass, modelClass, null);
+ }
+
public void start() {
- try {
- init(ui);
- ui.start();
- } finally {
- dispose();
- }
+ init(ui);
+ start(ui);
}
- public void dispose() {
- // par defaut, on ne fait rien
+ protected void start(UI ui) {
+ ui.start();
}
public <T> T getContextValue(Class<T> clazz, String name) {
@@ -124,4 +77,86 @@
protected void doCancel(UI ui) {
}
+
+ protected void doClose(UI ui, boolean wasCanceld) {
+ }
+
+ @SuppressWarnings("unchecked")
+ protected UI createUI(JAXXContext context, Window mainUI, Class<UI> uiClass, Class<M> modelClass, M model) throws Exception {
+ JAXXInitialContext uiContext = new JAXXInitialContext();
+ uiContext.add(mainUI == null ? context : mainUI);
+ // parent context model
+ uiContext.add(modelClass.newInstance());
+ if (model != null) {
+ uiContext.add("incoming", model);
+ }
+ // apply action
+ uiContext.add("apply", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doAction(ui);
+ } finally {
+ doClose(ui,false);
+ }
+ }
+ });
+ // cancel action
+ uiContext.add("cancel", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doCancel(ui);
+ } finally {
+ doClose(ui,true);
+ }
+ }
+ });
+
+ // instanciate ui
+
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{Window.class, JAXXContext.class});
+ return newUI;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected UI createUI(JAXXContext context, Class<UI> uiClass, Class<M> modelClass, M model, String title, String tip, ImageIcon icon) throws Exception {
+ JAXXInitialContext uiContext = new JAXXInitialContext();
+ uiContext.add(context);
+ // parent context model
+ uiContext.add(modelClass.newInstance());
+ if (model != null) {
+ uiContext.add("incoming", model);
+ }
+ // apply action
+ uiContext.add("apply", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doAction(ui);
+ } finally {
+ doClose(ui,false);
+ }
+ }
+ });
+ // cancel action
+ uiContext.add("cancel", new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ doCancel(ui);
+ } finally {
+ doClose(ui,true);
+ }
+ }
+ });
+
+ // instanciate ui
+ UI newUI = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{uiContext, title, tip, icon}, new Class[]{JAXXContext.class, String.class, String.class, ImageIcon.class});
+ return newUI;
+ }
}
1
0
r1268 - in jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime: . swing/wizard
by tchemit@users.labs.libre-entreprise.org March 16, 2009
by tchemit@users.labs.libre-entreprise.org March 16, 2009
March 16, 2009
Author: tchemit
Date: 2009-03-16 18:44:15 +0000 (Mon, 16 Mar 2009)
New Revision: 1268
Added:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/package.html
Removed:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java
Modified:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
Log:
wizard framework done
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-15 11:23:33 UTC (rev 1267)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -29,6 +29,7 @@
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.NoSuchElementException;
import java.util.Properties;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
@@ -413,6 +414,7 @@
public int size() {
return tabs.getTabCount();
}
+
public TabbedPaneIterator<O> reverse() {
setReverse(!reverse);
return this;
@@ -430,9 +432,9 @@
@Override
public O next() {
if (!hasNext()) {
- throw new IllegalStateException("no next objet! for " + this);
+ throw new NoSuchElementException();
}
- Component next = tabs.getComponent(index);
+ Component next = tabs.getComponentAt(index);
O result = get(index, next);
index += increment;
return result;
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-03-15 11:23:33 UTC (rev 1267)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -2,17 +2,21 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
-import java.util.List;
/**
* Un modèle de wizard.
*
- * @param <E> le type de l'énumération contenant les etapes.
*
+ * <b>Note:</b> le type des étapes doit être uné énumération qui implante
+ * {@link WizardStep}.
+ *
+ * @param <E> le type des étapes.
+ *
* @author tony
* @since 1.3
+ * @see WizardStep
*/
-public class WizardModel<E extends Enum<E>> {
+public class WizardModel<E extends WizardStep> {
public static final String STEPS_PROPERTY_NAME = "steps";
public static final String STEP_PROPERTY_NAME = "step";
@@ -26,7 +30,7 @@
/**
* Toutes les étapes à passer
*/
- protected List<E> steps;
+ protected java.util.List<E> steps;
/**
* L'étape courante
*/
@@ -36,11 +40,20 @@
*/
protected boolean validStep;
/**
+ * drapeau lorsque le modele effectue des operations
+ * de transformation de modele mais que les écouteurs
+ * ne devraient pas tenir compte des modifications
+ */
+ protected boolean valueAdjusting;
+ /**
* pour propager les changements dans le modèle vers l'ui
*/
protected PropertyChangeSupport pcs;
public WizardModel(Class<E> stepClass, E... steps) {
+ if (!Enum.class.isAssignableFrom(stepClass)) {
+ throw new IllegalArgumentException("stepClass must be an Enumeration but was " + stepClass.getName());
+ }
this.stepClass = stepClass;
this.pcs = new PropertyChangeSupport(this);
this.steps = new java.util.ArrayList<E>();
@@ -79,7 +92,7 @@
throw new NullPointerException("step can not be null");
}
if (!steps.contains(e)) {
- throw new IllegalStateException("step " + e + " is not in universe of steps (" + steps + ")");
+ throw new IllegalStateException("step " + e.toString() + " is not in universe of steps (" + steps + ")");
}
setStep(e);
}
@@ -98,6 +111,11 @@
}
public E getPreviousStep() {
+ E e = getPreviousStep(step);
+ return e;
+ }
+
+ public E getPreviousStep(E step) {
int index = getStepIndex(step);
if (index < 1) {
// si pas de step ou sur premier step
@@ -106,6 +124,15 @@
return steps.get(index - 1);
}
+ public E getNextStep(E step) {
+ int index = getStepIndex(step);
+ if (index < 1) {
+ // si pas de step ou sur premier step
+ return null;
+ }
+ return steps.get(index - 1);
+ }
+
public E getNextStep() {
int index = getStepIndex(step);
if (index == -1 || index == steps.size() - 1) {
@@ -115,10 +142,14 @@
return steps.get(index + 1);
}
- public List<E> getSteps() {
+ public java.util.List<E> getSteps() {
return steps;
}
+ public boolean isValueAdjusting() {
+ return valueAdjusting;
+ }
+
/**
* Change l'univers des etapes.
*
@@ -127,13 +158,17 @@
* @param steps le nouvel univers des etapes
*/
public void setSteps(E... steps) {
- List<E> oldValue = this.steps;
+ java.util.List<E> oldValue = this.steps;
this.steps = java.util.Collections.unmodifiableList(java.util.Arrays.asList(steps));
firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
// la propriete nextStep peut avoir changee
firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
}
+ public void setValueAdjusting(boolean valueAdjusting) {
+ this.valueAdjusting = valueAdjusting;
+ }
+
public boolean validate(E s) {
return step != null;
}
@@ -194,6 +229,10 @@
pcs.fireIndexedPropertyChange(propertyName, index, oldValue, newValue);
}
+ protected E[] updateStepUniverse() {
+ return null;
+ }
+
protected void updateUniverse() {
}
}
Deleted: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java 2009-03-15 11:23:33 UTC (rev 1267)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -1,20 +0,0 @@
-package jaxx.runtime.swing.wizard;
-
-/**
- *
- * @param <Action>
- * @author tony
- * @since 1.3
- */
-public interface WizardOperation<Action extends WizardOperationAction> {
-
- String name();
-
- int ordinal();
-
- String getLabel();
-
- String getDescription();
-
- public Action newAction();
-}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-03-15 11:23:33 UTC (rev 1267)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -6,27 +6,31 @@
import org.apache.commons.logging.LogFactory;
/**
+ * La classe de base a implanter pour definir l'action d'une operation
+ * dans un wizard.
*
* @author tony
* @param <E> le type d'étapes
- * @param <O> le type d'opérations
* @param <M> le type de modèle
* @since 1.3
*/
-public abstract class WizardOperationAction<E extends Enum<E>, O extends Enum<O>, M extends WizardOperationModel<E, O>> extends SwingWorker<WizardOperationState, String> {
+public abstract class WizardOperationAction<E extends WizardOperationStep, M extends WizardOperationModel<E>> extends SwingWorker<WizardOperationState, String> {
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(WizardOperationAction.class);
- O operation;
+ E operation;
WizardOperationState operationState;
Exception error;
- public WizardOperationAction(O operation) {
+ public WizardOperationAction(E operation) {
super();
+ if (!operation.isOperation()) {
+ throw new IllegalArgumentException("the step " + operation + " has no operation defined");
+ }
this.operation = operation;
}
- public O getOperation() {
+ public E getOperation() {
return operation;
}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-03-15 11:23:33 UTC (rev 1267)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -2,7 +2,6 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
import java.util.Date;
import javax.swing.SwingWorker.StateValue;
import jaxx.runtime.JAXXContext;
@@ -18,14 +17,13 @@
* Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setWaiting(boolean)}
*
* @param <E> le type des etapes
- * @param <O> le type des operations
* @param <M> le type de modele
* @param <A> le type d'action d'operation
*
* @author tony
* @since 1.3
*/
-public abstract class WizardOperationActionThread<E extends Enum<E>, O extends Enum<O>, M extends WizardOperationModel<E, O>, A extends WizardOperationAction<E, O, M>> extends Thread implements PropertyChangeListener {
+public abstract class WizardOperationActionThread<E extends WizardOperationStep, M extends WizardOperationModel<E>, A extends WizardOperationAction<E, M>> extends Thread implements PropertyChangeListener {
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(WizardOperationActionThread.class);
@@ -33,8 +31,6 @@
* l'état du thread si annulé
*/
private boolean canceled;
- /** suport of modification propagation */
- protected PropertyChangeSupport pcs;
protected Class<M> modelClass;
protected A currentAction;
/**
@@ -50,7 +46,6 @@
public WizardOperationActionThread(Class<M> modelClass) throws IllegalArgumentException {
super(WizardOperationActionThread.class.getSimpleName() + " " + new Date());
this.modelClass = modelClass;
- this.pcs = new PropertyChangeSupport(this);
}
public void cancel() {
@@ -66,20 +61,25 @@
setWaiting(false);
}
- public void launchOperation(A action) {
+ @SuppressWarnings("unchecked")
+ public void launchOperation(E operation) {
if (currentAction != null) {
// on ne peut traiter qu'une seule opération à la fois
throw new IllegalStateException("can not add a operation when thread is busy, or has another operation to be done");
}
- currentAction = action;
+ try {
+ currentAction = (A) operation.getActionClass().newInstance();
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
// on libere le thread pour qu'il execute l'opération
setWaiting(false);
}
@Override
public void propertyChange(PropertyChangeEvent evt) {
- log.info(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ log.trace(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
if ("state".equals(evt.getPropertyName())) {
//@SuppressWarnings("unchecked")
//A action = (A) evt.getSource();
@@ -166,39 +166,6 @@
log.trace(this);
}
- // PropertyChanged support
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- public synchronized boolean hasListeners(String propertyName) {
- return pcs.hasListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
- return pcs.getPropertyChangeListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- return pcs.getPropertyChangeListeners();
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- pcs.firePropertyChange(propertyName, oldValue, newValue);
- }
-
protected void setWaiting(boolean waiting) {
if (waiting && !canceled) {
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-03-15 11:23:33 UTC (rev 1267)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -2,16 +2,17 @@
import java.util.EnumMap;
import java.util.EnumSet;
+import java.util.Map;
+import java.util.Set;
/**
* Un modèle de wizard avec des opérations.
*
* @param <E> le type des étapes.
- * @param <O> le type des opérations.
* @author tony
* @since 1.3
*/
-public class WizardOperationModel<E extends Enum<E>, O extends Enum<O>> extends WizardModel<E> {
+public class WizardOperationModel<E extends WizardOperationStep> extends WizardModel<E> {
public static final String OPERATIONS_PROPERTY_NAME = "operations";
public static final String OPERATION_STATE_PROPERTY_NAME = "operationState";
@@ -20,15 +21,15 @@
/**
* le type d'une opération
*/
- protected Class<O> operationClass;
+// protected Class<O> operationClass;
/**
* La liste des opérations à effectuer
*/
- protected EnumSet<O> operations;
+ protected Set<E> operations;
/**
* Pour conserver les états des opérations
*/
- protected EnumMap<O, WizardOperationState> operationStates;
+ protected Map<E, WizardOperationState> operationStates;
/**
* L'état générale du modèle
*/
@@ -38,16 +39,15 @@
*/
protected boolean wasStarted;
- public WizardOperationModel(Class<E> stepClass, Class<O> operationClass, E... steps) {
+ @SuppressWarnings("unchecked")
+ public <T extends Enum<T>> WizardOperationModel(Class<E> stepClass, E... steps) {
super(stepClass, steps);
- this.operationClass = operationClass;
- this.operationStates = new EnumMap<O, WizardOperationState>(operationClass);
+ Class<T> k = (Class) stepClass;
+ this.operationStates = (Map) new EnumMap(k);
+ this.operations = (Set<E>) EnumSet.noneOf(k);
}
- public EnumSet<O> getOperations() {
- if (operations == null) {
- operations = EnumSet.noneOf(operationClass);
- }
+ public Set<E> getOperations() {
return operations;
}
@@ -60,43 +60,68 @@
}
@SuppressWarnings("unchecked")
- public O getOperation() {
- return ((WizardOperationStep<O>) getStep()).getOperation();
+ public E getOperation() {
+ return getStep() != null && getStep().isOperation() ? getStep() : null;
}
public WizardOperationState getOperationState() {
- O operation = getOperation();
+ E operation = getOperation();
return getOperationState(operation);
}
- public WizardOperationState getOperationState(O operation) {
+ public WizardOperationState getOperationState(E operation) {
return operationStates.get(operation);
}
public void setOperationState(WizardOperationState operationState) {
- O operation = getOperation();
+ E operation = getOperation();
setOperationState(operation, operationState);
}
- public void setOperationState(O operation, WizardOperationState operationState) {
+ public void setOperationState(E operation, WizardOperationState operationState) {
WizardOperationState oldValue = getOperationState(operation);
this.operationStates.put(operation, operationState);
- firePropertyChange(OPERATION_STATE_PROPERTY_NAME, oldValue, operationState);
- //fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, getOperationIndex(operation), oldValue, operationStates);
+ fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, getSteps().indexOf(operation), oldValue, operationState);
updateModelState(operation, operationState);
validate();
}
+ public boolean[] getAccessibleSteps() {
+ boolean[] result = new boolean[getSteps().size()];
+ int index = getSteps().indexOf(getStep());
+ if (index != -1) {
+
+ for (int i = 0, j = steps.size(); i < j; i++) {
+ if (i <= index) {
+ // tous les onglets inferieur ou egal au courant sont accessibles
+ result[i] = true;
+ continue;
+ }
+ // les onglets au dela de l'onglet sélectionné sont accessibles
+ // uniquement si l'onglet precedent est accessible, valide et son etat est a SUCCESSED
+ E previousStep = steps.get(i - 1);
+ result[i] = modelState == WizardOperationState.SUCCESSED ||
+ (result[i - 1] &&
+ validate(previousStep) &&
+ (!previousStep.isOperation() || getOperationState(previousStep) == WizardOperationState.SUCCESSED));
+ }
+ }
+ System.out.println("accessibles steps -------- " + java.util.Arrays.toString(result));
+ return result;
+ }
+
@Override
public void start() {
super.start();
+ updateUniverse();
+ //setSteps(steps.toArray((E[]) Array.newInstance(stepClass, steps.size())));
+
// le modèle n'est pas démarré
setModelState(WizardOperationState.PENDING);
- firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
}
public void cancel() {
- for (O op : operations) {
+ for (E op : operations) {
if (getOperationState(op) == WizardOperationState.PENDING) {
// on annule l'opération à venir
setOperationState(op, WizardOperationState.CANCELED);
@@ -104,10 +129,8 @@
}
}
- public WizardOperationModel<E, O> addOperation(O operation) {
- getOperations().add(operation);
- // on force la propagation de la nouvelle liste
- firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ public WizardOperationModel<E> addOperation(E operation) {
+ operations.add(operation);
// mis a jour de l'univers des etapes et operations
updateUniverse();
// validation
@@ -115,16 +138,27 @@
return this;
}
- public void removeOperation(O operation) {
- getOperations().remove(operation);
- // on force la propagation de la nouvelle liste
- firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ public void removeOperation(E operation) {
+ operations.remove(operation);
+
// mis a jour de l'univers des etapes et operations
updateUniverse();
// validation
validate();
}
+ @Override
+ public void setSteps(E... steps) {
+ super.setSteps(steps);
+ // on force la propagation de la nouvelle liste
+ firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ int index = 0;
+ for (E e : steps) {
+ fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, index++, null, getOperationState(e));
+ }
+ firePropertyChange(MODEL_STATE_PROPERTY_NAME, null, modelState);
+ }
+
protected void setModelState(WizardOperationState modelState) {
WizardOperationState oldValue = this.modelState;
this.modelState = modelState;
@@ -137,33 +171,33 @@
}
}
- protected void updateModelState(O operation, WizardOperationState operationState) {
+ protected void updateModelState(E operation, WizardOperationState operationState) {
switch (operationState) {
case RUNNING:
- //le model est occupé
+ //le modele est occupé
setModelState(WizardOperationState.RUNNING);
break;
case FAILED:
- //le model est en attente
- setModelState(WizardOperationState.PENDING);
+ //le modele est en erreur
+ setModelState(WizardOperationState.FAILED);
break;
case CANCELED:
- //le model devient annulé
+ //le modele devient annulé
setModelState(WizardOperationState.CANCELED);
break;
case PENDING:
- //le model est en attente
+ //le modele est en attente
setModelState(WizardOperationState.PENDING);
break;
case NEED_FIX:
- //le model est en attente
+ //le modele est en attente
setModelState(WizardOperationState.PENDING);
break;
case SUCCESSED:
// on regarde si on peut passer le model a l'état success
boolean valid = true;
- for (O o : operations) {
+ for (E o : operations) {
if (getOperationState(o) != WizardOperationState.SUCCESSED) {
valid = false;
break;
@@ -178,9 +212,15 @@
}
}
- protected int getOperationIndex(O operation) {
+ @Override
+ protected void updateUniverse() {
+ E[] newSteps = updateStepUniverse();
+ setSteps(newSteps);
+ }
+
+ protected int getOperationIndex(E operation) {
int index = 0;
- for (O o : operations) {
+ for (E o : operations) {
if (operation == o) {
return index;
}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2009-03-15 11:23:33 UTC (rev 1267)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -2,19 +2,33 @@
/**
*
- * @param <Operation>
+ * Le contrat a implanter pour une etapes dans le modèle de wizard avec
+ * opérations.
+ *
* @author tony
* @since 1.3
*/
-public interface WizardOperationStep<Operation extends Enum<Operation>> {
+public interface WizardOperationStep extends WizardStep {
- String name();
+ /**
+ * @return le label de l'opération
+ */
+ String getOperationLabel();
- int ordinal();
+ /**
+ * @return la description de l'opération
+ */
+ String getOperationDescription();
- String getLabel();
+ /**
+ * @return le type de l'action associée à l'étape ou <code>null</code> si
+ * l'étape n'a pas d'opération associée.
+ */
+ Class<? extends WizardOperationAction> getActionClass();
- String getDescription();
-
- Operation getOperation();
+ /**
+ * @return <code>true</code> si l'étape a une opération associée,
+ * <code>false</code> sinon.
+ */
+ boolean isOperation();
}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStep.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -0,0 +1,20 @@
+package jaxx.runtime.swing.wizard;
+
+import java.io.Serializable;
+
+/**
+ * le contrat d'une étape d'un wizard.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardStep extends Serializable {
+
+ String name();
+
+ int ordinal();
+
+ String getLabel();
+
+ String getDescription();
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardStepUI.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -0,0 +1,14 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ * Le contrat d'une ui d'étape.
+ *
+ * @param <E> le type d'étape
+ * @param <M> le type de modèle
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardStepUI<E extends WizardStep, M extends WizardModel<E>> {
+
+ E getStep();
+}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-03-15 11:23:33 UTC (rev 1267)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -12,13 +12,27 @@
* @author tony
* @since 1.3
*/
-public interface WizardUI<E extends Enum<E>, M extends WizardModel<E>> {
+public interface WizardUI<E extends WizardStep, M extends WizardModel<E>> {
- public E getSelectedStep();
-
M getModel();
+ E getSelectedStep();
+
+ WizardStepUI<E, M> getSelectedStepUI();
+
+ WizardStepUI<E, M> getStepUI(E step);
+
+ WizardStepUI<E, M> getStepUI(int stepIndex);
+
void start();
JTabbedPane getTabs();
+
+ void onStepsChanged(E[] steps);
+
+ void onStepChanged(E newStep);
+
+ void onModelStateChanged(WizardOperationState newState);
+
+ void onOperationStateChanged(E step,WizardOperationState newState) ;
}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-03-15 11:23:33 UTC (rev 1267)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -8,7 +8,7 @@
/**
*
- * Une classe pour lancer une ui avec wizard.
+ * Une classe pour lancer une ui de wizard.
*
* @param <E> le type des etapes
* @param <M> le type de modele
@@ -16,11 +16,45 @@
* @author tony
* @since 1.3
*/
-public abstract class WizardUILancher<E extends Enum<E>, M extends WizardModel<E>, UI extends WizardUI<E, M>> {
+public abstract class WizardUILancher<E extends WizardStep, M extends WizardModel<E>, UI extends WizardUI<E, M>> {
protected UI ui;
@SuppressWarnings("unchecked")
+ public WizardUILancher(JAXXContext context, JFrame mainUI, Class<UI> uiClass, M model) {
+ super();
+ try {
+ // instanciate ui parent context
+ JAXXInitialContext uiContext = new JAXXInitialContext();
+ uiContext.add(mainUI == null ? context : mainUI);
+ // parent context model
+ uiContext.add(model);
+ // apply action
+ uiContext.add("apply", new Runnable() {
+
+ @Override
+ public void run() {
+ doAction(ui);
+ }
+ });
+ // cancel action
+ uiContext.add("cancel", new Runnable() {
+
+ @Override
+ public void run() {
+ doCancel(ui);
+ }
+ });
+
+ // instanciate ui
+ ui = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{JFrame.class, JAXXContext.class});
+
+ } catch (Exception ex) {
+ throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
public WizardUILancher(JAXXContext context, JFrame mainUI, Class<UI> uiClass, Class<M> modelClass) {
super();
try {
@@ -64,7 +98,7 @@
}
public void dispose() {
- ui = null;
+ // par defaut, on ne fait rien
}
public <T> T getContextValue(Class<T> clazz, String name) {
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUtil.java 2009-03-16 18:44:15 UTC (rev 1268)
@@ -0,0 +1,93 @@
+package jaxx.runtime.swing.wizard;
+
+import java.beans.IndexedPropertyChangeEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.lang.reflect.Array;
+import org.apache.commons.logging.Log;
+
+/**
+ * Classe de méthodes utiles sur les wizard.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public class WizardUtil {
+
+ protected WizardUtil() {
+ }
+
+ public static boolean acceptStates(WizardOperationState state, WizardOperationState... accepted) {
+ for (WizardOperationState s : accepted) {
+ if (s == state) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean rejectStates(WizardOperationState state, WizardOperationState... rejected) {
+ for (WizardOperationState s : rejected) {
+ if (s == state) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static void addDebugLogListener(final Log log, WizardModel model) {
+ if (log.isDebugEnabled()) {
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ log.debug(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ }
+ });
+ }
+ }
+
+ public static void addTraceLogListener(final Log log,WizardModel model) {
+ if (log.isTraceEnabled()) {
+ model.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ log.trace(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ }
+ });
+ }
+ }
+
+ public static <E extends WizardStep, M extends WizardModel<E>> void installWizardUIListeners(final WizardUI<E, M> ui) {
+ ui.getModel().addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void propertyChange(PropertyChangeEvent evt) {
+ String propertyName = evt.getPropertyName();
+ if (WizardModel.STEPS_PROPERTY_NAME.equals(propertyName)) {
+ java.util.List<E> steps = (java.util.List<E>) evt.getNewValue();
+ ui.onStepsChanged(steps.toArray((E[]) Array.newInstance(ui.getModel().stepClass, steps.size())));
+ return;
+ }
+ if (WizardModel.STEP_PROPERTY_NAME.equals(propertyName)) {
+ ui.onStepChanged((E) evt.getNewValue());
+ return;
+ }
+ if (WizardOperationModel.MODEL_STATE_PROPERTY_NAME.equals(propertyName)) {
+ //TODO should be unicast : only for good stepUI ?
+ ui.onModelStateChanged((WizardOperationState) evt.getNewValue());
+ return;
+ }
+ if (WizardOperationModel.OPERATION_STATE_PROPERTY_NAME.equals(propertyName)) {
+ IndexedPropertyChangeEvent e = (IndexedPropertyChangeEvent) evt;
+ int stepIndex = e.getIndex();
+ E step = ui.getModel().getSteps().get(stepIndex);
+ ui.onOperationStateChanged(step, (WizardOperationState) evt.getNewValue());
+ return;
+ }
+ }
+ });
+ }
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/package.html
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/package.html (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/package.html 2009-03-16 18:44:15 UTC (rev 1268)
@@ -0,0 +1,9 @@
+<html>
+ <body>
+ <h1>JAXX - Wizard framework</h1>
+
+ This package contains all the classes of the wizard framework.
+
+ TODO
+ </body>
+</html>
\ No newline at end of file
1
0
r1267 - jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard
by tchemit@users.labs.libre-entreprise.org March 15, 2009
by tchemit@users.labs.libre-entreprise.org March 15, 2009
March 15, 2009
Author: tchemit
Date: 2009-03-15 11:23:33 +0000 (Sun, 15 Mar 2009)
New Revision: 1267
Modified:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
Log:
rendre publique les m?\195?\169thode d'acces au context
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-03-14 19:24:14 UTC (rev 1266)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-03-15 11:23:33 UTC (rev 1267)
@@ -67,16 +67,7 @@
ui = null;
}
- protected void init(UI ui) {
- }
-
- protected void doAction(UI ui) {
- }
-
- protected void doCancel(UI ui) {
- }
-
- protected <T> T getContextValue(Class<T> clazz, String name) {
+ public <T> T getContextValue(Class<T> clazz, String name) {
if (ui == null) {
throw new NullPointerException("ui can not be null");
}
@@ -87,7 +78,16 @@
return ((JAXXObject) ui).getContextValue(clazz, name);
}
- protected <T> T getContextValue(Class<T> clazz) {
+ public <T> T getContextValue(Class<T> clazz) {
return getContextValue(clazz, null);
}
+
+ protected void init(UI ui) {
+ }
+
+ protected void doAction(UI ui) {
+ }
+
+ protected void doCancel(UI ui) {
+ }
}
1
0
r1266 - in jaxx/trunk: jaxx-compiler-api/src/main/java/jaxx/compiler jaxx-runtime-swing/src/main/java/jaxx/runtime jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard
by tchemit@users.labs.libre-entreprise.org March 14, 2009
by tchemit@users.labs.libre-entreprise.org March 14, 2009
March 14, 2009
Author: tchemit
Date: 2009-03-14 19:24:14 +0000 (Sat, 14 Mar 2009)
New Revision: 1266
Added:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
Removed:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationAction.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationActionThread.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModelWithOperations.java
Modified:
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
Log:
wizard framework done
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java 2009-03-13 22:00:34 UTC (rev 1265)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -20,75 +20,61 @@
import java.util.List;
import java.util.Map;
-
/**
* Represents an object in the <code>.java</code> file being generated during compilation. There is
* a <code>CompiledObject</code> for each class tag encountered, and certain tags may generate
* additional objects for various reasons.
*/
public class CompiledObject {
+
/** The object's id. */
private String id;
-
/** Java code referring to the object. */
private String javaCode;
-
/** The object's class. */
private ClassDescriptor objectClass;
-
/** The style class. */
private String styleClass;
-
/** The container containing this CompiledObject. */
private CompiledObject parent;
-
/** true if this object overrides an object of the same id in a superclass of the object being compiled */
private boolean override;
-
/**
* Comma-separated Java code snippets representing the parameters that should be passed to the object's
* constructor.
*/
private String constructorParams;
-
/**
* Java code snippet which performs basic initialization of the object (after it has already been constructed).
* Because CompiledObject initialization order cannot be guaranteed, it is not safe to refer to other
* CompiledObjects from initializationCode -- you must refer to them from additionCode instead.
*/
private StringBuffer initializationCode = new StringBuffer();
-
/**
* Java code snippet which completes setup by adding any child objects, or otherwise manipulates any refererenced
* objects. Because CompiledObject initialization order cannot be guaranteed, it is not safe to refer to other
* CompiledObjects from initializationCode -- you must refer to them from additionCode instead.
*/
private StringBuffer additionCode = new StringBuffer();
-
/** List of all registered event handlers. */
private List<EventHandler> eventHandlers = new ArrayList<EventHandler>();
-
/** All properties that have been applied to this CompiledObject. */
private Map<String, String> properties = new HashMap<String, String>();
-
/** generic types of the compiled object */
private String[] genericTypes;
-
/** a flag to indicate if javaBean full support must be support for this object by root object */
private boolean javaBean;
-
/** code to initialize the bean (can be null) */
private String javaBeanInitCode;
-
/** the type of the override object (can be null if no oveeride) */
private ClassDescriptor overrideType;
-
/**
* the decorator (if null will use {@link DefaultCompiledObjectDecorator}).
*/
private CompiledObjectDecorator decorator;
-
+
public class ChildRef {
+
CompiledObject child;
String constraints;
String childJavaCode;
@@ -142,7 +128,6 @@
buffer.append(JAXXCompiler.getLineSeparator());
}
}
-
private List<ChildRef> childs;
/**
@@ -158,7 +143,6 @@
this(id, objectClass, compiler, false);
}
-
/**
* Creates a new <code>CompiledObject</code>. To be useful, the object should be registered with a
* <code>JAXXCompiler</code> using {@link JAXXCompiler#registerCompiledObject registerCompiledObject}.
@@ -173,7 +157,6 @@
this(id, id, objectClass, compiler, force);
}
-
/**
* Creates a new <code>CompiledObject</code>. To be useful, the object should be registered with a
* <code>JAXXCompiler</code> using {@link JAXXCompiler#registerCompiledObject registerCompiledObject}.
@@ -202,7 +185,6 @@
this.childs = new ArrayList<ChildRef>();
}
-
public static boolean isValidID(String id) {
boolean valid = true;
if (id.length() == 0) {
@@ -224,7 +206,6 @@
return valid;
}
-
/**
* True if this object overrides an object in the superclass of the class being compiled. For this to be true, the
* class currently being compiled must be a subclass of another <code>JAXXObject</code> which has an
@@ -237,7 +218,6 @@
return override;
}
-
/**
* Sets whether this class overrides an identically-named object in the parent class.
*
@@ -248,7 +228,6 @@
this.override = override;
}
-
/**
* Returns this object's CSS style class.
*
@@ -258,7 +237,6 @@
return styleClass;
}
-
/**
* Sets this object's CSS style class.
*
@@ -268,7 +246,6 @@
this.styleClass = styleClass;
}
-
/**
* Returns this object's parent container. Non-visual components (and the root container) return <code>null</code>.
*
@@ -278,7 +255,6 @@
return parent;
}
-
/**
* Sets this object's parent container.
*
@@ -291,7 +267,6 @@
this.parent = parent;
}
-
/**
* Returns the name of the method that should be generated in the compiled <code>.java</code> file
* in order to create this object. This is just a suggestion and may be ignored.
@@ -302,7 +277,6 @@
return "create" + org.apache.commons.lang.StringUtils.capitalize(getId());
}
-
/**
* Returns the name of the method that should be generated in the compiled <code>.java</code> file
* in order to add children to this object. This is just a suggestion and may be ignored.
@@ -313,7 +287,6 @@
return "addChildrenTo" + org.apache.commons.lang.StringUtils.capitalize(getId());
}
-
/**
* Returns the type of this object.
*
@@ -323,7 +296,6 @@
return objectClass;
}
-
/**
* Returns this object's id. Generally, a field with this name will be created in the compiled <code>.java</code>
* file in order to represent this object.
@@ -334,7 +306,6 @@
return id;
}
-
/**
* Returns Java code used to refer to this object in the compiled Java file. This is usually the same as its
* id.
@@ -382,7 +353,6 @@
return constructorParams;
}
-
/**
* Sets the parameters to pass to this object's constructor.
*
@@ -393,7 +363,6 @@
this.constructorParams = constructorParams;
}
-
/**
* Returns the code that performs basic initialization of this object, after it has already been constructed.
* This basic code should not reference any other <code>CompiledObjects</code> as they may not have
@@ -411,7 +380,6 @@
return result.toString();
}
-
protected String getInitializationCode(EventHandler handler, JAXXCompiler compiler) {
MethodDescriptor addMethod = handler.getAddMethod();
ClassDescriptor listenerClass = addMethod.getParameterTypes()[0];
@@ -421,7 +389,6 @@
TypeManager.getJavaCode(compiler.getEventHandlerMethodName(handler)) + "));" + JAXXCompiler.getLineSeparator();
}
-
/**
* Returns Java code to complete final setup on this object. This code may reference other
* <code>CompiledObjects</code>, as they are guaranteed to have all been created by this point.
@@ -432,7 +399,6 @@
return additionCode.toString();
}
-
/**
* Appends code to the initialization code block. A line separator is automatically appended to the end.
*
@@ -444,7 +410,6 @@
this.initializationCode.append(JAXXCompiler.getLineSeparator());
}
-
/**
* Appends code to the addition code block. A line separator is automatically appended to the end.
*
@@ -456,7 +421,6 @@
this.additionCode.append(JAXXCompiler.getLineSeparator());
}
-
/**
* Stores a property for this object. The only effect of calling this method is that the property will
* be returned by <code>getProperties()</code>.
@@ -469,7 +433,6 @@
properties.put(property, value);
}
-
/**
* Returns all properties which have been set for this object.
*
@@ -480,7 +443,6 @@
return properties;
}
-
// TODO: remove this temporary method and complete switchover to MethodDescriptors
public void addEventHandler(String eventId, Method addMethod, Method listenerMethod, String code, JAXXCompiler compiler) {
try {
@@ -490,13 +452,11 @@
MethodDescriptor addMethodDescriptor = descriptor.getMethodDescriptor(addMethod.getName(), listenerDescriptor);
MethodDescriptor listenerMethodDescriptor = listenerDescriptor.getMethodDescriptor(listenerMethod.getName(), ClassDescriptorLoader.getClassDescriptor(listenerMethod.getParameterTypes()[0].getName()));
addEventHandler(eventId, addMethodDescriptor, listenerMethodDescriptor, code, compiler);
- }
- catch (Exception e) {
+ } catch (Exception e) {
throw new RuntimeException(e);
}
}
-
/**
* Adds an event listener to this object. The generated code will appear in the initialization block.
*
@@ -517,7 +477,6 @@
}
}
-
/**
* Adds a child component to this container. The child is added without layout constraints.
*
@@ -530,7 +489,6 @@
addChild(child, null, compiler);
}
-
/**
* Adds a child component to this container. This variant allows the Java code for a layout constraints
* object to be specified.
@@ -546,8 +504,7 @@
if (constraints != null) {
constraints = compiler.checkJavaCode(constraints);
}
- }
- catch (CompilerException e) {
+ } catch (CompilerException e) {
compiler.reportError("While parsing 'constraints' attribute: " + e.getMessage());
}
@@ -561,7 +518,7 @@
String delegateCode = containerDelegate != null ? "." + containerDelegate + "()" : "";
child.setParent(this);
-
+
childs.add(new ChildRef(child, constraints, child.getJavaCode(), delegateCode));
}
}
@@ -571,7 +528,6 @@
return getObjectClass().getName() + "[id='" + id + "']";
}
-
public void registerDataBinding(String src, String property, String assignment, JAXXCompiler compiler) throws CompilerException {
compiler.registerDataBinding(src, getId() + "." + property, assignment);
}
@@ -584,7 +540,7 @@
for (int i = 0, j = getGenericTypesLength(); i < j; i++) {
result += ", " + genericTypes[i];
}
- return "< " + result.substring(1) + " >";
+ return "< " + result.substring(2) + " >";
}
public void setGenericTypes(String[] genericTypes) {
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-13 22:00:34 UTC (rev 1265)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -409,7 +409,10 @@
public void reset() {
setReverse(reverse);
}
-
+
+ public int size() {
+ return tabs.getTabCount();
+ }
public TabbedPaneIterator<O> reverse() {
setReverse(!reverse);
return this;
Deleted: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationAction.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationAction.java 2009-03-13 22:00:34 UTC (rev 1265)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationAction.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -1,94 +0,0 @@
-package jaxx.runtime.swing.wizard;
-
-import javax.swing.SwingWorker;
-import jaxx.runtime.JAXXContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- *
- * @author tony
- * @param <E>
- * @param <O>
- * @param <R>
- * @param <M>
- * @since 1.3
- */
-public abstract class WizardAbstractOperationAction<E extends Enum<E>,O extends Enum<O>, R extends Enum<R>, M extends WizardModelWithOperations<E,O,R>> extends SwingWorker<R, String> {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(WizardAbstractOperationAction.class);
- O operation;
- Exception error;
-
- public WizardAbstractOperationAction(O operation) {
- super();
- this.operation = operation;
- }
-
- public O getOperation() {
- return operation;
- }
-
- public abstract void start(JAXXContext context);
-
- public abstract void beforeAction(JAXXContext context, M model) throws Exception;
-
- public abstract R doAction(M model) throws Exception;
-
- public abstract R onError(M model, Exception e);
-
- public abstract R onCancel(M model, Exception e);
-
- public abstract void afterAction(M model, R result, Exception error);
-
- protected abstract M getModel();
-
- protected abstract JAXXContext getContext();
-
- @Override
- public String toString() {
- return super.toString() + " < operation: " + operation + ", state: " + getState() + " >";
- }
-
- @Override
- protected R doInBackground() throws Exception {
- R result;
- M model = getModel();
- try {
- log.info(this);
- beforeAction(getContext(), model);
- result = doAction(model);
- } catch (Exception e) {
- error = e;
- result = onError(model, e);
- }
- return result;
- }
-
- @Override
- protected void done() {
- R result = null;
- log.info(this);
- M model = getModel();
- try {
- if (isCancelled()) {
-
- result = onCancel(model, error);
- } else {
- result = get();
- }
- } catch (Exception e) {
- // ne devrait jamais arrivé ?
- log.error(e.getMessage(), e);
- throw new RuntimeException(e);
- } finally {
- // on enregistre le resultat de l'opération
-
- model.setOperationResult(operation, result);
-
- // on notifie le resultat de l'action
- firePropertyChange(WizardModelWithOperations.OPERATION_RESULT_PROPERTY_NAME, null, result);
- }
- }
-}
Deleted: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationActionThread.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationActionThread.java 2009-03-13 22:00:34 UTC (rev 1265)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationActionThread.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -1,265 +0,0 @@
-package jaxx.runtime.swing.wizard;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.Date;
-import jaxx.runtime.JAXXContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Thread qui réalise les opérations.
- *
- * Pour exécuter une nouvelle opération, on utilise la méthode
- * {@link #launchOperation(SynchroActionWorker)}.
- *
- * Le thread possède 2 états internes :
- *
- * - busy lorsqu'il exécute une opération
- *
- * - canceled lorqu'une annulation a été demandée via la méthode {@link #setCanceled(boolean)}
- *
- * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setwaiting(boolean)}
- * @param <E> le type des etapes
- * @param <O> le type des operations
- * @param <R> le type des resultats d'operation
- * @param <M> le type de modele
- * @param <A> le type d'action d'operation
- *
- * @author tony
- * @since 1.3
- */
-public abstract class WizardAbstractOperationActionThread<E extends Enum<E>, O extends Enum<O>, R extends Enum<R>, M extends WizardModelWithOperations<E, O, R>, A extends WizardAbstractOperationAction<E, O, R, M>> extends Thread implements PropertyChangeListener {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static final Log log = LogFactory.getLog(WizardAbstractOperationActionThread.class);
- public static final String BUSY_PROPERTY_NAME = "busy";
- public static final String CANCELED_PROPERTY_NAME = "canceled";
- /**
- * l'état du thread pendant les étapes non interactives
- */
- private boolean busy;
- /**
- * l'état du thread si annulé
- */
- private boolean canceled;
- /** suport of modification propagation */
- protected PropertyChangeSupport pcs;
- /** le context applicatif */
- protected JAXXContext cotext;
- protected Class<M> modelClass;
- protected A currentAction;
- /**
- * un lock pour permettre la suspension et la reprise du thread
- * lors du mode interactif.
- */
- private final Object LOCK = new Object();
-
- protected abstract M getModel();
- protected abstract JAXXContext getContext();
-
- public WizardAbstractOperationActionThread(Class<M> modelClass) throws IllegalArgumentException {
- super(WizardAbstractOperationActionThread.class.getSimpleName() + " " + new Date());
- this.modelClass = modelClass;
- this.pcs = new PropertyChangeSupport(this);
- }
-
- public boolean isBusy() {
- return busy;
- }
-
- public boolean isCanceled() {
- return canceled;
- }
-
- public void cancel() {
- setCanceled(true);
- //currentAction = null;
- setBusy(false);
- setWaiting(false);
- }
-
- public void launchOperation(A action) {
-
- if (busy || currentAction != null) {
- // on ne peut traiter qu'une seule opération à la fois
- throw new IllegalStateException("can not add a operation when thread is busy, or has another operation to be done");
- }
- currentAction = action;
- // on libere le thread pour qu'il execute l'opération
- setWaiting(false);
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (WizardModelWithOperations.OPERATION_RESULT_PROPERTY_NAME.equals(evt.getPropertyName())) {
- // on rend la main au thread pour qu'il attende une prochaine operation
- setWaiting(false);
- }
- }
-
- @Override
- public void run() {
- try {
-
- // on vérifie que le context contient bien le modèle
- if (getModel()==null) {
- throw new NullPointerException("could not find model "+modelClass+" for "+this);
- }
-
- while (!canceled) {
-
- if (canceled) {
- // une annulation a été demandé
- // donc même si une opération est demandée, on ne la traite
- // pas
- break;
- }
-
- // en attente qu'une opération
- // le block est bloqué jusqu'à arrivée d'une opération
- // ou une demande d'annulation
- setWaiting(true);
-
- // le thread a repris la main, donc plus en attente
- log.trace("no more waiting " + this);
-
- if (!canceled) {
- // une opération a été demandée
-
- // le thread passe en éta occupé
- setBusy(true);
- // le thread écoute les modifications de l'action
- currentAction.addPropertyChangeListener(this);
- // démarrage de l'opération
- currentAction.start(getContext());
- // le thread est bloqué jusqu'à la fin de l'opération
- // ou une demande d'annulation
- setWaiting(true);
- // la main a ete rendue, le thread n'est plus actif
- setBusy(false);
- }
-
- // le thread reprend la main des que l'operation
- // est terminée ou a été annulée, on passera alors
- // dans la méthode onPropertyChanged
- if (currentAction != null) {
- // le thread n'écoute plus l'action car elle est terminée
- // ou annulée
- currentAction.removePropertyChangeListener(this);
- // suppression de l'action
- currentAction = null;
- }
-
- }
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- if (busy) {
- setBusy(false);
- setWaiting(false);
- }
-
- log.info(this + " will close...");
- close();
- }
- }
-
- /**
- * La méthode pour nettoyer le thread, a la fermeture.
- *
- */
- protected void close() {
- // par defaut, on ne fait rien
- log.info(this);
- }
-
- // PropertyChanged support
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- public synchronized boolean hasListeners(String propertyName) {
- return pcs.hasListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
- return pcs.getPropertyChangeListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- return pcs.getPropertyChangeListeners();
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- pcs.firePropertyChange(propertyName, oldValue, newValue);
- }
-
- protected void setBusy(boolean busy) {
- boolean oldValue = this.busy;
- this.busy = busy;
- firePropertyChange(BUSY_PROPERTY_NAME, oldValue, busy);
- }
-
- protected void setCanceled(boolean canceled) {
- boolean oldValue = this.canceled;
- this.canceled = canceled;
- if (currentAction != null) {
- log.info("cancel action " + currentAction);
- // on a une action en cours, on l'annule
- currentAction.cancel(true);
- }
- // on annule aussi le model
- getModel().cancel();
- //on notifie les écouteur que le thread est annulé
- firePropertyChange(CANCELED_PROPERTY_NAME, oldValue, canceled);
- }
-
- protected void setWaiting(boolean waiting) {
-
- if (waiting && !canceled) {
- // locking thread
- try {
- lockThread();
- } catch (InterruptedException ex) {
- log.error(ex.getMessage(), ex);
- canceled = true;
- }
- }
-
- if (!waiting) {
- // release lock
- unlockThread();
- }
- }
-
- protected void lockThread() throws InterruptedException {
- synchronized (LOCK) {
- log.trace(this);
- // lock
- LOCK.wait();
- }
- }
-
- protected void unlockThread() {
- synchronized (LOCK) {
- log.trace(this);
- // unlock
- LOCK.notify();
- }
- }
-}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-03-13 22:00:34 UTC (rev 1265)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -19,7 +19,6 @@
public static final String PREVIOUS_STEP_PROPERTY_NAME = "previousStep";
public static final String NEXT_STEP_PROPERTY_NAME = "nextStep";
public static final String VALID_STEP_PROPERTY_NAME = "validStep";
-
/**
* le type d'une etape du model (doit etre une enumeration)
*/
@@ -134,7 +133,7 @@
// la propriete nextStep peut avoir changee
firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
}
-
+
public boolean validate(E s) {
return step != null;
}
@@ -160,6 +159,7 @@
pcs.removePropertyChangeListener(l);
}
}
+
protected Class<E> getStepClass() {
return stepClass;
}
@@ -190,7 +190,10 @@
pcs.firePropertyChange(propertyName, oldValue, newValue);
}
+ protected void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) {
+ pcs.fireIndexedPropertyChange(propertyName, index, oldValue, newValue);
+ }
+
protected void updateUniverse() {
-
}
}
Deleted: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModelWithOperations.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModelWithOperations.java 2009-03-13 22:00:34 UTC (rev 1265)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModelWithOperations.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -1,96 +0,0 @@
-package jaxx.runtime.swing.wizard;
-
-import java.util.EnumMap;
-import java.util.EnumSet;
-
-/**
- * Un modèle de wizard.
- *
- * @param <E> le type de l'énumération contenant les etapes.
- *
- * @param <O> le type de l'énumeration des opérations
- * @param <R> le type de l'énumération des résultats d'opération
- * @author tony
- * @since 1.3
- */
-public abstract class WizardModelWithOperations<E extends Enum<E>, O extends Enum<O>, R extends Enum<R>> extends WizardModel<E> {
-
- public static final String OPERATIONS_PROPERTY_NAME = "operations";
- public static final String OPERATION_RESULT_PROPERTY_NAME = "operationResult";
- /**
- * La liste des opérations à effectuer
- */
- protected EnumSet<O> operations;
- /**
- * Pour conserver les résultats des opérations
- */
- protected EnumMap<O, R> operationResults;
- protected Class<O> operationClass;
- protected Class<R> operationResultClass;
-
- public abstract void cancel();
-
- //protected abstract boolean isCancelResult(R operationResult);
- //protected abstract boolean isErrorResult(R operationResult);
-
- public WizardModelWithOperations(Class<E> stepClass, Class<O> operationClass, Class<R> operationResultClass, E... steps) {
- super(stepClass, steps);
- this.operationClass = operationClass;
- this.operationResultClass = operationResultClass;
- operationResults = new EnumMap<O, R>(operationClass);
- }
-
- public EnumSet<O> getOperations() {
- if (operations == null) {
- operations = EnumSet.noneOf(operationClass);
- }
- return operations;
- }
-
- public R getOperationResult(O operation) {
- return operationResults.get(operation);
- }
-
- public void setOperationResult(O operation, R operationResult) {
- R oldValue = getOperationResult(operation);
- operationResults.put(operation, operationResult);
- firePropertyChange(OPERATION_RESULT_PROPERTY_NAME, oldValue, operationResult);
- }
-
- @Override
- public void start() {
- super.start();
- firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
- }
-
- public WizardModelWithOperations<E, O, R> addOperation(O operation) {
- getOperations().add(operation);
- /*if (operation == SynchroOperation.EXPORT_DATA) {
- // pour exporter les données utilisateurs
- // les operations synchronisation de référentiel et validation
- // sont necessaires
- getOperations().add(SynchroOperation.SYNCHRONIZE_REFERENTIEL);
- getOperations().add(SynchroOperation.VALIDATION);
- }*/
- // on force la propagation de la nouvelle liste
- firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
-
- updateUniverse();
- validate();
- return this;
- }
-
- public void removeOperation(O operation) {
- getOperations().remove(operation);
- /*if (operation == SynchroOperation.SYNCHRONIZE_REFERENTIEL || operation == SynchroOperation.VALIDATION) {
- // pour exporter les données utilisateurs
- // les operations synchronisation de référentiel et validation
- // sont necessaires
- getOperations().remove(SynchroOperation.EXPORT_DATA);
- }*/
- // on force la propagation de la nouvelle liste
- firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
- updateUniverse();
- validate();
- }
-}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java 2009-03-13 22:00:34 UTC (rev 1265)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -6,7 +6,7 @@
* @author tony
* @since 1.3
*/
-public interface WizardOperation<Action extends WizardAbstractOperationAction> {
+public interface WizardOperation<Action extends WizardOperationAction> {
String name();
Copied: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (from rev 1265, jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationAction.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -0,0 +1,94 @@
+package jaxx.runtime.swing.wizard;
+
+import javax.swing.SwingWorker;
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author tony
+ * @param <E> le type d'étapes
+ * @param <O> le type d'opérations
+ * @param <M> le type de modèle
+ * @since 1.3
+ */
+public abstract class WizardOperationAction<E extends Enum<E>, O extends Enum<O>, M extends WizardOperationModel<E, O>> extends SwingWorker<WizardOperationState, String> {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(WizardOperationAction.class);
+ O operation;
+ WizardOperationState operationState;
+ Exception error;
+
+ public WizardOperationAction(O operation) {
+ super();
+ this.operation = operation;
+ }
+
+ public O getOperation() {
+ return operation;
+ }
+
+ public abstract void start(JAXXContext context);
+
+ public abstract void beforeAction(JAXXContext context, M model) throws Exception;
+
+ public abstract WizardOperationState doAction(M model) throws Exception;
+
+ public abstract WizardOperationState onError(M model, Exception e);
+
+ public abstract WizardOperationState onCancel(M model, Exception e);
+
+ public abstract void afterAction(M model, WizardOperationState result, Exception error);
+
+ protected abstract M getModel();
+
+ public WizardOperationState getOperationState() {
+ return operationState;
+ }
+
+ protected abstract JAXXContext getContext();
+
+ @Override
+ public String toString() {
+ return super.toString() + " < operation: " + operation + ", state: " + getState() + " >";
+ }
+
+ @Override
+ protected WizardOperationState doInBackground() throws Exception {
+ log.trace(this);
+ WizardOperationState result;
+ M model = getModel();
+ try {
+ beforeAction(getContext(), model);
+ result = doAction(model);
+ } catch (Exception e) {
+ error = e;
+ result = onError(model, e);
+ }
+ return result;
+ }
+
+ @Override
+ protected void done() {
+ log.trace(this);
+ WizardOperationState result = null;
+ try {
+ if (isCancelled()) {
+
+ result = onCancel(getModel(), error);
+ } else {
+ result = get();
+ }
+ } catch (Exception e) {
+ result = WizardOperationState.FAILED;
+ error = e;
+ // ne devrait jamais arrivé ?
+ log.error(e.getMessage(), e);
+ } finally {
+ // on enregistre le resultat de l'opération
+ this.operationState = result;
+ }
+ }
+}
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (from rev 1265, jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationActionThread.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -0,0 +1,235 @@
+package jaxx.runtime.swing.wizard;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.Date;
+import javax.swing.SwingWorker.StateValue;
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Thread qui réalise les opérations.
+ *
+ * Pour exécuter une nouvelle opération, on utilise la méthode
+ * {@link #launchOperation(SynchroActionWorker)}.
+ *
+ * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setWaiting(boolean)}
+ *
+ * @param <E> le type des etapes
+ * @param <O> le type des operations
+ * @param <M> le type de modele
+ * @param <A> le type d'action d'operation
+ *
+ * @author tony
+ * @since 1.3
+ */
+public abstract class WizardOperationActionThread<E extends Enum<E>, O extends Enum<O>, M extends WizardOperationModel<E, O>, A extends WizardOperationAction<E, O, M>> extends Thread implements PropertyChangeListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(WizardOperationActionThread.class);
+ /**
+ * l'état du thread si annulé
+ */
+ private boolean canceled;
+ /** suport of modification propagation */
+ protected PropertyChangeSupport pcs;
+ protected Class<M> modelClass;
+ protected A currentAction;
+ /**
+ * un lock pour permettre la suspension et la reprise du thread
+ * lors du mode interactif.
+ */
+ private final Object LOCK = new Object();
+
+ protected abstract M getModel();
+
+ protected abstract JAXXContext getContext();
+
+ public WizardOperationActionThread(Class<M> modelClass) throws IllegalArgumentException {
+ super(WizardOperationActionThread.class.getSimpleName() + " " + new Date());
+ this.modelClass = modelClass;
+ this.pcs = new PropertyChangeSupport(this);
+ }
+
+ public void cancel() {
+ if (currentAction != null) {
+ log.debug("cancel action " + currentAction);
+ // on a une action en cours, on l'annule
+ currentAction.cancel(true);
+ }
+ // on annule aussi le modele
+ getModel().cancel();
+ this.canceled = true;
+ // on rend la main au thread
+ setWaiting(false);
+ }
+
+ public void launchOperation(A action) {
+
+ if (currentAction != null) {
+ // on ne peut traiter qu'une seule opération à la fois
+ throw new IllegalStateException("can not add a operation when thread is busy, or has another operation to be done");
+ }
+ currentAction = action;
+ // on libere le thread pour qu'il execute l'opération
+ setWaiting(false);
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ log.info(evt.getPropertyName() + " <" + evt.getOldValue() + " - " + evt.getNewValue() + ">");
+ if ("state".equals(evt.getPropertyName())) {
+ //@SuppressWarnings("unchecked")
+ //A action = (A) evt.getSource();
+ StateValue state = (StateValue) evt.getNewValue();
+ if (state == StateValue.DONE) {
+ // on rend la main au thread pour qu'il attende une prochaine operation
+ //getModel().setOperationState(action.getOperation(), action.getOperationState());
+ setWaiting(false);
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ try {
+
+ // on vérifie que le context contient bien le modèle
+ if (getModel() == null) {
+ throw new NullPointerException("could not find model " + modelClass + " for " + this);
+ }
+
+ while (!canceled) {
+
+ if (canceled) {
+ // une annulation a été demandé
+ // donc même si une opération est demandée, on ne la traite
+ // pas
+ break;
+ }
+
+ // en attente qu'une opération
+ // le block est bloqué jusqu'à arrivée d'une opération
+ // ou une demande d'annulation
+ setWaiting(true);
+
+ // le thread a repris la main, donc plus en attente
+ log.trace("no more waiting " + this);
+
+ if (!canceled) {
+ // une opération a été demandée
+
+ // le thread écoute les modifications de l'action
+ currentAction.addPropertyChangeListener(this);
+
+ // l'opération passe en etant en cours
+ getModel().setOperationState(WizardOperationState.RUNNING);
+
+ // démarrage de l'opération dans un worker
+ currentAction.start(getContext());
+ // le thread est bloqué jusqu'à la fin de l'opération
+ // ou une demande d'annulation
+ setWaiting(true);
+
+ // le thread reprend la main des que l'operation
+ // est terminée ou a été annulée, on passera alors
+ // dans la méthode onPropertyChanged
+
+ getModel().setOperationState(currentAction.getOperationState());
+
+ // le thread n'écoute plus l'action car elle est terminée
+ // ou annulée
+ currentAction.removePropertyChangeListener(this);
+ // suppression de l'action
+ currentAction = null;
+ }
+
+ }
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ unlockThread();
+ log.trace(this + " will close...");
+ close();
+ }
+ }
+
+ /**
+ * La méthode pour nettoyer le thread, a la fermeture.
+ *
+ */
+ protected void close() {
+ // par defaut, on ne fait rien
+ log.trace(this);
+ }
+
+ // PropertyChanged support
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ protected void setWaiting(boolean waiting) {
+
+ if (waiting && !canceled) {
+ // locking thread
+ try {
+ lockThread();
+ } catch (InterruptedException ex) {
+ log.error(ex.getMessage(), ex);
+ canceled = true;
+ }
+ }
+
+ if (!waiting) {
+ // release lock
+ unlockThread();
+ }
+ }
+
+ protected void lockThread() throws InterruptedException {
+ synchronized (LOCK) {
+ log.trace(this);
+ // lock
+ LOCK.wait();
+ }
+ }
+
+ protected void unlockThread() {
+ synchronized (LOCK) {
+ log.trace(this);
+ // unlock
+ LOCK.notify();
+ }
+ }
+}
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (from rev 1265, jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModelWithOperations.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -0,0 +1,191 @@
+package jaxx.runtime.swing.wizard;
+
+import java.util.EnumMap;
+import java.util.EnumSet;
+
+/**
+ * Un modèle de wizard avec des opérations.
+ *
+ * @param <E> le type des étapes.
+ * @param <O> le type des opérations.
+ * @author tony
+ * @since 1.3
+ */
+public class WizardOperationModel<E extends Enum<E>, O extends Enum<O>> extends WizardModel<E> {
+
+ public static final String OPERATIONS_PROPERTY_NAME = "operations";
+ public static final String OPERATION_STATE_PROPERTY_NAME = "operationState";
+ public static final String MODEL_STATE_PROPERTY_NAME = "modelState";
+ public static final String WAS_STARTED_PROPERTY_NAME = "wasStarted";
+ /**
+ * le type d'une opération
+ */
+ protected Class<O> operationClass;
+ /**
+ * La liste des opérations à effectuer
+ */
+ protected EnumSet<O> operations;
+ /**
+ * Pour conserver les états des opérations
+ */
+ protected EnumMap<O, WizardOperationState> operationStates;
+ /**
+ * L'état générale du modèle
+ */
+ protected WizardOperationState modelState;
+ /**
+ * un drapeau pour savoir siune opération a été lancée
+ */
+ protected boolean wasStarted;
+
+ public WizardOperationModel(Class<E> stepClass, Class<O> operationClass, E... steps) {
+ super(stepClass, steps);
+ this.operationClass = operationClass;
+ this.operationStates = new EnumMap<O, WizardOperationState>(operationClass);
+ }
+
+ public EnumSet<O> getOperations() {
+ if (operations == null) {
+ operations = EnumSet.noneOf(operationClass);
+ }
+ return operations;
+ }
+
+ public WizardOperationState getModelState() {
+ return modelState;
+ }
+
+ public boolean isWasStarted() {
+ return wasStarted;
+ }
+
+ @SuppressWarnings("unchecked")
+ public O getOperation() {
+ return ((WizardOperationStep<O>) getStep()).getOperation();
+ }
+
+ public WizardOperationState getOperationState() {
+ O operation = getOperation();
+ return getOperationState(operation);
+ }
+
+ public WizardOperationState getOperationState(O operation) {
+ return operationStates.get(operation);
+ }
+
+ public void setOperationState(WizardOperationState operationState) {
+ O operation = getOperation();
+ setOperationState(operation, operationState);
+ }
+
+ public void setOperationState(O operation, WizardOperationState operationState) {
+ WizardOperationState oldValue = getOperationState(operation);
+ this.operationStates.put(operation, operationState);
+ firePropertyChange(OPERATION_STATE_PROPERTY_NAME, oldValue, operationState);
+ //fireIndexedPropertyChange(OPERATION_STATE_PROPERTY_NAME, getOperationIndex(operation), oldValue, operationStates);
+ updateModelState(operation, operationState);
+ validate();
+ }
+
+ @Override
+ public void start() {
+ super.start();
+ // le modèle n'est pas démarré
+ setModelState(WizardOperationState.PENDING);
+ firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ }
+
+ public void cancel() {
+ for (O op : operations) {
+ if (getOperationState(op) == WizardOperationState.PENDING) {
+ // on annule l'opération à venir
+ setOperationState(op, WizardOperationState.CANCELED);
+ }
+ }
+ }
+
+ public WizardOperationModel<E, O> addOperation(O operation) {
+ getOperations().add(operation);
+ // on force la propagation de la nouvelle liste
+ firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ // mis a jour de l'univers des etapes et operations
+ updateUniverse();
+ // validation
+ validate();
+ return this;
+ }
+
+ public void removeOperation(O operation) {
+ getOperations().remove(operation);
+ // on force la propagation de la nouvelle liste
+ firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ // mis a jour de l'univers des etapes et operations
+ updateUniverse();
+ // validation
+ validate();
+ }
+
+ protected void setModelState(WizardOperationState modelState) {
+ WizardOperationState oldValue = this.modelState;
+ this.modelState = modelState;
+ firePropertyChange(MODEL_STATE_PROPERTY_NAME, oldValue, modelState);
+ if (!wasStarted) {
+ if ((oldValue == null || oldValue == WizardOperationState.PENDING) && modelState == WizardOperationState.RUNNING) {
+ this.wasStarted = true;
+ firePropertyChange(WAS_STARTED_PROPERTY_NAME, false, true);
+ }
+ }
+ }
+
+ protected void updateModelState(O operation, WizardOperationState operationState) {
+
+ switch (operationState) {
+ case RUNNING:
+ //le model est occupé
+ setModelState(WizardOperationState.RUNNING);
+ break;
+ case FAILED:
+ //le model est en attente
+ setModelState(WizardOperationState.PENDING);
+ break;
+ case CANCELED:
+ //le model devient annulé
+ setModelState(WizardOperationState.CANCELED);
+ break;
+ case PENDING:
+ //le model est en attente
+ setModelState(WizardOperationState.PENDING);
+ break;
+ case NEED_FIX:
+ //le model est en attente
+ setModelState(WizardOperationState.PENDING);
+ break;
+ case SUCCESSED:
+ // on regarde si on peut passer le model a l'état success
+ boolean valid = true;
+ for (O o : operations) {
+ if (getOperationState(o) != WizardOperationState.SUCCESSED) {
+ valid = false;
+ break;
+ }
+ }
+ if (valid) {
+ setModelState(WizardOperationState.SUCCESSED);
+ } else {
+ setModelState(WizardOperationState.PENDING);
+ }
+ break;
+ }
+ }
+
+ protected int getOperationIndex(O operation) {
+ int index = 0;
+ for (O o : operations) {
+ if (operation == o) {
+ return index;
+ }
+ index++;
+ }
+ return -1;
+ }
+}
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationModel.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationState.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -0,0 +1,32 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ * Pour caractériser l'état d'une opération.
+ */
+public enum WizardOperationState {
+
+ /**
+ * quand l'opération n'a pas encore été réalisée
+ */
+ PENDING,
+ /**
+ * quand l'opération est en cours
+ */
+ RUNNING,
+ /**
+ * quand l'opération est annulé en cours d'exécution
+ */
+ CANCELED,
+ /**
+ * quand une erreur s'est produite pendant l'exécution
+ */
+ FAILED,
+ /**
+ * quand l'exécution s'est terminée mais requière des corrections
+ */
+ NEED_FIX,
+ /**
+ * quand l'exécution s'est terminée et ne requière pas de correction
+ */
+ SUCCESSED
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperationStep.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -0,0 +1,20 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ *
+ * @param <Operation>
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardOperationStep<Operation extends Enum<Operation>> {
+
+ String name();
+
+ int ordinal();
+
+ String getLabel();
+
+ String getDescription();
+
+ Operation getOperation();
+}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-03-13 22:00:34 UTC (rev 1265)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -18,8 +18,6 @@
M getModel();
- void init();
-
void start();
JTabbedPane getTabs();
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-03-13 22:00:34 UTC (rev 1265)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-03-14 19:24:14 UTC (rev 1266)
@@ -20,18 +20,14 @@
protected UI ui;
- protected abstract void doAction(UI ui);
-
@SuppressWarnings("unchecked")
public WizardUILancher(JAXXContext context, JFrame mainUI, Class<UI> uiClass, Class<M> modelClass) {
super();
try {
+ // instanciate ui parent context
JAXXInitialContext uiContext = new JAXXInitialContext();
- // instanciate ui
- // parent context
uiContext.add(mainUI == null ? context : mainUI);
- // parent context
- // model
+ // parent context model
uiContext.add(modelClass.newInstance());
// apply action
uiContext.add("apply", new Runnable() {
@@ -51,7 +47,7 @@
});
// instanciate ui
- ui = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext});
+ ui = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext}, new Class[]{JFrame.class, JAXXContext.class});
} catch (Exception ex) {
throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
@@ -59,20 +55,28 @@
}
public void start() {
- init(ui);
- //ui.start();
+ try {
+ init(ui);
+ ui.start();
+ } finally {
+ dispose();
+ }
}
+ public void dispose() {
+ ui = null;
+ }
+
protected void init(UI ui) {
}
- protected void afterInit(UI ui) {
+ protected void doAction(UI ui) {
}
protected void doCancel(UI ui) {
}
- public <T> T getContextValue(Class<T> clazz, String name) {
+ protected <T> T getContextValue(Class<T> clazz, String name) {
if (ui == null) {
throw new NullPointerException("ui can not be null");
}
@@ -83,11 +87,7 @@
return ((JAXXObject) ui).getContextValue(clazz, name);
}
- public <T> T getContextValue(Class<T> clazz) {
+ protected <T> T getContextValue(Class<T> clazz) {
return getContextValue(clazz, null);
}
-
- public void dispose() {
- ui = null;
- }
}
1
0
r1265 - in jaxx/trunk: . jaxx-compiler-api jaxx-compiler-api/src/main/java/jaxx/compiler jaxx-compiler-api/src/main/java/jaxx/tags jaxx-example jaxx-example/src/main/java/jaxx/demo jaxx-example/src/main/resources/i18n jaxx-runtime-swing/src/main/java/jaxx/runtime jaxx-runtime-swing/src/main/java/jaxx/runtime/swing jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard
by tchemit@users.labs.libre-entreprise.org March 13, 2009
by tchemit@users.labs.libre-entreprise.org March 13, 2009
March 13, 2009
Author: tchemit
Date: 2009-03-13 22:00:34 +0000 (Fri, 13 Mar 2009)
New Revision: 1265
Added:
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/EmptyDemo.jaxx
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationAction.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationActionThread.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModelWithOperations.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
Removed:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java
Modified:
jaxx/trunk/changelog.txt
jaxx/trunk/jaxx-compiler-api/changelog.txt
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultObjectHandler.java
jaxx/trunk/jaxx-example/changelog.txt
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
jaxx/trunk/pom.xml
Log:
- improve demo
- can now use geneticType on javaBean object
- add an extra method $afterCompleteSetup method to be included if find in script at last statement of $completeSetup method
-use i18n 0.10
-introduce Wizard package (must do javadoc)
- add iterator method util on JTabbedPane
Modified: jaxx/trunk/changelog.txt
===================================================================
--- jaxx/trunk/changelog.txt 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/changelog.txt 2009-03-13 22:00:34 UTC (rev 1265)
@@ -1,3 +1,5 @@
+1.3
+ * 20090313 [chemit] - use i18n 0.10
1.2 ??? 2009????
* 20090223 [chemit] - move sources from jaxx-util to jaxx-swing-action module
- delete jaxx-util module
Modified: jaxx/trunk/jaxx-compiler-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-13 22:00:34 UTC (rev 1265)
@@ -1,4 +1,7 @@
1.3 ??? 200902??
+ * 20090313 [chemit] - can now use geneticType on javaBean object
+ - add an extra method $afterCompleteSetup method to be included if find in script at last statement of $completeSetup method
+
* 20090309 [chemit] - must get the goal property from the event id to make possible inheritance
- improve override properties create method : when same type do not re-instanciate it
* 20090229 [chemit] - fix bug in ClassDescriptorLoader when searching for an arrayof primitive type
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -575,26 +575,27 @@
public void registerDataBinding(String src, String property, String assignment, JAXXCompiler compiler) throws CompilerException {
compiler.registerDataBinding(src, getId() + "." + property, assignment);
}
-
- /** @return the array of generic types of the compiled object, or a empty array if none defined */
- public ClassDescriptor[] getGenericTypes() {
- if (genericTypes == null) {
- return new ClassDescriptor[0];
+ public String getGenericTypes() {
+ if (getGenericTypesLength() == 0) {
+ // not using it
+ return "";
}
- try {
- ClassDescriptor[] result = new ClassDescriptor[genericTypes.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = ClassDescriptorLoader.getClassDescriptor(genericTypes[i], getObjectClass().getClassLoader());
- }
- return result;
+ String result = "";
+ for (int i = 0, j = getGenericTypesLength(); i < j; i++) {
+ result += ", " + genericTypes[i];
}
- catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
+ return "< " + result.substring(1) + " >";
}
public void setGenericTypes(String[] genericTypes) {
- this.genericTypes = genericTypes;
+ if (genericTypes == null) {
+ this.genericTypes = null;
+ return;
+ }
+ this.genericTypes = new String[genericTypes.length];
+ for (int i = 0, j = genericTypes.length; i < j; i++) {
+ this.genericTypes[i] = genericTypes[i].trim();
+ }
}
public boolean isJavaBean() {
@@ -647,4 +648,8 @@
additionCode = buffer.append(additionCode);
}
+
+ public int getGenericTypesLength() {
+ return genericTypes == null ? 0 : genericTypes.length;
+ }
}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -887,6 +887,15 @@
return scriptMethods.toArray(new MethodDescriptor[scriptMethods.size()]);
}
+ public MethodDescriptor getScriptMethod(String methodName) {
+ for (MethodDescriptor m :symbolTable.getScriptMethods()) {
+ if (methodName.equals(m.getName())) {
+ return m;
+ }
+ }
+ return null;
+ }
+
public boolean isFailed() {
return failed;
}
@@ -1399,16 +1408,8 @@
if (clazz.isArray()) {
String canonicalName = getCanonicalName(clazz.getComponentType());
if (canonicalName != null) {
- if (compiled.getGenericTypes().length > 0) {
- canonicalName += "<";
- for (int i = 0; i < compiled.getGenericTypes().length; i++) {
- ClassDescriptor classDescriptor = compiled.getGenericTypes()[i];
- if (i > 0) {
- canonicalName += " ,";
- }
- canonicalName += classDescriptor.getName();
- }
- canonicalName += ">";
+ if (compiled.getGenericTypesLength() > 0) {
+ canonicalName += compiled.getGenericTypes();
}
return canonicalName + "[]";
}
@@ -1416,16 +1417,8 @@
}
String canonicalName = clazz.getName().replace('$', '.');
- if (compiled.getGenericTypes().length > 0) {
- canonicalName += "<";
- for (int i = 0; i < compiled.getGenericTypes().length; i++) {
- ClassDescriptor classDescriptor = compiled.getGenericTypes()[i];
- if (i > 0) {
- canonicalName += " ,";
- }
- canonicalName += classDescriptor.getName();
- }
- canonicalName += ">";
+ if (compiled.getGenericTypesLength() > 0) {
+ canonicalName += compiled.getGenericTypes();
}
return canonicalName;
}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -536,7 +536,11 @@
code.append(compiler.getLateInitializer());
code.append(JAXXCompiler.getLineSeparator());
}
-
+ //TC-20090313 add an extra method after complete setup
+ MethodDescriptor method = compiler.getScriptMethod("$afterCompleteSetup");
+ if (method!=null) {
+ code.append("$afterCompleteSetup();").append(JAXXCompiler.getLineSeparator());
+ }
return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$completeSetup", code.toString());
}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultObjectHandler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -539,7 +539,12 @@
setDefaults(object, tag, compiler);
setAttributes(object, tag, compiler);
-
+ if (object.getGenericTypesLength() > 0 && !(object == compiler.getRootObject() || object.isJavaBean())) {
+ // can ony be apply to root object or javaBean object
+ compiler.reportWarning("'genericType' attribute can only be found on root, or a javaBean object tag but was found on tag " + tag);
+ object.setGenericTypes(null);
+ return;
+ }
compileChildrenSecondPass(tag, compiler);
}
@@ -625,8 +630,9 @@
String name = attribute.getName();
String value = attribute.getValue();
if (name.equals("javaBean")) {
+ //compiler.preprocessScript(value);
continue;
- }
+ }
if (name.equals("constraints") || isEventHandlerName(name)) {
compiler.preprocessScript(value); // adds dependencies as a side effect
} else if (name.equals("constructorParams")) {
@@ -695,12 +701,12 @@
}
if (name.equals("genericType")) {
- if (object != compiler.getRootObject()) {
- // can ony be apply to root object
- compiler.reportError("'genericType' attribute can only be found on root tag but was found on tag " + tag);
- return;
+ //TC-20090313 check after all atributes been processed
+ if (object == compiler.getRootObject() ) {
+ compiler.setGenericType(value);
+ } else {
+ object.setGenericTypes(value.split(","));
}
- compiler.setGenericType(value);
continue;
}
@@ -1041,9 +1047,9 @@
*/
protected int constantValue(String key, String value) {
JAXXBeanInfo JAXXBeanInfo = getJAXXBeanInfo();
- JAXXPropertyDescriptor[] properties = JAXXBeanInfo.getJAXXPropertyDescriptors();
+ JAXXPropertyDescriptor[] props = JAXXBeanInfo.getJAXXPropertyDescriptors();
String lowercaseValue = value.toLowerCase();
- for (JAXXPropertyDescriptor property : properties) {
+ for (JAXXPropertyDescriptor property : props) {
if (property.getName().equals(key)) {
Object[] values = (Object[]) property.getValue("enumerationValues");
if (values != null) {
Modified: jaxx/trunk/jaxx-example/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-example/changelog.txt 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-example/changelog.txt 2009-03-13 22:00:34 UTC (rev 1265)
@@ -1,3 +1,6 @@
+1.3
+ * 20090313 [chemit] - improve demo
+
1.1 chemit 20090220
* 20090202 [chemit] - no more scope attribute on validator
- fix I18NTableCellRenderer (must have tip inside)
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-03-13 22:00:34 UTC (rev 1265)
@@ -14,13 +14,12 @@
<script><![CDATA[
import jaxx.runtime.SwingUtil;
-public void initLayer() {
+void $afterCompleteSetup() {
for (JComponent boxed : SwingUtil.getLayeredComponents(this)) {
jaxx.runtime.swing.BlockingLayerUI ui = layerUI.clone();
if ( boxed == c) {
- ui.setUseIcon(false);
ui.setBlock(true);
- }
+ }
SwingUtil.getLayer(boxed).setUI(ui);
//ui.setDirty(true);
}
@@ -31,12 +30,8 @@
jaxx.runtime.swing.BlockingLayerUI ui = (jaxx.runtime.swing.BlockingLayerUI)SwingUtil.getLayer(boxed).getUI();
if ( boxed == c) {
ui.setBlock(active);
- } else {
- ui.setUseIcon(active);
- }
- //ui.setBlock(active && boxed == c);
- //ui.setUseIcon(active && boxed != c);
- //ui.setDirty(true);
+ }
+ ui.setUseIcon(active);
}
}
Added: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/EmptyDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/EmptyDemo.jaxx (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/EmptyDemo.jaxx 2009-03-13 22:00:34 UTC (rev 1265)
@@ -0,0 +1,5 @@
+<DemoPanel>
+<JPanel id='demoPanel'>
+ <JLabel text='emptyNode'/>
+</JPanel>
+</DemoPanel>
\ No newline at end of file
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-03-13 22:00:34 UTC (rev 1265)
@@ -1,21 +1,26 @@
<Application title="JAXX Demo" width='1024' height='800' defaultCloseOperation='exit_on_close'>
<script><![CDATA[
-protected void changePanel() {
- Object value = list.getSelectionValue();
- if (value instanceof DemoPanel) {
- cardLayout.show(preview, ((DemoPanel) value).getLabel());
- }
+
+org.codelutin.i18n.I18n.init();
+
+void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ int i=0;
+ while( i < list.getRowCount()) {
+ list.expandRow(i++);
+ }
+ }
+ });
}
-// init i18n
-org.codelutin.i18n.I18n.init();
-boxedDecoratorDemo.initLayer();
-//boxedDecoratorDemo.setLayer(true);
]]></script>
<JSplitPane>
<!--JSplitPane dividerLocation='200'-->
<JScrollPane>
- <JTree id='list' showsRootHandles='true' onValueChanged='changePanel()'
+ <JTree id='list' showsRootHandles='true'
+ onValueChanged='cardLayout.show(preview, list.getSelectionValue() instanceof DemoPanel ? ((DemoPanel) list.getSelectionValue()).getLabel() : emptyDemo.getLabel())'
cellRenderer='{new javax.swing.tree.DefaultTreeCellRenderer() {
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if (value instanceof DemoPanel)
@@ -82,6 +87,7 @@
<java.awt.CardLayout id='cardLayout'/>
<JPanel id='preview' layout='{cardLayout}'>
+ <EmptyDemo id='emptyDemo' constraints='emptyDemo.getLabel()'/>
<JButtonDemo id='buttonDemo' constraints='buttonDemo.getLabel()'/>
<JCheckBoxDemo id='checkBoxDemo' constraints='checkBoxDemo.getLabel()'/>
<JCheckBoxMenuItemDemo id='checkBoxMenuItemDemo' constraints='checkBoxMenuItemDemo.getLabel()'/>
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-03-13 22:00:34 UTC (rev 1265)
@@ -88,6 +88,7 @@
button\ A=
button\ B=
button\ C=
+button\ C\ (full\ block)=
button\ with\ layer=
cancel=
close=
@@ -96,6 +97,7 @@
edit=
edit2=
edit3=
+emptyNode=< empty node >
no\ layer=
valid=
validator.field=Champ
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-03-13 22:00:34 UTC (rev 1265)
@@ -88,6 +88,7 @@
button\ A=
button\ B=
button\ C=
+button\ C\ (full\ block)=
button\ with\ layer=
cancel=
close=
@@ -96,6 +97,7 @@
edit=
edit2=
edit3=
+emptyNode=< empty node >
no\ layer=
valid=
validator.field=Champ
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map;
@@ -31,6 +32,7 @@
import java.util.Properties;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
+import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import jaxx.runtime.swing.I18nTableCellRenderer;
@@ -357,4 +359,101 @@
}
}
}
+
+ /**
+ * Iterate the components of a {@link JTabbedPane} in natural order.
+ *
+ * Says using method {@link JTabbedPane#getComponent(int)}
+ * @param tabs the
+ * @return
+ * @since 1.4
+ */
+ public static TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs) {
+ return new TabbedPaneIterator<Component>(false, tabs) {
+
+ @Override
+ protected Component get(int index, Component comp) {
+ return comp;
+ }
+ };
+ }
+
+ /**
+ * A simple iterator on a {@link JTabbedPane}.
+ *
+ * Implements the method {@link #get(int, java.awt.Component)} to obtain
+ * the data required given the component (or index).
+ *
+ * You can also inverse the order by usin the method {@link #reverse()}.
+ *
+ * Note: After the use of the method {@link #reverse()} the iterator returns
+ * to the first element.
+ *
+ * @param <O> the type of return elements.
+ * @since 1.4
+ */
+ public static abstract class TabbedPaneIterator<O> implements Iterator<O> {
+
+ final JTabbedPane tabs;
+ boolean reverse;
+ int index;
+ int increment;
+
+ protected abstract O get(int index, Component comp);
+
+ public TabbedPaneIterator(boolean reverse, JTabbedPane tabs) {
+ this.tabs = tabs;
+ setReverse(reverse);
+ }
+
+ public void reset() {
+ setReverse(reverse);
+ }
+
+ public TabbedPaneIterator<O> reverse() {
+ setReverse(!reverse);
+ return this;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return reverse ? index > 0 : index < tabs.getTabCount();
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ @Override
+ public O next() {
+ if (!hasNext()) {
+ throw new IllegalStateException("no next objet! for " + this);
+ }
+ Component next = tabs.getComponent(index);
+ O result = get(index, next);
+ index += increment;
+ return result;
+ }
+
+ @Override
+ public void remove() {
+ throw new IllegalStateException("not implemented for " + this);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "< reverse:" + reverse + ", index:" + index + ", size:" + tabs.getTabCount() + " >";
+ }
+
+ protected void setReverse(boolean reverse) {
+ if (reverse) {
+ index = tabs.getTabCount() - 1;
+ increment = -1;
+ } else {
+ index = 0;
+ increment = 1;
+ }
+ this.reverse = reverse;
+ }
+ }
}
Deleted: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -1,191 +0,0 @@
-package jaxx.runtime.swing;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.List;
-
-/**
- * Un modèle de wizard.
- *
- * @param <E> le type de l'énumération contenant les etapes.
- *
- * @author tony
- * @since 1.3
- */
-public class WizardModel<E extends Enum<E>> {
-
- public static final String STEPS_PROPERTY_NAME = "steps";
- public static final String STEP_PROPERTY_NAME = "step";
- public static final String PREVIOUS_STEP_PROPERTY_NAME = "previousStep";
- public static final String NEXT_STEP_PROPERTY_NAME = "nextStep";
- public static final String VALID_STEP_PROPERTY_NAME = "validStep";
- /**
- * le type d'une etape du model (doit etre une enumeration)
- */
- protected final Class<E> stepClass;
- /**
- * Toutes les étapes à passer
- */
- protected List<E> steps;
- /**
- * L'étape courante
- */
- protected E step;
- /**
- * drapeau pour valider l'état de l'étape courante
- */
- protected boolean validStep;
- /**
- * pour propager les changements dans le modèle vers l'ui
- */
- protected PropertyChangeSupport pcs;
-
- public WizardModel(Class<E> stepClass, E... steps) {
- this.stepClass = stepClass;
- this.pcs = new PropertyChangeSupport(this);
- this.steps = new java.util.ArrayList<E>();
- if (steps.length > 0) {
- setSteps(steps);
- }
- }
-
- public void start() {
- if (steps.isEmpty()) {
- throw new IllegalStateException("can not start, no step found");
- }
- step = null;
- E startStep = steps.get(0);
- setStep(startStep);
- }
-
- public void gotoNextStep() {
- E nextStep = getNextStep();
- if (nextStep == null) {
- throw new IllegalStateException("no next step to go");
- }
- setStep(nextStep);
- }
-
- public void gotoPreviousStep() {
- E previousStep = getPreviousStep();
- if (previousStep == null) {
- throw new IllegalStateException("no previous step to go");
- }
- setStep(previousStep);
- }
-
- public void gotoStep(E e) {
- if (e == null) {
- throw new NullPointerException("step can not be null");
- }
- if (!steps.contains(e)) {
- throw new IllegalStateException("step " + e + " is not in universe of steps (" + steps + ")");
- }
- setStep(e);
- }
-
- public E getStep() {
- return step;
- }
-
- public int getStepIndex(E s) {
- int index = steps.indexOf(s);
- return index;
- }
-
- public boolean isValidStep() {
- return validStep;
- }
-
- public E getPreviousStep() {
- int index = getStepIndex(step);
- if (index < 1) {
- // si pas de step ou sur premier step
- return null;
- }
- return steps.get(index - 1);
- }
-
- public E getNextStep() {
- int index = getStepIndex(step);
- if (index == -1 || index == steps.size() - 1) {
- // si pas de step positionne ou dernier etape
- return null;
- }
- return steps.get(index + 1);
- }
-
- public List<E> getSteps() {
- return steps;
- }
-
- /**
- * Change l'univers des etapes.
- *
- * Note: on presume ici que l'étape courante est toujours la meme.
- *
- * @param steps le nouvel univers des etapes
- */
- public void setSteps(E... steps) {
- List<E> oldValue = this.steps;
- this.steps = java.util.Collections.unmodifiableList(java.util.Arrays.asList(steps));
- firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
- // la propriete nextStep peut avoir changee
- firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
- }
-
- public boolean validate(E s) {
- return step != null;
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListeners() {
- for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
- pcs.removePropertyChangeListener(l);
- }
- }
- protected Class<E> getStepClass() {
- return stepClass;
- }
-
- protected void setStep(E step) {
- E oldValue = this.step;
- this.step = step;
- firePropertyChange(STEP_PROPERTY_NAME, oldValue, step);
- // la propriete nextStep peut avoir changee
- firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
- // la propriete previousStep peut avoir changee
- firePropertyChange(PREVIOUS_STEP_PROPERTY_NAME, null, getPreviousStep());
- validate();
- }
-
- protected void validate() {
- if (step == null) {
- // pas de validation quand aucune etape n'est sélectionnée
- return;
- }
- boolean validate = validate(step);
- this.validStep = validate;
- // toujours forcer la propagation
- firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep);
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- pcs.firePropertyChange(propertyName, oldValue, newValue);
- }
-}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationAction.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationAction.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationAction.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -0,0 +1,94 @@
+package jaxx.runtime.swing.wizard;
+
+import javax.swing.SwingWorker;
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author tony
+ * @param <E>
+ * @param <O>
+ * @param <R>
+ * @param <M>
+ * @since 1.3
+ */
+public abstract class WizardAbstractOperationAction<E extends Enum<E>,O extends Enum<O>, R extends Enum<R>, M extends WizardModelWithOperations<E,O,R>> extends SwingWorker<R, String> {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(WizardAbstractOperationAction.class);
+ O operation;
+ Exception error;
+
+ public WizardAbstractOperationAction(O operation) {
+ super();
+ this.operation = operation;
+ }
+
+ public O getOperation() {
+ return operation;
+ }
+
+ public abstract void start(JAXXContext context);
+
+ public abstract void beforeAction(JAXXContext context, M model) throws Exception;
+
+ public abstract R doAction(M model) throws Exception;
+
+ public abstract R onError(M model, Exception e);
+
+ public abstract R onCancel(M model, Exception e);
+
+ public abstract void afterAction(M model, R result, Exception error);
+
+ protected abstract M getModel();
+
+ protected abstract JAXXContext getContext();
+
+ @Override
+ public String toString() {
+ return super.toString() + " < operation: " + operation + ", state: " + getState() + " >";
+ }
+
+ @Override
+ protected R doInBackground() throws Exception {
+ R result;
+ M model = getModel();
+ try {
+ log.info(this);
+ beforeAction(getContext(), model);
+ result = doAction(model);
+ } catch (Exception e) {
+ error = e;
+ result = onError(model, e);
+ }
+ return result;
+ }
+
+ @Override
+ protected void done() {
+ R result = null;
+ log.info(this);
+ M model = getModel();
+ try {
+ if (isCancelled()) {
+
+ result = onCancel(model, error);
+ } else {
+ result = get();
+ }
+ } catch (Exception e) {
+ // ne devrait jamais arrivé ?
+ log.error(e.getMessage(), e);
+ throw new RuntimeException(e);
+ } finally {
+ // on enregistre le resultat de l'opération
+
+ model.setOperationResult(operation, result);
+
+ // on notifie le resultat de l'action
+ firePropertyChange(WizardModelWithOperations.OPERATION_RESULT_PROPERTY_NAME, null, result);
+ }
+ }
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationActionThread.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationActionThread.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardAbstractOperationActionThread.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -0,0 +1,265 @@
+package jaxx.runtime.swing.wizard;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.Date;
+import jaxx.runtime.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Thread qui réalise les opérations.
+ *
+ * Pour exécuter une nouvelle opération, on utilise la méthode
+ * {@link #launchOperation(SynchroActionWorker)}.
+ *
+ * Le thread possède 2 états internes :
+ *
+ * - busy lorsqu'il exécute une opération
+ *
+ * - canceled lorqu'une annulation a été demandée via la méthode {@link #setCanceled(boolean)}
+ *
+ * Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setwaiting(boolean)}
+ * @param <E> le type des etapes
+ * @param <O> le type des operations
+ * @param <R> le type des resultats d'operation
+ * @param <M> le type de modele
+ * @param <A> le type d'action d'operation
+ *
+ * @author tony
+ * @since 1.3
+ */
+public abstract class WizardAbstractOperationActionThread<E extends Enum<E>, O extends Enum<O>, R extends Enum<R>, M extends WizardModelWithOperations<E, O, R>, A extends WizardAbstractOperationAction<E, O, R, M>> extends Thread implements PropertyChangeListener {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ private static final Log log = LogFactory.getLog(WizardAbstractOperationActionThread.class);
+ public static final String BUSY_PROPERTY_NAME = "busy";
+ public static final String CANCELED_PROPERTY_NAME = "canceled";
+ /**
+ * l'état du thread pendant les étapes non interactives
+ */
+ private boolean busy;
+ /**
+ * l'état du thread si annulé
+ */
+ private boolean canceled;
+ /** suport of modification propagation */
+ protected PropertyChangeSupport pcs;
+ /** le context applicatif */
+ protected JAXXContext cotext;
+ protected Class<M> modelClass;
+ protected A currentAction;
+ /**
+ * un lock pour permettre la suspension et la reprise du thread
+ * lors du mode interactif.
+ */
+ private final Object LOCK = new Object();
+
+ protected abstract M getModel();
+ protected abstract JAXXContext getContext();
+
+ public WizardAbstractOperationActionThread(Class<M> modelClass) throws IllegalArgumentException {
+ super(WizardAbstractOperationActionThread.class.getSimpleName() + " " + new Date());
+ this.modelClass = modelClass;
+ this.pcs = new PropertyChangeSupport(this);
+ }
+
+ public boolean isBusy() {
+ return busy;
+ }
+
+ public boolean isCanceled() {
+ return canceled;
+ }
+
+ public void cancel() {
+ setCanceled(true);
+ //currentAction = null;
+ setBusy(false);
+ setWaiting(false);
+ }
+
+ public void launchOperation(A action) {
+
+ if (busy || currentAction != null) {
+ // on ne peut traiter qu'une seule opération à la fois
+ throw new IllegalStateException("can not add a operation when thread is busy, or has another operation to be done");
+ }
+ currentAction = action;
+ // on libere le thread pour qu'il execute l'opération
+ setWaiting(false);
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (WizardModelWithOperations.OPERATION_RESULT_PROPERTY_NAME.equals(evt.getPropertyName())) {
+ // on rend la main au thread pour qu'il attende une prochaine operation
+ setWaiting(false);
+ }
+ }
+
+ @Override
+ public void run() {
+ try {
+
+ // on vérifie que le context contient bien le modèle
+ if (getModel()==null) {
+ throw new NullPointerException("could not find model "+modelClass+" for "+this);
+ }
+
+ while (!canceled) {
+
+ if (canceled) {
+ // une annulation a été demandé
+ // donc même si une opération est demandée, on ne la traite
+ // pas
+ break;
+ }
+
+ // en attente qu'une opération
+ // le block est bloqué jusqu'à arrivée d'une opération
+ // ou une demande d'annulation
+ setWaiting(true);
+
+ // le thread a repris la main, donc plus en attente
+ log.trace("no more waiting " + this);
+
+ if (!canceled) {
+ // une opération a été demandée
+
+ // le thread passe en éta occupé
+ setBusy(true);
+ // le thread écoute les modifications de l'action
+ currentAction.addPropertyChangeListener(this);
+ // démarrage de l'opération
+ currentAction.start(getContext());
+ // le thread est bloqué jusqu'à la fin de l'opération
+ // ou une demande d'annulation
+ setWaiting(true);
+ // la main a ete rendue, le thread n'est plus actif
+ setBusy(false);
+ }
+
+ // le thread reprend la main des que l'operation
+ // est terminée ou a été annulée, on passera alors
+ // dans la méthode onPropertyChanged
+ if (currentAction != null) {
+ // le thread n'écoute plus l'action car elle est terminée
+ // ou annulée
+ currentAction.removePropertyChangeListener(this);
+ // suppression de l'action
+ currentAction = null;
+ }
+
+ }
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (busy) {
+ setBusy(false);
+ setWaiting(false);
+ }
+
+ log.info(this + " will close...");
+ close();
+ }
+ }
+
+ /**
+ * La méthode pour nettoyer le thread, a la fermeture.
+ *
+ */
+ protected void close() {
+ // par defaut, on ne fait rien
+ log.info(this);
+ }
+
+ // PropertyChanged support
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ protected void setBusy(boolean busy) {
+ boolean oldValue = this.busy;
+ this.busy = busy;
+ firePropertyChange(BUSY_PROPERTY_NAME, oldValue, busy);
+ }
+
+ protected void setCanceled(boolean canceled) {
+ boolean oldValue = this.canceled;
+ this.canceled = canceled;
+ if (currentAction != null) {
+ log.info("cancel action " + currentAction);
+ // on a une action en cours, on l'annule
+ currentAction.cancel(true);
+ }
+ // on annule aussi le model
+ getModel().cancel();
+ //on notifie les écouteur que le thread est annulé
+ firePropertyChange(CANCELED_PROPERTY_NAME, oldValue, canceled);
+ }
+
+ protected void setWaiting(boolean waiting) {
+
+ if (waiting && !canceled) {
+ // locking thread
+ try {
+ lockThread();
+ } catch (InterruptedException ex) {
+ log.error(ex.getMessage(), ex);
+ canceled = true;
+ }
+ }
+
+ if (!waiting) {
+ // release lock
+ unlockThread();
+ }
+ }
+
+ protected void lockThread() throws InterruptedException {
+ synchronized (LOCK) {
+ log.trace(this);
+ // lock
+ LOCK.wait();
+ }
+ }
+
+ protected void unlockThread() {
+ synchronized (LOCK) {
+ log.trace(this);
+ // unlock
+ LOCK.notify();
+ }
+ }
+}
Copied: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (from rev 1258, jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java)
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -0,0 +1,196 @@
+package jaxx.runtime.swing.wizard;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.List;
+
+/**
+ * Un modèle de wizard.
+ *
+ * @param <E> le type de l'énumération contenant les etapes.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public class WizardModel<E extends Enum<E>> {
+
+ public static final String STEPS_PROPERTY_NAME = "steps";
+ public static final String STEP_PROPERTY_NAME = "step";
+ public static final String PREVIOUS_STEP_PROPERTY_NAME = "previousStep";
+ public static final String NEXT_STEP_PROPERTY_NAME = "nextStep";
+ public static final String VALID_STEP_PROPERTY_NAME = "validStep";
+
+ /**
+ * le type d'une etape du model (doit etre une enumeration)
+ */
+ protected final Class<E> stepClass;
+ /**
+ * Toutes les étapes à passer
+ */
+ protected List<E> steps;
+ /**
+ * L'étape courante
+ */
+ protected E step;
+ /**
+ * drapeau pour valider l'état de l'étape courante
+ */
+ protected boolean validStep;
+ /**
+ * pour propager les changements dans le modèle vers l'ui
+ */
+ protected PropertyChangeSupport pcs;
+
+ public WizardModel(Class<E> stepClass, E... steps) {
+ this.stepClass = stepClass;
+ this.pcs = new PropertyChangeSupport(this);
+ this.steps = new java.util.ArrayList<E>();
+ if (steps.length > 0) {
+ setSteps(steps);
+ }
+ }
+
+ public void start() {
+ if (steps.isEmpty()) {
+ throw new IllegalStateException("can not start, no step found");
+ }
+ step = null;
+ E startStep = steps.get(0);
+ setStep(startStep);
+ }
+
+ public void gotoNextStep() {
+ E nextStep = getNextStep();
+ if (nextStep == null) {
+ throw new IllegalStateException("no next step to go");
+ }
+ setStep(nextStep);
+ }
+
+ public void gotoPreviousStep() {
+ E previousStep = getPreviousStep();
+ if (previousStep == null) {
+ throw new IllegalStateException("no previous step to go");
+ }
+ setStep(previousStep);
+ }
+
+ public void gotoStep(E e) {
+ if (e == null) {
+ throw new NullPointerException("step can not be null");
+ }
+ if (!steps.contains(e)) {
+ throw new IllegalStateException("step " + e + " is not in universe of steps (" + steps + ")");
+ }
+ setStep(e);
+ }
+
+ public E getStep() {
+ return step;
+ }
+
+ public int getStepIndex(E s) {
+ int index = steps.indexOf(s);
+ return index;
+ }
+
+ public boolean isValidStep() {
+ return validStep;
+ }
+
+ public E getPreviousStep() {
+ int index = getStepIndex(step);
+ if (index < 1) {
+ // si pas de step ou sur premier step
+ return null;
+ }
+ return steps.get(index - 1);
+ }
+
+ public E getNextStep() {
+ int index = getStepIndex(step);
+ if (index == -1 || index == steps.size() - 1) {
+ // si pas de step positionne ou dernier etape
+ return null;
+ }
+ return steps.get(index + 1);
+ }
+
+ public List<E> getSteps() {
+ return steps;
+ }
+
+ /**
+ * Change l'univers des etapes.
+ *
+ * Note: on presume ici que l'étape courante est toujours la meme.
+ *
+ * @param steps le nouvel univers des etapes
+ */
+ public void setSteps(E... steps) {
+ List<E> oldValue = this.steps;
+ this.steps = java.util.Collections.unmodifiableList(java.util.Arrays.asList(steps));
+ firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
+ // la propriete nextStep peut avoir changee
+ firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
+ }
+
+ public boolean validate(E s) {
+ return step != null;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListeners() {
+ for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+ protected Class<E> getStepClass() {
+ return stepClass;
+ }
+
+ protected void setStep(E step) {
+ E oldValue = this.step;
+ this.step = step;
+ firePropertyChange(STEP_PROPERTY_NAME, oldValue, step);
+ // la propriete nextStep peut avoir changee
+ firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
+ // la propriete previousStep peut avoir changee
+ firePropertyChange(PREVIOUS_STEP_PROPERTY_NAME, null, getPreviousStep());
+ validate();
+ }
+
+ protected void validate() {
+ if (step == null) {
+ // pas de validation quand aucune etape n'est sélectionnée
+ return;
+ }
+ boolean validate = validate(step);
+ this.validStep = validate;
+ // toujours forcer la propagation
+ firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ protected void updateUniverse() {
+
+ }
+}
Property changes on: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModel.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModelWithOperations.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModelWithOperations.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardModelWithOperations.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -0,0 +1,96 @@
+package jaxx.runtime.swing.wizard;
+
+import java.util.EnumMap;
+import java.util.EnumSet;
+
+/**
+ * Un modèle de wizard.
+ *
+ * @param <E> le type de l'énumération contenant les etapes.
+ *
+ * @param <O> le type de l'énumeration des opérations
+ * @param <R> le type de l'énumération des résultats d'opération
+ * @author tony
+ * @since 1.3
+ */
+public abstract class WizardModelWithOperations<E extends Enum<E>, O extends Enum<O>, R extends Enum<R>> extends WizardModel<E> {
+
+ public static final String OPERATIONS_PROPERTY_NAME = "operations";
+ public static final String OPERATION_RESULT_PROPERTY_NAME = "operationResult";
+ /**
+ * La liste des opérations à effectuer
+ */
+ protected EnumSet<O> operations;
+ /**
+ * Pour conserver les résultats des opérations
+ */
+ protected EnumMap<O, R> operationResults;
+ protected Class<O> operationClass;
+ protected Class<R> operationResultClass;
+
+ public abstract void cancel();
+
+ //protected abstract boolean isCancelResult(R operationResult);
+ //protected abstract boolean isErrorResult(R operationResult);
+
+ public WizardModelWithOperations(Class<E> stepClass, Class<O> operationClass, Class<R> operationResultClass, E... steps) {
+ super(stepClass, steps);
+ this.operationClass = operationClass;
+ this.operationResultClass = operationResultClass;
+ operationResults = new EnumMap<O, R>(operationClass);
+ }
+
+ public EnumSet<O> getOperations() {
+ if (operations == null) {
+ operations = EnumSet.noneOf(operationClass);
+ }
+ return operations;
+ }
+
+ public R getOperationResult(O operation) {
+ return operationResults.get(operation);
+ }
+
+ public void setOperationResult(O operation, R operationResult) {
+ R oldValue = getOperationResult(operation);
+ operationResults.put(operation, operationResult);
+ firePropertyChange(OPERATION_RESULT_PROPERTY_NAME, oldValue, operationResult);
+ }
+
+ @Override
+ public void start() {
+ super.start();
+ firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ }
+
+ public WizardModelWithOperations<E, O, R> addOperation(O operation) {
+ getOperations().add(operation);
+ /*if (operation == SynchroOperation.EXPORT_DATA) {
+ // pour exporter les données utilisateurs
+ // les operations synchronisation de référentiel et validation
+ // sont necessaires
+ getOperations().add(SynchroOperation.SYNCHRONIZE_REFERENTIEL);
+ getOperations().add(SynchroOperation.VALIDATION);
+ }*/
+ // on force la propagation de la nouvelle liste
+ firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+
+ updateUniverse();
+ validate();
+ return this;
+ }
+
+ public void removeOperation(O operation) {
+ getOperations().remove(operation);
+ /*if (operation == SynchroOperation.SYNCHRONIZE_REFERENTIEL || operation == SynchroOperation.VALIDATION) {
+ // pour exporter les données utilisateurs
+ // les operations synchronisation de référentiel et validation
+ // sont necessaires
+ getOperations().remove(SynchroOperation.EXPORT_DATA);
+ }*/
+ // on force la propagation de la nouvelle liste
+ firePropertyChange(OPERATIONS_PROPERTY_NAME, null, operations);
+ updateUniverse();
+ validate();
+ }
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardOperation.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -0,0 +1,20 @@
+package jaxx.runtime.swing.wizard;
+
+/**
+ *
+ * @param <Action>
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardOperation<Action extends WizardAbstractOperationAction> {
+
+ String name();
+
+ int ordinal();
+
+ String getLabel();
+
+ String getDescription();
+
+ public Action newAction();
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUI.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -0,0 +1,26 @@
+package jaxx.runtime.swing.wizard;
+
+import javax.swing.JTabbedPane;
+
+/**
+ *
+ * Contrat a respecter pour une ui de wizard.
+ *
+ * @param <E> le type d'etape
+ * @param <M> le type de model
+ *
+ * @author tony
+ * @since 1.3
+ */
+public interface WizardUI<E extends Enum<E>, M extends WizardModel<E>> {
+
+ public E getSelectedStep();
+
+ M getModel();
+
+ void init();
+
+ void start();
+
+ JTabbedPane getTabs();
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-03-13 22:00:34 UTC (rev 1265)
@@ -0,0 +1,93 @@
+package jaxx.runtime.swing.wizard;
+
+import javax.swing.JFrame;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.beanutils.ConstructorUtils;
+
+/**
+ *
+ * Une classe pour lancer une ui avec wizard.
+ *
+ * @param <E> le type des etapes
+ * @param <M> le type de modele
+ * @param <UI> le type d'ui
+ * @author tony
+ * @since 1.3
+ */
+public abstract class WizardUILancher<E extends Enum<E>, M extends WizardModel<E>, UI extends WizardUI<E, M>> {
+
+ protected UI ui;
+
+ protected abstract void doAction(UI ui);
+
+ @SuppressWarnings("unchecked")
+ public WizardUILancher(JAXXContext context, JFrame mainUI, Class<UI> uiClass, Class<M> modelClass) {
+ super();
+ try {
+ JAXXInitialContext uiContext = new JAXXInitialContext();
+ // instanciate ui
+ // parent context
+ uiContext.add(mainUI == null ? context : mainUI);
+ // parent context
+ // model
+ uiContext.add(modelClass.newInstance());
+ // apply action
+ uiContext.add("apply", new Runnable() {
+
+ @Override
+ public void run() {
+ doAction(ui);
+ }
+ });
+ // cancel action
+ uiContext.add("cancel", new Runnable() {
+
+ @Override
+ public void run() {
+ doCancel(ui);
+ }
+ });
+
+ // instanciate ui
+ ui = (UI) ConstructorUtils.invokeConstructor(uiClass, new Object[]{mainUI, uiContext});
+
+ } catch (Exception ex) {
+ throw new RuntimeException("could not instanciate launcher for reason " + ex.getMessage(), ex);
+ }
+ }
+
+ public void start() {
+ init(ui);
+ //ui.start();
+ }
+
+ protected void init(UI ui) {
+ }
+
+ protected void afterInit(UI ui) {
+ }
+
+ protected void doCancel(UI ui) {
+ }
+
+ public <T> T getContextValue(Class<T> clazz, String name) {
+ if (ui == null) {
+ throw new NullPointerException("ui can not be null");
+ }
+ if (!(ui instanceof JAXXObject)) {
+ throw new ClassCastException("ui can not be casted to JAXXObject ");
+ }
+
+ return ((JAXXObject) ui).getContextValue(clazz, name);
+ }
+
+ public <T> T getContextValue(Class<T> clazz) {
+ return getContextValue(clazz, null);
+ }
+
+ public void dispose() {
+ ui = null;
+ }
+}
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-03-12 09:03:21 UTC (rev 1264)
+++ jaxx/trunk/pom.xml 2009-03-13 22:00:34 UTC (rev 1265)
@@ -148,7 +148,7 @@
<!-- libs version -->
<lutinutil.version>1.0.3</lutinutil.version>
<jaxx.version>${project.version}</jaxx.version>
- <i18n.version>0.9</i18n.version>
+ <i18n.version>0.10</i18n.version>
<lutinpluginutil.version>0.3</lutinpluginutil.version>
</properties>
1
0
r1264 - in jaxx/trunk/jaxx-runtime-swing: . src/main/java/jaxx/runtime
by tchemit@users.labs.libre-entreprise.org March 12, 2009
by tchemit@users.labs.libre-entreprise.org March 12, 2009
March 12, 2009
Author: tchemit
Date: 2009-03-12 09:03:21 +0000 (Thu, 12 Mar 2009)
New Revision: 1264
Modified:
jaxx/trunk/jaxx-runtime-swing/changelog.txt
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
Log:
add some usefull code from ObServe (load Nimbus L&F, load ui configuration)
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-10 22:57:32 UTC (rev 1263)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-12 09:03:21 UTC (rev 1264)
@@ -1,4 +1,5 @@
1.3 ?? 200903??
+ * 20090312 [chemit] - add some usefull code from ObServe (load Nimbus L&F, load ui configuration)
* 20090309 [chemit] - in BlockingLayerUI, add a new state 'block' to enable/disable blocking mode with a blockingColor
* 20090303 [chemit] - in BlockingLayerUI, add a new state 'useIcon' to enable/disable use of the action icon
- add a simple WizardModel
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-10 22:57:32 UTC (rev 1263)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-03-12 09:03:21 UTC (rev 1264)
@@ -1,11 +1,15 @@
package jaxx.runtime;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
+import java.awt.Rectangle;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
@@ -24,7 +28,11 @@
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Properties;
+import javax.swing.ImageIcon;
import javax.swing.JComponent;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
import jaxx.runtime.swing.I18nTableCellRenderer;
import jaxx.runtime.swing.Item;
import jaxx.runtime.swing.JAXXComboBox;
@@ -46,6 +54,8 @@
static private final Log log = LogFactory.getLog(SwingUtil.class);
private static Field numReaders;
private static Field notifyingListeners;
+ public static final String ICON_PREFIX = "icon.";
+ public static final String COLOR_PREFIX = "color.";
public static void setText(final JTextComponent c, final String text) {
try {
@@ -261,4 +271,90 @@
return result;
}
+
+ /**
+ * Centrer un component graphique au center d'un autre component.
+ *
+ * <b>Note:</b> si le parent est null, alors on ne fait rien.
+ *
+ * @param parent le component parent
+ * @param component le component à centrer
+ */
+ public static void center(Component parent, Component component) {
+ if (parent == null) {
+ return;
+ }
+ Rectangle r = parent.getBounds();
+ int x = r.x + (r.width - component.getSize().width) / 2;
+ int y = r.y + (r.height - component.getSize().height) / 2;
+ component.setLocation(x, y);
+ }
+
+ /**
+ * Try to load the Nimbus look and feel.
+ * <p/>
+ * @throws UnsupportedLookAndFeelException
+ * if nimbus is not applicable
+ * @throws ClassNotFoundException
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ public static void initNimbusLoookAndFeel() throws UnsupportedLookAndFeelException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+
+ for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
+ if ("Nimbus".equals(laf.getName())) {
+ UIManager.setLookAndFeel(laf.getClassName());
+ }
+ }
+ }
+
+ /**
+ * Load the ui.properties file and set in {@link UIManager} colors and icons found.
+ *
+ * @param defaultUIConfig le path vers le fichier de la config d'ui par défaut (doit etre dansle class-path)
+ * @param extraUIConfig le path vers une surcharge de la config d'ui (doit etre dans le class-path)
+ *
+ * @throws IOException if could not load the ui.properties file
+ */
+ public static void loadUIConfig(String defaultUIConfig, String extraUIConfig) throws IOException {
+
+ Properties p = new Properties();
+ log.info("loading default UI config " + defaultUIConfig);
+ p.load(SwingUtil.class.getResourceAsStream(defaultUIConfig));
+ if (log.isDebugEnabled()) {
+ log.debug(p.toString());
+ }
+ if (extraUIConfig != null) {
+ InputStream extraStream = SwingUtil.class.getResourceAsStream(extraUIConfig);
+ if (extraStream == null) {
+ log.warn("could not find extraUIConfig : " + extraUIConfig);
+ } else {
+ log.info("loading extra UI config " + extraUIConfig);
+ Properties p2 = new Properties(p);
+ p2.load(extraStream);
+ if (log.isDebugEnabled()) {
+ log.debug(p2.toString());
+ }
+ p.putAll(p2);
+ }
+ }
+ for (Entry<Object, Object> entry : p.entrySet()) {
+ String key = (String) entry.getKey();
+ if (key.startsWith(ICON_PREFIX)) {
+ ImageIcon icon;
+ try {
+ icon = createImageIcon((String) entry.getValue());
+ UIManager.put(key.substring(ICON_PREFIX.length()), icon);
+ } catch (Exception e) {
+ log.warn("could not load icon " + entry.getValue());
+ }
+ continue;
+ }
+ if (key.startsWith(COLOR_PREFIX)) {
+ String value = (String) entry.getValue();
+ String[] rgb = value.split(",");
+ UIManager.put(key.substring(COLOR_PREFIX.length()), new Color(Integer.valueOf(rgb[0]), Integer.valueOf(rgb[1]), Integer.valueOf(rgb[2])));
+ }
+ }
+ }
}
1
0
r1263 - jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator
by tchemit@users.labs.libre-entreprise.org March 10, 2009
by tchemit@users.labs.libre-entreprise.org March 10, 2009
March 10, 2009
Author: tchemit
Date: 2009-03-10 22:57:32 +0000 (Tue, 10 Mar 2009)
New Revision: 1263
Modified:
jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-validation.xml
Log:
improve CollectionUniqueKeyValidator
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-validation.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-validation.xml 2009-03-10 22:57:22 UTC (rev 1262)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/resources/jaxx/runtime/validator/ValidatorBean-validation.xml 2009-03-10 22:57:32 UTC (rev 1263)
@@ -85,6 +85,11 @@
<param name="keys">intValue,stringValue,stringValue2</param>
<message>collectionUniqueKey.four.failed</message>
</field-validator>
+ <field-validator type="collectionUniqueKey">
+ <param name="keys">stringValue</param>
+ <param name="againstProperty">entry</param>
+ <message>collectionUniqueKey.five.failed</message>
+ </field-validator>
</field>
</validators>
\ No newline at end of file
1
0
r1262 - in jaxx/trunk/jaxx-runtime-validator/src: main/java/jaxx/runtime/validator/field test/java/jaxx/runtime/validator test/java/jaxx/runtime/validator/field
by tchemit@users.labs.libre-entreprise.org March 10, 2009
by tchemit@users.labs.libre-entreprise.org March 10, 2009
March 10, 2009
Author: tchemit
Date: 2009-03-10 22:57:22 +0000 (Tue, 10 Mar 2009)
New Revision: 1262
Modified:
jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/ValidatorBean.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java
Log:
improve CollectionUniqueKeyValidator
Modified: jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java 2009-03-09 00:39:23 UTC (rev 1261)
+++ jaxx/trunk/jaxx-runtime-validator/src/main/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidator.java 2009-03-10 22:57:22 UTC (rev 1262)
@@ -18,8 +18,8 @@
*/
public class CollectionUniqueKeyValidator extends FieldExpressionValidator {
+ public enum Mode {
- public enum Mode {
/** au moins une entrée de la collection doit etre valide */
AT_LEAST_ONE,
/** exactement une entrée dela collection doit être valide */
@@ -29,17 +29,36 @@
/** aucune valeur de la collection doivent etre valides */
NONE
}
-
/**
* la liste des propriétés d'une entrée de la collection qui définit la
* clef unique.
*/
protected String[] keys;
+ /**
+ * Une propriété optionnelle pour valider que l'objet reflétée par cette
+ * propriété ne viole pas l'intégrité de la clef unique.
+ * Cela permet de valider l'unicité sans que l'objet soit dans la collection
+ */
+ protected String againstProperty;
+ /**
+ * Lors de l'utilisation de la againstProperty et qu'un ne peut pas utiliser
+ * le equals sur l'objet, on peut spécifier une expression pour exclure des tests
+ * à exclure lors de la recherche de la violation de clef unique.
+ */
+ protected String againstIndexExpression;
public String[] getKeys() {
return keys;
}
+ public String getAgainstProperty() {
+ return againstProperty;
+ }
+
+ public String getAgainstIndexExpression() {
+ return againstIndexExpression;
+ }
+
public void setKeys(String[] keys) {
if (keys != null && keys.length == 1 && keys[0].indexOf(",") != -1) {
this.keys = keys[0].split(",");
@@ -48,6 +67,14 @@
}
}
+ public void setAgainstProperty(String againstProperty) {
+ this.againstProperty = againstProperty;
+ }
+
+ public void setAgainstIndexExpression(String againstIndexExpression) {
+ this.againstIndexExpression = againstIndexExpression;
+ }
+
@Override
public void validate(Object object) throws ValidationException {
@@ -59,26 +86,55 @@
Collection<?> col = getCollection(object);
- if (col.size() < 2) {
+ Object againstBean = againstProperty == null ? null : getFieldValue(againstProperty, object);
+
+ Integer againstIndex = (Integer) (againstIndexExpression == null ? -1 : getFieldValue(againstIndexExpression, object));
+ if (againstIndex == null) {
+ againstIndex = -1;
+ }
+ if (againstBean == null && col.size() < 2) {
// la liste ne contient pas deux entrées donc c'est valide
return;
}
boolean answer = true;
+ Integer againstHashCode = againstBean == null ? null : getUniqueKeyHashCode(againstBean);
+
List<Integer> hashCodes = new ArrayList<Integer>();
+ int index = 0;
for (Object o : col) {
Integer hash = getUniqueKeyHashCode(o);
- if (hashCodes.contains(hash)) {
- // on a deja rencontre cette clef unique,
- // donc la validation a echouee
- answer = false;
- break;
+ if (againstBean == null) {
+ if (hashCodes.contains(hash)) {
+ // on a deja rencontre cette clef unique,
+ // donc la validation a echouee
+ answer = false;
+ break;
+ }
+ } else {
+ // utilisation de againstBean
+ if (againstIndex != -1) {
+ if (index != againstIndex && hash.equals(againstHashCode)) {
+ // on a deja rencontre cette clef unique,
+ // donc la validation a echouee
+ answer = false;
+ break;
+ }
+ } else {
+ if (!againstBean.equals(o) && hash.equals(againstHashCode)) {
+ // on a deja rencontre cette clef unique,
+ // donc la validation a echouee
+ answer = false;
+ break;
+ }
+ }
}
-
// nouveau hashcode enregistre
hashCodes.add(hash);
+ // index suivant
+ index++;
}
if (!answer) {
@@ -137,5 +193,4 @@
public String getValidatorType() {
return "collectionUniqueKey";
}
-
}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/ValidatorBean.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/ValidatorBean.java 2009-03-09 00:39:23 UTC (rev 1261)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/ValidatorBean.java 2009-03-10 22:57:22 UTC (rev 1262)
@@ -59,6 +59,8 @@
protected String stringValue;
+ protected ValidatorBeanEntry entry;
+
PropertyChangeSupport p;
public ValidatorBean() {
@@ -101,6 +103,10 @@
return notExistingDirectory;
}
+ public ValidatorBeanEntry getEntry() {
+ return entry;
+ }
+
public Collection<ValidatorBeanEntry> getEntries() {
return entries;
}
@@ -142,4 +148,11 @@
p.firePropertyChange("entries", null, entries);
}
+ public void setEntry(ValidatorBeanEntry entry) {
+ this.entry = entry;
+ p.firePropertyChange("entry", null, entry);
+ }
+
+
+
}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java 2009-03-09 00:39:23 UTC (rev 1261)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/field/CollectionUniqueKeyValidatorTest.java 2009-03-10 22:57:22 UTC (rev 1262)
@@ -21,6 +21,7 @@
assertFieldInError("entries", "collectionUniqueKey.two.failed", false);
assertFieldInError("entries", "collectionUniqueKey.three.failed", false);
assertFieldInError("entries", "collectionUniqueKey.four.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.five.failed", false);
// add a entry
bean.setEntries(Arrays.asList(beanEntry));
@@ -29,7 +30,17 @@
assertFieldInError("entries", "collectionUniqueKey.two.failed", false);
assertFieldInError("entries", "collectionUniqueKey.three.failed", false);
assertFieldInError("entries", "collectionUniqueKey.four.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.five.failed", false);
+ // add violating property
+ bean.setEntry(beanEntry3);
+ assertFieldInError("entries", "collectionUniqueKey.one.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.two.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.three.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.four.failed", false);
+ assertFieldInError("entries", "collectionUniqueKey.five.failed", true);
+
+
// two entries with same key
bean.setEntries(Arrays.asList(beanEntry, beanEntry));
1
0
r1261 - jaxx/trunk/jaxx-example/src/main/java/jaxx/demo
by tchemit@users.labs.libre-entreprise.org March 9, 2009
by tchemit@users.labs.libre-entreprise.org March 9, 2009
March 9, 2009
Author: tchemit
Date: 2009-03-09 00:39:23 +0000 (Mon, 09 Mar 2009)
New Revision: 1261
Modified:
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
Log:
update BlockingLAyerUI example with block mode
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-03-09 00:39:02 UTC (rev 1260)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-03-09 00:39:23 UTC (rev 1261)
@@ -4,6 +4,7 @@
blockIcon='{SwingUtil.createImageIcon("action-block.png")}'
acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}'
useIcon='true'
+ blockingColor='{new Color(50,50,50)}'
acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
@@ -13,16 +14,32 @@
<script><![CDATA[
import jaxx.runtime.SwingUtil;
-public void setLayer(boolean active) {
+public void initLayer() {
for (JComponent boxed : SwingUtil.getLayeredComponents(this)) {
- jaxx.runtime.swing.BlockingLayerUI ui = active ? layerUI.clone() : null;
- if ( ui != null && boxed == c) {
+ jaxx.runtime.swing.BlockingLayerUI ui = layerUI.clone();
+ if ( boxed == c) {
ui.setUseIcon(false);
- }
+ ui.setBlock(true);
+ }
SwingUtil.getLayer(boxed).setUI(ui);
+ //ui.setDirty(true);
}
}
+public void setLayer(boolean active) {
+ for (JComponent boxed : SwingUtil.getLayeredComponents(this)) {
+ jaxx.runtime.swing.BlockingLayerUI ui = (jaxx.runtime.swing.BlockingLayerUI)SwingUtil.getLayer(boxed).getUI();
+ if ( boxed == c) {
+ ui.setBlock(active);
+ } else {
+ ui.setUseIcon(active);
+ }
+ //ui.setBlock(active && boxed == c);
+ //ui.setUseIcon(active && boxed != c);
+ //ui.setDirty(true);
+ }
+}
+
protected void accept(ActionEvent e, String suffix) {
JButton source = (JButton) e.getSource();
String clickedMessage = (String) source.getClientProperty("clickedText");
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-03-09 00:39:02 UTC (rev 1260)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-03-09 00:39:23 UTC (rev 1261)
@@ -9,7 +9,8 @@
// init i18n
org.codelutin.i18n.I18n.init();
-boxedDecoratorDemo.setLayer(true);
+boxedDecoratorDemo.initLayer();
+//boxedDecoratorDemo.setLayer(true);
]]></script>
<JSplitPane>
<!--JSplitPane dividerLocation='200'-->
1
0
r1260 - in jaxx/trunk/jaxx-compiler-api: . src/main/java/jaxx/compiler
by tchemit@users.labs.libre-entreprise.org March 9, 2009
by tchemit@users.labs.libre-entreprise.org March 9, 2009
March 9, 2009
Author: tchemit
Date: 2009-03-09 00:39:02 +0000 (Mon, 09 Mar 2009)
New Revision: 1260
Modified:
jaxx/trunk/jaxx-compiler-api/changelog.txt
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java
Log:
- must get the goal property from the event id to make possible inheritance
- improve override properties create method : when same type do not re-instanciate it
Modified: jaxx/trunk/jaxx-compiler-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-09 00:35:43 UTC (rev 1259)
+++ jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-09 00:39:02 UTC (rev 1260)
@@ -1,4 +1,6 @@
1.3 ??? 200902??
+ * 20090309 [chemit] - must get the goal property from the event id to make possible inheritance
+ - improve override properties create method : when same type do not re-instanciate it
* 20090229 [chemit] - fix bug in ClassDescriptorLoader when searching for an arrayof primitive type
- add a profile mode
* 20090228 [chemit] - fix bug in MethodDescriptor when no returnType defined (constructor method) in getReturnType method invocation
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-03-09 00:35:43 UTC (rev 1259)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-03-09 00:39:02 UTC (rev 1260)
@@ -41,27 +41,34 @@
return object.getInitializationCode(compiler);
}
StringBuffer result = new StringBuffer();
- result.append(object.getId());
- result.append(" = ");
- if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
- result.append(object.getJavaBeanInitCode()).append(";");
+ if (object.isOverride() && object.getOverrideType()==object.getObjectClass()) {
+ //TC-20090309 on utilise le super code quand l'objet est de meme type
+ result.append("super.").append(object.getCreationMethodName()).append("();");
} else {
- String constructorParams = object.getConstructorParams();
- if (constructorParams != null) {
- //TC - 20081017 compiledObject can have generics
- result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
- //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
+ result.append(object.getId());
+ result.append(" = ");
+ if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
+ result.append(object.getJavaBeanInitCode()).append(";");
} else {
- //TC - 20081017 compiledObject can have generics
- result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
+ String constructorParams = object.getConstructorParams();
+ if (constructorParams != null) {
+ //TC - 20081017 compiledObject can have generics
+ result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
+ //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
+ } else {
+ //TC - 20081017 compiledObject can have generics
+ result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
+ }
}
+ result.append(JAXXCompiler.getLineSeparator());
+ result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
}
result.append(JAXXCompiler.getLineSeparator());
String initCode = object.getInitializationCode(compiler);
if (initCode != null && initCode.length() > 0) {
result.append(initCode);
}
- result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
+
return result.toString();
}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-03-09 00:35:43 UTC (rev 1259)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-03-09 00:39:02 UTC (rev 1260)
@@ -628,7 +628,12 @@
if (getOptions().isOptimize()) {
result = "$ev" + eventHandlerMethodNames.size();
} else {
- result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + handler.getObjectCode();
+ //TC-20090309 must get the goal property from the event id
+ // to make possible inheritance
+ String id = handler.getEventId().substring(0,handler.getEventId().indexOf("."));
+
+ result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + id;
+ //result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + handler.getObjectCode();
}
eventHandlerMethodNames.put(handler, result);
}
1
0
r1259 - in jaxx/trunk/jaxx-runtime-swing: . src/main/java/jaxx/runtime/swing
by tchemit@users.labs.libre-entreprise.org March 9, 2009
by tchemit@users.labs.libre-entreprise.org March 9, 2009
March 9, 2009
Author: tchemit
Date: 2009-03-09 00:35:43 +0000 (Mon, 09 Mar 2009)
New Revision: 1259
Modified:
jaxx/trunk/jaxx-runtime-swing/changelog.txt
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
Log:
in BlockingLayerUI, add a new state 'block' to enable/disable blocking mode with a blockingColor
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-04 23:12:53 UTC (rev 1258)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-09 00:35:43 UTC (rev 1259)
@@ -1,4 +1,5 @@
1.3 ?? 200903??
+ * 20090309 [chemit] - in BlockingLayerUI, add a new state 'block' to enable/disable blocking mode with a blockingColor
* 20090303 [chemit] - in BlockingLayerUI, add a new state 'useIcon' to enable/disable use of the action icon
- add a simple WizardModel
* 20090301 [chemit] - add usefull methods in JAXXButtonGroup
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-03-04 23:12:53 UTC (rev 1258)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-03-09 00:35:43 UTC (rev 1259)
@@ -1,8 +1,12 @@
package jaxx.runtime.swing;
+import java.awt.AlphaComposite;
+import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
+import java.awt.Insets;
import java.awt.Point;
+import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
@@ -34,6 +38,7 @@
public static final String CAN_CLICK_PROPERTY = "canClick";
public static final String ACCEPT_ICON_PROPERTY = "acceptIcon";
public static final String BLOCK_ICON_PROPERTY = "blockIcon";
+ public static final String BLOCK_PROPERTY = "block";
private static final long serialVersionUID = 1L;
/**
* Action to be treated when click on icon
@@ -48,6 +53,10 @@
*/
protected BufferedImage acceptIcon;
/**
+ * Optinal color to put fill background when blocking
+ */
+ protected Color blockingColor;
+ /**
* Internal state to known when we can accept click
*/
protected boolean canClick;
@@ -60,6 +69,10 @@
* By default, this is active.
*/
protected boolean useIcon = true;
+ /**
+ * Internal state when should block event and paint layer
+ */
+ protected boolean block;
public void setAcceptAction(Action acceptAction) {
this.acceptAction = acceptAction;
@@ -86,6 +99,28 @@
}
}
+ public void setBlock(boolean block) {
+ boolean oldvalue = this.block;
+ this.block = block;
+ firePropertyChange(BLOCK_PROPERTY, oldvalue, block);
+ if (oldvalue != block) {
+ setDirty(true);
+ }
+ }
+
+ @Override
+ public void setDirty(boolean isDirty) {
+ super.setDirty(isDirty);
+ }
+
+ public void setBlockIcon(BufferedImage blockIcon) {
+ this.blockIcon = blockIcon;
+ }
+
+ public void setBlockingColor(Color blockingColor) {
+ this.blockingColor = blockingColor;
+ }
+
public BufferedImage getBlockIcon() {
return blockIcon;
}
@@ -99,7 +134,11 @@
}
public void setUseIcon(boolean useIcon) {
+ boolean oldvalue = this.useIcon;
this.useIcon = useIcon;
+ if (oldvalue != useIcon) {
+ setDirty(true);
+ }
}
@Override
@@ -109,13 +148,17 @@
clone.acceptIcon = acceptIcon;
clone.blockIcon = blockIcon;
clone.useIcon = useIcon;
+ clone.block = block;
+ clone.blockingColor = blockingColor;
clone.setCanClick(false);
return clone;
}
@Override
protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) {
- e.consume();
+ if (useIcon || block) {
+ e.consume();
+ }
}
@Override
@@ -123,7 +166,9 @@
if (useIcon) {
updateCanClickState(l, e);
}
- e.consume();
+ if (useIcon || block) {
+ e.consume();
+ }
}
@Override
@@ -143,12 +188,32 @@
break;
}
}
- e.consume();
+ if (useIcon || block) {
+ e.consume();
+ }
+
}
@Override
protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
super.paintLayer(g2, l);
+ if (block && blockingColor != null) {
+ // to be in sync with the view if the layer has a border
+ /*Insets layerInsets = l.getInsets();
+ g2.translate(layerInsets.left, layerInsets.top);
+
+ JComponent view = l.getView();
+ // To prevent painting on view's border
+ Insets insets = view.getInsets();
+ g2.clip(new Rectangle(insets.left, insets.top,
+ view.getWidth() - insets.left - insets.right,
+ view.getHeight() - insets.top - insets.bottom));
+ */
+
+ g2.setColor(blockingColor);
+ g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .1f));
+ g2.fillRect(0, 0, l.getWidth(), l.getHeight());
+ }
if (useIcon && getCurrentIcon() != null) {
g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null);
}
1
0
r1258 - jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing
by tchemit@users.labs.libre-entreprise.org March 4, 2009
by tchemit@users.labs.libre-entreprise.org March 4, 2009
March 4, 2009
Author: tchemit
Date: 2009-03-04 23:12:53 +0000 (Wed, 04 Mar 2009)
New Revision: 1258
Modified:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java
Log:
methode setSteps rendue publique
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java 2009-03-03 19:33:22 UTC (rev 1257)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java 2009-03-04 23:12:53 UTC (rev 1258)
@@ -119,6 +119,21 @@
return steps;
}
+ /**
+ * Change l'univers des etapes.
+ *
+ * Note: on presume ici que l'étape courante est toujours la meme.
+ *
+ * @param steps le nouvel univers des etapes
+ */
+ public void setSteps(E... steps) {
+ List<E> oldValue = this.steps;
+ this.steps = java.util.Collections.unmodifiableList(java.util.Arrays.asList(steps));
+ firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
+ // la propriete nextStep peut avoir changee
+ firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
+ }
+
public boolean validate(E s) {
return step != null;
}
@@ -159,21 +174,6 @@
validate();
}
- /**
- * Change l'univers des etapes.
- *
- * Note: on presume ici que l'étape courante est toujours la meme.
- *
- * @param steps le nouvel univers des etapes
- */
- protected void setSteps(E... steps) {
- List<E> oldValue = this.steps;
- this.steps = java.util.Collections.unmodifiableList(java.util.Arrays.asList(steps));
- firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
- // la propriete nextStep peut avoir changee
- firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
- }
-
protected void validate() {
if (step == null) {
// pas de validation quand aucune etape n'est sélectionnée
1
0
r1257 - jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing
by tchemit@users.labs.libre-entreprise.org March 3, 2009
by tchemit@users.labs.libre-entreprise.org March 3, 2009
March 3, 2009
Author: tchemit
Date: 2009-03-03 19:33:22 +0000 (Tue, 03 Mar 2009)
New Revision: 1257
Modified:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java
Log:
add a simple wizrd model
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java 2009-03-03 19:33:04 UTC (rev 1256)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java 2009-03-03 19:33:22 UTC (rev 1257)
@@ -10,6 +10,7 @@
* @param <E> le type de l'énumération contenant les etapes.
*
* @author tony
+ * @since 1.3
*/
public class WizardModel<E extends Enum<E>> {
1
0
r1256 - in jaxx/trunk/jaxx-runtime-swing: . src/main/java/jaxx/runtime/swing
by tchemit@users.labs.libre-entreprise.org March 3, 2009
by tchemit@users.labs.libre-entreprise.org March 3, 2009
March 3, 2009
Author: tchemit
Date: 2009-03-03 19:33:04 +0000 (Tue, 03 Mar 2009)
New Revision: 1256
Added:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java
Modified:
jaxx/trunk/jaxx-runtime-swing/changelog.txt
Log:
add a simple wizrd model
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-03 16:38:42 UTC (rev 1255)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-03 19:33:04 UTC (rev 1256)
@@ -1,5 +1,6 @@
1.3 ?? 200903??
* 20090303 [chemit] - in BlockingLayerUI, add a new state 'useIcon' to enable/disable use of the action icon
+ - add a simple WizardModel
* 20090301 [chemit] - add usefull methods in JAXXButtonGroup
1.2 letellier 2009022?
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/WizardModel.java 2009-03-03 19:33:04 UTC (rev 1256)
@@ -0,0 +1,190 @@
+package jaxx.runtime.swing;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.List;
+
+/**
+ * Un modèle de wizard.
+ *
+ * @param <E> le type de l'énumération contenant les etapes.
+ *
+ * @author tony
+ */
+public class WizardModel<E extends Enum<E>> {
+
+ public static final String STEPS_PROPERTY_NAME = "steps";
+ public static final String STEP_PROPERTY_NAME = "step";
+ public static final String PREVIOUS_STEP_PROPERTY_NAME = "previousStep";
+ public static final String NEXT_STEP_PROPERTY_NAME = "nextStep";
+ public static final String VALID_STEP_PROPERTY_NAME = "validStep";
+ /**
+ * le type d'une etape du model (doit etre une enumeration)
+ */
+ protected final Class<E> stepClass;
+ /**
+ * Toutes les étapes à passer
+ */
+ protected List<E> steps;
+ /**
+ * L'étape courante
+ */
+ protected E step;
+ /**
+ * drapeau pour valider l'état de l'étape courante
+ */
+ protected boolean validStep;
+ /**
+ * pour propager les changements dans le modèle vers l'ui
+ */
+ protected PropertyChangeSupport pcs;
+
+ public WizardModel(Class<E> stepClass, E... steps) {
+ this.stepClass = stepClass;
+ this.pcs = new PropertyChangeSupport(this);
+ this.steps = new java.util.ArrayList<E>();
+ if (steps.length > 0) {
+ setSteps(steps);
+ }
+ }
+
+ public void start() {
+ if (steps.isEmpty()) {
+ throw new IllegalStateException("can not start, no step found");
+ }
+ step = null;
+ E startStep = steps.get(0);
+ setStep(startStep);
+ }
+
+ public void gotoNextStep() {
+ E nextStep = getNextStep();
+ if (nextStep == null) {
+ throw new IllegalStateException("no next step to go");
+ }
+ setStep(nextStep);
+ }
+
+ public void gotoPreviousStep() {
+ E previousStep = getPreviousStep();
+ if (previousStep == null) {
+ throw new IllegalStateException("no previous step to go");
+ }
+ setStep(previousStep);
+ }
+
+ public void gotoStep(E e) {
+ if (e == null) {
+ throw new NullPointerException("step can not be null");
+ }
+ if (!steps.contains(e)) {
+ throw new IllegalStateException("step " + e + " is not in universe of steps (" + steps + ")");
+ }
+ setStep(e);
+ }
+
+ public E getStep() {
+ return step;
+ }
+
+ public int getStepIndex(E s) {
+ int index = steps.indexOf(s);
+ return index;
+ }
+
+ public boolean isValidStep() {
+ return validStep;
+ }
+
+ public E getPreviousStep() {
+ int index = getStepIndex(step);
+ if (index < 1) {
+ // si pas de step ou sur premier step
+ return null;
+ }
+ return steps.get(index - 1);
+ }
+
+ public E getNextStep() {
+ int index = getStepIndex(step);
+ if (index == -1 || index == steps.size() - 1) {
+ // si pas de step positionne ou dernier etape
+ return null;
+ }
+ return steps.get(index + 1);
+ }
+
+ public List<E> getSteps() {
+ return steps;
+ }
+
+ public boolean validate(E s) {
+ return step != null;
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListeners() {
+ for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
+ pcs.removePropertyChangeListener(l);
+ }
+ }
+ protected Class<E> getStepClass() {
+ return stepClass;
+ }
+
+ protected void setStep(E step) {
+ E oldValue = this.step;
+ this.step = step;
+ firePropertyChange(STEP_PROPERTY_NAME, oldValue, step);
+ // la propriete nextStep peut avoir changee
+ firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
+ // la propriete previousStep peut avoir changee
+ firePropertyChange(PREVIOUS_STEP_PROPERTY_NAME, null, getPreviousStep());
+ validate();
+ }
+
+ /**
+ * Change l'univers des etapes.
+ *
+ * Note: on presume ici que l'étape courante est toujours la meme.
+ *
+ * @param steps le nouvel univers des etapes
+ */
+ protected void setSteps(E... steps) {
+ List<E> oldValue = this.steps;
+ this.steps = java.util.Collections.unmodifiableList(java.util.Arrays.asList(steps));
+ firePropertyChange(STEPS_PROPERTY_NAME, oldValue, this.steps);
+ // la propriete nextStep peut avoir changee
+ firePropertyChange(NEXT_STEP_PROPERTY_NAME, null, getNextStep());
+ }
+
+ protected void validate() {
+ if (step == null) {
+ // pas de validation quand aucune etape n'est sélectionnée
+ return;
+ }
+ boolean validate = validate(step);
+ this.validStep = validate;
+ // toujours forcer la propagation
+ firePropertyChange(VALID_STEP_PROPERTY_NAME, null, validStep);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+}
1
0
r1255 - jaxx/trunk/jaxx-example/src/main/java/jaxx/demo
by tchemit@users.labs.libre-entreprise.org March 3, 2009
by tchemit@users.labs.libre-entreprise.org March 3, 2009
March 3, 2009
Author: tchemit
Date: 2009-03-03 16:38:42 +0000 (Tue, 03 Mar 2009)
New Revision: 1255
Modified:
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
Log:
in BlockingLayerUI, add a new state 'useIcon' to enable/disable use of the action icon
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-03-03 16:38:17 UTC (rev 1254)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-03-03 16:38:42 UTC (rev 1255)
@@ -3,6 +3,7 @@
<jaxx.runtime.swing.BlockingLayerUI id='layerUI'
blockIcon='{SwingUtil.createImageIcon("action-block.png")}'
acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}'
+ useIcon='true'
acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
@@ -15,6 +16,9 @@
public void setLayer(boolean active) {
for (JComponent boxed : SwingUtil.getLayeredComponents(this)) {
jaxx.runtime.swing.BlockingLayerUI ui = active ? layerUI.clone() : null;
+ if ( ui != null && boxed == c) {
+ ui.setUseIcon(false);
+ }
SwingUtil.getLayer(boxed).setUI(ui);
}
}
@@ -41,7 +45,7 @@
onActionPerformed='accept(event, "from button (no layer)")'/>
<JButton text='button B' decorator='boxed' _clickedText='"button B was clicked"'
onActionPerformed='accept(event, "from button (no layer)")'/>
- <JButton text='button C' decorator='boxed' _clickedText='"button C was clicked"'
+ <JButton id='c' text='button C (full block)' decorator='boxed' _clickedText='"button C was clicked"'
onActionPerformed='accept(event, "from button (no layer)");'/>
</JPanel>
</cell>
1
0
r1254 - in jaxx/trunk/jaxx-runtime-swing: . src/main/java/jaxx/runtime/swing
by tchemit@users.labs.libre-entreprise.org March 3, 2009
by tchemit@users.labs.libre-entreprise.org March 3, 2009
March 3, 2009
Author: tchemit
Date: 2009-03-03 16:38:17 +0000 (Tue, 03 Mar 2009)
New Revision: 1254
Modified:
jaxx/trunk/jaxx-runtime-swing/changelog.txt
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
Log:
in BlockingLayerUI, add a new state 'useIcon' to enable/disable use of the action icon
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-03 07:50:33 UTC (rev 1253)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-03 16:38:17 UTC (rev 1254)
@@ -1,4 +1,5 @@
1.3 ?? 200903??
+ * 20090303 [chemit] - in BlockingLayerUI, add a new state 'useIcon' to enable/disable use of the action icon
* 20090301 [chemit] - add usefull methods in JAXXButtonGroup
1.2 letellier 2009022?
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-03-03 07:50:33 UTC (rev 1253)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-03-03 16:38:17 UTC (rev 1254)
@@ -51,6 +51,15 @@
* Internal state to known when we can accept click
*/
protected boolean canClick;
+ /**
+ * A flag to enable or disable the use of the icon.
+ *
+ * If set to false, no icon will be displayed and no action
+ * will be possible.
+ *
+ * By default, this is active.
+ */
+ protected boolean useIcon = true;
public void setAcceptAction(Action acceptAction) {
this.acceptAction = acceptAction;
@@ -89,12 +98,17 @@
return canClick;
}
+ public void setUseIcon(boolean useIcon) {
+ this.useIcon = useIcon;
+ }
+
@Override
public BlockingLayerUI clone() {
BlockingLayerUI clone = new BlockingLayerUI();
clone.acceptAction = acceptAction;
clone.acceptIcon = acceptIcon;
clone.blockIcon = blockIcon;
+ clone.useIcon = useIcon;
clone.setCanClick(false);
return clone;
}
@@ -106,25 +120,28 @@
@Override
protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) {
- updateCanClickState(l, e);
+ if (useIcon) {
+ updateCanClickState(l, e);
+ }
e.consume();
}
@Override
protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) {
-
- switch (e.getID()) {
- case MouseEvent.MOUSE_ENTERED:
- updateCanClickState(l, e);
- break;
- case MouseEvent.MOUSE_EXITED:
- setCanClick(false);
- break;
- case MouseEvent.MOUSE_CLICKED:
- if (canClick) {
- acceptEvent(e, l);
- }
- break;
+ if (useIcon) {
+ switch (e.getID()) {
+ case MouseEvent.MOUSE_ENTERED:
+ updateCanClickState(l, e);
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ setCanClick(false);
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ if (canClick) {
+ acceptEvent(e, l);
+ }
+ break;
+ }
}
e.consume();
}
@@ -132,7 +149,7 @@
@Override
protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
super.paintLayer(g2, l);
- if (getCurrentIcon() != null) {
+ if (useIcon && getCurrentIcon() != null) {
g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null);
}
}
1
0
r1253 - in jaxx/trunk/jaxx-runtime-api: . src/main/java/jaxx/runtime
by tchemit@users.labs.libre-entreprise.org March 3, 2009
by tchemit@users.labs.libre-entreprise.org March 3, 2009
March 3, 2009
Author: tchemit
Date: 2009-03-03 07:50:33 +0000 (Tue, 03 Mar 2009)
New Revision: 1253
Modified:
jaxx/trunk/jaxx-runtime-api/changelog.txt
jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java
jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java
Log:
add pcs in ApplicationContext
add method in Util to filter JAXX property changed listeners
Modified: jaxx/trunk/jaxx-runtime-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-03-01 20:36:23 UTC (rev 1252)
+++ jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-03-03 07:50:33 UTC (rev 1253)
@@ -1,4 +1,8 @@
-1.2 ??? 2009????
+1.3 ??? 200903??
+ * 20090302 [chemit] - add pcs in ApplicationContext
+ - add method in Util to filter JAXX property changed listeners
+
+1.2 letellier 2009022?
* 2009021 [chemit] - introduce DefaultApplicationContext iwth annotation system.
1.1 chemit 20090220
Modified: jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java
===================================================================
--- jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-03-01 20:36:23 UTC (rev 1252)
+++ jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-03-03 07:50:33 UTC (rev 1253)
@@ -1,5 +1,7 @@
package jaxx.runtime;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
import java.lang.annotation.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -81,6 +83,7 @@
public DefaultApplicationContext() {
super();
forwards = new HashMap<Class, Class>();
+ pcs = new PropertyChangeSupport(this);
}
public DefaultApplicationContext(JAXXObject ui) {
@@ -89,6 +92,9 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(DefaultApplicationContext.class);
+ /** to manage properties modifications */
+ protected PropertyChangeSupport pcs;
+
@SuppressWarnings({"unchecked"})
@Override
public <T> T getContextValue(Class<T> clazz, String name) {
@@ -178,6 +184,34 @@
super.removeContextValue(klazz, name);
}
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
protected Object newInstance(Class<?> clazz) throws IllegalArgumentException {
Object value = null;
@@ -240,4 +274,8 @@
throw new IllegalArgumentException(ex);
}
}
+
+ protected void firePropertyChange(String name, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(name, oldValue, newValue);
+ }
}
Modified: jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java
===================================================================
--- jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-03-01 20:36:23 UTC (rev 1252)
+++ jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-03-03 07:50:33 UTC (rev 1253)
@@ -12,6 +12,8 @@
import javax.swing.UIManager;
import java.awt.Component;
import java.awt.Dimension;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeListenerProxy;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
@@ -409,6 +411,45 @@
return createIcon(iconPath + "i18n/" + name + ".png");
}
+ /**
+ * detects all PropertychangedListener added by Jaxx uis
+ * (should be a {@link DataBindingListener}
+ *
+ * @param propertyNames the array of property names to find
+ * @param listeners the array of listeners to filter
+ * @return the filtered listeners
+ */
+ public static PropertyChangeListener[] findJaxxPropertyChangeListener(String[] propertyNames, PropertyChangeListener... listeners) {
+ if (listeners == null || listeners.length == 0) {
+ return new PropertyChangeListener[0];
+ }
+ List<String> pNames = Arrays.asList(propertyNames);
+
+ List<PropertyChangeListener> toRemove = new ArrayList<PropertyChangeListener>();
+
+ for (PropertyChangeListener listener : listeners) {
+ String pName = null;
+ PropertyChangeListenerProxy plistener = null;
+ if (listener instanceof PropertyChangeListenerProxy) {
+ plistener = (PropertyChangeListenerProxy) listener;
+ if (!pNames.contains(plistener.getPropertyName())) {
+ // not on the good property
+ continue;
+ }
+ listener = (PropertyChangeListener) plistener.getListener();
+ pName = plistener.getPropertyName();
+ }
+ if (plistener != null && pName != null && listener instanceof DataBindingListener) {
+ if (log.isDebugEnabled()) {
+ log.debug("find config listener to remove [" + pName + "] : " + listener);
+ }
+ toRemove.add(plistener);
+ //toRemove.add(listener);
+ }
+ }
+ return toRemove.toArray(new PropertyChangeListener[toRemove.size()]);
+ }
+
private static String getIconPath() {
String iconPath = UIManager.getString(DEFAULT_ICON_PATH_PROPERTY);
if (iconPath == null) {
1
0
r1252 - in jaxx/trunk/jaxx-runtime-swing: . src/main/java/jaxx/runtime/swing
by tchemit@users.labs.libre-entreprise.org March 1, 2009
by tchemit@users.labs.libre-entreprise.org March 1, 2009
March 1, 2009
Author: tchemit
Date: 2009-03-01 20:36:23 +0000 (Sun, 01 Mar 2009)
New Revision: 1252
Modified:
jaxx/trunk/jaxx-runtime-swing/changelog.txt
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java
Log:
add usefull methods in JAXXButtonGroup
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-01 13:04:25 UTC (rev 1251)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-03-01 20:36:23 UTC (rev 1252)
@@ -1,4 +1,7 @@
-1.2 ??? 2009????
+1.3 ?? 200903??
+ * 20090301 [chemit] - add usefull methods in JAXXButtonGroup
+
+1.2 letellier 2009022?
* 20090223 [chemit] - rename jaxx.runtime.swing.Utils to jaxx.runtime.SwingUtil
1.1 chemit 20090220
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java 2009-03-01 13:04:25 UTC (rev 1251)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/JAXXButtonGroup.java 2009-03-01 20:36:23 UTC (rev 1252)
@@ -34,6 +34,7 @@
protected transient ChangeEvent changeEvent = new ChangeEvent(this);
private transient ChangeListener changeListener = new ChangeListener() {
+ @Override
public void stateChanged(ChangeEvent e) {
updateSelectedValue();
if (useToolTipText) {
@@ -64,9 +65,9 @@
while (e.hasMoreElements()) {
AbstractButton button = e.nextElement();
if (button.isSelected()) {
- Object selectedValue = button.getClientProperty(VALUE_CLIENT_PROPERTY );
- if (selectedValue != getSelectedValue()) {
- setSelectedValue(selectedValue);
+ Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY );
+ if (buttonValue != getSelectedValue()) {
+ setSelectedValue(buttonValue);
}
}
}
@@ -89,7 +90,30 @@
return selectedValue;
}
+ public AbstractButton getSelectedButton() {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ if (button.isSelected()) {
+ return button;
+ }
+ }
+ return null;
+ }
+ public AbstractButton getButton(Object value) {
+ Enumeration<AbstractButton> e = getElements();
+ while (e.hasMoreElements()) {
+ AbstractButton button = e.nextElement();
+ Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY );
+ if (value.equals(buttonValue)) {
+ return button;
+ }
+ }
+ return null;
+ }
+
+
public void setSelectedValue(Object value) {
Object oldValue = getSelectedValue();
this.selectedValue = value;
@@ -114,8 +138,8 @@
Enumeration<AbstractButton> e = getElements();
while (e.hasMoreElements()) {
AbstractButton button = e.nextElement();
- Object selectedValue = button.getClientProperty(VALUE_CLIENT_PROPERTY );
- if (value.equals(selectedValue)) {
+ Object buttonValue = button.getClientProperty(VALUE_CLIENT_PROPERTY );
+ if (value.equals(buttonValue)) {
button.setSelected(true);
break;
}
1
0
r1251 - jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler
by tchemit@users.labs.libre-entreprise.org March 1, 2009
by tchemit@users.labs.libre-entreprise.org March 1, 2009
March 1, 2009
Author: tchemit
Date: 2009-03-01 13:04:25 +0000 (Sun, 01 Mar 2009)
New Revision: 1251
Modified:
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXProfile.java
Log:
in profile, no stats if only one file was treated
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXProfile.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXProfile.java 2009-03-01 12:52:04 UTC (rev 1250)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXProfile.java 2009-03-01 13:04:25 UTC (rev 1251)
@@ -181,14 +181,16 @@
buffer.append(line);
- printReportLine(buffer, reportPattern, "total (" + compilers.size() + " files)", cfp.total, csp.total, ssp.total, gp.total, total.total);
+ if (compilers.size() > 1) {
+ printReportLine(buffer, reportPattern, "total (" + compilers.size() + " files)", cfp.total, csp.total, ssp.total, gp.total, total.total);
- buffer.append(line);
- printReportLine2(buffer, reportPattern, "min", cfp.min, csp.min, ssp.min, gp.min, total.min);
- printReportLine2(buffer, reportPattern, "max", cfp.max, csp.max, ssp.max, gp.max, total.max);
- printReportLine(buffer, reportPattern, "average", cfp.average, csp.average, ssp.average, gp.average, total.average);
- buffer.append(line);
+ buffer.append(line);
+ printReportLine2(buffer, reportPattern, "min", cfp.min, csp.min, ssp.min, gp.min, total.min);
+ printReportLine2(buffer, reportPattern, "max", cfp.max, csp.max, ssp.max, gp.max, total.max);
+ printReportLine(buffer, reportPattern, "average", cfp.average, csp.average, ssp.average, gp.average, total.average);
+ buffer.append(line);
+ }
cfp.clear();
csp.clear();
ssp.clear();
1
0
r1250 - in jaxx/trunk: jaxx-compiler-api jaxx-compiler-api/src/main/java/jaxx/compiler jaxx-compiler-api/src/main/java/jaxx/reflect jaxx-compiler-api/src/main/java/jaxx/tags maven-jaxx-plugin maven-jaxx-plugin/src/main/java/org/codelutin/jaxx
by tchemit@users.labs.libre-entreprise.org March 1, 2009
by tchemit@users.labs.libre-entreprise.org March 1, 2009
March 1, 2009
Author: tchemit
Date: 2009-03-01 12:52:04 +0000 (Sun, 01 Mar 2009)
New Revision: 1250
Added:
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXProfile.java
Modified:
jaxx/trunk/jaxx-compiler-api/changelog.txt
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/reflect/ClassDescriptorLoader.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/reflect/MethodDescriptor.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java
jaxx/trunk/maven-jaxx-plugin/changelog.txt
jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
Log:
add a profile mode
fix some bugs in ClassDescriptorLoader and MethodDescriptor
make possible to block $initialize method while internalContext is not set
Modified: jaxx/trunk/jaxx-compiler-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-02-25 16:18:04 UTC (rev 1249)
+++ jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-03-01 12:52:04 UTC (rev 1250)
@@ -1,4 +1,10 @@
1.3 ??? 200902??
+ * 20090229 [chemit] - fix bug in ClassDescriptorLoader when searching for an arrayof primitive type
+ - add a profile mode
+ * 20090228 [chemit] - fix bug in MethodDescriptor when no returnType defined (constructor method) in getReturnType method invocation
+ - generate default constructors only if none defined in script
+ - add primitive type void in ClassDescriptorLoader
+ - add a contextInitialized property in JAXX generated file to control JAXXContext initialization
* 20090225 [chemit] - add a mecanism to make possible injection of client properties
1.2 letellier 20090225 (release for isis)
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java 2009-02-25 16:18:04 UTC (rev 1249)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java 2009-03-01 12:52:04 UTC (rev 1250)
@@ -16,6 +16,7 @@
private boolean keepJavaFiles;
private boolean optimize;
private boolean verbose;
+ private boolean profile;
/** a flag to enable or disable i18n generation */
private boolean i18nable;
@@ -282,4 +283,13 @@
this.defaultDecoratorClass = defaultDecoratorClass;
}
+ public boolean isProfile() {
+ return profile;
+ }
+
+ public void setProfile(boolean profile) {
+ this.profile = profile;
+ }
+
+
}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-02-25 16:18:04 UTC (rev 1249)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-03-01 12:52:04 UTC (rev 1250)
@@ -24,17 +24,14 @@
protected static final Log log = LogFactory.getLog(JAXXCompilerLaunchor.class);
protected enum LifeCycle {
+
init,// state before compilation
compile_first_pass, // state when first pass of compilation
compile_second_pass, // state when second pass of compilation
stylesheet_pass, // state when applygin stylesheet phase after compilation
- generate_pass // state when generation phase
+ generate_pass, // state when generation phase
+ profile_pass // state when profile
}
-
- protected static final int PASS_1 = 0;
-
- protected static final int PASS_2 = 1;
-
/** shared instance of unique launchor at a givne time. */
protected static JAXXCompilerLaunchor singleton;
@@ -127,31 +124,24 @@
initializer.initialize();
}
}
-
/** options of the launchor and underlines compilers */
protected CompilerOptions options;
/** original list of files to compile */
protected final File[] files;
/** original list of classes to compile */
protected final String[] classNames;
-
/** Files to be treated while compilation. */
protected List<File> jaxxFiles = new ArrayList<File>();
-
/** Class names corresponding to the files in the jaxxFiles list. */
protected List<String> jaxxFileClassNames = new ArrayList<String>();
-
/** Maps the names of classes being compiled to the compiler instance handling the compilation. */
protected Map<String, JAXXCompiler> compilers = new HashMap<String, JAXXCompiler>();
-
/** Maps the names of classes being compiled to their symbol tables (created after the first compiler pass). */
protected Map<File, SymbolTable> symbolTables = new HashMap<File, SymbolTable>();
-
protected LifeCycle currentPass;
- //protected int currentPass;
-
protected int errorCount;
protected int warningCount;
+ protected JAXXProfile profiler;
protected JAXXCompilerLaunchor(File[] files, String[] classNames, CompilerOptions options) {
this.options = options == null ? new CompilerOptions() : options;
@@ -160,9 +150,11 @@
if (this.options.isVerbose()) {
log.info("files : " + Arrays.toString(files));
}
+ if (this.options.isProfile()) {
+ profiler = new JAXXProfile();
+ }
}
-
public void init() {
// forces static initializer to run if it hasn't yet
}
@@ -174,7 +166,9 @@
jaxxFileClassNames.clear();
symbolTables.clear();
compilers.clear();
- //CompiledObjectDecorator.reset();
+ if (profiler != null) {
+ profiler.clear();
+ }
}
public String getVersion() {
@@ -245,7 +239,9 @@
boolean success = true;
// pass 1
- currentPass = LifeCycle.compile_first_pass;
+ if (!nextStep(LifeCycle.compile_first_pass, success)) {
+ return false;
+ }
boolean compiled;
do {
compiled = false;
@@ -255,8 +251,8 @@
while (filesIterator.hasNext()) {
File file = filesIterator.next();
String className = classNamesIterator.next();
- if (options.isVerbose()) {
- log.info("compile first pass for " + className);
+ if (log.isDebugEnabled()) {
+ log.debug("compile first pass for " + className);
}
if (symbolTables.get(file) == null) {
compiled = true;
@@ -278,8 +274,10 @@
//destDir = file.getParentFile();
}
JAXXCompiler compiler = newCompiler(file.getParentFile(), file, className);
+ addProfileTime(compiler, currentPass.name() + "_start");
compilers.put(className, compiler);
compiler.compileFirstPass();
+ addProfileTime(compiler, currentPass.name() + "_end");
assert !symbolTables.values().contains(compiler.getSymbolTable()) : "symbolTable is already registered";
symbolTables.put(file, compiler.getSymbolTable());
if (compiler.isFailed()) {
@@ -289,34 +287,30 @@
}
} while (compiled);
- if (!success) {
- return report(false);
- }
// pass 2
- currentPass = LifeCycle.compile_second_pass;
+ if (!nextStep(LifeCycle.compile_second_pass, success)) {
+ return false;
+ }
assert jaxxFiles.size() == jaxxFileClassNames.size();
List<File> jaxxFilesClone = new ArrayList<File>(jaxxFiles);
for (String className : jaxxFileClassNames) {
- JAXXCompiler compiler = compilers.get(className);
- if (compiler == null) {
- throw new CompilerException("Internal error: could not find compiler for " + className + " during second pass");
+ JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during second pass");
+ addProfileTime(compiler, currentPass.name() + "_start");
+ if (log.isDebugEnabled()) {
+ log.debug("runInitializers for " + className);
}
- if (options.isVerbose()) {
-
- log.info("runInitializers for " + className);
- }
if (!compiler.isFailed()) {
compiler.runInitializers();
}
- if (options.isVerbose()) {
-
- log.info("compile second pass for " + className);
+ if (log.isDebugEnabled()) {
+ log.debug("compile second pass for " + className);
}
compiler.compileSecondPass();
- if (options.isVerbose()) {
- log.info("done with result [" + !compiler.isFailed() + "] for " + className);
+ addProfileTime(compiler, currentPass.name() + "_end");
+ if (log.isDebugEnabled()) {
+ log.debug("done with result [" + !compiler.isFailed() + "] for " + className);
}
if (compiler.isFailed()) {
success = false;
@@ -326,58 +320,61 @@
throw new AssertionError("Internal error: compilation set altered during pass 2 (was " + jaxxFilesClone + ", modified to " + jaxxFiles + ")");
}
- if (!success) {
- return report(false);
- }
-
// stylesheet application
- currentPass = LifeCycle.stylesheet_pass;
+ if (!nextStep(LifeCycle.stylesheet_pass, success)) {
+ return false;
+ }
assert jaxxFiles.size() == jaxxFileClassNames.size();
for (String className : jaxxFileClassNames) {
- JAXXCompiler compiler = compilers.get(className);
- if (compiler == null) {
- throw new CompilerException("Internal error: could not find compiler for " + className + " during stylesheet application");
- }
+ JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during stylesheet application");
+ addProfileTime(compiler, currentPass.name() + "_start");
compiler.applyStylesheets();
+ addProfileTime(compiler, currentPass.name() + "_end");
if (compiler.isFailed()) {
success = false;
}
}
- if (!success) {
- return report(false);
- }
// code generation
- currentPass = LifeCycle.generate_pass;
+ if (!nextStep(LifeCycle.generate_pass, success)) {
+ return false;
+ }
assert jaxxFiles.size() == jaxxFileClassNames.size();
List<Generator> generators = new ArrayList<Generator>();
for (Generator generator : ServiceLoader.load(Generator.class)) {
generators.add(generator);
}
for (String className : jaxxFileClassNames) {
- JAXXCompiler compiler = compilers.get(className);
- if (compiler == null) {
- throw new CompilerException("Internal error: could not find compiler for " + className + " during code generation");
- }
+ JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during code generation");
+ addProfileTime(compiler, currentPass.name() + "_start");
compiler.generateCode(generators);
+ addProfileTime(compiler, currentPass.name() + "_end");
//compiler.generateCode();
if (compiler.isFailed()) {
success = false;
}
}
+ if (options.isProfile()) {
+ // profile pass (only if succes compile)
+ if (!nextStep(LifeCycle.profile_pass, success)) {
+ return false;
+ }
+ StringBuilder buffer = profiler.computeProfileReport();
+ log.info(buffer.toString());
+ }
+
return report(success);
- }
- catch (CompilerException e) {
+
+ //FIXME : deal better the exception treatment...
+ } catch (CompilerException e) {
System.err.println(e.getMessage());
e.printStackTrace();
return false;
- }
- catch (Throwable e) {
+ } catch (Throwable e) {
e.printStackTrace();
return false;
- }
- finally {
+ } finally {
//TC - 20081018 only reset when no error was detected
if (options.isResetAfterCompile() && errorCount == 0) {
reset();
@@ -385,6 +382,22 @@
}
}
+ protected JAXXCompiler getCompiler(String className, String message) {
+ JAXXCompiler compiler = compilers.get(className);
+ if (compiler == null) {
+ throw new CompilerException(message);
+ }
+ return compiler;
+ }
+
+ protected boolean nextStep(LifeCycle nextCycle, boolean success) {
+ if (!success) {
+ return report(false);
+ }
+ currentPass = nextCycle;
+ return true;
+ }
+
protected boolean report(boolean success) {
if (warningCount == 1) {
System.err.println("1 warning");
@@ -404,6 +417,12 @@
return cons.newInstance(parentFile, file, className, options);
}
+ public static void addProfileTime(JAXXCompiler compiler, String key) {
+ JAXXProfile p = JAXXCompilerLaunchor.get().profiler;
+ if (p != null) {
+ p.addTime(compiler, key);
+ }
+ }
protected static void showUsage() {
System.out.println("Usage: jaxxc <options> <source files>");
@@ -422,68 +441,5 @@
System.out.println();
System.out.println("See http://www.jaxxframework.org/ for full documentation.");
}
-
- public static void main(String[] arg) throws Exception {
- //todo make this works again
- /*boolean success = true;
-
- CompilerOptions options = new CompilerOptions();
- List<String> files = new ArrayList<String>();
- for (int i = 0; i < arg.length; i++) {
- if (arg[i].endsWith(".jaxx")) {
- files.add(arg[i]);
- } else if (arg[i].equals("-d")) {
- if (++i < arg.length) {
- File targetDirectory = new File(arg[i]);
- if (!targetDirectory.exists()) {
- System.err.println("Error: could not find target directory: " + targetDirectory);
- errorCount++;
- success = false;
- }
- options.setTargetDirectory(targetDirectory);
- } else {
- success = false;
- }
- } else if (arg[i].equals("-cp") || arg[i].equals("-classpath")) {
- if (++i < arg.length) {
- options.setClassPath(arg[i]);
- } else {
- success = false;
- }
- } else if (arg[i].equals("-javac_opts")) {
- if (++i < arg.length) {
- options.setJavacOpts(arg[i]);
- } else {
- success = false;
- }
- } else if (arg[i].equals("-k") || arg[i].equals("-keep")) {
- options.setKeepJavaFiles(true);
- } else if (arg[i].equals("-j") || arg[i].equals("-java")) {
- options.setKeepJavaFiles(true);
- } else if (arg[i].equals("-o") || arg[i].equals("-optimize")) {
- options.setOptimize(true);
- } else if (arg[i].equals("-version")) {
- System.err.println("jaxxc version " + getVersion() + " by Ethan Nicholas");
- System.err.println("http://www.jaxxframework.org/");
- System.exit(0);
- } else if (arg[i].equals("-internalDumpVersion")) { // used by ant to extract the version info
- System.out.println("jaxx.version=" + getVersion());
- return;
- } else {
- success = false;
- }
- }
-
- success &= (errorCount == 0 && files.size() > 0);
-
- if (success) {
- success = compile(new File("."), files.toArray(new String[files.size()]), options);
- } else {
- showUsage();
- System.exit(1);
- }
-
- System.exit(success ? 0 : 1);*/
- }
-
+
}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-02-25 16:18:04 UTC (rev 1249)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-03-01 12:52:04 UTC (rev 1250)
@@ -4,6 +4,7 @@
import jaxx.CompilerException;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.reflect.FieldDescriptor;
import jaxx.reflect.MethodDescriptor;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
@@ -45,6 +46,9 @@
protected static final JavaField ALL_COMPONENTS_CREATED_FIELD = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
"boolean", "allComponentsCreated"
);
+ protected static final JavaField CONTEXT_INITIALIZED = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
+ "boolean", "contextInitialized","true"
+ );
protected static final JavaField PREVIOUS_VALUES_FIELD = JavaField.newField(0,
"java.util.Map", "$previousValues", "new java.util.HashMap()"
);
@@ -247,24 +251,46 @@
}
javaFile.addField(ALL_COMPONENTS_CREATED_FIELD);
+ boolean overrideContextInitialized = false;
+ FieldDescriptor[] scriptFields = compiler.getScriptFields();
+ for (FieldDescriptor f : scriptFields) {
+ if ("contextInitialized".equals(f.getName())) {
+ overrideContextInitialized=true;
+ break;
+ }
+ }
+ if (!overrideContextInitialized) {
+ javaFile.addField(CONTEXT_INITIALIZED);
+ }
javaFile.addField(createJAXXObjectDescriptorField(compiler, javaFile));
if (compiler.getStylesheet() != null) {
javaFile.addField(PREVIOUS_VALUES_FIELD);
}
-
/*for (CompiledObject object : compiler.getObjects().values()) {
- List<CompiledObject.ChildRef> refList = object.getChilds();
- if (refList==null || refList.isEmpty()) {
- continue;
+ List<CompiledObject.ChildRef> refList = object.getChilds();
+ if (refList==null || refList.isEmpty()) {
+ continue;
+ }
+ for (ChildRef childRef : refList) {
+ childRef.addToAdditionCode(buffer);
+ }
+ }*/
+ //TC 20090228 - only generate constructors if not done in scripts
+ boolean constructorDetected=false;
+ MethodDescriptor[] methods = compiler.getScriptMethods();
+ for (MethodDescriptor m : methods) {
+ m.getReturnType();
+ if (className.equals(m.getName())) {
+ constructorDetected=true;
+ break;
}
- for (ChildRef childRef : refList) {
- childRef.addToAdditionCode(buffer);
- }
- }*/
- javaFile.addMethod(createConstructor(compiler, className, superclassIsJAXXObject));
- javaFile.addMethod(createConstructorWithInitialContext(compiler, className, superclassIsJAXXObject));
-
+ }
+ if (!constructorDetected) {
+ javaFile.addMethod(createConstructor(compiler, className, superclassIsJAXXObject));
+ javaFile.addMethod(createConstructorWithInitialContext(compiler, className, superclassIsJAXXObject));
+ }
+
javaFile.addMethod(createInitializer(compiler));
javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD);
@@ -432,7 +458,7 @@
public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException {
StringBuffer code = new StringBuffer();
CompiledObject root = compiler.getRootObject();
- code.append("if (allComponentsCreated) {");
+ code.append("if (allComponentsCreated || !contextInitialized) {");
code.append(JAXXCompiler.getLineSeparator());
code.append(" return;");
code.append(JAXXCompiler.getLineSeparator());
Added: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXProfile.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXProfile.java (rev 0)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXProfile.java 2009-03-01 12:52:04 UTC (rev 1250)
@@ -0,0 +1,238 @@
+package jaxx.compiler;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.SortedMap;
+import jaxx.compiler.JAXXCompilerLaunchor.LifeCycle;
+import org.codelutin.util.StringUtil;
+
+/**
+ * Pour profiler les temps d'execution pendant une compilation.
+ *
+ * @author tony
+ * @since 1.3
+ */
+public class JAXXProfile {
+
+ void clear() {
+ entries.clear();
+ compilers.clear();
+ }
+
+ protected class CompilerEntry {
+
+ JAXXCompiler compiler;
+ SortedMap<String, Long> times;
+
+ public CompilerEntry(JAXXCompiler compiler) {
+ this.compiler = compiler;
+ times = new java.util.TreeMap<String, Long>();
+ }
+ }
+
+ public static class ProfileResult {
+
+ long min, max, average, total;
+ Map<JAXXCompiler, Long> delta;
+ List<Long> times;
+
+ ProfileResult(String label, Map<JAXXCompiler, Long> delta) {
+ this.delta = delta;
+ times = new java.util.ArrayList<Long>(delta.values());
+ java.util.Collections.sort(times);
+ min = times.get(0);
+ max = times.get(times.size() - 1);
+ total = 0;
+ average = 0;
+ for (Long t : times) {
+ total += t;
+ }
+ average = total / times.size();
+ }
+
+ public long getTime(JAXXCompiler compiler) {
+ for (Entry<JAXXCompiler, Long> entry : delta.entrySet()) {
+ if (entry.getKey().equals(compiler)) {
+ return entry.getValue();
+ }
+ }
+ throw new IllegalArgumentException("could not find time for compiler " + compiler);
+ }
+
+ public void clear() {
+ times.clear();
+ delta.clear();
+ }
+
+ public JAXXCompiler getCompiler(Long l) {
+ for (Entry<JAXXCompiler, Long> entry : delta.entrySet()) {
+ if (entry.getValue().equals(l)) {
+ return entry.getKey();
+ }
+ }
+ throw new IllegalArgumentException("could not find compiler for time " + l);
+ }
+ }
+ SortedMap<Integer, CompilerEntry> entries;
+ List<JAXXCompiler> compilers;
+
+ public JAXXProfile() {
+ compilers = new java.util.ArrayList<JAXXCompiler>();
+ entries = new java.util.TreeMap<Integer, CompilerEntry>();
+ }
+
+ public void addTime(JAXXCompiler compiler, String key) {
+ CompilerEntry e = getEntry(compiler);
+ e.times.put(key, System.nanoTime());
+ }
+
+ public Map<JAXXCompiler, Long> getDelta(String label, String keyOne, String keyTwo) {
+ Map<JAXXCompiler, Long> result = new java.util.HashMap<JAXXCompiler, Long>();
+ for (java.util.Map.Entry<Integer, CompilerEntry> e : entries.entrySet()) {
+ JAXXCompiler c = getCompiler(e.getKey());
+ CompilerEntry entry = e.getValue();
+ Long t0 = entry.times.get(keyOne);
+ Long t1 = entry.times.get(keyTwo);
+ if (t0 == null) {
+ throw new NullPointerException("could not find time for " + keyOne + " on compiler " + c.getOutputClassName());
+ }
+ if (t1 == null) {
+ throw new NullPointerException("could not find time for " + keyTwo + " on compiler " + c.getOutputClassName());
+ }
+ long delta = t1 - t0;
+ result.put(c, delta);
+ }
+ return result;
+ }
+
+ public ProfileResult newProfileResult(LifeCycle step) {
+ ProfileResult result;
+ String name = step.name();
+ Map<JAXXCompiler, Long> delta = getDelta(name, name + "_start", name + "_end");
+ result = new ProfileResult(name, delta);
+ return result;
+ }
+
+ public ProfileResult newProfileResult(ProfileResult... toCumul) {
+ ProfileResult result;
+ Map<JAXXCompiler, Long> delta = new java.util.HashMap<JAXXCompiler, Long>();
+ for (JAXXCompiler c : compilers) {
+ long total = 0;
+ for (ProfileResult cumul : toCumul) {
+ long time = cumul.getTime(c);
+ total += time;
+ }
+ delta.put(c, total);
+ }
+ result = new ProfileResult("all", delta);
+ return result;
+ }
+
+ public StringBuilder computeProfileReport() {
+
+ StringBuilder buffer = new StringBuilder();
+
+ if (compilers.isEmpty()) {
+ return buffer.append("no jaxx file treated, no profile report");
+ }
+
+ // compute max size of the fqn of a compiled file
+ int maxLength = 0;
+ for (JAXXCompiler compiler : compilers) {
+ int l = compiler.getOutputClassName().length();
+ if (l > maxLength) {
+ maxLength = l;
+ }
+ }
+
+ ProfileResult cfp = newProfileResult(LifeCycle.compile_first_pass);
+ ProfileResult csp = newProfileResult(LifeCycle.compile_second_pass);
+ ProfileResult ssp = newProfileResult(LifeCycle.stylesheet_pass);
+ ProfileResult gp = newProfileResult(LifeCycle.generate_pass);
+ ProfileResult total = newProfileResult(cfp, csp, ssp, gp);
+
+ String reportPattern = "\n|%1$-" + maxLength + "s|%2$15s|%3$15s|%4$15s|%5$15s|%6$15s|";
+
+ char[] tmpC = new char[maxLength];
+ Arrays.fill(tmpC, '-');
+ String line = String.format(reportPattern,
+ new String(tmpC),
+ "---------------",
+ "---------------",
+ "---------------",
+ "---------------",
+ "---------------");
+
+ buffer.append(line);
+
+ buffer.append(String.format(reportPattern,
+ "(files / stats) \\ passes",
+ "compile round 1", "compile round 2", "stylesheet", "generation", "all passes"));
+
+ buffer.append(line);
+
+ // affiche les temps de tous les fichiers en temp total croissant
+ for (Long l : total.times) {
+ JAXXCompiler c = total.getCompiler(l);
+ printReportLine(buffer, reportPattern, c.getOutputClassName(), cfp.getTime(c), csp.getTime(c), ssp.getTime(c), gp.getTime(c), total.getTime(c));
+ }
+
+ buffer.append(line);
+
+ printReportLine(buffer, reportPattern, "total (" + compilers.size() + " files)", cfp.total, csp.total, ssp.total, gp.total, total.total);
+
+ buffer.append(line);
+ printReportLine2(buffer, reportPattern, "min", cfp.min, csp.min, ssp.min, gp.min, total.min);
+ printReportLine2(buffer, reportPattern, "max", cfp.max, csp.max, ssp.max, gp.max, total.max);
+ printReportLine(buffer, reportPattern, "average", cfp.average, csp.average, ssp.average, gp.average, total.average);
+ buffer.append(line);
+
+ cfp.clear();
+ csp.clear();
+ ssp.clear();
+ gp.clear();
+ total.clear();
+
+ return buffer;
+ }
+ public static final String TIME_PATTERN = "%1$9s - %2$2d%%";
+
+ protected void printReportLine(StringBuilder buffer, String reportPattern, String label, long firstPassCounter, long secondPassCounter, long cssCounter, long generatorCounter, long totalCounter) {
+ float percentCFP = ((float) firstPassCounter / totalCounter) * 100;
+ float percentCSP = ((float) secondPassCounter / totalCounter) * 100;
+ float percentCSSP = ((float) cssCounter / totalCounter) * 100;
+ float percentGP = ((float) generatorCounter / totalCounter) * 100;
+ String strCFP = String.format(TIME_PATTERN, StringUtil.convertTime(firstPassCounter), (int) percentCFP);
+ String strCSP = String.format(TIME_PATTERN, StringUtil.convertTime(secondPassCounter), (int) percentCSP);
+ String strCSSP = String.format(TIME_PATTERN, StringUtil.convertTime(cssCounter), (int) percentCSSP);
+ String strGP = String.format(TIME_PATTERN, StringUtil.convertTime(generatorCounter), (int) percentGP);
+
+ buffer.append(String.format(reportPattern, label, strCFP, strCSP, strCSSP, strGP, StringUtil.convertTime(totalCounter)));
+ }
+
+ protected void printReportLine2(StringBuilder buffer, String reportPattern, String label, long firstPassCounter, long secondPassCounter, long cssCounter, long generatorCounter, long totalCounter) {
+ buffer.append(String.format(reportPattern, label, StringUtil.convertTime(firstPassCounter), StringUtil.convertTime(secondPassCounter), StringUtil.convertTime(cssCounter), StringUtil.convertTime(generatorCounter), StringUtil.convertTime(totalCounter)));
+ }
+
+ protected CompilerEntry getEntry(JAXXCompiler compiler) {
+ int key = compiler.getOutputClassName().hashCode();
+ CompilerEntry result = entries.get(key);
+ if (result == null) {
+ result = new CompilerEntry(compiler);
+ entries.put(key, result);
+ compilers.add(compiler);
+ }
+ return result;
+ }
+
+ protected JAXXCompiler getCompiler(int hasCode) {
+ for (JAXXCompiler c : compilers) {
+ if (hasCode == c.getOutputClassName().hashCode()) {
+ return c;
+ }
+ }
+ return null;
+ }
+}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/reflect/ClassDescriptorLoader.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/reflect/ClassDescriptorLoader.java 2009-02-25 16:18:04 UTC (rev 1249)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/reflect/ClassDescriptorLoader.java 2009-03-01 12:52:04 UTC (rev 1250)
@@ -121,8 +121,39 @@
}
}
- public static Class getClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ public static Class getPrimitiveBoxedClass(String className) throws ClassNotFoundException {
if (className.equals("boolean")) {
+ return Boolean.class;
+ }
+ if (className.equals("byte")) {
+ return Byte.class;
+ }
+ if (className.equals("short")) {
+ return Short.class;
+ }
+ if (className.equals("int")) {
+ return Integer.class;
+ }
+ if (className.equals("long")) {
+ return Long.class;
+ }
+ if (className.equals("float")) {
+ return Float.class;
+ }
+ if (className.equals("double")) {
+ return Double.class;
+ }
+ if (className.equals("char")) {
+ return Character.class;
+ }
+ if (className.equals("void")) {
+ return Void.class;
+ }
+ return null;
+ }
+
+ public static Class getPrimitiveClass(String className) throws ClassNotFoundException {
+ if (className.equals("boolean")) {
return boolean.class;
}
if (className.equals("byte")) {
@@ -146,18 +177,57 @@
if (className.equals("char")) {
return char.class;
}
+ if (className.equals("void")) {
+ return void.class;
+ }
+ // detect arrays
int arrayCount = 0;
while (className.endsWith("[]")) {
arrayCount++;
className = className.substring(0, className.length() - 2);
}
+ Class klass=null;
if (arrayCount > 0) {
+ klass = getPrimitiveClass(className);
+ if (klass==null) {
+ // none primitive array
+ return null;
+ }
+ // must take the boxed class, other it does not works
+ // to make a Class.forName("[Lchar;"); but works
+ // with Class.forName("[LCharacter;"); ...
+ klass =getPrimitiveBoxedClass(className);
+ className=klass.getName();
+
className = "L" + className + ";";
while (arrayCount > 0) {
className = "[" + className;
arrayCount--;
}
+ System.out.println("primitive array class "+className);
+ return Class.forName(className);
}
+ return null;
+ }
+
+ public static Class getClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ Class klass = getPrimitiveClass(className);
+ if (klass!=null) {
+ return klass;
+ }
+ // try an array of none primitive classes
+ int arrayCount = 0;
+ while (className.endsWith("[]")) {
+ arrayCount++;
+ className = className.substring(0, className.length() - 2);
+ }
+ if (arrayCount > 0) {
+ className = "L" + className + ";";
+ while (arrayCount > 0) {
+ className = "[" + className;
+ arrayCount--;
+ }
+ }
try {
return classLoader != null ? Class.forName(className, true, classLoader) : Class.forName(className);
} catch (ClassNotFoundException e) {
@@ -185,7 +255,6 @@
}
}
-
private static MethodDescriptor createMethodDescriptor(Method javaMethod, ClassLoader classLoader) {
String methodName = javaMethod.getName();
int modifiers = javaMethod.getModifiers();
@@ -206,7 +275,6 @@
return new FieldDescriptor(fieldName, modifiers, type, classLoader);
}
-
private static JAXXObjectDescriptor getJAXXObjectDescriptor(Class<?> jaxxClass) {
if (!JAXXObject.class.isAssignableFrom(jaxxClass) || jaxxClass == JAXXObject.class) {
return null;
@@ -226,7 +294,6 @@
}
}
-
private static ClassDescriptor createClassDescriptorFromJavaSource(URL javaSource, ClassLoader classLoader) throws ClassNotFoundException {
try {
InputStream in = javaSource.openStream();
@@ -240,7 +307,6 @@
}
}
-
private static ClassDescriptor createClassDescriptorFromSymbolTable(String className, ClassLoader classLoader) throws ClassNotFoundException {
final JAXXCompiler compiler = JAXXCompilerLaunchor.get().getJAXXCompiler(className);
final SymbolTable symbolTable = JAXXCompilerLaunchor.get().getSymbolTable(className);
@@ -280,6 +346,7 @@
(String[]) interfaces.toArray(new String[interfaces.size()]), false, false, null, null, classLoader,
(MethodDescriptor[]) publicMethods.toArray(new MethodDescriptor[publicMethods.size()]),
(FieldDescriptor[]) publicFields.toArray(new FieldDescriptor[publicFields.size()])) {
+ @Override
public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException {
String type = symbolTable.getClassTagIds().get(name);
if (type != null) {
@@ -288,7 +355,7 @@
throw new NoSuchFieldException(name);
}
-
+ @Override
public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException {
throw new NoSuchMethodException(name);
}
@@ -328,10 +395,12 @@
fields[i] = createFieldDescriptor(javaFields[i], javaClass.getClassLoader());
}
return new ClassDescriptor(name, packageName, superclassName, interfaceNames, isInterface, isArray, componentTypeName, jaxxObjectDescriptor, classLoader, methods, fields) {
+ @Override
public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException {
return createFieldDescriptor(javaClass.getDeclaredField(name), javaClass.getClassLoader());
}
+ @Override
public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException {
try {
Class[] parameterTypeClasses = new Class[parameterTypes.length];
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/reflect/MethodDescriptor.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/reflect/MethodDescriptor.java 2009-02-25 16:18:04 UTC (rev 1249)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/reflect/MethodDescriptor.java 2009-03-01 12:52:04 UTC (rev 1250)
@@ -24,11 +24,15 @@
public ClassDescriptor getReturnType() {
- try {
+ try {
+ //TC 20090228 : fix bug when no return type defined (constructor method)
+ if (returnType == null) {
+ return null;
+ }
return ClassDescriptorLoader.getClassDescriptor(returnType);
}
catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
+ throw new RuntimeException("could not find return type " + returnType, e);
}
}
@@ -44,7 +48,7 @@
return result;
}
catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
+ throw new RuntimeException("could not find the parameter types " + java.util.Arrays.toString(parameterTypes), e);
}
}
}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-02-25 16:18:04 UTC (rev 1249)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-03-01 12:52:04 UTC (rev 1250)
@@ -268,6 +268,7 @@
* @throws IllegalArgumentException if the property is an enumeration, but the value is not valid
* @throws NumberFormatException if the property is not an enumeration
*/
+ @Override
protected int constantValue(String key, String value) {
if ((key.equals("mnemonic") || key.equals("displayedMnemonic"))) {
if (value.length() == 1) {
Modified: jaxx/trunk/maven-jaxx-plugin/changelog.txt
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-02-25 16:18:04 UTC (rev 1249)
+++ jaxx/trunk/maven-jaxx-plugin/changelog.txt 2009-03-01 12:52:04 UTC (rev 1250)
@@ -1,3 +1,8 @@
+1.3 ??? 200903??
+ * 20090301 [chemit] - add a profile mode (-Djaxx.profile)
+
+1.2 letelier 2009022?
+
1.1 chemit 20090220
* 20090203 [chemit] - mojo's property src is now by default in src/main/java
* 20090202 [chemit] - introduce a property validatorClass to specify the validator implementation
Modified: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-02-25 16:18:04 UTC (rev 1249)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-03-01 12:52:04 UTC (rev 1250)
@@ -256,6 +256,14 @@
* @parameter expression="${jaxx.useUIManagerForIcon}" default-value="false"
*/
protected boolean useUIManagerForIcon;
+ /**
+ * flag to activate profile mode.
+ * <p/>
+ * By default, not active.
+ *
+ * @parameter expression="${jaxx.profile}" default-value="false"
+ */
+ protected boolean profile;
protected String[] files;
@@ -377,6 +385,7 @@
result.setVerbose(verbose);
result.setI18nable(i18nable);
result.setAddLogger(addLogger);
+ result.setProfile(profile);
result.setResetAfterCompile(resetAfterCompile);
result.setJaxxContextImplementorClass(jaxxContextImplementorClass);
result.setExtraImports(extraImports);
@@ -431,18 +440,21 @@
JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, options);
if (!launchor.compile()) {
- throw new MojoFailureException("Aborting due to errors reported by jaxxc");
+ throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
}
+ } catch (MojoExecutionException e) {
+ getLog().error(e);
+ throw e;
} catch (Exception e) {
- getLog().error(e);
+ //getLog().error(e);
Throwable e2 = e;
while (e2.getCause() != null) {
e2 = e.getCause();
}
getLog().error(e2);
- throw new MojoExecutionException(e.getMessage(), e);
+ throw new MojoExecutionException(e2.getMessage(), e2);
}
}
1
0
r1249 - jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime
by tchemit@users.labs.libre-entreprise.org Feb. 25, 2009
by tchemit@users.labs.libre-entreprise.org Feb. 25, 2009
Feb. 25, 2009
Author: tchemit
Date: 2009-02-25 16:18:04 +0000 (Wed, 25 Feb 2009)
New Revision: 1249
Modified:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
Log:
fix NPE
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-02-25 14:17:29 UTC (rev 1248)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-02-25 16:18:04 UTC (rev 1249)
@@ -176,6 +176,10 @@
public static List<JComponent> getLayeredComponents(JAXXObject object) {
List<JComponent> result = new ArrayList<JComponent>();
for (Entry<String, Object> child : object.get$objectMap().entrySet()) {
+ if (child.getValue() == null) {
+ log.warn("find a null object in $objectMap " + child.getKey());
+ continue;
+ }
if (JComponent.class.isAssignableFrom(child.getValue().getClass())) {
JComponent comp = (JComponent) child.getValue();
if (isLayered(comp)) {
1
0
r1248 - in jaxx/trunk: jaxx-compiler-api jaxx-compiler-api/src/main/java/jaxx/tags jaxx-example/src/main/java/jaxx/demo maven-jaxx-plugin/src/test/java/org/codelutin/jaxx maven-jaxx-plugin/src/test/resources/testcases maven-jaxx-plugin/src/test/resources/testcases/clientProperty
by tchemit@users.labs.libre-entreprise.org Feb. 25, 2009
by tchemit@users.labs.libre-entreprise.org Feb. 25, 2009
Feb. 25, 2009
Author: tchemit
Date: 2009-02-25 14:17:29 +0000 (Wed, 25 Feb 2009)
New Revision: 1248
Added:
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClientProperty.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/clientProperty/
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/clientProperty/TestOne.jaxx
Modified:
jaxx/trunk/jaxx-compiler-api/changelog.txt
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java
Log:
add a mecanism to make possible injection of client properties
Modified: jaxx/trunk/jaxx-compiler-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-02-25 09:55:48 UTC (rev 1247)
+++ jaxx/trunk/jaxx-compiler-api/changelog.txt 2009-02-25 14:17:29 UTC (rev 1248)
@@ -1,3 +1,8 @@
+1.3 ??? 200902??
+ * 20090225 [chemit] - add a mecanism to make possible injection of client properties
+
+1.2 letellier 20090225 (release for isis)
+
1.1 chemit 20090220
* 20090202 [chemit] - can now generate abstract and generic classes
* 20090202 [chemit] - introduce a property validatorFQN in CompilerOptions to specify the validator implementation
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-02-25 09:55:48 UTC (rev 1247)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultComponentHandler.java 2009-02-25 14:17:29 UTC (rev 1248)
@@ -23,11 +23,13 @@
import java.beans.IntrospectionException;
import java.io.IOException;
import java.lang.reflect.Field;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
public class DefaultComponentHandler extends DefaultObjectHandler {
+
/** log */
protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class);
-
private String containerDelegate;
public DefaultComponentHandler(ClassDescriptor beanClass) {
@@ -83,7 +85,6 @@
closeComponent(compiler.getOpenComponent(), tag, compiler);
}
-
protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
String constraints = tag.getAttribute("constraints");
if (constraints != null && constraints.length() > 0) {
@@ -197,6 +198,15 @@
@Override
public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) {
+
+ if (propertyName.startsWith("_")) {
+ // client property
+ if (stringValue.startsWith("{")) {
+ stringValue = stringValue.substring(1, stringValue.length() - 1);
+ }
+ object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + propertyName.substring(1) + "\", " + stringValue + ");");
+ return;
+ }
if ("icon".equals(propertyName)) {
if (!(stringValue.startsWith("{") || stringValue.endsWith("}"))) {
// this is a customized icon, add the icon creation code
@@ -223,6 +233,27 @@
super.setAttribute(object, propertyName, stringValue, inline, compiler);
}
+ @Override
+ protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler) {
+ super.scanAttributesForDependencies(tag, compiler);
+ // check for clientProperty attributes
+ //FIXME make this works,... it seems jaxx compiler does not come here ?
+ //FIXME see the the firstPassHandler in JAXXCompiler ?
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0, max = children.getLength(); i < max; i++) {
+ Attr attr = (Attr) children.item(i);
+ String name = attr.getName();
+ if (!name.startsWith("_")) {
+ continue;
+ }
+ String value = attr.getValue();
+ if (value.startsWith("{")) {
+ compiler.reportWarning(tag, "an clientProperty attribute " + name.substring(1) + " does not required curly value but was : " + value, 0);
+ }
+ }
+
+ }
+
/**
* Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For
* example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and
@@ -254,7 +285,6 @@
return super.constantValue(key, value);
}
-
/**
* Returns <code>true</code> if this component can contain other components. For children to be
* allowed, the component must be a subclass of <code>Container</code> and its <code>JAXXBeanInfo</code>
@@ -277,7 +307,6 @@
return container;
}
-
public String getContainerDelegate() {
try {
init();
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-02-25 09:55:48 UTC (rev 1247)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-02-25 14:17:29 UTC (rev 1248)
@@ -21,7 +21,8 @@
protected void accept(ActionEvent e, String suffix) {
JButton source = (JButton) e.getSource();
- String msg = "'" + source.getText() + "' clicked - " + suffix;
+ String clickedMessage = (String) source.getClientProperty("clickedText");
+ String msg = "'" + source.getText() + "' clicked - " + suffix + " : " + clickedMessage;
((DefaultListModel)messages.getModel()).addElement(msg);
}]]>
</script>
@@ -36,11 +37,11 @@
<row>
<cell weighty='0.5'>
<JPanel layout='{new GridLayout(1,3,3,3)}'>
- <JButton text='button A' decorator='boxed'
+ <JButton text='button A' decorator='boxed' _clickedText='"button A was clicked"'
onActionPerformed='accept(event, "from button (no layer)")'/>
- <JButton text='button B' decorator='boxed'
+ <JButton text='button B' decorator='boxed' _clickedText='"button B was clicked"'
onActionPerformed='accept(event, "from button (no layer)")'/>
- <JButton text='button C' decorator='boxed'
+ <JButton text='button C' decorator='boxed' _clickedText='"button C was clicked"'
onActionPerformed='accept(event, "from button (no layer)");'/>
</JPanel>
</cell>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2009-02-25 09:55:48 UTC (rev 1247)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/CompilerTest.java 2009-02-25 14:17:29 UTC (rev 1248)
@@ -33,6 +33,12 @@
checkPattern(mojo, ".getUIManagerActionIcon(\"myActionIcon.png\")", true);
}
+ public void testClientProperty() throws Exception {
+ mojo.execute();
+ checkPattern(mojo, ".putClientProperty(\"testOne\", \"oneTest\")", true);
+ checkPattern(mojo, ".putClientProperty(\"testTwo\", \"anotherTest\")", true);
+ }
+
public void testSpecialSubclassing() throws Exception {
mojo.execute();
assertNumberJaxxFiles(7);
@@ -81,6 +87,7 @@
assertNumberJaxxFiles(34);
mojo.setLog(new SystemStreamLog() {
+
@Override
public boolean isErrorEnabled() {
return false;
Added: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClientProperty.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClientProperty.xml (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClientProperty.xml 2009-02-25 14:17:29 UTC (rev 1248)
@@ -0,0 +1,23 @@
+<?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">
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <configuration>
+ <src>${basedir}/src/test/resources</src>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <force>true</force>
+ <addLogger>false</addLogger>
+ <includes>
+ <value>**/clientProperty/*.jaxx</value>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/clientProperty/TestOne.jaxx
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/clientProperty/TestOne.jaxx (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/clientProperty/TestOne.jaxx 2009-02-25 14:17:29 UTC (rev 1248)
@@ -0,0 +1,3 @@
+<JPanel id='root'>
+ <JButton id='boxedButton' _testOne='"oneTest"' _testTwo='{"anotherTest"}'/>
+</JPanel>
1
0
r1247 - in jaxx/trunk: . jaxx-compiler-api jaxx-compiler-swing jaxx-compiler-validator jaxx-example jaxx-runtime-api jaxx-runtime-swing jaxx-runtime-validator jaxx-runtime-validator-swing jaxx-swing-action maven-jaxx-plugin
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
Feb. 25, 2009
Author: sletellier
Date: 2009-02-25 09:55:48 +0000 (Wed, 25 Feb 2009)
New Revision: 1247
Modified:
jaxx/trunk/jaxx-compiler-api/pom.xml
jaxx/trunk/jaxx-compiler-swing/pom.xml
jaxx/trunk/jaxx-compiler-validator/pom.xml
jaxx/trunk/jaxx-example/pom.xml
jaxx/trunk/jaxx-runtime-api/pom.xml
jaxx/trunk/jaxx-runtime-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator/pom.xml
jaxx/trunk/jaxx-swing-action/pom.xml
jaxx/trunk/maven-jaxx-plugin/pom.xml
jaxx/trunk/pom.xml
Log:
[maven-release-plugin] prepare for next development iteration
Modified: jaxx/trunk/jaxx-compiler-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-api/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/jaxx-compiler-api/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -44,8 +44,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-compiler-api</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-compiler-api</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-compiler-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -50,8 +50,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-compiler-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-compiler-swing</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-compiler-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -56,8 +56,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-compiler-validator</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-compiler-validator</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/jaxx-example/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -147,9 +147,9 @@
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-example</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-example</developerConnection>
</scm>
<profiles>
Modified: jaxx/trunk/jaxx-runtime-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-api/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/jaxx-runtime-api/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -57,8 +57,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-api</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-api</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -44,8 +44,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-swing</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -51,8 +51,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-validator</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-validator</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -44,8 +44,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-validator-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-runtime-validator-swing</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -11,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -81,9 +81,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/jaxx…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-swing-action</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/jaxx-swing-action</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -134,9 +134,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/mave…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/maven-jaxx-plugin</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk/maven-jaxx-plugin</developerConnection>
</scm>
</project>
\ No newline at end of file
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
+++ jaxx/trunk/pom.xml 2009-02-25 09:55:48 UTC (rev 1247)
@@ -14,7 +14,7 @@
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.3-SNAPSHOT</version>
<modules>
<module>jaxx-runtime-api</module>
@@ -202,9 +202,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</connection>
- <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</developerConnection>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/trunk</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/trunk/?roo…</url>
</scm>
<!-- Maven Environment : Repositories -->
1
0
r1246 - in jaxx/tags: . jaxx-1.2 jaxx-1.2/jaxx-compiler-api jaxx-1.2/jaxx-compiler-swing jaxx-1.2/jaxx-compiler-validator jaxx-1.2/jaxx-example jaxx-1.2/jaxx-runtime-api jaxx-1.2/jaxx-runtime-swing jaxx-1.2/jaxx-runtime-validator jaxx-1.2/jaxx-runtime-validator-swing jaxx-1.2/jaxx-swing-action jaxx-1.2/maven-jaxx-plugin
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
Feb. 25, 2009
Author: sletellier
Date: 2009-02-25 09:55:41 +0000 (Wed, 25 Feb 2009)
New Revision: 1246
Added:
jaxx/tags/jaxx-1.2/
jaxx/tags/jaxx-1.2/jaxx-compiler-api/pom.xml
jaxx/tags/jaxx-1.2/jaxx-compiler-swing/pom.xml
jaxx/tags/jaxx-1.2/jaxx-compiler-validator/pom.xml
jaxx/tags/jaxx-1.2/jaxx-example/pom.xml
jaxx/tags/jaxx-1.2/jaxx-runtime-api/pom.xml
jaxx/tags/jaxx-1.2/jaxx-runtime-swing/pom.xml
jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing/pom.xml
jaxx/tags/jaxx-1.2/jaxx-runtime-validator/pom.xml
jaxx/tags/jaxx-1.2/jaxx-swing-action/pom.xml
jaxx/tags/jaxx-1.2/maven-jaxx-plugin/pom.xml
jaxx/tags/jaxx-1.2/pom.xml
Removed:
jaxx/tags/jaxx-1.2/jaxx-compiler-api/pom.xml
jaxx/tags/jaxx-1.2/jaxx-compiler-swing/pom.xml
jaxx/tags/jaxx-1.2/jaxx-compiler-validator/pom.xml
jaxx/tags/jaxx-1.2/jaxx-example/pom.xml
jaxx/tags/jaxx-1.2/jaxx-runtime-api/pom.xml
jaxx/tags/jaxx-1.2/jaxx-runtime-swing/pom.xml
jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing/pom.xml
jaxx/tags/jaxx-1.2/jaxx-runtime-validator/pom.xml
jaxx/tags/jaxx-1.2/jaxx-swing-action/pom.xml
jaxx/tags/jaxx-1.2/maven-jaxx-plugin/pom.xml
jaxx/tags/jaxx-1.2/pom.xml
Log:
[maven-release-plugin] copy for tag jaxx-1.2
Copied: jaxx/tags/jaxx-1.2 (from rev 1242, jaxx/trunk)
Deleted: jaxx/tags/jaxx-1.2/jaxx-compiler-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-api/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/jaxx-compiler-api/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,52 +0,0 @@
-<?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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-compiler-api</artifactId>
-
- <dependencies>
-
- <!-- sibling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx compiler api</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
- <packaging>jar</packaging>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-</project>
Copied: jaxx/tags/jaxx-1.2/jaxx-compiler-api/pom.xml (from rev 1245, jaxx/trunk/jaxx-compiler-api/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/jaxx-compiler-api/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/jaxx-compiler-api/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,51 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-compiler-api</artifactId>
+
+ <dependencies>
+
+ <!-- sibling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx compiler api</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</developerConnection>
+ </scm>
+</project>
Deleted: jaxx/tags/jaxx-1.2/jaxx-compiler-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/jaxx-compiler-swing/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,58 +0,0 @@
-<?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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-compiler-swing</artifactId>
-
- <dependencies>
-
- <!-- sibling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-compiler-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx compiler swing extension</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
- <packaging>jar</packaging>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-</project>
Copied: jaxx/tags/jaxx-1.2/jaxx-compiler-swing/pom.xml (from rev 1245, jaxx/trunk/jaxx-compiler-swing/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/jaxx-compiler-swing/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/jaxx-compiler-swing/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,57 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-compiler-swing</artifactId>
+
+ <dependencies>
+
+ <!-- sibling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-compiler-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx compiler swing extension</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</developerConnection>
+ </scm>
+</project>
Deleted: jaxx/tags/jaxx-1.2/jaxx-compiler-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/jaxx-compiler-validator/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,64 +0,0 @@
-<?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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-compiler-validator</artifactId>
-
- <dependencies>
-
- <!-- sibling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-validator</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-validator-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-compiler-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx compiler validation extension</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
- <packaging>jar</packaging>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-</project>
Copied: jaxx/tags/jaxx-1.2/jaxx-compiler-validator/pom.xml (from rev 1245, jaxx/trunk/jaxx-compiler-validator/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/jaxx-compiler-validator/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/jaxx-compiler-validator/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,63 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-compiler-validator</artifactId>
+
+ <dependencies>
+
+ <!-- sibling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-validator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-validator-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-compiler-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx compiler validation extension</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</developerConnection>
+ </scm>
+</project>
Deleted: jaxx/tags/jaxx-1.2/jaxx-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/jaxx-example/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,290 +0,0 @@
-<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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-example</artifactId>
-
- <dependencies>
-
- <!-- sibiling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-validator-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx Examples</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
-
- <packaging>jar</packaging>
-
- <properties>
-
- <maven.jar.main.class>jaxx.demo.JAXXDemo</maven.jar.main.class>
-
- <!-- jnlp -->
- <keystorepath>${codelutin.keystorepath}</keystorepath>
- <keystorealias>CodeLutin</keystorealias>
- <keystorepass>codelutin</keystorepass>
-
- <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory>
-
- </properties>
-
- <build>
-
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*.jaxx</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- </resources>
-
- <pluginManagement>
- <plugins>
-
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>./lib/</classpathPrefix>
- </manifest>
- </archive>
- </configuration>
- </plugin>
-
- </plugins>
-
- </pluginManagement>
-
- <plugins>
-
- <plugin>
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>maven-jaxx-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <configuration>
- <entries>
- <entry>
- <basedir>${maven.gen.dir}/java/</basedir>
- <includes>
- <param>**\/**.java</param>
- </includes>
- </entry>
- </entries>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>parserJava</goal>
- <goal>gen</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <artifactId>maven-dependency-plugin</artifactId>
- <configuration>
- <outputDirectory>${project.build.directory}/lib</outputDirectory>
- </configuration>
- </plugin>
-
- </plugins>
- </build>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
-
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-
- <profiles>
- <!-- by default jnlp is only perform on a release stage when using the maven-release-plugin -->
- <profile>
- <id>release-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
-
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
- <execution>
- <id>JnlpSun</id>
- <phase>verify</phase>
- <configuration>
- <tasks>
- <mkdir dir="${jnlp.build.directory}"/>
- <copy file="${project.basedir}/src/main/jnlp/sun.jnlp"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}"
- failonerror="false">
- <filterset>
- <filter token="lib" value="javahelp-2.0.02.jar"/>
- <filter token="url" value="${project.url}"/>
- </filterset>
- </copy>
- <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}"
- failonerror="false">
- <filterset>
- <filter token="lib" value="jxlayer-3.0.1.jar"/>
- <filter token="url" value="${project.url}"/>
- </filterset>
- </copy>
- <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib"
- failonerror="false"/>
- <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib"
- failonerror="false"/>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
-
- <execution>
- <id>JnlpToSite</id>
- <phase>pre-site</phase>
- <configuration>
- <tasks>
- <mkdir dir="${maven.site.gen.dir}/resources"/>
- <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}"
- failonerror="false" overwrite="false">
- <fileset dir="${jnlp.build.directory}">
- <include name="**"/>
- </fileset>
- </copy>
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo.webstart</groupId>
- <artifactId>webstart-maven-plugin</artifactId>
- <version>1.0-alpha-2-cl_20081018</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>jnlp-inline</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <force>false</force>
- <dependencies>
- <excludes>
- <exclude>javax.help:javahelp</exclude>
- <exclude>org.swinglabs:jxlayer</exclude>
- </excludes>
- </dependencies>
- <libPath>lib</libPath>
- <extensions>
- <sun>sun.jnlp</sun>
- <jxlayer>jxlayer.jnlp</jxlayer>
- </extensions>
- <jnlp>
- <outputFile>launch-demo.jnlp</outputFile>
- <mainClass>${maven.jar.main.class}</mainClass>
- <allPermissions>true</allPermissions>
- <offlineAllowed>true</offlineAllowed>
- </jnlp>
-
- <sign>
- <keystore>${keystorepath}</keystore>
- <keypass/>
- <storepass>${keystorepass}</storepass>
- <storetype/>
- <alias>${keystorealias}</alias>
- <validity/>
- <dnameCn/>
- <dnameOu/>
- <dnameO/>
- <dnameL/>
- <dnameSt/>
- <dnameC/>
- <verify>true</verify>
- <keystoreConfig>
- <delete>false</delete>
- <gen>false</gen>
- </keystoreConfig>
- </sign>
-
- <pack200>false</pack200>
- <gzip>true</gzip>
- <verbose>false</verbose>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
\ No newline at end of file
Copied: jaxx/tags/jaxx-1.2/jaxx-example/pom.xml (from rev 1245, jaxx/trunk/jaxx-example/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/jaxx-example/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/jaxx-example/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,280 @@
+<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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-example</artifactId>
+
+ <dependencies>
+
+ <!-- sibiling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-validator-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx Examples</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+
+ <maven.jar.main.class>jaxx.demo.JAXXDemo</maven.jar.main.class>
+
+ <!-- jnlp -->
+ <keystorepath>${codelutin.keystorepath}</keystorepath>
+ <keystorealias>CodeLutin</keystorealias>
+ <keystorepass>codelutin</keystorepass>
+
+ <jnlp.build.directory>${project.build.directory}/jnlp</jnlp.build.directory>
+
+ </properties>
+
+ <build>
+
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.jaxx</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ </resources>
+
+ <pluginManagement>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>./lib/</classpathPrefix>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+
+ </pluginManagement>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <configuration>
+ <entries>
+ <entry>
+ <basedir>${maven.gen.dir}/java/</basedir>
+ <includes>
+ <param>**\/**.java</param>
+ </includes>
+ </entry>
+ </entries>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <configuration>
+ <outputDirectory>${project.build.directory}/lib</outputDirectory>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</developerConnection>
+ </scm>
+
+ <profiles>
+ <!-- by default jnlp is only perform on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
+ <execution>
+ <id>JnlpSun</id>
+ <phase>verify</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${jnlp.build.directory}" />
+ <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <filterset>
+ <filter token="lib" value="javahelp-2.0.02.jar" />
+ <filter token="url" value="${project.url}" />
+ </filterset>
+ </copy>
+ <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <filterset>
+ <filter token="lib" value="jxlayer-3.0.1.jar" />
+ <filter token="url" value="${project.url}" />
+ </filterset>
+ </copy>
+ <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
+ <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>JnlpToSite</id>
+ <phase>pre-site</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${maven.site.gen.dir}/resources" />
+ <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}" failonerror="false" overwrite="false">
+ <fileset dir="${jnlp.build.directory}">
+ <include name="**" />
+ </fileset>
+ </copy>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo.webstart</groupId>
+ <artifactId>webstart-maven-plugin</artifactId>
+ <version>1.0-alpha-2-cl_20081018</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>jnlp-inline</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <force>false</force>
+ <dependencies>
+ <excludes>
+ <exclude>javax.help:javahelp</exclude>
+ <exclude>org.swinglabs:jxlayer</exclude>
+ </excludes>
+ </dependencies>
+ <libPath>lib</libPath>
+ <extensions>
+ <sun>sun.jnlp</sun>
+ <jxlayer>jxlayer.jnlp</jxlayer>
+ </extensions>
+ <jnlp>
+ <outputFile>launch-demo.jnlp</outputFile>
+ <mainClass>${maven.jar.main.class}</mainClass>
+ <allPermissions>true</allPermissions>
+ <offlineAllowed>true</offlineAllowed>
+ </jnlp>
+
+ <sign>
+ <keystore>${keystorepath}</keystore>
+ <keypass />
+ <storepass>${keystorepass}</storepass>
+ <storetype />
+ <alias>${keystorealias}</alias>
+ <validity />
+ <dnameCn />
+ <dnameOu />
+ <dnameO />
+ <dnameL />
+ <dnameSt />
+ <dnameC />
+ <verify>true</verify>
+ <keystoreConfig>
+ <delete>false</delete>
+ <gen>false</gen>
+ </keystoreConfig>
+ </sign>
+
+ <pack200>false</pack200>
+ <gzip>true</gzip>
+ <verbose>false</verbose>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
Deleted: jaxx/tags/jaxx-1.2/jaxx-runtime-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-api/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/jaxx-runtime-api/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,65 +0,0 @@
-<?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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
-
- <dependencies>
-
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
-
- <!-- pour utiliser javaHelp -->
- <dependency>
- <groupId>javax.help</groupId>
- <artifactId>javahelp</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.swinglabs</groupId>
- <artifactId>jxlayer</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-jxpath</groupId>
- <artifactId>commons-jxpath</artifactId>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx runtime api</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
- <packaging>jar</packaging>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-</project>
Copied: jaxx/tags/jaxx-1.2/jaxx-runtime-api/pom.xml (from rev 1245, jaxx/trunk/jaxx-runtime-api/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/jaxx-runtime-api/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/jaxx-runtime-api/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,64 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-runtime-api</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ <!-- pour utiliser javaHelp -->
+ <dependency>
+ <groupId>javax.help</groupId>
+ <artifactId>javahelp</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>jxlayer</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx runtime api</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</developerConnection>
+ </scm>
+</project>
Deleted: jaxx/tags/jaxx-1.2/jaxx-runtime-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/jaxx-runtime-swing/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,52 +0,0 @@
-<?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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
-
- <dependencies>
-
- <!-- sibling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx runtime swing extension</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
- <packaging>jar</packaging>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-</project>
Copied: jaxx/tags/jaxx-1.2/jaxx-runtime-swing/pom.xml (from rev 1245, jaxx/trunk/jaxx-runtime-swing/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/jaxx-runtime-swing/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/jaxx-runtime-swing/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,51 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-runtime-swing</artifactId>
+
+ <dependencies>
+
+ <!-- sibling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx runtime swing extension</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</developerConnection>
+ </scm>
+</project>
Deleted: jaxx/tags/jaxx-1.2/jaxx-runtime-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/jaxx-runtime-validator/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,59 +0,0 @@
-<?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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-runtime-validator</artifactId>
-
- <dependencies>
-
- <!-- sibling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- validation framework -->
-
- <dependency>
- <groupId>com.opensymphony</groupId>
- <artifactId>xwork</artifactId>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx runtime validation</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
- <packaging>jar</packaging>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-</project>
Copied: jaxx/tags/jaxx-1.2/jaxx-runtime-validator/pom.xml (from rev 1245, jaxx/trunk/jaxx-runtime-validator/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/jaxx-runtime-validator/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/jaxx-runtime-validator/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,58 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-runtime-validator</artifactId>
+
+ <dependencies>
+
+ <!-- sibling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- validation framework -->
+
+ <dependency>
+ <groupId>com.opensymphony</groupId>
+ <artifactId>xwork</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx runtime validation</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</developerConnection>
+ </scm>
+</project>
Deleted: jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,52 +0,0 @@
-<?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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-runtime-validator-swing</artifactId>
-
- <dependencies>
-
- <!-- sibling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-validator</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx validation swing extension</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
- <packaging>jar</packaging>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-</project>
Copied: jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing/pom.xml (from rev 1245, jaxx/trunk/jaxx-runtime-validator-swing/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,51 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-runtime-validator-swing</artifactId>
+
+ <dependencies>
+
+ <!-- sibling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-validator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx validation swing extension</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</developerConnection>
+ </scm>
+</project>
Deleted: jaxx/tags/jaxx-1.2/jaxx-swing-action/pom.xml
===================================================================
--- jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/jaxx-swing-action/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,90 +0,0 @@
-<?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">
-
- <modelVersion>4.0.0</modelVersion>
-
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>jaxx-swing-action</artifactId>
-
- <dependencies>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-runtime-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>javassist</artifactId>
- <version>3.7.ga</version>
- </dependency>
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx lutin library swing extension (tabs and actions)</description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
- <packaging>jar</packaging>
-
- <build>
-
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <!-- the code contains some AnnotationProcessor -->
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
-
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>parserJava</goal>
- <goal>gen</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-
-</project>
Copied: jaxx/tags/jaxx-1.2/jaxx-swing-action/pom.xml (from rev 1245, jaxx/trunk/jaxx-swing-action/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/jaxx-swing-action/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/jaxx-swing-action/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,89 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>jaxx-swing-action</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-runtime-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.7.ga</version>
+ </dependency>
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx lutin library swing extension (tabs and actions)</description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+ <packaging>jar</packaging>
+
+ <build>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <!-- the code contains some AnnotationProcessor -->
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</developerConnection>
+ </scm>
+
+</project>
Deleted: jaxx/tags/jaxx-1.2/maven-jaxx-plugin/pom.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/maven-jaxx-plugin/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,143 +0,0 @@
-<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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.codelutin.jaxx</groupId>
- <artifactId>maven-jaxx-plugin</artifactId>
-
- <dependencies>
-
- <!-- sibling dependencies -->
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-compiler-api</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-compiler-validator</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-compiler-swing</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>jaxx-swing-action</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- maven plugin project dependencies -->
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- </dependency>
-
- <!-- other dependencies -->
-
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinpluginutil</artifactId>
- </dependency>
-
- <!-- pour acceder aux BeansInfos swing via Introspector -->
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>dt</artifactId>
- <!--version>${java.version}</version-->
- <scope>system</scope>
- <systemPath>/${java.home}/../lib/dt.jar</systemPath>
- </dependency>
-
- <!-- tests dependencies -->
-
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-plugin-testing-harness</artifactId>
- <version>1.1</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-verifier</artifactId>
- <version>1.0</version>
- <scope>test</scope>
- </dependency>
-
-
- </dependencies>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>
- Maven 2 plugin to generate java source from ui interface definitions
- in jaxx format.
- </description>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
-
- <packaging>maven-plugin</packaging>
- <build>
- <plugins>
-
- <plugin>
- <artifactId>maven-plugin-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>helpmojo</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
-
- <reporting>
- <plugins>
- <plugin>
- <artifactId>maven-plugin-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
- </scm>
-
-</project>
\ No newline at end of file
Copied: jaxx/tags/jaxx-1.2/maven-jaxx-plugin/pom.xml (from rev 1245, jaxx/trunk/maven-jaxx-plugin/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/maven-jaxx-plugin/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/maven-jaxx-plugin/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,142 @@
+<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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+ </parent>
+
+ <groupId>org.codelutin.jaxx</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+
+ <dependencies>
+
+ <!-- sibling dependencies -->
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-compiler-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-compiler-validator</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-compiler-swing</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>jaxx-swing-action</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- maven plugin project dependencies -->
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ </dependency>
+
+ <!-- other dependencies -->
+
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinpluginutil</artifactId>
+ </dependency>
+
+ <!-- pour acceder aux BeansInfos swing via Introspector -->
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>dt</artifactId>
+ <!--version>${java.version}</version-->
+ <scope>system</scope>
+ <systemPath>/${java.home}/../lib/dt.jar</systemPath>
+ </dependency>
+
+ <!-- tests dependencies -->
+
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>1.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-verifier</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ </dependencies>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>
+ Maven 2 plugin to generate java source from ui interface definitions
+ in jaxx format.
+ </description>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>maven-plugin</packaging>
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</developerConnection>
+ </scm>
+
+</project>
\ No newline at end of file
Deleted: jaxx/tags/jaxx-1.2/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/tags/jaxx-1.2/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -1,266 +0,0 @@
-<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">
-
- <modelVersion>4.0.0</modelVersion>
-
- <!-- ************************************************************* -->
- <!-- *** POM Relationships *************************************** -->
- <!-- ************************************************************* -->
-
- <parent>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinproject</artifactId>
- <version>3.4</version>
- </parent>
-
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
-
- <modules>
- <module>jaxx-runtime-api</module>
- <module>jaxx-runtime-swing</module>
- <module>jaxx-runtime-validator</module>
- <module>jaxx-runtime-validator-swing</module>
-
- <module>jaxx-compiler-api</module>
- <module>jaxx-compiler-swing</module>
- <module>jaxx-compiler-validator</module>
-
- <module>jaxx-swing-action</module>
- <module>maven-jaxx-plugin</module>
-
- <module>jaxx-example</module>
- </modules>
-
- <dependencies>
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinutil</artifactId>
- </dependency>
- </dependencies>
-
- <dependencyManagement>
- <dependencies>
-
- <!-- lutin dependencies -->
-
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinutil</artifactId>
- <version>${lutinutil.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>lutinpluginutil</artifactId>
- <version>${lutinpluginutil.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- common dependencies -->
-
- <dependency>
- <groupId>commons-jxpath</groupId>
- <artifactId>commons-jxpath</artifactId>
- <version>1.3</version>
- </dependency>
-
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.4</version>
- </dependency>
-
- <!-- sun dependencies -->
-
- <dependency>
- <groupId>com.sun</groupId>
- <artifactId>dt</artifactId>
- <version>${java.version}</version>
- <scope>system</scope>
- <systemPath>/${java.home}/../lib/dt.jar</systemPath>
- </dependency>
-
- <dependency>
- <groupId>javax.help</groupId>
- <artifactId>javahelp</artifactId>
- <version>2.0.02</version>
- </dependency>
-
- <!-- maven dependencies -->
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>2.0.4</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.0.4</version>
- <scope>compile</scope>
- </dependency>
-
- <!-- xworks dependencies -->
-
- <dependency>
- <groupId>com.opensymphony</groupId>
- <artifactId>xwork</artifactId>
- <version>2.1.1-cl_20090130</version>
- <!--version>2.1.1</version-->
- </dependency>
-
- <!-- swinglabs dependencies -->
-
- <dependency>
- <groupId>org.swinglabs</groupId>
- <artifactId>jxlayer</artifactId>
- <version>3.0.1</version>
- </dependency>
-
- </dependencies>
- </dependencyManagement>
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>${project.artifactId}</name>
- <description>Jaxx lutin library parent pom</description>
- <inceptionYear>2008</inceptionYear>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
-
- <packaging>pom</packaging>
-
- <properties>
-
- <!-- id du projet du labs -->
- <labs.id>38</labs.id>
-
- <!-- nom du projet du labs -->
- <labs.project>buix</labs.project>
-
- <!-- libs version -->
- <lutinutil.version>1.0.3</lutinutil.version>
- <jaxx.version>${project.version}</jaxx.version>
- <i18n.version>0.9</i18n.version>
- <lutinpluginutil.version>0.3</lutinpluginutil.version>
- </properties>
-
- <build>
-
- <pluginManagement>
- <plugins>
-
- <!-- plugin i18n -->
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <version>${i18n.version}</version>
- </plugin>
-
- <plugin>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>2.4.3</version>
- </plugin>
-
- </plugins>
- </pluginManagement>
-
- <plugins>
- <!-- Always process jrst files, but only called on pre-site phase -->
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-jrst-plugin</artifactId>
- <version>0.8.4</version>
- <configuration>
- <directoryIn>${maven.src.dir}/site</directoryIn>
- <directoryOut>${maven.site.gen.dir}</directoryOut>
- <defaultLocale>fr</defaultLocale>
- <inputEncoding>${project.build.sourceEncoding}</inputEncoding>
- <outputEncoding>${project.build.sourceEncoding}</outputEncoding>
- </configuration>
- <executions>
- <execution>
- <phase>pre-site</phase>
- <goals>
- <goal>jrst</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
- </build>
-
- <!-- ************************************************************* -->
- <!-- *** Build Environment ************************************** -->
- <!-- ************************************************************* -->
- <scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
- </scm>
-
- <!-- Maven Environment : Repositories -->
-
- <!--Code Lutin Repository-->
- <repositories>
- <repository>
-
- <id>codelutin-repository</id>
- <name>CodeLutinRepository</name>
- <url>http://lutinbuilder.labs.libre-entreprise.org/maven2</url>
- <snapshots>
- <enabled>true</enabled>
- <checksumPolicy>warn</checksumPolicy>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <checksumPolicy>warn</checksumPolicy>
- </releases>
- </repository>
- </repositories>
-
- <profiles>
- <!-- perform only on a release stage when using the maven-release-plugin -->
- <profile>
- <id>release-profile</id>
- <activation>
- <property>
- <name>performRelease</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <!-- always add license and third-party files to classpath -->
- <plugin>
- <groupId>org.codelutin</groupId>
- <artifactId>maven-license-switcher-plugin</artifactId>
- <version>0.6</version>
- <configuration>
- <licenseName>${license-switcher.licenseName}</licenseName>
- </configuration>
- <executions>
- <execution>
- <id>attach-licenses</id>
- <goals>
- <goal>license</goal>
- <goal>third-party</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
-</project>
\ No newline at end of file
Copied: jaxx/tags/jaxx-1.2/pom.xml (from rev 1245, jaxx/trunk/pom.xml)
===================================================================
--- jaxx/tags/jaxx-1.2/pom.xml (rev 0)
+++ jaxx/tags/jaxx-1.2/pom.xml 2009-02-25 09:55:41 UTC (rev 1246)
@@ -0,0 +1,265 @@
+<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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinproject</artifactId>
+ <version>3.4</version>
+ </parent>
+
+ <groupId>org.codelutin</groupId>
+ <artifactId>jaxx</artifactId>
+ <version>1.2</version>
+
+ <modules>
+ <module>jaxx-runtime-api</module>
+ <module>jaxx-runtime-swing</module>
+ <module>jaxx-runtime-validator</module>
+ <module>jaxx-runtime-validator-swing</module>
+
+ <module>jaxx-compiler-api</module>
+ <module>jaxx-compiler-swing</module>
+ <module>jaxx-compiler-validator</module>
+
+ <module>jaxx-swing-action</module>
+ <module>maven-jaxx-plugin</module>
+
+ <module>jaxx-example</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinutil</artifactId>
+ </dependency>
+ </dependencies>
+
+ <dependencyManagement>
+ <dependencies>
+
+ <!-- lutin dependencies -->
+
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinutil</artifactId>
+ <version>${lutinutil.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codelutin</groupId>
+ <artifactId>lutinpluginutil</artifactId>
+ <version>${lutinpluginutil.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- common dependencies -->
+
+ <dependency>
+ <groupId>commons-jxpath</groupId>
+ <artifactId>commons-jxpath</artifactId>
+ <version>1.3</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ </dependency>
+
+ <!-- sun dependencies -->
+
+ <dependency>
+ <groupId>com.sun</groupId>
+ <artifactId>dt</artifactId>
+ <version>${java.version}</version>
+ <scope>system</scope>
+ <systemPath>/${java.home}/../lib/dt.jar</systemPath>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.help</groupId>
+ <artifactId>javahelp</artifactId>
+ <version>2.0.02</version>
+ </dependency>
+
+ <!-- maven dependencies -->
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>2.0.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <!-- xworks dependencies -->
+
+ <dependency>
+ <groupId>com.opensymphony</groupId>
+ <artifactId>xwork</artifactId>
+ <version>2.1.1-cl_20090130</version>
+ <!--version>2.1.1</version-->
+ </dependency>
+
+ <!-- swinglabs dependencies -->
+
+ <dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>jxlayer</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>${project.artifactId}</name>
+ <description>Jaxx lutin library parent pom</description>
+ <inceptionYear>2008</inceptionYear>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>pom</packaging>
+
+ <properties>
+
+ <!-- id du projet du labs -->
+ <labs.id>38</labs.id>
+
+ <!-- nom du projet du labs -->
+ <labs.project>buix</labs.project>
+
+ <!-- libs version -->
+ <lutinutil.version>1.0.3</lutinutil.version>
+ <jaxx.version>${project.version}</jaxx.version>
+ <i18n.version>0.9</i18n.version>
+ <lutinpluginutil.version>0.3</lutinpluginutil.version>
+ </properties>
+
+ <build>
+
+ <pluginManagement>
+ <plugins>
+
+ <!-- plugin i18n -->
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <version>${i18n.version}</version>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>2.4.3</version>
+ </plugin>
+
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <!-- Always process jrst files, but only called on pre-site phase -->
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-jrst-plugin</artifactId>
+ <version>0.8.4</version>
+ <configuration>
+ <directoryIn>${maven.src.dir}/site</directoryIn>
+ <directoryOut>${maven.site.gen.dir}</directoryOut>
+ <defaultLocale>fr</defaultLocale>
+ <inputEncoding>${project.build.sourceEncoding}</inputEncoding>
+ <outputEncoding>${project.build.sourceEncoding}</outputEncoding>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>jrst</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Environment ************************************** -->
+ <!-- ************************************************************* -->
+ <scm>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ </scm>
+
+ <!-- Maven Environment : Repositories -->
+
+ <!--Code Lutin Repository-->
+ <repositories>
+ <repository>
+
+ <id>codelutin-repository</id>
+ <name>CodeLutinRepository</name>
+ <url>http://lutinbuilder.labs.libre-entreprise.org/maven2</url>
+ <snapshots>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ <checksumPolicy>warn</checksumPolicy>
+ </releases>
+ </repository>
+ </repositories>
+
+ <profiles>
+ <!-- perform only on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>release-profile</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <!-- always add license and third-party files to classpath -->
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-license-switcher-plugin</artifactId>
+ <version>0.6</version>
+ <configuration>
+ <licenseName>${license-switcher.licenseName}</licenseName>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-licenses</id>
+ <goals>
+ <goal>license</goal>
+ <goal>third-party</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
\ No newline at end of file
1
0
r1245 - in jaxx/trunk: . jaxx-compiler-api jaxx-compiler-swing jaxx-compiler-validator jaxx-example jaxx-runtime-api jaxx-runtime-swing jaxx-runtime-validator jaxx-runtime-validator-swing jaxx-swing-action maven-jaxx-plugin
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
Feb. 25, 2009
Author: sletellier
Date: 2009-02-25 09:55:32 +0000 (Wed, 25 Feb 2009)
New Revision: 1245
Modified:
jaxx/trunk/jaxx-compiler-api/pom.xml
jaxx/trunk/jaxx-compiler-swing/pom.xml
jaxx/trunk/jaxx-compiler-validator/pom.xml
jaxx/trunk/jaxx-example/pom.xml
jaxx/trunk/jaxx-runtime-api/pom.xml
jaxx/trunk/jaxx-runtime-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator/pom.xml
jaxx/trunk/jaxx-swing-action/pom.xml
jaxx/trunk/maven-jaxx-plugin/pom.xml
jaxx/trunk/pom.xml
Log:
[maven-release-plugin] prepare release jaxx-1.2
Modified: jaxx/trunk/jaxx-compiler-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-api/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/jaxx-compiler-api/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -45,8 +44,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-compiler-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -51,8 +50,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-compiler-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -57,8 +56,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/jaxx-example/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,5 +1,4 @@
-<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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +9,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -148,9 +147,9 @@
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</developerConnection>
</scm>
<profiles>
@@ -175,29 +174,21 @@
<phase>verify</phase>
<configuration>
<tasks>
- <mkdir dir="${jnlp.build.directory}"/>
- <copy file="${project.basedir}/src/main/jnlp/sun.jnlp"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}"
- failonerror="false">
+ <mkdir dir="${jnlp.build.directory}" />
+ <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
<filterset>
- <filter token="lib" value="javahelp-2.0.02.jar"/>
- <filter token="url" value="${project.url}"/>
+ <filter token="lib" value="javahelp-2.0.02.jar" />
+ <filter token="url" value="${project.url}" />
</filterset>
</copy>
- <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}"
- failonerror="false">
+ <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
<filterset>
- <filter token="lib" value="jxlayer-3.0.1.jar"/>
- <filter token="url" value="${project.url}"/>
+ <filter token="lib" value="jxlayer-3.0.1.jar" />
+ <filter token="url" value="${project.url}" />
</filterset>
</copy>
- <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib"
- failonerror="false"/>
- <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib"
- failonerror="false"/>
+ <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
+ <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
</tasks>
</configuration>
<goals>
@@ -210,11 +201,10 @@
<phase>pre-site</phase>
<configuration>
<tasks>
- <mkdir dir="${maven.site.gen.dir}/resources"/>
- <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}"
- failonerror="false" overwrite="false">
+ <mkdir dir="${maven.site.gen.dir}/resources" />
+ <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}" failonerror="false" overwrite="false">
<fileset dir="${jnlp.build.directory}">
- <include name="**"/>
+ <include name="**" />
</fileset>
</copy>
</tasks>
@@ -259,17 +249,17 @@
<sign>
<keystore>${keystorepath}</keystore>
- <keypass/>
+ <keypass />
<storepass>${keystorepass}</storepass>
- <storetype/>
+ <storetype />
<alias>${keystorealias}</alias>
- <validity/>
- <dnameCn/>
- <dnameOu/>
- <dnameO/>
- <dnameL/>
- <dnameSt/>
- <dnameC/>
+ <validity />
+ <dnameCn />
+ <dnameOu />
+ <dnameO />
+ <dnameL />
+ <dnameSt />
+ <dnameC />
<verify>true</verify>
<keystoreConfig>
<delete>false</delete>
Modified: jaxx/trunk/jaxx-runtime-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-api/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/jaxx-runtime-api/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -58,8 +57,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -45,8 +44,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -52,8 +51,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -45,8 +44,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -12,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -82,9 +81,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,5 +1,4 @@
-<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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +9,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -135,9 +134,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</developerConnection>
</scm>
</project>
\ No newline at end of file
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
+++ jaxx/trunk/pom.xml 2009-02-25 09:55:32 UTC (rev 1245)
@@ -1,5 +1,4 @@
-<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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -15,7 +14,7 @@
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
<modules>
<module>jaxx-runtime-api</module>
@@ -203,9 +202,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</connection>
+ <developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
</scm>
<!-- Maven Environment : Repositories -->
1
0
r1244 - in jaxx/trunk: . jaxx-compiler-api jaxx-compiler-swing jaxx-compiler-validator jaxx-example jaxx-runtime-api jaxx-runtime-swing jaxx-runtime-validator jaxx-runtime-validator-swing jaxx-swing-action maven-jaxx-plugin
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
Feb. 25, 2009
Author: sletellier
Date: 2009-02-25 09:53:24 +0000 (Wed, 25 Feb 2009)
New Revision: 1244
Modified:
jaxx/trunk/jaxx-compiler-api/pom.xml
jaxx/trunk/jaxx-compiler-swing/pom.xml
jaxx/trunk/jaxx-compiler-validator/pom.xml
jaxx/trunk/jaxx-example/pom.xml
jaxx/trunk/jaxx-runtime-api/pom.xml
jaxx/trunk/jaxx-runtime-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator/pom.xml
jaxx/trunk/jaxx-swing-action/pom.xml
jaxx/trunk/maven-jaxx-plugin/pom.xml
jaxx/trunk/pom.xml
Log:
[maven-release-plugin] rollback the release of jaxx-1.2
Modified: jaxx/trunk/jaxx-compiler-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-api/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/jaxx-compiler-api/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,5 +1,6 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -44,8 +45,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-compiler-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,5 +1,6 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -50,8 +51,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-compiler-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,5 +1,6 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -56,8 +57,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/jaxx-example/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,4 +1,5 @@
-<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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -9,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -147,9 +148,9 @@
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
<profiles>
@@ -174,21 +175,29 @@
<phase>verify</phase>
<configuration>
<tasks>
- <mkdir dir="${jnlp.build.directory}" />
- <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <mkdir dir="${jnlp.build.directory}"/>
+ <copy file="${project.basedir}/src/main/jnlp/sun.jnlp"
+ verbose="${maven.verbose}" todir="${jnlp.build.directory}"
+ failonerror="false">
<filterset>
- <filter token="lib" value="javahelp-2.0.02.jar" />
- <filter token="url" value="${project.url}" />
+ <filter token="lib" value="javahelp-2.0.02.jar"/>
+ <filter token="url" value="${project.url}"/>
</filterset>
</copy>
- <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
+ <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp"
+ verbose="${maven.verbose}" todir="${jnlp.build.directory}"
+ failonerror="false">
<filterset>
- <filter token="lib" value="jxlayer-3.0.1.jar" />
- <filter token="url" value="${project.url}" />
+ <filter token="lib" value="jxlayer-3.0.1.jar"/>
+ <filter token="url" value="${project.url}"/>
</filterset>
</copy>
- <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
- <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
+ <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar"
+ verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib"
+ failonerror="false"/>
+ <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar"
+ verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib"
+ failonerror="false"/>
</tasks>
</configuration>
<goals>
@@ -201,10 +210,11 @@
<phase>pre-site</phase>
<configuration>
<tasks>
- <mkdir dir="${maven.site.gen.dir}/resources" />
- <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}" failonerror="false" overwrite="false">
+ <mkdir dir="${maven.site.gen.dir}/resources"/>
+ <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}"
+ failonerror="false" overwrite="false">
<fileset dir="${jnlp.build.directory}">
- <include name="**" />
+ <include name="**"/>
</fileset>
</copy>
</tasks>
@@ -249,17 +259,17 @@
<sign>
<keystore>${keystorepath}</keystore>
- <keypass />
+ <keypass/>
<storepass>${keystorepass}</storepass>
- <storetype />
+ <storetype/>
<alias>${keystorealias}</alias>
- <validity />
- <dnameCn />
- <dnameOu />
- <dnameO />
- <dnameL />
- <dnameSt />
- <dnameC />
+ <validity/>
+ <dnameCn/>
+ <dnameOu/>
+ <dnameO/>
+ <dnameL/>
+ <dnameSt/>
+ <dnameC/>
<verify>true</verify>
<keystoreConfig>
<delete>false</delete>
Modified: jaxx/trunk/jaxx-runtime-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-api/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/jaxx-runtime-api/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,5 +1,6 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -57,8 +58,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,5 +1,6 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -44,8 +45,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,5 +1,6 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -51,8 +52,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,5 +1,6 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -44,8 +45,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,5 +1,6 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +12,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -81,9 +82,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,4 +1,5 @@
-<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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -9,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -134,9 +135,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</developerConnection>
+ <url>${maven.scm.url.child}</url>
+ <connection>${maven.scm.connection.child}</connection>
+ <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
</scm>
</project>
\ No newline at end of file
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
+++ jaxx/trunk/pom.xml 2009-02-25 09:53:24 UTC (rev 1244)
@@ -1,4 +1,5 @@
-<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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -14,7 +15,7 @@
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2</version>
+ <version>1.2-SNAPSHOT</version>
<modules>
<module>jaxx-runtime-api</module>
@@ -202,9 +203,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</connection>
- <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</developerConnection>
- <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>${maven.scm.connection}</connection>
+ <developerConnection>${maven.scm.developerConnection}</developerConnection>
+ <url>${maven.scm.url}</url>
</scm>
<!-- Maven Environment : Repositories -->
1
0
r1243 - in jaxx/trunk: . jaxx-compiler-api jaxx-compiler-swing jaxx-compiler-validator jaxx-example jaxx-runtime-api jaxx-runtime-swing jaxx-runtime-validator jaxx-runtime-validator-swing jaxx-swing-action maven-jaxx-plugin
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
by sletellier@users.labs.libre-entreprise.org Feb. 25, 2009
Feb. 25, 2009
Author: sletellier
Date: 2009-02-25 09:47:34 +0000 (Wed, 25 Feb 2009)
New Revision: 1243
Modified:
jaxx/trunk/jaxx-compiler-api/pom.xml
jaxx/trunk/jaxx-compiler-swing/pom.xml
jaxx/trunk/jaxx-compiler-validator/pom.xml
jaxx/trunk/jaxx-example/pom.xml
jaxx/trunk/jaxx-runtime-api/pom.xml
jaxx/trunk/jaxx-runtime-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
jaxx/trunk/jaxx-runtime-validator/pom.xml
jaxx/trunk/jaxx-swing-action/pom.xml
jaxx/trunk/maven-jaxx-plugin/pom.xml
jaxx/trunk/pom.xml
Log:
[maven-release-plugin] prepare release jaxx-1.2
Modified: jaxx/trunk/jaxx-compiler-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-api/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/jaxx-compiler-api/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -45,8 +44,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-api</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-compiler-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/jaxx-compiler-swing/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -51,8 +50,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-swing</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-compiler-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/jaxx-compiler-validator/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -57,8 +56,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-compiler-validator</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/jaxx-example/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,5 +1,4 @@
-<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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +9,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -148,9 +147,9 @@
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-example</developerConnection>
</scm>
<profiles>
@@ -175,29 +174,21 @@
<phase>verify</phase>
<configuration>
<tasks>
- <mkdir dir="${jnlp.build.directory}"/>
- <copy file="${project.basedir}/src/main/jnlp/sun.jnlp"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}"
- failonerror="false">
+ <mkdir dir="${jnlp.build.directory}" />
+ <copy file="${project.basedir}/src/main/jnlp/sun.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
<filterset>
- <filter token="lib" value="javahelp-2.0.02.jar"/>
- <filter token="url" value="${project.url}"/>
+ <filter token="lib" value="javahelp-2.0.02.jar" />
+ <filter token="url" value="${project.url}" />
</filterset>
</copy>
- <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}"
- failonerror="false">
+ <copy file="${project.basedir}/src/main/jnlp/jxlayer.jnlp" verbose="${maven.verbose}" todir="${jnlp.build.directory}" failonerror="false">
<filterset>
- <filter token="lib" value="jxlayer-3.0.1.jar"/>
- <filter token="url" value="${project.url}"/>
+ <filter token="lib" value="jxlayer-3.0.1.jar" />
+ <filter token="url" value="${project.url}" />
</filterset>
</copy>
- <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib"
- failonerror="false"/>
- <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar"
- verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib"
- failonerror="false"/>
+ <copy file="${project.build.directory}/lib/javahelp-2.0.02.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
+ <copy file="${project.build.directory}/lib/jxlayer-3.0.1.jar" verbose="${maven.verbose}" todir="${jnlp.build.directory}/lib" failonerror="false" />
</tasks>
</configuration>
<goals>
@@ -210,11 +201,10 @@
<phase>pre-site</phase>
<configuration>
<tasks>
- <mkdir dir="${maven.site.gen.dir}/resources"/>
- <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}"
- failonerror="false" overwrite="false">
+ <mkdir dir="${maven.site.gen.dir}/resources" />
+ <copy todir="${maven.site.gen.dir}/resources" verbose="${maven.verbose}" failonerror="false" overwrite="false">
<fileset dir="${jnlp.build.directory}">
- <include name="**"/>
+ <include name="**" />
</fileset>
</copy>
</tasks>
@@ -259,17 +249,17 @@
<sign>
<keystore>${keystorepath}</keystore>
- <keypass/>
+ <keypass />
<storepass>${keystorepass}</storepass>
- <storetype/>
+ <storetype />
<alias>${keystorealias}</alias>
- <validity/>
- <dnameCn/>
- <dnameOu/>
- <dnameO/>
- <dnameL/>
- <dnameSt/>
- <dnameC/>
+ <validity />
+ <dnameCn />
+ <dnameOu />
+ <dnameO />
+ <dnameL />
+ <dnameSt />
+ <dnameC />
<verify>true</verify>
<keystoreConfig>
<delete>false</delete>
Modified: jaxx/trunk/jaxx-runtime-api/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-api/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/jaxx-runtime-api/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -58,8 +57,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-api</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/jaxx-runtime-swing/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -45,8 +44,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-swing</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-validator/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/jaxx-runtime-validator/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -52,8 +51,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-runtime-validator-swing/pom.xml
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/jaxx-runtime-validator-swing/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -45,8 +44,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-runtime-validator-swing</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,6 +1,5 @@
<?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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -12,7 +11,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -82,9 +81,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/jaxx-swing-action</developerConnection>
</scm>
</project>
Modified: jaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/maven-jaxx-plugin/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,5 +1,4 @@
-<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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -10,7 +9,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
</parent>
<groupId>org.codelutin.jaxx</groupId>
@@ -135,9 +134,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <url>${maven.scm.url.child}</url>
- <connection>${maven.scm.connection.child}</connection>
- <developerConnection>${maven.scm.developerConnection.child}</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2/maven-jaxx-plugin</developerConnection>
</scm>
</project>
\ No newline at end of file
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-02-24 11:21:33 UTC (rev 1242)
+++ jaxx/trunk/pom.xml 2009-02-25 09:47:34 UTC (rev 1243)
@@ -1,5 +1,4 @@
-<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">
+<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">
<modelVersion>4.0.0</modelVersion>
@@ -15,7 +14,7 @@
<groupId>org.codelutin</groupId>
<artifactId>jaxx</artifactId>
- <version>1.2-SNAPSHOT</version>
+ <version>1.2</version>
<modules>
<module>jaxx-runtime-api</module>
@@ -203,9 +202,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
+ <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</connection>
+ <developerConnection>scm:svn:svn+ssh://letellier@labs.libre-entreprise.org/svnroot/buix/jaxx/tags/jaxx-1.2</developerConnection>
+ <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/jaxx/tags/jaxx-…</url>
</scm>
<!-- Maven Environment : Repositories -->
1
0
r1242 - jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime
by tchemit@users.labs.libre-entreprise.org Feb. 24, 2009
by tchemit@users.labs.libre-entreprise.org Feb. 24, 2009
Feb. 24, 2009
Author: tchemit
Date: 2009-02-24 11:21:33 +0000 (Tue, 24 Feb 2009)
New Revision: 1242
Modified:
jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java
Log:
implantation initMethod
Modified: jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java
===================================================================
--- jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-02-23 13:06:52 UTC (rev 1241)
+++ jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-02-24 11:21:33 UTC (rev 1242)
@@ -123,6 +123,10 @@
throw new IllegalArgumentException("an " + AutoLoad.class.getName() + " can not have a named context but was call with this one : " + name);
}
value = newInstance(clazz);
+ if (!anno.initMethod().trim().isEmpty()){
+ // apply method on class
+ newAccess(clazz, value, anno.initMethod().trim());
+ }
if (log.isDebugEnabled()) {
log.debug("new instance " + clazz + " : " + value);
}
@@ -219,4 +223,21 @@
throw new IllegalArgumentException(ex);
}
}
+
+ protected Object newAccess(Class<?> clazz, Object parent, String methodName) throws IllegalArgumentException {
+ Object value;
+ try {
+ Method m = clazz.getMethod(methodName);
+ value = m.invoke(parent);
+ return value;
+ } catch (NoSuchMethodException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (SecurityException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ }
}
1
0
r1241 - in jaxx/trunk: . jaxx-compiler-swing/src/main/java/jaxx/tags/swing jaxx-example/src/main/java/jaxx/demo jaxx-runtime-swing jaxx-runtime-swing/src/main/java/jaxx/runtime/swing jaxx-swing-action jaxx-swing-action/src/main/java/org/codelutin/jaxx jaxx-swing-action/src/main/java/org/codelutin/jaxx/util jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config jaxx-swing-action/src/main/resources/i18n jaxx-util/src/main/java/org/codelutin/jaxx/util jaxx-util/src/main/java/org/codeluti
by tchemit@users.labs.libre-entreprise.org Feb. 23, 2009
by tchemit@users.labs.libre-entreprise.org Feb. 23, 2009
Feb. 23, 2009
Author: tchemit
Date: 2009-02-23 13:06:52 +0000 (Mon, 23 Feb 2009)
New Revision: 1241
Added:
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUI.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FormElement.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIFactory.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIHelper.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIProvider.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java
jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java
Removed:
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Utils.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUI.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FormElement.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIFactory.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIHelper.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIProvider.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java
jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java
Modified:
jaxx/trunk/changelog.txt
jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/tags/swing/JTextComponentHandler.java
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx
jaxx/trunk/jaxx-runtime-swing/changelog.txt
jaxx/trunk/jaxx-swing-action/pom.xml
jaxx/trunk/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties
jaxx/trunk/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties
jaxx/trunk/pom.xml
Log:
- move sources from jaxx-util to jaxx-swing-action module
- delete jaxx-util module
- rename jaxx.runtime.swing.Utils to jaxx.runtime.SwingUtil
Modified: jaxx/trunk/changelog.txt
===================================================================
--- jaxx/trunk/changelog.txt 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/changelog.txt 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,3 +1,7 @@
+1.2 ??? 2009????
+ * 20090223 [chemit] - move sources from jaxx-util to jaxx-swing-action module
+ - delete jaxx-util module
+
1.1 chemit 20090220
* 20090203 [chemit] - use i18n 0.9 (zeroConf)
* 20090203 [chemit] - use lutinproject 3.4
Modified: jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/tags/swing/JTextComponentHandler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/tags/swing/JTextComponentHandler.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/tags/swing/JTextComponentHandler.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -16,6 +16,7 @@
import javax.swing.JTextArea;
import javax.swing.event.DocumentListener;
import javax.swing.text.JTextComponent;
+import jaxx.runtime.SwingUtil;
public class JTextComponentHandler extends DefaultComponentHandler {
private static final int DEFAULT_COLUMNS = 15;
@@ -45,7 +46,8 @@
@Override
public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException {
if (name.equals("text")) {
- return "jaxx.runtime.swing.Utils.setText(" + id + ", " + valueCode + ");\n";
+ return SwingUtil.class.getName()+".setText(" + id + ", " + valueCode + ");\n";
+ //return "jaxx.runtime.swing.Utils.setText(" + id + ", " + valueCode + ");\n";
}
return super.getSetPropertyCode(id, name, valueCode, compiler);
}
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/ValidationTableDemo.jaxx 2009-02-23 13:06:52 UTC (rev 1241)
@@ -28,15 +28,15 @@
<script><![CDATA[
import static org.codelutin.i18n.I18n.n_;
-import jaxx.runtime.swing.Utils;
+import jaxx.runtime.SwingUtil;
static boolean wasinit=false;
errorTable.setDefaultRenderer(Object.class, new jaxx.runtime.validator.swing.SwingValidatorErrorTableRenderer());
-Utils.setI18nTableHeaderRenderer(errorTable, n_("validator.scope"), n_("validator.scope.tip"), n_("validator.field"), n_("validator.field.tip"), n_("validator.message"), n_("validator.message.tip"));
+SwingUtil.setI18nTableHeaderRenderer(errorTable, n_("validator.scope"), n_("validator.scope.tip"), n_("validator.field"), n_("validator.field.tip"), n_("validator.message"), n_("validator.message.tip"));
public void setVisible(boolean value) {
if (!wasinit) {
- Utils.fixTableColumnWidth(errorTable, 0, 20);
+ SwingUtil.fixTableColumnWidth(errorTable, 0, 20);
wasinit=true;
}
super.setVisible(value);
Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,3 +1,6 @@
+1.2 ??? 2009????
+ * 20090223 [chemit] - rename jaxx.runtime.swing.Utils to jaxx.runtime.SwingUtil
+
1.1 chemit 20090220
* 20090124 [chemit] - add a cache on context path to improve performance on NavigationTreeNode
- improve I18nTableCellRenderer to display toolTipText
Deleted: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Utils.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Utils.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Utils.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,143 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.runtime.swing;
-
-import java.util.List;
-import javax.swing.DefaultComboBoxModel;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.SwingUtilities;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import javax.swing.text.AbstractDocument;
-import javax.swing.text.JTextComponent;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- *
- * @author tony
- * @deprecatedwill remove in release 1.2, prefer use the {@link jaxx.runtime.SwingUtil} class.
- *
- */
-public class Utils {
- private static Field numReaders;
- private static Field notifyingListeners;
-
- @Deprecated
- public static void setText(final JTextComponent c, final String text) {
- try {
- // AbstractDocument deadlocks if we try to acquire a write lock while a read lock is held by the current thread
- // If there are any readers, dispatch an invokeLater. This should only happen in the event of circular bindings.
- // Similarly, circular bindings can result in an "Attempt to mutate in notification" error, which we deal with
- // by checking for the 'notifyingListeners' property.
- AbstractDocument document = (AbstractDocument) c.getDocument();
- if (numReaders == null) {
- numReaders = AbstractDocument.class.getDeclaredField("numReaders");
- numReaders.setAccessible(true);
- }
- if (notifyingListeners == null) {
- notifyingListeners = AbstractDocument.class.getDeclaredField("notifyingListeners");
- notifyingListeners.setAccessible(true);
- }
-
- if (notifyingListeners.get(document).equals(Boolean.TRUE)) {
- return;
- }
-
- if ((Integer) numReaders.get(document) > 0) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- if (!c.getText().equals(text)) {
- c.setText(text);
- }
- }
- });
- return;
- }
-
- String oldText = c.getText();
- if (oldText == null || !oldText.equals(text)) {
- c.setText(text);
- }
- }
- catch (NoSuchFieldException e) {
- throw new RuntimeException(e);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- catch (SecurityException e) {
- c.setText(text);
- }
- }
-
- /**
- * Fill a combo box model with some datas, and select after all the given object
- *
- * @param combo the combo to fill
- * @param data data ot inject in combo
- * @param select the object to select in combo after reflling his model
- */
- @Deprecated
- public static void fillComboBox(JComboBox combo, Collection<?> data, Object select) {
- if (!(combo.getModel() instanceof DefaultComboBoxModel)) {
- throw new IllegalArgumentException("this method need a DefaultComboBoxModel for this model but was " + combo.getModel().getClass());
- }
- DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel();
- // evince the model
- model.removeListDataListener(combo);
- model.removeAllElements();
- for (Object o : data) {
- model.addElement(o);
- }
- // attach the model
- model.addListDataListener(combo);
- model.setSelectedItem(select);
- }
-
- /**
- * Fill a combo box model with some datas, and select after all the given object
- *
- * @param combo the combo to fill
- * @param data data ot inject in combo
- * @param select the object to select in combo after reflling his model
- * @param firstNull add a first null element
- */
- @Deprecated
- public static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull) {
- List<Item> items = new ArrayList<Item>();
- if (firstNull)
- items.add(new Item("null", " ", null, false));
- for (Object d : data){
- items.add(new Item(d.toString(), d.toString(), d, d.equals(select)));
- }
- combo.setItems(items);
- }
- @Deprecated
- public static void fixTableColumnWidth(JTable table, int columnIndex, int width) {
- TableColumn column = table.getColumnModel().getColumn(columnIndex);
- column.setMaxWidth(width);
- column.setMinWidth(width);
- column.setWidth(width);
- column.setPreferredWidth(width);
- }
- @Deprecated
- public static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor) {
- TableColumn column = table.getColumnModel().getColumn(columnIndex);
- column.setCellEditor(editor);
- }
- @Deprecated
- public static void setTableColumnRenderer(JTable table, int columnIndex, TableCellRenderer editor) {
- TableColumn column = table.getColumnModel().getColumn(columnIndex);
- column.setCellRenderer(editor);
- }
- @Deprecated
- public static void setI18nTableHeaderRenderer(JTable table, String... libelles) {
- table.getTableHeader().setDefaultRenderer(new I18nTableCellRenderer(table.getTableHeader().getDefaultRenderer(), libelles));
- }
-}
Modified: jaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-swing-action/pom.xml 2009-02-23 13:06:52 UTC (rev 1241)
@@ -22,12 +22,6 @@
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>jaxx-util</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>jaxx-runtime-swing</artifactId>
<version>${project.version}</version>
</dependency>
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** @author chemit */
+public abstract class AbstractUIAction<H extends DialogUIHandler<?, ?>> extends javax.swing.AbstractAction {
+
+ protected static Log log = LogFactory.getLog(AbstractUIAction.class);
+
+ protected transient DialogUI<? extends H> ui;
+
+ private static final long serialVersionUID = 1L;
+
+ protected AbstractUIAction(String name, javax.swing.Icon icon, DialogUI<? extends H> ui) {
+ super(name, icon);
+ this.ui = ui;
+ }
+
+ protected H getHandler() {
+ checkInit();
+ return ui.getHandler();
+ }
+
+ protected void setUi(DialogUI<? extends H> ui) {
+ this.ui = ui;
+ }
+
+ public DialogUI<? extends H> getUi() {
+ return ui;
+ }
+
+ protected void checkInit() throws IllegalStateException {
+ /*if (ui == null) {
+ throw new IllegalStateException("no handler, nor ui referenced in " + this);
+ } */
+ }
+
+}
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUI.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUI.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUI.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUI.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,129 @@
+/**
+ * ##% 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.AbstractAction;
+import javax.swing.AbstractButton;
+import javax.swing.ImageIcon;
+import javax.swing.JDialog;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
+import java.lang.reflect.Constructor;
+
+/**
+ * A abstract dialog contract to be realised by a dialogUI (WindowEvent adapter)
+ * <p/>
+ * TODO : make jaxx authorized implementing interface for root tag :)
+ *
+ * @author chemit
+ */
+public abstract class DialogUI<H extends DialogUIHandler> extends JDialog implements WindowListener {
+
+ protected static Log log = LogFactory.getLog(DialogUI.class);
+
+ public javax.swing.AbstractAction newAction(Class<?> actionClass, Object... params) {
+ Constructor<?> constructor = null;
+ for (Constructor<?> cons : actionClass.getConstructors()) {
+ Class<?>[] prototype = cons.getParameterTypes();
+ if (prototype.length > 0 && DialogUI.class.isAssignableFrom(prototype[0])) {
+ // use this constructor
+ constructor = cons;
+ break;
+ }
+ }
+ if (constructor == null) {
+ throw new IllegalStateException("could not find a matching constructor for " + actionClass);
+ }
+
+ // wrap params
+ Object[] parameters = new Object[1 + params.length];
+ parameters[0] = this;
+ System.arraycopy(params, 0, parameters, 1, params.length);
+ try {
+ AbstractAction action = (AbstractAction) constructor.newInstance(parameters);
+ if (log.isInfoEnabled()) {
+ log.info(action);
+ }
+ return action;
+ } catch (Exception e) {
+ throw new IllegalStateException("could not init the action " + actionClass + " for reason : " + e.getMessage());
+ }
+ }
+
+ private H handler;
+
+ public abstract AbstractButton getHelp();
+
+ public abstract Object getObjectById(java.lang.String s);
+
+ protected DialogUI() {
+ UIHelper.setQuitAction(this);
+ addWindowListener(this);
+ //TODO will be handled by jaxx with javax.help...
+ //getHelp().setAction(newAction(HelpAction.class));
+ }
+
+ public H getHandler() {
+ return handler;
+ }
+
+ public void setHandler(H handler) {
+ this.handler = handler;
+ }
+
+ protected ImageIcon createActionIcon(String name) {
+ return UIHelper.createActionIcon(name);
+ }
+
+ public void windowOpened(WindowEvent e) {
+ }
+
+ public void windowClosed(WindowEvent e) {
+ }
+
+ public void windowClosing(WindowEvent e) {
+ }
+
+ public void windowIconified(WindowEvent e) {
+ }
+
+ public void windowDeiconified(WindowEvent e) {
+ }
+
+ public void windowActivated(WindowEvent e) {
+ }
+
+ public void windowDeactivated(WindowEvent e) {
+ }
+
+ @Override
+ public synchronized void addWindowListener(WindowListener l) {
+ super.addWindowListener(l);
+ if (log.isDebugEnabled()) {
+ log.debug("after added (" + getWindowListeners().length + ") : " + l);
+ }
+ }
+
+ @Override
+ public synchronized void removeWindowListener(WindowListener l) {
+ super.removeWindowListener(l);
+ if (log.isDebugEnabled()) {
+ log.debug("after removed (" + getWindowListeners().length + ") : " + l);
+ }
+ }
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUI.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,235 @@
+/**
+ * ##% 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.util;
+
+import static org.codelutin.i18n.I18n._;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.ImageIcon;
+import java.lang.reflect.Constructor;
+
+/**
+ * Definition of an ui, with his model, handler and ui class definitions.
+ * <p/>
+ * The class contains also a shared instace of concrete ui.
+ *
+ * @author chemit
+ */
+public class DialogUIDef<M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> implements java.io.Serializable {
+
+ static protected final Log log = LogFactory.getLog(DialogUIDef.class);
+
+ public static <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> DialogUIDef<M, U, H> newDef(Class<H> handlerClass, Class<U> uiClass, Class<M> modelClass, String showActionLibelle, String showActionTip, String uiTitle) {
+ DialogUIDef<M, U, H> result;
+ result = new DialogUIDef<M, U, H>(handlerClass, uiClass, modelClass, showActionLibelle, showActionTip, uiTitle);
+ return result;
+ }
+
+ /**
+ * model class
+ */
+ private final Class<M> modelClass;
+
+ /**
+ * handler class
+ */
+ private final Class<H> handlerClass;
+
+ /**
+ * abstract ui class
+ */
+ private final Class<U> uiClass;
+
+ /**
+ * concrete lookup ui class
+ */
+ private Class<? extends U> uiImplClass;
+
+ /**
+ * shared instance of ui
+ */
+ protected U uiInstance;
+
+ /**
+ * unique name of ui def
+ */
+ protected final String name;
+
+ protected final String uiTitle;
+ protected final String showActionLibelle;
+ protected final String showActionTip;
+
+ protected ImageIcon showUIActionIcon;
+
+
+ private static final long serialVersionUID = 1L;
+
+ private DialogUIDef(Class<H> handlerClass, Class<U> uiClass, Class<M> modelClass,
+ String showActionLibelle, String showActionTip, String uiTitle) {
+ this.handlerClass = handlerClass;
+ this.uiClass = uiClass;
+ this.modelClass = modelClass;
+ this.showActionLibelle = showActionLibelle;
+ this.name = uiClass.getSimpleName().toLowerCase();
+ this.showActionTip = showActionTip;
+ this.uiTitle = uiTitle;
+ }
+
+ public Class<U> getUiClass() {
+ return uiClass;
+ }
+
+ public Class<H> getHandlerClass() {
+ return handlerClass;
+ }
+
+ public Class<M> getModelClass() {
+ return modelClass;
+ }
+
+ public Class<? extends U> getUiImplClass() {
+ return uiImplClass;
+ }
+
+ public String getUiTitle() {
+ return _(uiTitle);
+ }
+
+ public String getShowActionLibelle() {
+ return _(showActionLibelle);
+ }
+
+ public String getShowActionTip() {
+ return _(showActionTip);
+ }
+
+ public ImageIcon getShowUIActionIcon() {
+ if (showUIActionIcon == null) {
+ showUIActionIcon = UIHelper.createActionIcon("show-" + name);
+ }
+ return showUIActionIcon;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public void setUiImplClass(Class<?> uiImplClass) {
+ this.uiImplClass = (Class<? extends U>) uiImplClass;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ return this == o || o instanceof DialogUIDef && uiClass.equals(((DialogUIDef) o).uiClass);
+ }
+
+ @Override
+ public int hashCode() {
+ return uiClass.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(super.toString()).append('<');
+ sb.append(printClass("handler", handlerClass, true));
+ sb.append(printClass("model", modelClass, true));
+ sb.append(printClass("ui", uiClass, true));
+ sb.append(printClass("uiImpl", uiImplClass, false));
+ return sb.toString();
+ }
+
+ protected U getUiInstance() {
+ // no lazy instanciation, to control ui instanciation...
+ /*if (uiInstance == null) {
+ if (uiImplClass == null) {
+ throw new IllegalStateException("no concrete ui impl found in " + this);
+ }
+ synchronized (this) {
+ try {
+ uiInstance = uiImplClass.newInstance();
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui " + this,e);
+ }
+ }
+ }*/
+ return uiInstance;
+ }
+
+ protected void setUiInstance(U uiInstance) {
+ this.uiInstance = uiInstance;
+ }
+
+ protected U newUI() {
+ if (uiImplClass == null) {
+ throw new IllegalStateException("no concrete ui impl found in " + this);
+ }
+ try {
+ U result = uiImplClass.newInstance();
+ log.info(result);
+ return result;
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui " + this, e);
+ }
+ }
+
+ protected M newModel() {
+ if (modelClass == null) {
+ throw new IllegalStateException("no model impl found in " + this);
+ }
+ try {
+ M model = modelClass.newInstance();
+ log.info(model);
+ return model;
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui " + this, e);
+ }
+ }
+
+ protected H newHandler(U ui, M model, Object... params) {
+ if (handlerClass == null) {
+ throw new IllegalStateException("no handler impl found in " + this);
+ }
+ try {
+ Class[] prototype = getHandlerPrototype(params);
+ Object[] parameters = getHandlerParameters(ui, model, params);
+ H result = handlerClass.getConstructor(prototype).newInstance(parameters);
+ log.info(result);
+ return result;
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui " + this, e);
+ }
+ }
+
+ protected Object[] getHandlerParameters(U ui, M model, Object[] params) {
+ Object[] result = new Object[2 + params.length];
+ result[0] = ui;
+ result[1] = model;
+ System.arraycopy(params, 0, result, 2, params.length);
+ return result;
+ }
+
+ protected Class[] getHandlerPrototype(Object[] params) {
+ int length = params.length;
+ for (Constructor<?> constructor : handlerClass.getConstructors()) {
+ Class<?>[] prototype = constructor.getParameterTypes();
+ if (prototype.length == 2 + length && prototype[0] == uiClass && prototype[1] == modelClass) {
+ return prototype;
+ }
+ }
+ throw new IllegalStateException("could not find a matching constructor in " + handlerClass);
+ }
+
+ protected String printClass(String s, Class<?> aClass, boolean notLast) {
+ return s + ':' + (aClass == null ? null : aClass.getSimpleName()) + (notLast ? ", " : ">");
+ }
+}
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.event.WindowListener;
+import java.beans.PropertyChangeListener;
+
+/**
+ * DialogUI handler
+ *
+ * @author chemit
+ */
+public abstract class DialogUIHandler<M extends DialogUIModel, U extends DialogUI<? extends DialogUIHandler>> implements PropertyChangeListener {
+
+ protected static Log log = LogFactory.getLog(DialogUIHandler.class);
+
+ /** ui handled */
+ private U ui;
+
+ /** model handled */
+ private M model;
+
+ protected DialogUIHandler(U ui, M model) {
+ this.ui = ui;
+ this.model = model;
+ }
+
+ public U getUi() {
+ return ui;
+ }
+
+ public M getModel() {
+ return model;
+ }
+
+ public void init() {
+ if (model == null) {
+ throw new IllegalStateException("no model was defined for " + this);
+ }
+ model.addPropertyChangeListener(this);
+ }
+
+ public void dispose() {
+ model.dispose();
+ for (WindowListener windowListener : getUi().getWindowListeners()) {
+ getUi().removeWindowListener(windowListener);
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ dispose();
+ }
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,97 @@
+/**
+ * ##% 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ * Abstract ui model, with property change support.
+ *
+ * @author chemit
+ */
+public abstract class DialogUIModel {
+
+ static protected final Log log = LogFactory.getLog(DialogUIModel.class);
+
+ /** support for change properties support */
+ protected PropertyChangeSupport changeSupport;
+
+ public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ if (listener == null) {
+ return;
+ }
+ if (changeSupport == null) {
+ changeSupport = new PropertyChangeSupport(this);
+ }
+ changeSupport.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
+ if (listener == null) {
+ return;
+ }
+ if (changeSupport == null) {
+ changeSupport = new PropertyChangeSupport(this);
+ }
+ changeSupport.addPropertyChangeListener(listener);
+ }
+
+ public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
+ if (listener == null || changeSupport == null) {
+ return;
+ }
+ changeSupport.removePropertyChangeListener(listener);
+ }
+
+ public synchronized void removePropertyChangeListeners() {
+ if (changeSupport == null) {
+ return;
+ }
+ for (PropertyChangeListener listener : getPropertyChangeListeners()) {
+ changeSupport.removePropertyChangeListener(listener);
+ }
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ if (changeSupport == null) {
+ return new PropertyChangeListener[0];
+ }
+ return changeSupport.getPropertyChangeListeners();
+ }
+
+ public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ if (changeSupport == null || (oldValue == null && newValue == null) ||
+ (oldValue != null && oldValue.equals(newValue))) {
+ return;
+ }
+ changeSupport.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ public void dispose() {
+ for (PropertyChangeListener listener : changeSupport.getPropertyChangeListeners()) {
+ changeSupport.removePropertyChangeListener(listener);
+ }
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ dispose();
+ }
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,84 @@
+/**
+ * ##% 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.util;
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+/**
+ * A windowListenr for ui managed by {@link org.codelutin.jaxx.util.UIFactory}.
+ * <p/>
+ * To be used when all ui from factory are closed, via {@link #allWindowsClosed(java.awt.event.WindowEvent)} method.
+ *
+ * @author chemit
+ */
+public abstract class FactoryWindowListener extends WindowAdapter {
+
+ /**
+ * method to be invoked when all ui registred in factory are really disposed.
+ *
+ * @param e event
+ */
+ public abstract void allWindowsClosed(WindowEvent e);
+
+ /** underlying factory of ui */
+ private UIFactory factory;
+
+ /** flag to make sure {@link #allWindowsClosed(java.awt.event.WindowEvent)} is called only once. */
+ private boolean wasClosed;
+
+ @Override
+ public void windowClosed(WindowEvent e) {
+ if (UIFactory.log.isDebugEnabled()) {
+ UIFactory.log.debug(this + " : " + e);
+ }
+ if (e.getWindow().isVisible()) {
+ // only deal with real closed and none visible windows...
+ return;
+ }
+ for (DialogUIDef def : factory.getDefs()) {
+ DialogUI ui = def.uiInstance;
+ if (ui != null && ui.isVisible()) {
+ // at least one ui visible, do not close all
+ return;
+ }
+ }
+
+ if (wasClosed) {
+ // make sure to process only once
+ return;
+ }
+ if (UIFactory.log.isInfoEnabled()) {
+ UIFactory.log.info("closing factory listener " + this);
+ }
+
+ synchronized (this) {
+ try {
+ allWindowsClosed(e);
+ } finally {
+ wasClosed = true;
+ factory.removeFactoryWindowListener(this);
+ }
+ }
+ }
+
+ protected UIFactory getFactory() {
+ return factory;
+ }
+
+ protected void setFactory(UIFactory factory) {
+ this.factory = factory;
+ }
+}
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FormElement.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FormElement.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FormElement.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FormElement.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,29 @@
+/**
+ * ##% 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.util;
+
+/** @author chemit */
+public interface FormElement<U extends DialogUI> {
+
+ String name();
+
+ int ordinal();
+
+ Object getValue(U ui);
+
+ void setValue(U ui, String value);
+
+ javax.swing.JLabel getLabel(U ui);
+}
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/FormElement.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,135 @@
+/**
+ * ##% 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.event.ActionEvent;
+
+/** @author chemit */
+public abstract class ShowUIAction<M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> extends javax.swing.AbstractAction {
+
+ protected static Log log = LogFactory.getLog(AbstractUIAction.class);
+
+ protected transient DialogUI<?> ui;
+
+ private static final long serialVersionUID = 1L;
+
+ protected DialogUIDef<M, U, H> uiDef;
+
+ protected transient UIFactory factory;
+
+ protected String position;
+
+ protected boolean undecorated = true;
+
+ protected U initUI(ActionEvent e) {
+ return getFactory().getUI(uiDef);
+ }
+
+ public ShowUIAction(DialogUI<?> ui, DialogUIDef<M, U, H> uiDef, UIFactory factory, boolean showText) {
+ super(uiDef.getShowActionLibelle(), uiDef.getShowUIActionIcon());
+ this.ui = ui;
+ this.uiDef = uiDef;
+ String name = (String) getValue(NAME);
+ putValue(DISPLAYED_MNEMONIC_INDEX_KEY, name.length() - 1);
+ putValue(ACCELERATOR_KEY, (int) name.charAt(name.length() - 1));
+ if (!showText) {
+ putValue(NAME, null);
+ }
+ putValue(SHORT_DESCRIPTION, uiDef.getShowActionTip());
+ this.factory = factory;
+ }
+
+ public DialogUI<?> getUi() {
+ return ui;
+ }
+
+ public DialogUIDef<M, U, H> getUiDef() {
+ return uiDef;
+ }
+
+ public UIFactory getFactory() {
+ return factory;
+ }
+
+ public void setUiDef(DialogUIDef<M, U, H> uiDef) {
+ this.uiDef = uiDef;
+ }
+
+ public void setPosition(String position) {
+ this.position = position;
+ }
+
+ public void setUndecorated(boolean undecorated) {
+ this.undecorated = undecorated;
+ }
+
+ public void actionPerformed(java.awt.event.ActionEvent e) {
+ checkInit();
+ U ui = initUI(e);
+ ui.setTitle(uiDef.getUiTitle());
+ log.info(ui.getTitle());
+ //TODO ui.setUndecorated(undecorated);
+ setPosition(this.getUi(), ui, position);
+
+ ui.setVisible(true);
+ }
+
+ protected void setPosition(javax.swing.JDialog parentUI, javax.swing.JDialog ui, String position) {
+ if (position == null || parentUI == null) {
+ return;
+ }
+ Point parentLocation = parentUI.getLocationOnScreen();
+ Dimension parentSize = parentUI.getSize();
+
+ if (position.equals("bottom-left")) {
+ int top = (int) (parentLocation.getY() + parentSize.getHeight());
+ int left = (int) (parentLocation.getX());
+ Point newLocation = new Point(left, top);
+ newLocation.setLocation(left, top);
+ ui.setLocation(newLocation);
+ return;
+ }
+ if (position.equals("top-left")) {
+ int top = (int) (parentLocation.getY());
+ int left = (int) (parentLocation.getX());
+ Point newLocation = new Point(left, top);
+ newLocation.setLocation(left, top);
+ ui.setLocation(newLocation);
+ return;
+ }
+ if (position.equals("top-right")) {
+ int top = (int) (parentLocation.getY());
+ int left = (int) (parentLocation.getX() + parentSize.getWidth());
+ Point newLocation = new Point(left, top);
+ newLocation.setLocation(left, top);
+ ui.setLocation(newLocation);
+ return;
+ }
+ if (position.equals(("center"))) {
+ //TODO
+ }
+ }
+
+ protected void checkInit() throws IllegalStateException {
+ if (factory == null) {
+ throw new IllegalStateException("no factory found in " + this);
+ }
+ }
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIFactory.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIFactory.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIFactory.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIFactory.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,184 @@
+/**
+/**
+ * ##% 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.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.StringUtil;
+
+import javax.swing.event.EventListenerList;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+/**
+ * Factory for UI, using a cache and a provider to find ui implementations.
+ *
+ * @author chemit
+ */
+public class UIFactory {
+
+ static protected final Log log = LogFactory.getLog(UIFactory.class);
+
+ private final String applicationName;
+
+ private final DialogUIDef[] defs;
+
+ private final EventListenerList listeners;
+
+ public UIFactory(String applicationName, DialogUIDef[] defs, FactoryWindowListener... listeners) {
+ this.applicationName = applicationName;
+ this.listeners = new EventListenerList();
+ for (FactoryWindowListener listener : listeners) {
+ listener.setFactory(this);
+ addFactoryWindowListener(listener);
+ }
+ this.defs = defs;
+ long t0 = System.nanoTime();
+ if (log.isDebugEnabled()) {
+ log.debug("start at " + new java.util.Date());
+ }
+ try {
+ init();
+ } catch (Exception e) {
+ log.error(e);
+ throw new RuntimeException(e);
+ } finally {
+ if (log.isDebugEnabled()) {
+ log.info("end in " + StringUtil.convertTime(t0, System.nanoTime()));
+ }
+ }
+ }
+
+ public void addFactoryWindowListener(FactoryWindowListener l) {
+ listeners.add(FactoryWindowListener.class, l);
+ if (log.isDebugEnabled()) {
+ log.debug("after added (" + listeners.getListenerCount() + ") : " + l);
+ }
+ }
+
+ public void removeFactoryWindowListener(FactoryWindowListener l) {
+ listeners.remove(FactoryWindowListener.class, l);
+ for (DialogUIDef def : getDefs()) {
+ if (def.uiInstance != null) {
+ def.uiInstance.removeWindowListener(l);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(" after removed (" + listeners.getListenerCount() + ") : " + l);
+ }
+ if (listeners.getListenerCount(FactoryWindowListener.class) == 0) {
+ // close for real factory
+ close();
+ }
+ }
+
+ public void close() {
+ log.info(this + " at " + new java.util.Date());
+ for (DialogUIDef<?, ?, ?> def : defs) {
+ DialogUI<?> ui = def.uiInstance;
+ if (ui != null) {
+ ui.getHandler().dispose();
+ def.uiInstance = null;
+ }
+ }
+ if (listeners.getListenerCount(FactoryWindowListener.class) > 0) {
+ log.warn("some listeners where not properly removed, force deletion...");
+ for (FactoryWindowListener listener : listeners.getListeners(FactoryWindowListener.class)) {
+ removeFactoryWindowListener(listener);
+ }
+ }
+
+ }
+
+ protected void init() {
+
+ UIProvider[] providers = detectProviders();
+
+ for (DialogUIDef<?, ?, ?> def : defs) {
+ initDef(providers, def);
+ if (def.getUiImplClass() == null) {
+ throw new IllegalStateException("could not find implementation for ui def " + def);
+ }
+ }
+ }
+
+ protected void initDef(UIProvider[] providers, DialogUIDef<?, ?, ?> def) {
+ for (UIProvider provider : providers) {
+ Class<?> uiImplClass = provider.findUIImplementation(def);
+ if (uiImplClass != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("init done for " + def);
+ }
+ // ui implementation was found
+ break;
+ }
+ }
+ }
+
+ protected UIProvider[] detectProviders() {
+ long t0 = System.nanoTime();
+ List<UIProvider> providers = new ArrayList<UIProvider>();
+ for (UIProvider provider : ServiceLoader.load(UIProvider.class)) {
+ if (applicationName.equals(provider.getApplicationName())) {
+ if (log.isDebugEnabled()) {
+ log.debug("provider detected [" + provider + ']');
+ }
+ providers.add(provider);
+ }
+ }
+ log.info("found " + providers.size() + " ui provider(s) in " + StringUtil.convertTime(t0, System.nanoTime()) + " : " + providers);
+ return providers.toArray(new UIProvider[providers.size()]);
+ }
+
+ protected DialogUIDef[] getDefs() {
+ return defs;
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ close();
+ }
+
+ public <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> U getUI(DialogUIDef<M, U, H> uiType, Object... params) {
+ U ui = uiType.uiInstance;
+ if (ui == null) {
+ try {
+ ui = uiType.newUI();
+ M model = uiType.newModel();
+ H handler = uiType.newHandler(ui, model, params);
+ registerUI(uiType, ui, handler);
+ } catch (Exception e) {
+ throw new IllegalStateException("could not instanciate ui handler " + uiType + " for reason : " + e.getMessage(), e);
+ }
+ }
+ return ui;
+ }
+
+ protected <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> void registerUI(DialogUIDef<M, U, H> uiType, U ui, H handler) {
+ ui.setHandler(handler);
+ handler.init();
+ uiType.setUiInstance(ui);
+ for (FactoryWindowListener listener : listeners.getListeners(FactoryWindowListener.class)) {
+ if (log.isDebugEnabled()) {
+ log.debug("----- addFactoryWindowListener " + listener + " to " + ui);
+ }
+ ui.addWindowListener(listener);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIFactory.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIHelper.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIHelper.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIHelper.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIHelper.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,70 @@
+/*
+* ##% 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.util;
+
+import javax.swing.AbstractAction;
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import javax.swing.JDialog;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
+import java.awt.event.ActionEvent;
+
+/**
+ * Ui helper class.
+ *
+ * @author tony
+ */
+public class UIHelper {
+
+ public static ImageIcon createImageIcon(String path) {
+ java.net.URL imgURL = UIHelper.class.getResource("/icons/" + path);
+ if (imgURL != null) {
+ return new ImageIcon(imgURL);
+ } else {
+ throw new IllegalArgumentException("could not find icon " + path);
+ }
+ }
+
+ /**
+ * Attach to <code>ui</code> an abort action,accessible by <code>ESC</code> key.
+ *
+ * @param ui ui
+ */
+ public static void setQuitAction(final JDialog ui) {
+ JRootPane rootPane = ui.getRootPane();
+
+ Action quitAction = new AbstractAction("quit") {
+ private static final long serialVersionUID = -869095664995763057L;
+
+ public void actionPerformed(ActionEvent e) {
+ ui.dispose();
+ }
+ };
+ rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "quit");
+ rootPane.getActionMap().put("quit", quitAction);
+ ui.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+ }
+
+ public static ImageIcon createActionIcon(String name) {
+ return createImageIcon("action-" + name + ".png");
+ }
+
+}
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIHelper.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIProvider.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIProvider.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIProvider.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIProvider.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,86 @@
+/**
+ * ##% 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.util;
+
+/** @author chemit */
+public abstract class UIProvider {
+
+ /** the name of application using this provider */
+ protected String applicationName;
+
+ /** the name of ui implementation used by this provider */
+ protected String providerName;
+
+ /** array of ui implementations */
+ protected Class<?>[] implementations;
+
+ protected UIProvider(String applicationName, String providerName, Class<?>... implementations) {
+ this.applicationName = applicationName;
+ this.providerName = providerName;
+ this.implementations = implementations;
+ }
+
+ public String getProviderName() {
+ return providerName;
+ }
+
+ public String getApplicationName() {
+ return applicationName;
+ }
+
+ public Class<?>[] getImplementations() {
+ return implementations;
+ }
+
+ public Class<?> findUIImplementation(DialogUIDef<?, ?, ?> def) {
+ Class<? extends DialogUI<?>> uiClass = def.getUiClass();
+ for (Class<?> klass : implementations) {
+ if (uiClass.isAssignableFrom(klass)) {
+ def.setUiImplClass(klass);
+ return klass;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(super.toString()).append('<');
+ sb.append(printClass("application", applicationName, true));
+ sb.append(printClass("provider", providerName, true));
+ sb.append(printClass("uis", implementations.length, false));
+ return sb.toString();
+ }
+
+ protected String printClass(String s, Object aClass, boolean notLast) {
+ return s + ':' + (aClass == null ? null : aClass) + (notLast ? ", " : ">");
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof UIProvider)) return false;
+
+ UIProvider that = (UIProvider) o;
+ return applicationName.equals(that.applicationName) && providerName.equals(that.providerName);
+
+ }
+
+ @Override
+ public int hashCode() {
+ return (31 * applicationName.hashCode()) + providerName.hashCode();
+ }
+
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/UIProvider.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -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.util.config;
+
+import org.codelutin.jaxx.util.AbstractUIAction;
+import org.codelutin.jaxx.util.DialogUI;
+import org.codelutin.jaxx.util.UIHelper;
+
+import java.awt.event.ActionEvent;
+
+/** @author chemit */
+public class CancelAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
+ private static final long serialVersionUID = 1L;
+
+ public CancelAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
+ super(null, UIHelper.createActionIcon("cancel-config"), dialogUI);
+ if (showLabel) {
+ String text = org.codelutin.i18n.I18n._("lutinui.config.cancel");
+ putValue(NAME, text);
+ putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
+ putValue(MNEMONIC_KEY, (int) text.charAt(0));
+ }
+ String libelle = org.codelutin.i18n.I18n._("lutinui.config.cancel.tooltip");
+ putValue(SHORT_DESCRIPTION, libelle);
+
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ getUi().dispose();
+ }
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,105 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.jaxx.util.DialogUI;
+
+import javax.swing.AbstractButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPasswordField;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+
+/**
+ * A abstract dialog contract to be realised by a dialogUI (WindowEvent adapter)
+ * <p/>
+ * TODO : make jaxx authorized implementing interface for root tag :)
+ *
+ * @author chemit
+ */
+public abstract class DialogConfigUI<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends DialogUI<H> {
+
+ public abstract AbstractButton getOk();
+
+ public abstract AbstractButton getReset();
+
+ public abstract AbstractButton getCancel();
+
+ public JComponent getElement(E key) {
+ Object id = getObjectById(key.name());
+ if (id == null) {
+ log.error(new NullPointerException("no widget for key "+key));
+ return null;
+ }
+ if (!(id instanceof JComponent)) {
+ throw new IllegalArgumentException(id + " is not a JComponent");
+ }
+ return (JComponent) id;
+ }
+
+ public Object getElementValue(E key) {
+ JComponent o = getElement(key);
+ if (o instanceof JPasswordField) {
+ return new String(((JPasswordField) o).getPassword());
+ }
+ if (o instanceof JTextField) {
+ return ((JTextField) o).getText();
+ }
+ if (o instanceof JRadioButton) {
+ return ((JRadioButton) o).isSelected();
+ }
+ if (o instanceof JCheckBox) {
+ return ((JCheckBox) o).isSelected();
+ }
+
+ if (o instanceof JComboBox) {
+ return ((JComboBox) o).getSelectedItem();
+ }
+ return "";
+ }
+
+ public void setElementValue(E key, Object value) {
+ JComponent o = getElement(key);
+
+ String strValue = value == null ? "" : String.valueOf(value);
+ if (o instanceof JPasswordField) {
+ ((JPasswordField) o).setText(strValue);
+ }
+ if (o instanceof JTextField) {
+ ((JTextField) o).setText(strValue);
+ }
+ if (o instanceof JRadioButton) {
+ ((JRadioButton) o).setSelected(Boolean.valueOf(strValue.isEmpty() ? "false" : strValue));
+ }
+ if (o instanceof JCheckBox) {
+ ((JCheckBox) o).setSelected(Boolean.valueOf(strValue.isEmpty() ? "false" : strValue));
+ }
+ if (o instanceof JComboBox) {
+ ((JComboBox) o).setSelectedItem(value);
+ }
+ }
+
+ public JLabel getElementLabel(E key) {
+ return (JLabel) getObjectById(key.name() + "Label");
+ }
+
+ public void doCheck(E key) {
+ getHandler().doCheck(key);
+ }
+
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,156 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.jaxx.util.DialogUIHandler;
+import org.codelutin.util.ConverterUtil;
+import org.codelutin.util.config.Config;
+import org.codelutin.util.config.Property;
+
+import javax.swing.JComponent;
+import java.awt.Color;
+import java.beans.PropertyChangeEvent;
+import java.util.EnumMap;
+import java.util.EnumSet;
+
+/**
+ * DialogUI handler
+ *
+ * @author chemit
+ */
+public abstract class DialogConfigUIHandler<E extends Enum<E>, M extends DialogConfigUIModel<E, ?>, U extends DialogConfigUI<E, ?>> extends DialogUIHandler<M, U> {
+
+ protected DialogConfigUIHandler(U ui, M model) {
+ super(ui, model);
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isDebugEnabled()) {
+ log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
+ }
+ String action = evt.getPropertyName();
+
+ if (DialogConfigUIModel.CONFIG_PROPERTY_CHANGED.equals(action)) {
+ // update ui with model values,
+ populateUI();
+ // revalidate form
+ doCheckAll();
+ return;
+ }
+
+ if (DialogConfigUIModel.MODIFIED_PROPERTY_CHANGED.equals(action)) {
+ Boolean newValue = (Boolean) evt.getNewValue();
+ boolean modified = newValue != null && newValue;
+ getUi().getReset().setEnabled(modified);
+ getUi().getOk().setEnabled(modified && getModel().isConfigValid());
+ return;
+ }
+
+ if (DialogConfigUIModel.UNVALID_PROPERTY_CHANGED.equals(action)) {
+ updateUI();
+ return;
+ }
+
+ throw new IllegalStateException("unimplemented property changed : " + evt + " for " + this);
+ }
+
+ public void doCheck(E key) {
+ Object uiValue = getUi().getElementValue(key);
+ DialogConfigUIModel<E, ?> model = getModel();
+ Object currentValue = model.getCurrent().getProperty(key);
+ if (currentValue == null) {
+ currentValue = "";
+ } else {
+ currentValue = String.valueOf(currentValue);
+ }
+
+ model.validateProperty(key, uiValue);
+ model.changeModifiedState(key, uiValue, currentValue);
+ }
+
+ public void doCheckAll() {
+ DialogConfigUIModel<E, ?> model = getModel();
+ EnumSet<E> unvalids = EnumSet.noneOf(model.klass);
+ for (E e : model.getCheckedKeysSet()) {
+ Object uiValue = getUi().getElementValue(e);
+ if (!model.isValid(e, uiValue)) {
+ unvalids.add(e);
+ }
+ }
+ model.setUnvalids(unvalids);
+ unvalids.clear();
+ }
+
+ protected boolean prepareSave() {
+ DialogConfigUI<E, ?> ui = getUi();
+ DialogConfigUIModel<E, ?> model = getModel();
+
+ Config<E> current = model.getCurrent();
+
+ if (!model.isConfigValid()) {
+ log.warn("do not save a unvalid config : " + model.getUnvalids());
+ return false;
+ }
+
+ if (!model.isModified()) {
+ log.warn("nothing to save");
+ return false;
+ }
+ EnumSet<E> toTreate = model.getCheckedKeysSet();
+ // transfert checkable values from ui to model
+ for (E key : model.getModifieds()) {
+ if (!toTreate.contains(key)) {
+ continue;
+ }
+ Object value = ui.getElementValue(key);
+ Class<?> type = ((Property) key).getType();
+ Object newValue = ConverterUtil.convert(type, value);
+ current.setProperty(key, newValue);
+ }
+
+ return true;
+ }
+
+ protected void populateUI() {
+ U ui = getUi();
+ EnumMap<E, Object> map = getModel().getCurrent().getProperties();
+ for (E e : getModel().getCheckedKeysSet()) {
+ Object value = map.get(e);
+ populateUI(ui, e, value);
+ }
+ }
+
+ protected void populateUI(U ui, E key, Object value) {
+ ui.setElementValue(key, value);
+ }
+
+ protected void updateUI() {
+ EnumSet<E> unvalids = getModel().getUnvalids();
+ for (E key : unvalids) {
+ setLabelColor(key, false);
+ }
+ for (E key : EnumSet.complementOf(unvalids)) {
+ setLabelColor(key, true);
+ }
+ }
+
+ protected void setLabelColor(E key, boolean valid) {
+ JComponent component = getUi().getElementLabel(key);
+ if (component != null && component.isVisible()) {
+ component.setForeground(valid ? Color.black : Color.red);
+ }
+ }
+
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,220 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.jaxx.util.DialogUIModel;
+import org.codelutin.util.config.Config;
+
+import java.util.EnumSet;
+
+/**
+ * Abstract config ui model.
+ *
+ * @author chemit
+ */
+public abstract class DialogConfigUIModel<E extends Enum<E>, C extends Config<E>> extends DialogUIModel {
+
+ public static final String CONFIG_PROPERTY_CHANGED = "config";
+ public static final String MODIFIED_PROPERTY_CHANGED = "modify";
+ public static final String UNVALID_PROPERTY_CHANGED = "unvalid";
+
+ /** @return a empty config */
+ protected abstract C newConfig();
+
+ /**
+ * @param key property key
+ * @param value value to validate
+ * @return <code>true</code> if given value is valid for property, <code>false>/code> otherwise
+ */
+ protected abstract boolean isValid(E key, Object value);
+
+ /**
+ * object used to init model and save model, this is an external object.
+ * <p/>
+ * The object must have bean read-write properties for each value of E
+ */
+ protected Object src;
+
+ /** current config used in model */
+ protected C current;
+
+ /** set of modified properties */
+ protected EnumSet<E> modifieds;
+
+ /** set of unvalid properties */
+ protected EnumSet<E> unvalids;
+
+ /** enum class */
+ protected Class<E> klass;
+
+ /** set of key not to check */
+ protected EnumSet<E> uncheckedKeys;
+
+ /** set of all keys checkable */
+ protected EnumSet<E> checkedKeysSet;
+
+ protected DialogConfigUIModel(Class<E> klass) {
+ this.klass = klass;
+ this.current = newConfig();
+ this.modifieds = EnumSet.noneOf(klass);
+ this.unvalids = EnumSet.noneOf(klass);
+ }
+
+ public EnumSet<E> getCheckedKeysSet() {
+ if (checkedKeysSet == null) {
+ if (uncheckedKeys != null) {
+ checkedKeysSet = EnumSet.complementOf(uncheckedKeys);
+ } else {
+ checkedKeysSet = EnumSet.allOf(klass);
+ }
+ }
+ return checkedKeysSet;
+ }
+
+ public Object getSrc() {
+ return src;
+ }
+
+ public C getCurrent() {
+ return current;
+ }
+
+ public EnumSet<E> getUnivserse() {
+ return getCurrent().getUniverse();
+ }
+
+ public EnumSet<E> getModifieds() {
+ return modifieds;
+ }
+
+ public EnumSet<E> getUnvalids() {
+ return unvalids;
+ }
+
+ public boolean isModified() {
+ return !modifieds.isEmpty();
+ }
+
+ public boolean isConfigValid() {
+ return unvalids.isEmpty();
+ }
+
+ public void populate(Object src) {
+ this.src = src;
+ this.current = newConfig();
+ if (src != null) {
+ this.current.copyFrom(src);
+ }
+ this.modifieds.clear();
+ this.unvalids.clear();
+ setModified(false);
+ firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this);
+ }
+
+ public void reset() {
+ populate(src);
+ }
+
+ public void setModified(boolean modified) {
+ firePropertyChange(MODIFIED_PROPERTY_CHANGED, null, modified);
+ }
+
+ public void setUnvalid(boolean unvalid) {
+ firePropertyChange(UNVALID_PROPERTY_CHANGED, null, unvalid);
+ }
+
+ public void addModified(E key) {
+ if (!modifieds.contains(key)) {
+ modifieds.add(key);
+ log.debug(key);
+ }
+ setModified(!modifieds.isEmpty());
+ }
+
+ public void removeModified(E key) {
+
+ if (modifieds.contains(key)) {
+ modifieds.remove(key);
+ }
+ setModified(!modifieds.isEmpty());
+ }
+
+ public void removeModified(EnumSet<E> keys) {
+ for (E key : keys) {
+ if (modifieds.contains(key)) {
+ modifieds.remove(key);
+ }
+ }
+ setModified(!modifieds.isEmpty());
+ }
+
+ public void setUnvalids(EnumSet<E> keys) {
+ for (E key : keys) {
+ if (!unvalids.contains(key)) {
+ unvalids.add(key);
+ }
+ }
+ for (E key : EnumSet.complementOf(keys)) {
+ if (unvalids.contains(key)) {
+ unvalids.remove(key);
+ }
+ }
+ setUnvalid(!unvalids.isEmpty());
+ }
+
+
+ public void addUnvalid(E key) {
+ if (!unvalids.contains(key)) {
+ unvalids.add(key);
+ }
+ setUnvalid(!unvalids.isEmpty());
+ }
+
+ public void removeUnvalid(E key) {
+ if (unvalids.contains(key)) {
+ unvalids.remove(key);
+ }
+ setUnvalid(!unvalids.isEmpty());
+ }
+
+ public void save() {
+ current.copyTo(src, modifieds);
+ modifieds.clear();
+ // redisplay config
+ firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this);
+ }
+
+ public void changeModifiedState(E key, Object uiValue, Object currentValue) {
+ if (uiValue!=null && uiValue.equals(currentValue)) {
+ removeModified(key);
+ } else {
+ addModified(key);
+ }
+ }
+
+ public void clear(E key) {
+ log.info(key);
+ modifieds.remove(key);
+ unvalids.remove(key);
+ }
+
+ protected void validateProperty(E key, Object uiValue) {
+ if (isValid(key, uiValue)) {
+ removeUnvalid(key);
+ } else {
+ addUnvalid(key);
+ }
+ }
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -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.util.config;
+
+import org.codelutin.jaxx.util.AbstractUIAction;
+import org.codelutin.jaxx.util.DialogUI;
+import org.codelutin.jaxx.util.UIHelper;
+
+import java.awt.event.ActionEvent;
+
+/** @author chemit */
+public class ResetAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
+ private static final long serialVersionUID = 1L;
+
+ public ResetAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
+ super(null, UIHelper.createActionIcon("reset-config"), dialogUI);
+ if (showLabel) {
+ String text = org.codelutin.i18n.I18n._("lutinui.config.reset");
+ putValue(NAME, text);
+ putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
+ putValue(MNEMONIC_KEY, (int) text.charAt(0));
+ }
+ String libelle = org.codelutin.i18n.I18n._("lutinui.config.reset.tooltip");
+ putValue(SHORT_DESCRIPTION, libelle);
+
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ getHandler().getModel().reset();
+ }
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java (from rev 1237, jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java)
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java (rev 0)
+++ jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -0,0 +1,50 @@
+/**
+ * ##% 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.util.config;
+
+import org.codelutin.jaxx.util.AbstractUIAction;
+import org.codelutin.jaxx.util.DialogUI;
+import org.codelutin.jaxx.util.UIHelper;
+
+import java.awt.event.ActionEvent;
+
+/** @author chemit */
+public class SaveAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
+ private static final long serialVersionUID = 1L;
+
+ public SaveAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
+ super(null, UIHelper.createActionIcon("save-config"), dialogUI);
+ if (showLabel) {
+ String text = org.codelutin.i18n.I18n._("lutinui.config.save");
+ putValue(NAME, text);
+ putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
+ putValue(MNEMONIC_KEY, (int) text.charAt(0));
+ }
+ String libelle = org.codelutin.i18n.I18n._("lutinui.config.save.tooltip");
+ putValue(SHORT_DESCRIPTION, libelle);
+ }
+
+ public void actionPerformed(ActionEvent e) {
+
+ if (getHandler().prepareSave()) {
+
+ // save model to src
+ getHandler().getModel().save();
+
+ // close ui
+ getUi().dispose();
+ }
+ }
+}
Property changes on: jaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jaxx/trunk/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-en_GB.properties 2009-02-23 13:06:52 UTC (rev 1241)
@@ -2,3 +2,9 @@
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
+lutinui.config.cancel=Cancel
+lutinui.config.cancel.tooltip=Cancel and quit
+lutinui.config.reset=Reset
+lutinui.config.reset.tooltip=Reset configuration
+lutinui.config.save=Save
+lutinui.config.save.tooltip=Save configuration and quit
Modified: jaxx/trunk/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-swing-action/src/main/resources/i18n/jaxx-swing-action-fr_FR.properties 2009-02-23 13:06:52 UTC (rev 1241)
@@ -2,3 +2,9 @@
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
+lutinui.config.cancel=Annuler
+lutinui.config.cancel.tooltip=Annuler les modification et quitter
+lutinui.config.reset=R\u00E9initialiser
+lutinui.config.reset.tooltip=R\u00E9initialiser la configuration
+lutinui.config.save=Sauver
+lutinui.config.save.tooltip=Sauver la configuration et quitter
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/AbstractUIAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,53 +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.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/** @author chemit */
-public abstract class AbstractUIAction<H extends DialogUIHandler<?, ?>> extends javax.swing.AbstractAction {
-
- protected static Log log = LogFactory.getLog(AbstractUIAction.class);
-
- protected transient DialogUI<? extends H> ui;
-
- private static final long serialVersionUID = 1L;
-
- protected AbstractUIAction(String name, javax.swing.Icon icon, DialogUI<? extends H> ui) {
- super(name, icon);
- this.ui = ui;
- }
-
- protected H getHandler() {
- checkInit();
- return ui.getHandler();
- }
-
- protected void setUi(DialogUI<? extends H> ui) {
- this.ui = ui;
- }
-
- public DialogUI<? extends H> getUi() {
- return ui;
- }
-
- protected void checkInit() throws IllegalStateException {
- /*if (ui == null) {
- throw new IllegalStateException("no handler, nor ui referenced in " + this);
- } */
- }
-
-}
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUI.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUI.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUI.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,129 +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.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.AbstractAction;
-import javax.swing.AbstractButton;
-import javax.swing.ImageIcon;
-import javax.swing.JDialog;
-import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
-import java.lang.reflect.Constructor;
-
-/**
- * A abstract dialog contract to be realised by a dialogUI (WindowEvent adapter)
- * <p/>
- * TODO : make jaxx authorized implementing interface for root tag :)
- *
- * @author chemit
- */
-public abstract class DialogUI<H extends DialogUIHandler> extends JDialog implements WindowListener {
-
- protected static Log log = LogFactory.getLog(DialogUI.class);
-
- public javax.swing.AbstractAction newAction(Class<?> actionClass, Object... params) {
- Constructor<?> constructor = null;
- for (Constructor<?> cons : actionClass.getConstructors()) {
- Class<?>[] prototype = cons.getParameterTypes();
- if (prototype.length > 0 && DialogUI.class.isAssignableFrom(prototype[0])) {
- // use this constructor
- constructor = cons;
- break;
- }
- }
- if (constructor == null) {
- throw new IllegalStateException("could not find a matching constructor for " + actionClass);
- }
-
- // wrap params
- Object[] parameters = new Object[1 + params.length];
- parameters[0] = this;
- System.arraycopy(params, 0, parameters, 1, params.length);
- try {
- AbstractAction action = (AbstractAction) constructor.newInstance(parameters);
- if (log.isInfoEnabled()) {
- log.info(action);
- }
- return action;
- } catch (Exception e) {
- throw new IllegalStateException("could not init the action " + actionClass + " for reason : " + e.getMessage());
- }
- }
-
- private H handler;
-
- public abstract AbstractButton getHelp();
-
- public abstract Object getObjectById(java.lang.String s);
-
- protected DialogUI() {
- UIHelper.setQuitAction(this);
- addWindowListener(this);
- //TODO will be handled by jaxx with javax.help...
- //getHelp().setAction(newAction(HelpAction.class));
- }
-
- public H getHandler() {
- return handler;
- }
-
- public void setHandler(H handler) {
- this.handler = handler;
- }
-
- protected ImageIcon createActionIcon(String name) {
- return UIHelper.createActionIcon(name);
- }
-
- public void windowOpened(WindowEvent e) {
- }
-
- public void windowClosed(WindowEvent e) {
- }
-
- public void windowClosing(WindowEvent e) {
- }
-
- public void windowIconified(WindowEvent e) {
- }
-
- public void windowDeiconified(WindowEvent e) {
- }
-
- public void windowActivated(WindowEvent e) {
- }
-
- public void windowDeactivated(WindowEvent e) {
- }
-
- @Override
- public synchronized void addWindowListener(WindowListener l) {
- super.addWindowListener(l);
- if (log.isDebugEnabled()) {
- log.debug("after added (" + getWindowListeners().length + ") : " + l);
- }
- }
-
- @Override
- public synchronized void removeWindowListener(WindowListener l) {
- super.removeWindowListener(l);
- if (log.isDebugEnabled()) {
- log.debug("after removed (" + getWindowListeners().length + ") : " + l);
- }
- }
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIDef.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,235 +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.util;
-
-import static org.codelutin.i18n.I18n._;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.ImageIcon;
-import java.lang.reflect.Constructor;
-
-/**
- * Definition of an ui, with his model, handler and ui class definitions.
- * <p/>
- * The class contains also a shared instace of concrete ui.
- *
- * @author chemit
- */
-public class DialogUIDef<M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> implements java.io.Serializable {
-
- static protected final Log log = LogFactory.getLog(DialogUIDef.class);
-
- public static <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> DialogUIDef<M, U, H> newDef(Class<H> handlerClass, Class<U> uiClass, Class<M> modelClass, String showActionLibelle, String showActionTip, String uiTitle) {
- DialogUIDef<M, U, H> result;
- result = new DialogUIDef<M, U, H>(handlerClass, uiClass, modelClass, showActionLibelle, showActionTip, uiTitle);
- return result;
- }
-
- /**
- * model class
- */
- private final Class<M> modelClass;
-
- /**
- * handler class
- */
- private final Class<H> handlerClass;
-
- /**
- * abstract ui class
- */
- private final Class<U> uiClass;
-
- /**
- * concrete lookup ui class
- */
- private Class<? extends U> uiImplClass;
-
- /**
- * shared instance of ui
- */
- protected U uiInstance;
-
- /**
- * unique name of ui def
- */
- protected final String name;
-
- protected final String uiTitle;
- protected final String showActionLibelle;
- protected final String showActionTip;
-
- protected ImageIcon showUIActionIcon;
-
-
- private static final long serialVersionUID = 1L;
-
- private DialogUIDef(Class<H> handlerClass, Class<U> uiClass, Class<M> modelClass,
- String showActionLibelle, String showActionTip, String uiTitle) {
- this.handlerClass = handlerClass;
- this.uiClass = uiClass;
- this.modelClass = modelClass;
- this.showActionLibelle = showActionLibelle;
- this.name = uiClass.getSimpleName().toLowerCase();
- this.showActionTip = showActionTip;
- this.uiTitle = uiTitle;
- }
-
- public Class<U> getUiClass() {
- return uiClass;
- }
-
- public Class<H> getHandlerClass() {
- return handlerClass;
- }
-
- public Class<M> getModelClass() {
- return modelClass;
- }
-
- public Class<? extends U> getUiImplClass() {
- return uiImplClass;
- }
-
- public String getUiTitle() {
- return _(uiTitle);
- }
-
- public String getShowActionLibelle() {
- return _(showActionLibelle);
- }
-
- public String getShowActionTip() {
- return _(showActionTip);
- }
-
- public ImageIcon getShowUIActionIcon() {
- if (showUIActionIcon == null) {
- showUIActionIcon = UIHelper.createActionIcon("show-" + name);
- }
- return showUIActionIcon;
- }
-
- @SuppressWarnings({"unchecked"})
- public void setUiImplClass(Class<?> uiImplClass) {
- this.uiImplClass = (Class<? extends U>) uiImplClass;
- }
-
- @Override
- public boolean equals(Object o) {
- return this == o || o instanceof DialogUIDef && uiClass.equals(((DialogUIDef) o).uiClass);
- }
-
- @Override
- public int hashCode() {
- return uiClass.hashCode();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(super.toString()).append('<');
- sb.append(printClass("handler", handlerClass, true));
- sb.append(printClass("model", modelClass, true));
- sb.append(printClass("ui", uiClass, true));
- sb.append(printClass("uiImpl", uiImplClass, false));
- return sb.toString();
- }
-
- protected U getUiInstance() {
- // no lazy instanciation, to control ui instanciation...
- /*if (uiInstance == null) {
- if (uiImplClass == null) {
- throw new IllegalStateException("no concrete ui impl found in " + this);
- }
- synchronized (this) {
- try {
- uiInstance = uiImplClass.newInstance();
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui " + this,e);
- }
- }
- }*/
- return uiInstance;
- }
-
- protected void setUiInstance(U uiInstance) {
- this.uiInstance = uiInstance;
- }
-
- protected U newUI() {
- if (uiImplClass == null) {
- throw new IllegalStateException("no concrete ui impl found in " + this);
- }
- try {
- U result = uiImplClass.newInstance();
- log.info(result);
- return result;
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui " + this, e);
- }
- }
-
- protected M newModel() {
- if (modelClass == null) {
- throw new IllegalStateException("no model impl found in " + this);
- }
- try {
- M model = modelClass.newInstance();
- log.info(model);
- return model;
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui " + this, e);
- }
- }
-
- protected H newHandler(U ui, M model, Object... params) {
- if (handlerClass == null) {
- throw new IllegalStateException("no handler impl found in " + this);
- }
- try {
- Class[] prototype = getHandlerPrototype(params);
- Object[] parameters = getHandlerParameters(ui, model, params);
- H result = handlerClass.getConstructor(prototype).newInstance(parameters);
- log.info(result);
- return result;
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui " + this, e);
- }
- }
-
- protected Object[] getHandlerParameters(U ui, M model, Object[] params) {
- Object[] result = new Object[2 + params.length];
- result[0] = ui;
- result[1] = model;
- System.arraycopy(params, 0, result, 2, params.length);
- return result;
- }
-
- protected Class[] getHandlerPrototype(Object[] params) {
- int length = params.length;
- for (Constructor<?> constructor : handlerClass.getConstructors()) {
- Class<?>[] prototype = constructor.getParameterTypes();
- if (prototype.length == 2 + length && prototype[0] == uiClass && prototype[1] == modelClass) {
- return prototype;
- }
- }
- throw new IllegalStateException("could not find a matching constructor in " + handlerClass);
- }
-
- protected String printClass(String s, Class<?> aClass, boolean notLast) {
- return s + ':' + (aClass == null ? null : aClass.getSimpleName()) + (notLast ? ", " : ">");
- }
-}
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIHandler.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,70 +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.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.awt.event.WindowListener;
-import java.beans.PropertyChangeListener;
-
-/**
- * DialogUI handler
- *
- * @author chemit
- */
-public abstract class DialogUIHandler<M extends DialogUIModel, U extends DialogUI<? extends DialogUIHandler>> implements PropertyChangeListener {
-
- protected static Log log = LogFactory.getLog(DialogUIHandler.class);
-
- /** ui handled */
- private U ui;
-
- /** model handled */
- private M model;
-
- protected DialogUIHandler(U ui, M model) {
- this.ui = ui;
- this.model = model;
- }
-
- public U getUi() {
- return ui;
- }
-
- public M getModel() {
- return model;
- }
-
- public void init() {
- if (model == null) {
- throw new IllegalStateException("no model was defined for " + this);
- }
- model.addPropertyChangeListener(this);
- }
-
- public void dispose() {
- model.dispose();
- for (WindowListener windowListener : getUi().getWindowListeners()) {
- getUi().removeWindowListener(windowListener);
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- dispose();
- }
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/DialogUIModel.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,97 +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.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-
-/**
- * Abstract ui model, with property change support.
- *
- * @author chemit
- */
-public abstract class DialogUIModel {
-
- static protected final Log log = LogFactory.getLog(DialogUIModel.class);
-
- /** support for change properties support */
- protected PropertyChangeSupport changeSupport;
-
- public synchronized void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- if (listener == null) {
- return;
- }
- if (changeSupport == null) {
- changeSupport = new PropertyChangeSupport(this);
- }
- changeSupport.addPropertyChangeListener(propertyName, listener);
- }
-
- public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
- if (listener == null) {
- return;
- }
- if (changeSupport == null) {
- changeSupport = new PropertyChangeSupport(this);
- }
- changeSupport.addPropertyChangeListener(listener);
- }
-
- public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
- if (listener == null || changeSupport == null) {
- return;
- }
- changeSupport.removePropertyChangeListener(listener);
- }
-
- public synchronized void removePropertyChangeListeners() {
- if (changeSupport == null) {
- return;
- }
- for (PropertyChangeListener listener : getPropertyChangeListeners()) {
- changeSupport.removePropertyChangeListener(listener);
- }
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- if (changeSupport == null) {
- return new PropertyChangeListener[0];
- }
- return changeSupport.getPropertyChangeListeners();
- }
-
- public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- if (changeSupport == null || (oldValue == null && newValue == null) ||
- (oldValue != null && oldValue.equals(newValue))) {
- return;
- }
- changeSupport.firePropertyChange(propertyName, oldValue, newValue);
- }
-
- public void dispose() {
- for (PropertyChangeListener listener : changeSupport.getPropertyChangeListeners()) {
- changeSupport.removePropertyChangeListener(listener);
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- dispose();
- }
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FactoryWindowListener.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,84 +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.util;
-
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-/**
- * A windowListenr for ui managed by {@link org.codelutin.jaxx.util.UIFactory}.
- * <p/>
- * To be used when all ui from factory are closed, via {@link #allWindowsClosed(java.awt.event.WindowEvent)} method.
- *
- * @author chemit
- */
-public abstract class FactoryWindowListener extends WindowAdapter {
-
- /**
- * method to be invoked when all ui registred in factory are really disposed.
- *
- * @param e event
- */
- public abstract void allWindowsClosed(WindowEvent e);
-
- /** underlying factory of ui */
- private UIFactory factory;
-
- /** flag to make sure {@link #allWindowsClosed(java.awt.event.WindowEvent)} is called only once. */
- private boolean wasClosed;
-
- @Override
- public void windowClosed(WindowEvent e) {
- if (UIFactory.log.isDebugEnabled()) {
- UIFactory.log.debug(this + " : " + e);
- }
- if (e.getWindow().isVisible()) {
- // only deal with real closed and none visible windows...
- return;
- }
- for (DialogUIDef def : factory.getDefs()) {
- DialogUI ui = def.uiInstance;
- if (ui != null && ui.isVisible()) {
- // at least one ui visible, do not close all
- return;
- }
- }
-
- if (wasClosed) {
- // make sure to process only once
- return;
- }
- if (UIFactory.log.isInfoEnabled()) {
- UIFactory.log.info("closing factory listener " + this);
- }
-
- synchronized (this) {
- try {
- allWindowsClosed(e);
- } finally {
- wasClosed = true;
- factory.removeFactoryWindowListener(this);
- }
- }
- }
-
- protected UIFactory getFactory() {
- return factory;
- }
-
- protected void setFactory(UIFactory factory) {
- this.factory = factory;
- }
-}
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FormElement.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FormElement.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/FormElement.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,29 +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.util;
-
-/** @author chemit */
-public interface FormElement<U extends DialogUI> {
-
- String name();
-
- int ordinal();
-
- Object getValue(U ui);
-
- void setValue(U ui, String value);
-
- javax.swing.JLabel getLabel(U ui);
-}
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/ShowUIAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,135 +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.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.awt.Dimension;
-import java.awt.Point;
-import java.awt.event.ActionEvent;
-
-/** @author chemit */
-public abstract class ShowUIAction<M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> extends javax.swing.AbstractAction {
-
- protected static Log log = LogFactory.getLog(AbstractUIAction.class);
-
- protected transient DialogUI<?> ui;
-
- private static final long serialVersionUID = 1L;
-
- protected DialogUIDef<M, U, H> uiDef;
-
- protected transient UIFactory factory;
-
- protected String position;
-
- protected boolean undecorated = true;
-
- protected U initUI(ActionEvent e) {
- return getFactory().getUI(uiDef);
- }
-
- public ShowUIAction(DialogUI<?> ui, DialogUIDef<M, U, H> uiDef, UIFactory factory, boolean showText) {
- super(uiDef.getShowActionLibelle(), uiDef.getShowUIActionIcon());
- this.ui = ui;
- this.uiDef = uiDef;
- String name = (String) getValue(NAME);
- putValue(DISPLAYED_MNEMONIC_INDEX_KEY, name.length() - 1);
- putValue(ACCELERATOR_KEY, (int) name.charAt(name.length() - 1));
- if (!showText) {
- putValue(NAME, null);
- }
- putValue(SHORT_DESCRIPTION, uiDef.getShowActionTip());
- this.factory = factory;
- }
-
- public DialogUI<?> getUi() {
- return ui;
- }
-
- public DialogUIDef<M, U, H> getUiDef() {
- return uiDef;
- }
-
- public UIFactory getFactory() {
- return factory;
- }
-
- public void setUiDef(DialogUIDef<M, U, H> uiDef) {
- this.uiDef = uiDef;
- }
-
- public void setPosition(String position) {
- this.position = position;
- }
-
- public void setUndecorated(boolean undecorated) {
- this.undecorated = undecorated;
- }
-
- public void actionPerformed(java.awt.event.ActionEvent e) {
- checkInit();
- U ui = initUI(e);
- ui.setTitle(uiDef.getUiTitle());
- log.info(ui.getTitle());
- //TODO ui.setUndecorated(undecorated);
- setPosition(this.getUi(), ui, position);
-
- ui.setVisible(true);
- }
-
- protected void setPosition(javax.swing.JDialog parentUI, javax.swing.JDialog ui, String position) {
- if (position == null || parentUI == null) {
- return;
- }
- Point parentLocation = parentUI.getLocationOnScreen();
- Dimension parentSize = parentUI.getSize();
-
- if (position.equals("bottom-left")) {
- int top = (int) (parentLocation.getY() + parentSize.getHeight());
- int left = (int) (parentLocation.getX());
- Point newLocation = new Point(left, top);
- newLocation.setLocation(left, top);
- ui.setLocation(newLocation);
- return;
- }
- if (position.equals("top-left")) {
- int top = (int) (parentLocation.getY());
- int left = (int) (parentLocation.getX());
- Point newLocation = new Point(left, top);
- newLocation.setLocation(left, top);
- ui.setLocation(newLocation);
- return;
- }
- if (position.equals("top-right")) {
- int top = (int) (parentLocation.getY());
- int left = (int) (parentLocation.getX() + parentSize.getWidth());
- Point newLocation = new Point(left, top);
- newLocation.setLocation(left, top);
- ui.setLocation(newLocation);
- return;
- }
- if (position.equals(("center"))) {
- //TODO
- }
- }
-
- protected void checkInit() throws IllegalStateException {
- if (factory == null) {
- throw new IllegalStateException("no factory found in " + this);
- }
- }
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIFactory.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIFactory.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIFactory.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,184 +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.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.util.StringUtil;
-
-import javax.swing.event.EventListenerList;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.ServiceLoader;
-
-/**
- * Factory for UI, using a cache and a provider to find ui implementations.
- *
- * @author chemit
- */
-public class UIFactory {
-
- static protected final Log log = LogFactory.getLog(UIFactory.class);
-
- private final String applicationName;
-
- private final DialogUIDef[] defs;
-
- private final EventListenerList listeners;
-
- public UIFactory(String applicationName, DialogUIDef[] defs, FactoryWindowListener... listeners) {
- this.applicationName = applicationName;
- this.listeners = new EventListenerList();
- for (FactoryWindowListener listener : listeners) {
- listener.setFactory(this);
- addFactoryWindowListener(listener);
- }
- this.defs = defs;
- long t0 = System.nanoTime();
- if (log.isDebugEnabled()) {
- log.debug("start at " + new java.util.Date());
- }
- try {
- init();
- } catch (Exception e) {
- log.error(e);
- throw new RuntimeException(e);
- } finally {
- if (log.isDebugEnabled()) {
- log.info("end in " + StringUtil.convertTime(t0, System.nanoTime()));
- }
- }
- }
-
- public void addFactoryWindowListener(FactoryWindowListener l) {
- listeners.add(FactoryWindowListener.class, l);
- if (log.isDebugEnabled()) {
- log.debug("after added (" + listeners.getListenerCount() + ") : " + l);
- }
- }
-
- public void removeFactoryWindowListener(FactoryWindowListener l) {
- listeners.remove(FactoryWindowListener.class, l);
- for (DialogUIDef def : getDefs()) {
- if (def.uiInstance != null) {
- def.uiInstance.removeWindowListener(l);
- }
- }
- if (log.isDebugEnabled()) {
- log.debug(" after removed (" + listeners.getListenerCount() + ") : " + l);
- }
- if (listeners.getListenerCount(FactoryWindowListener.class) == 0) {
- // close for real factory
- close();
- }
- }
-
- public void close() {
- log.info(this + " at " + new java.util.Date());
- for (DialogUIDef<?, ?, ?> def : defs) {
- DialogUI<?> ui = def.uiInstance;
- if (ui != null) {
- ui.getHandler().dispose();
- def.uiInstance = null;
- }
- }
- if (listeners.getListenerCount(FactoryWindowListener.class) > 0) {
- log.warn("some listeners where not properly removed, force deletion...");
- for (FactoryWindowListener listener : listeners.getListeners(FactoryWindowListener.class)) {
- removeFactoryWindowListener(listener);
- }
- }
-
- }
-
- protected void init() {
-
- UIProvider[] providers = detectProviders();
-
- for (DialogUIDef<?, ?, ?> def : defs) {
- initDef(providers, def);
- if (def.getUiImplClass() == null) {
- throw new IllegalStateException("could not find implementation for ui def " + def);
- }
- }
- }
-
- protected void initDef(UIProvider[] providers, DialogUIDef<?, ?, ?> def) {
- for (UIProvider provider : providers) {
- Class<?> uiImplClass = provider.findUIImplementation(def);
- if (uiImplClass != null) {
- if (log.isDebugEnabled()) {
- log.debug("init done for " + def);
- }
- // ui implementation was found
- break;
- }
- }
- }
-
- protected UIProvider[] detectProviders() {
- long t0 = System.nanoTime();
- List<UIProvider> providers = new ArrayList<UIProvider>();
- for (UIProvider provider : ServiceLoader.load(UIProvider.class)) {
- if (applicationName.equals(provider.getApplicationName())) {
- if (log.isDebugEnabled()) {
- log.debug("provider detected [" + provider + ']');
- }
- providers.add(provider);
- }
- }
- log.info("found " + providers.size() + " ui provider(s) in " + StringUtil.convertTime(t0, System.nanoTime()) + " : " + providers);
- return providers.toArray(new UIProvider[providers.size()]);
- }
-
- protected DialogUIDef[] getDefs() {
- return defs;
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- close();
- }
-
- public <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> U getUI(DialogUIDef<M, U, H> uiType, Object... params) {
- U ui = uiType.uiInstance;
- if (ui == null) {
- try {
- ui = uiType.newUI();
- M model = uiType.newModel();
- H handler = uiType.newHandler(ui, model, params);
- registerUI(uiType, ui, handler);
- } catch (Exception e) {
- throw new IllegalStateException("could not instanciate ui handler " + uiType + " for reason : " + e.getMessage(), e);
- }
- }
- return ui;
- }
-
- protected <M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>> void registerUI(DialogUIDef<M, U, H> uiType, U ui, H handler) {
- ui.setHandler(handler);
- handler.init();
- uiType.setUiInstance(ui);
- for (FactoryWindowListener listener : listeners.getListeners(FactoryWindowListener.class)) {
- if (log.isDebugEnabled()) {
- log.debug("----- addFactoryWindowListener " + listener + " to " + ui);
- }
- ui.addWindowListener(listener);
- }
- }
-
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIHelper.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIHelper.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIHelper.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,70 +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.util;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.ImageIcon;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JRootPane;
-import javax.swing.KeyStroke;
-import java.awt.event.ActionEvent;
-
-/**
- * Ui helper class.
- *
- * @author tony
- */
-public class UIHelper {
-
- public static ImageIcon createImageIcon(String path) {
- java.net.URL imgURL = UIHelper.class.getResource("/icons/" + path);
- if (imgURL != null) {
- return new ImageIcon(imgURL);
- } else {
- throw new IllegalArgumentException("could not find icon " + path);
- }
- }
-
- /**
- * Attach to <code>ui</code> an abort action,accessible by <code>ESC</code> key.
- *
- * @param ui ui
- */
- public static void setQuitAction(final JDialog ui) {
- JRootPane rootPane = ui.getRootPane();
-
- Action quitAction = new AbstractAction("quit") {
- private static final long serialVersionUID = -869095664995763057L;
-
- public void actionPerformed(ActionEvent e) {
- ui.dispose();
- }
- };
- rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "quit");
- rootPane.getActionMap().put("quit", quitAction);
- ui.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
- }
-
- public static ImageIcon createActionIcon(String name) {
- return createImageIcon("action-" + name + ".png");
- }
-
-}
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIProvider.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIProvider.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/UIProvider.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,86 +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.util;
-
-/** @author chemit */
-public abstract class UIProvider {
-
- /** the name of application using this provider */
- protected String applicationName;
-
- /** the name of ui implementation used by this provider */
- protected String providerName;
-
- /** array of ui implementations */
- protected Class<?>[] implementations;
-
- protected UIProvider(String applicationName, String providerName, Class<?>... implementations) {
- this.applicationName = applicationName;
- this.providerName = providerName;
- this.implementations = implementations;
- }
-
- public String getProviderName() {
- return providerName;
- }
-
- public String getApplicationName() {
- return applicationName;
- }
-
- public Class<?>[] getImplementations() {
- return implementations;
- }
-
- public Class<?> findUIImplementation(DialogUIDef<?, ?, ?> def) {
- Class<? extends DialogUI<?>> uiClass = def.getUiClass();
- for (Class<?> klass : implementations) {
- if (uiClass.isAssignableFrom(klass)) {
- def.setUiImplClass(klass);
- return klass;
- }
- }
- return null;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(super.toString()).append('<');
- sb.append(printClass("application", applicationName, true));
- sb.append(printClass("provider", providerName, true));
- sb.append(printClass("uis", implementations.length, false));
- return sb.toString();
- }
-
- protected String printClass(String s, Object aClass, boolean notLast) {
- return s + ':' + (aClass == null ? null : aClass) + (notLast ? ", " : ">");
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof UIProvider)) return false;
-
- UIProvider that = (UIProvider) o;
- return applicationName.equals(that.applicationName) && providerName.equals(that.providerName);
-
- }
-
- @Override
- public int hashCode() {
- return (31 * applicationName.hashCode()) + providerName.hashCode();
- }
-
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/CancelAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -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.util.config;
-
-import org.codelutin.jaxx.util.AbstractUIAction;
-import org.codelutin.jaxx.util.DialogUI;
-import org.codelutin.jaxx.util.UIHelper;
-
-import java.awt.event.ActionEvent;
-
-/** @author chemit */
-public class CancelAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
- private static final long serialVersionUID = 1L;
-
- public CancelAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
- super(null, UIHelper.createActionIcon("cancel-config"), dialogUI);
- if (showLabel) {
- String text = org.codelutin.i18n.I18n._("lutinui.config.cancel");
- putValue(NAME, text);
- putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
- putValue(MNEMONIC_KEY, (int) text.charAt(0));
- }
- String libelle = org.codelutin.i18n.I18n._("lutinui.config.cancel.tooltip");
- putValue(SHORT_DESCRIPTION, libelle);
-
- }
-
- public void actionPerformed(ActionEvent e) {
- getUi().dispose();
- }
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUI.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,105 +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.util.config;
-
-import org.codelutin.jaxx.util.DialogUI;
-
-import javax.swing.AbstractButton;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPasswordField;
-import javax.swing.JRadioButton;
-import javax.swing.JTextField;
-
-/**
- * A abstract dialog contract to be realised by a dialogUI (WindowEvent adapter)
- * <p/>
- * TODO : make jaxx authorized implementing interface for root tag :)
- *
- * @author chemit
- */
-public abstract class DialogConfigUI<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends DialogUI<H> {
-
- public abstract AbstractButton getOk();
-
- public abstract AbstractButton getReset();
-
- public abstract AbstractButton getCancel();
-
- public JComponent getElement(E key) {
- Object id = getObjectById(key.name());
- if (id == null) {
- log.error(new NullPointerException("no widget for key "+key));
- return null;
- }
- if (!(id instanceof JComponent)) {
- throw new IllegalArgumentException(id + " is not a JComponent");
- }
- return (JComponent) id;
- }
-
- public Object getElementValue(E key) {
- JComponent o = getElement(key);
- if (o instanceof JPasswordField) {
- return new String(((JPasswordField) o).getPassword());
- }
- if (o instanceof JTextField) {
- return ((JTextField) o).getText();
- }
- if (o instanceof JRadioButton) {
- return ((JRadioButton) o).isSelected();
- }
- if (o instanceof JCheckBox) {
- return ((JCheckBox) o).isSelected();
- }
-
- if (o instanceof JComboBox) {
- return ((JComboBox) o).getSelectedItem();
- }
- return "";
- }
-
- public void setElementValue(E key, Object value) {
- JComponent o = getElement(key);
-
- String strValue = value == null ? "" : String.valueOf(value);
- if (o instanceof JPasswordField) {
- ((JPasswordField) o).setText(strValue);
- }
- if (o instanceof JTextField) {
- ((JTextField) o).setText(strValue);
- }
- if (o instanceof JRadioButton) {
- ((JRadioButton) o).setSelected(Boolean.valueOf(strValue.isEmpty() ? "false" : strValue));
- }
- if (o instanceof JCheckBox) {
- ((JCheckBox) o).setSelected(Boolean.valueOf(strValue.isEmpty() ? "false" : strValue));
- }
- if (o instanceof JComboBox) {
- ((JComboBox) o).setSelectedItem(value);
- }
- }
-
- public JLabel getElementLabel(E key) {
- return (JLabel) getObjectById(key.name() + "Label");
- }
-
- public void doCheck(E key) {
- getHandler().doCheck(key);
- }
-
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIHandler.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,156 +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.util.config;
-
-import org.codelutin.jaxx.util.DialogUIHandler;
-import org.codelutin.util.ConverterUtil;
-import org.codelutin.util.config.Config;
-import org.codelutin.util.config.Property;
-
-import javax.swing.JComponent;
-import java.awt.Color;
-import java.beans.PropertyChangeEvent;
-import java.util.EnumMap;
-import java.util.EnumSet;
-
-/**
- * DialogUI handler
- *
- * @author chemit
- */
-public abstract class DialogConfigUIHandler<E extends Enum<E>, M extends DialogConfigUIModel<E, ?>, U extends DialogConfigUI<E, ?>> extends DialogUIHandler<M, U> {
-
- protected DialogConfigUIHandler(U ui, M model) {
- super(ui, model);
- }
-
- public void propertyChange(PropertyChangeEvent evt) {
- if (log.isDebugEnabled()) {
- log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue());
- }
- String action = evt.getPropertyName();
-
- if (DialogConfigUIModel.CONFIG_PROPERTY_CHANGED.equals(action)) {
- // update ui with model values,
- populateUI();
- // revalidate form
- doCheckAll();
- return;
- }
-
- if (DialogConfigUIModel.MODIFIED_PROPERTY_CHANGED.equals(action)) {
- Boolean newValue = (Boolean) evt.getNewValue();
- boolean modified = newValue != null && newValue;
- getUi().getReset().setEnabled(modified);
- getUi().getOk().setEnabled(modified && getModel().isConfigValid());
- return;
- }
-
- if (DialogConfigUIModel.UNVALID_PROPERTY_CHANGED.equals(action)) {
- updateUI();
- return;
- }
-
- throw new IllegalStateException("unimplemented property changed : " + evt + " for " + this);
- }
-
- public void doCheck(E key) {
- Object uiValue = getUi().getElementValue(key);
- DialogConfigUIModel<E, ?> model = getModel();
- Object currentValue = model.getCurrent().getProperty(key);
- if (currentValue == null) {
- currentValue = "";
- } else {
- currentValue = String.valueOf(currentValue);
- }
-
- model.validateProperty(key, uiValue);
- model.changeModifiedState(key, uiValue, currentValue);
- }
-
- public void doCheckAll() {
- DialogConfigUIModel<E, ?> model = getModel();
- EnumSet<E> unvalids = EnumSet.noneOf(model.klass);
- for (E e : model.getCheckedKeysSet()) {
- Object uiValue = getUi().getElementValue(e);
- if (!model.isValid(e, uiValue)) {
- unvalids.add(e);
- }
- }
- model.setUnvalids(unvalids);
- unvalids.clear();
- }
-
- protected boolean prepareSave() {
- DialogConfigUI<E, ?> ui = getUi();
- DialogConfigUIModel<E, ?> model = getModel();
-
- Config<E> current = model.getCurrent();
-
- if (!model.isConfigValid()) {
- log.warn("do not save a unvalid config : " + model.getUnvalids());
- return false;
- }
-
- if (!model.isModified()) {
- log.warn("nothing to save");
- return false;
- }
- EnumSet<E> toTreate = model.getCheckedKeysSet();
- // transfert checkable values from ui to model
- for (E key : model.getModifieds()) {
- if (!toTreate.contains(key)) {
- continue;
- }
- Object value = ui.getElementValue(key);
- Class<?> type = ((Property) key).getType();
- Object newValue = ConverterUtil.convert(type, value);
- current.setProperty(key, newValue);
- }
-
- return true;
- }
-
- protected void populateUI() {
- U ui = getUi();
- EnumMap<E, Object> map = getModel().getCurrent().getProperties();
- for (E e : getModel().getCheckedKeysSet()) {
- Object value = map.get(e);
- populateUI(ui, e, value);
- }
- }
-
- protected void populateUI(U ui, E key, Object value) {
- ui.setElementValue(key, value);
- }
-
- protected void updateUI() {
- EnumSet<E> unvalids = getModel().getUnvalids();
- for (E key : unvalids) {
- setLabelColor(key, false);
- }
- for (E key : EnumSet.complementOf(unvalids)) {
- setLabelColor(key, true);
- }
- }
-
- protected void setLabelColor(E key, boolean valid) {
- JComponent component = getUi().getElementLabel(key);
- if (component != null && component.isVisible()) {
- component.setForeground(valid ? Color.black : Color.red);
- }
- }
-
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/DialogConfigUIModel.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,220 +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.util.config;
-
-import org.codelutin.jaxx.util.DialogUIModel;
-import org.codelutin.util.config.Config;
-
-import java.util.EnumSet;
-
-/**
- * Abstract config ui model.
- *
- * @author chemit
- */
-public abstract class DialogConfigUIModel<E extends Enum<E>, C extends Config<E>> extends DialogUIModel {
-
- public static final String CONFIG_PROPERTY_CHANGED = "config";
- public static final String MODIFIED_PROPERTY_CHANGED = "modify";
- public static final String UNVALID_PROPERTY_CHANGED = "unvalid";
-
- /** @return a empty config */
- protected abstract C newConfig();
-
- /**
- * @param key property key
- * @param value value to validate
- * @return <code>true</code> if given value is valid for property, <code>false>/code> otherwise
- */
- protected abstract boolean isValid(E key, Object value);
-
- /**
- * object used to init model and save model, this is an external object.
- * <p/>
- * The object must have bean read-write properties for each value of E
- */
- protected Object src;
-
- /** current config used in model */
- protected C current;
-
- /** set of modified properties */
- protected EnumSet<E> modifieds;
-
- /** set of unvalid properties */
- protected EnumSet<E> unvalids;
-
- /** enum class */
- protected Class<E> klass;
-
- /** set of key not to check */
- protected EnumSet<E> uncheckedKeys;
-
- /** set of all keys checkable */
- protected EnumSet<E> checkedKeysSet;
-
- protected DialogConfigUIModel(Class<E> klass) {
- this.klass = klass;
- this.current = newConfig();
- this.modifieds = EnumSet.noneOf(klass);
- this.unvalids = EnumSet.noneOf(klass);
- }
-
- public EnumSet<E> getCheckedKeysSet() {
- if (checkedKeysSet == null) {
- if (uncheckedKeys != null) {
- checkedKeysSet = EnumSet.complementOf(uncheckedKeys);
- } else {
- checkedKeysSet = EnumSet.allOf(klass);
- }
- }
- return checkedKeysSet;
- }
-
- public Object getSrc() {
- return src;
- }
-
- public C getCurrent() {
- return current;
- }
-
- public EnumSet<E> getUnivserse() {
- return getCurrent().getUniverse();
- }
-
- public EnumSet<E> getModifieds() {
- return modifieds;
- }
-
- public EnumSet<E> getUnvalids() {
- return unvalids;
- }
-
- public boolean isModified() {
- return !modifieds.isEmpty();
- }
-
- public boolean isConfigValid() {
- return unvalids.isEmpty();
- }
-
- public void populate(Object src) {
- this.src = src;
- this.current = newConfig();
- if (src != null) {
- this.current.copyFrom(src);
- }
- this.modifieds.clear();
- this.unvalids.clear();
- setModified(false);
- firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this);
- }
-
- public void reset() {
- populate(src);
- }
-
- public void setModified(boolean modified) {
- firePropertyChange(MODIFIED_PROPERTY_CHANGED, null, modified);
- }
-
- public void setUnvalid(boolean unvalid) {
- firePropertyChange(UNVALID_PROPERTY_CHANGED, null, unvalid);
- }
-
- public void addModified(E key) {
- if (!modifieds.contains(key)) {
- modifieds.add(key);
- log.debug(key);
- }
- setModified(!modifieds.isEmpty());
- }
-
- public void removeModified(E key) {
-
- if (modifieds.contains(key)) {
- modifieds.remove(key);
- }
- setModified(!modifieds.isEmpty());
- }
-
- public void removeModified(EnumSet<E> keys) {
- for (E key : keys) {
- if (modifieds.contains(key)) {
- modifieds.remove(key);
- }
- }
- setModified(!modifieds.isEmpty());
- }
-
- public void setUnvalids(EnumSet<E> keys) {
- for (E key : keys) {
- if (!unvalids.contains(key)) {
- unvalids.add(key);
- }
- }
- for (E key : EnumSet.complementOf(keys)) {
- if (unvalids.contains(key)) {
- unvalids.remove(key);
- }
- }
- setUnvalid(!unvalids.isEmpty());
- }
-
-
- public void addUnvalid(E key) {
- if (!unvalids.contains(key)) {
- unvalids.add(key);
- }
- setUnvalid(!unvalids.isEmpty());
- }
-
- public void removeUnvalid(E key) {
- if (unvalids.contains(key)) {
- unvalids.remove(key);
- }
- setUnvalid(!unvalids.isEmpty());
- }
-
- public void save() {
- current.copyTo(src, modifieds);
- modifieds.clear();
- // redisplay config
- firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this);
- }
-
- public void changeModifiedState(E key, Object uiValue, Object currentValue) {
- if (uiValue!=null && uiValue.equals(currentValue)) {
- removeModified(key);
- } else {
- addModified(key);
- }
- }
-
- public void clear(E key) {
- log.info(key);
- modifieds.remove(key);
- unvalids.remove(key);
- }
-
- protected void validateProperty(E key, Object uiValue) {
- if (isValid(key, uiValue)) {
- removeUnvalid(key);
- } else {
- addUnvalid(key);
- }
- }
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/ResetAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -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.util.config;
-
-import org.codelutin.jaxx.util.AbstractUIAction;
-import org.codelutin.jaxx.util.DialogUI;
-import org.codelutin.jaxx.util.UIHelper;
-
-import java.awt.event.ActionEvent;
-
-/** @author chemit */
-public class ResetAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
- private static final long serialVersionUID = 1L;
-
- public ResetAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
- super(null, UIHelper.createActionIcon("reset-config"), dialogUI);
- if (showLabel) {
- String text = org.codelutin.i18n.I18n._("lutinui.config.reset");
- putValue(NAME, text);
- putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
- putValue(MNEMONIC_KEY, (int) text.charAt(0));
- }
- String libelle = org.codelutin.i18n.I18n._("lutinui.config.reset.tooltip");
- putValue(SHORT_DESCRIPTION, libelle);
-
- }
-
- public void actionPerformed(ActionEvent e) {
- getHandler().getModel().reset();
- }
-}
\ No newline at end of file
Deleted: jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java
===================================================================
--- jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/jaxx-util/src/main/java/org/codelutin/jaxx/util/config/SaveAction.java 2009-02-23 13:06:52 UTC (rev 1241)
@@ -1,50 +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.util.config;
-
-import org.codelutin.jaxx.util.AbstractUIAction;
-import org.codelutin.jaxx.util.DialogUI;
-import org.codelutin.jaxx.util.UIHelper;
-
-import java.awt.event.ActionEvent;
-
-/** @author chemit */
-public class SaveAction<E extends Enum<E>, H extends DialogConfigUIHandler<E, ?, ?>> extends AbstractUIAction<H> {
- private static final long serialVersionUID = 1L;
-
- public SaveAction(DialogUI<? extends H> dialogUI, boolean showLabel) {
- super(null, UIHelper.createActionIcon("save-config"), dialogUI);
- if (showLabel) {
- String text = org.codelutin.i18n.I18n._("lutinui.config.save");
- putValue(NAME, text);
- putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0);
- putValue(MNEMONIC_KEY, (int) text.charAt(0));
- }
- String libelle = org.codelutin.i18n.I18n._("lutinui.config.save.tooltip");
- putValue(SHORT_DESCRIPTION, libelle);
- }
-
- public void actionPerformed(ActionEvent e) {
-
- if (getHandler().prepareSave()) {
-
- // save model to src
- getHandler().getModel().save();
-
- // close ui
- getUi().dispose();
- }
- }
-}
Modified: jaxx/trunk/pom.xml
===================================================================
--- jaxx/trunk/pom.xml 2009-02-23 13:06:47 UTC (rev 1240)
+++ jaxx/trunk/pom.xml 2009-02-23 13:06:52 UTC (rev 1241)
@@ -18,7 +18,6 @@
<version>1.2-SNAPSHOT</version>
<modules>
- <module>jaxx-util</module>
<module>jaxx-runtime-api</module>
<module>jaxx-runtime-swing</module>
<module>jaxx-runtime-validator</module>
1
0
r1240 - in jaxx/trunk/jaxx-util/src: main/resources site
by tchemit@users.labs.libre-entreprise.org Feb. 23, 2009
by tchemit@users.labs.libre-entreprise.org Feb. 23, 2009
Feb. 23, 2009
Author: tchemit
Date: 2009-02-23 13:06:47 +0000 (Mon, 23 Feb 2009)
New Revision: 1240
Removed:
jaxx/trunk/jaxx-util/src/main/resources/i18n/
jaxx/trunk/jaxx-util/src/main/resources/icons/
jaxx/trunk/jaxx-util/src/site/fr/
Log:
- move sources from jaxx-util to jaxx-swing-action module
- delete jaxx-util module
- rename jaxx.runtime.swing.Utils to jaxx.runtime.SwingUtil
1
0
r1239 - in jaxx/trunk: jaxx-compiler-api/src/main/java/jaxx jaxx-compiler-api/src/main/java/jaxx/compiler jaxx-compiler-api/src/main/java/jaxx/tags jaxx-compiler-swing/src/main/java/jaxx jaxx-compiler-swing/src/main/java/jaxx/compiler jaxx-compiler-swing/src/main/java/jaxx/tags/swing jaxx-compiler-swing/src/main/resources/META-INF/services jaxx-compiler-validator/src/main/java/jaxx/compiler jaxx-example jaxx-example/src/main/java/jaxx/demo jaxx-example/src/main/resources jaxx-example/src/main
by tchemit@users.labs.libre-entreprise.org Feb. 23, 2009
by tchemit@users.labs.libre-entreprise.org Feb. 23, 2009
Feb. 23, 2009
Author: tchemit
Date: 2009-02-23 02:06:29 +0000 (Mon, 23 Feb 2009)
New Revision: 1239
Added:
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObjectDecorator.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/SwingInitializer.java
jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
jaxx/trunk/jaxx-example/src/main/resources/icons/
jaxx/trunk/jaxx-example/src/main/resources/icons/action-accept.png
jaxx/trunk/jaxx-example/src/main/resources/icons/action-block.png
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/DecoratorTest.java
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Decorator.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/decorator/
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/decorator/BoxedDecorator.jaxx
Removed:
jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/tags/swing/SwingInitializer.java
Modified:
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/DefaultInitializer.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JavaFile.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultObjectHandler.java
jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/TagManager.java
jaxx/trunk/jaxx-compiler-swing/src/main/resources/META-INF/services/jaxx.spi.Initializer
jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/compiler/ValidatorGenerator.java
jaxx/trunk/jaxx-example/
jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java
jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Utils.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/AbstractValidatorTest.java
jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/JaxxBaseTest.java
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1750.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1751.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/CSSTests.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ErrorJaxxContextImplementorClass.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Errors.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Force.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nText.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nTitle.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nToolTipText.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Initializers.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/InnerClasses.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/NoLog.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/OverridingDataBindings.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Script.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/SpecialSubclassing.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ValidatorErrors.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ValidatorOk.xml
jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/WithLog.xml
Log:
introduce CompiledObjectDecorator.
offer the default implementation, and a boxed one.
refactor plugin tests
begin nromalisation of classnames (should remove Util, Utils and other to have JaxxUtil, SwingUtil,...)
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/DefaultInitializer.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/DefaultInitializer.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/DefaultInitializer.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -15,6 +15,8 @@
import jaxx.types.TypeManager;
import java.awt.Component;
+import jaxx.compiler.CompiledObjectDecorator;
+import jaxx.compiler.DefaultCompiledObjectDecorator;
/** Initializes support for java. */
public class DefaultInitializer implements jaxx.spi.Initializer {
@@ -44,5 +46,7 @@
TypeManager.registerTypeConverter(char.class, primitiveConverter);
TypeManager.registerTypeConverter(Character.class, primitiveConverter);
TypeManager.registerTypeConverter(String.class, primitiveConverter);
+
+ CompiledObjectDecorator.registerDecorator("default", DefaultCompiledObjectDecorator.class);
}
}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObject.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -83,6 +83,11 @@
/** the type of the override object (can be null if no oveeride) */
private ClassDescriptor overrideType;
+ /**
+ * the decorator (if null will use {@link DefaultCompiledObjectDecorator}).
+ */
+ private CompiledObjectDecorator decorator;
+
public class ChildRef {
CompiledObject child;
String constraints;
@@ -556,24 +561,8 @@
String delegateCode = containerDelegate != null ? "." + containerDelegate + "()" : "";
child.setParent(this);
- /*String javaCode = child.getJavaCode();
- if (compiler.hasValidator()) {
- // some validators are defined on this object
- boolean found = compiler.isComponentUsedByValidator(child.getId());
- if (found) {
- // box the child component in a JxLayer
- javaCode = "jaxx.runtime.Util.boxComponentWithJxLayer(" + javaCode + ")";
- }
- }*/
-
+
childs.add(new ChildRef(child, constraints, child.getJavaCode(), delegateCode));
- /*if (constraints != null) {
- appendAdditionCode(this.javaCode + delegateCode + ".add(" + javaCode + ", " + constraints + ");");
- //appendAdditionCode(getJavaCode() + delegateCode + ".add(" + javaCode + ", " + constraints + ");");
- } else {
- appendAdditionCode(this.javaCode + delegateCode + ".add(" + javaCode + ");");
- //appendAdditionCode(getJavaCode() + delegateCode + ".add(" + javaCode + ");");
- }*/
}
}
@@ -636,6 +625,14 @@
return childs;
}
+ public CompiledObjectDecorator getDecorator() {
+ return decorator;
+ }
+
+ public void setDecorator(CompiledObjectDecorator decorator) {
+ this.decorator = decorator;
+ }
+
public void finalizeCompiler() {
StringBuffer buffer = new StringBuffer();
Added: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObjectDecorator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObjectDecorator.java (rev 0)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompiledObjectDecorator.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,76 @@
+package jaxx.compiler;
+
+import java.util.Map;
+import java.util.TreeMap;
+import jaxx.CompilerException;
+
+/**
+ *
+ * A class to decorate a compiled object at generation time.
+ *
+ * Contains also a cache of decorator in a dictonnary indexed by fqn of decorator.
+ *
+ * Use the {@link #getDecorator(java.lang.String)} to obtain the cached decorator.
+ *
+ * Note : The implementation of this class must be stateless.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public abstract class CompiledObjectDecorator {
+
+ protected static Map<String, CompiledObjectDecorator> cache;
+
+ public static void registerDecorator(String key, Class<? extends CompiledObjectDecorator> klass) {
+ synchronized (getCache()) {
+ if (getCache().containsKey(key)) {
+ throw new IllegalArgumentException("the decorator with key [" + key + "] is already registred! use another key name");
+ }
+ try {
+ getCache().put(key, klass.newInstance());
+ } catch (InstantiationException ex) {
+ throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
+ }
+ }
+ }
+
+ public static CompiledObjectDecorator getDecorator(String name) {
+ CompiledObjectDecorator decorator = getCache().get(name);
+ if (decorator == null) {
+ throw new IllegalArgumentException("could not find decorator with key " + name + " (known decorators : " + getCache().keySet());
+ }
+ return decorator;
+ }
+
+ public static CompiledObjectDecorator getDecorator(Class<?> type) {
+ for (CompiledObjectDecorator decorator : getCache().values()) {
+ if (type == decorator.getClass()) {
+ return decorator;
+ }
+ }
+ return null;
+ }
+
+ protected static synchronized Map<String, CompiledObjectDecorator> getCache() {
+ if (cache == null) {
+ cache = new TreeMap<String, CompiledObjectDecorator>();
+ }
+ return cache;
+ }
+
+ public static void reset() {
+ if (cache != null) {
+ cache.clear();
+ }
+ }
+
+ public abstract void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName);
+
+ public abstract String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException;
+
+ public abstract boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall);
+
+ public abstract String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings);
+}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/CompilerOptions.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -43,6 +43,9 @@
/** a flag to use {@link javax.swing.UIManager} to retreave icons. */
private boolean useUIManagerForIcon;
+ /** the default compiled object decorator to use if none specifed via decorator attribute */
+ private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
+
/**
* Returns the target directory, generally specified with the "-d" option on the command line.
*
@@ -270,4 +273,13 @@
public void setValidatorFQN(String validatorFQN) {
this.validatorFQN = validatorFQN;
}
+
+ public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() {
+ return defaultDecoratorClass;
+ }
+
+ public void setDefaultDecoratorClass(Class<? extends CompiledObjectDecorator> defaultDecoratorClass) {
+ this.defaultDecoratorClass = defaultDecoratorClass;
+ }
+
}
Added: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java (rev 0)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,112 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package jaxx.compiler;
+
+import java.lang.reflect.Modifier;
+import jaxx.CompilerException;
+import jaxx.types.TypeManager;
+
+/**
+ * The default compiledObjectDecorator.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class DefaultCompiledObjectDecorator extends CompiledObjectDecorator {
+
+ @Override
+ public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
+
+ if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
+ String id = object.getId();
+ int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
+ if (object == root) {
+ javaFile.addField(new JavaField(access, fullClassName, id, "this"));
+ } else {
+ //TC -20081017 can have generic on compiled Object
+ javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean());
+ }
+ }
+
+ if (!compiler.inlineCreation(object) && object != root) {
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
+ }
+ }
+
+ @Override
+ public String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
+ if (object instanceof ScriptInitializer) {
+ return object.getInitializationCode(compiler);
+ }
+ StringBuffer result = new StringBuffer();
+ result.append(object.getId());
+ result.append(" = ");
+ if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
+ result.append(object.getJavaBeanInitCode()).append(";");
+ } else {
+ String constructorParams = object.getConstructorParams();
+ if (constructorParams != null) {
+ //TC - 20081017 compiledObject can have generics
+ result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
+ //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
+ } else {
+ //TC - 20081017 compiledObject can have generics
+ result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
+ }
+ }
+ result.append(JAXXCompiler.getLineSeparator());
+ String initCode = object.getInitializationCode(compiler);
+ if (initCode != null && initCode.length() > 0) {
+ result.append(initCode);
+ }
+ result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
+ return result.toString();
+ }
+
+ @Override
+ public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings) {
+ StringBuffer code = new StringBuffer();
+ //TC - 20081017 only generate the method if not empty ?
+ if (object.getId().startsWith("$")) {
+ code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
+ } else {
+ String additionCode = object.getAdditionCode();
+ if (additionCode.length() > 0) {
+ code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
+ additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
+ }
+ }
+ //code.append(getLineSeparator());
+ return code.toString();
+ }
+
+ @Override
+ public boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall) {
+ if (object == root) {
+ String rootCode = root.getInitializationCode(compiler);
+ if (rootCode != null && rootCode.length() > 0) {
+ code.append(rootCode);
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ } else {
+ if (!object.isOverride()) {
+ if (compiler.inlineCreation(object)) {
+ if (lastWasMethodCall) {
+ lastWasMethodCall = false;
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append(getCreationCode(compiler, object));
+ code.append(JAXXCompiler.getLineSeparator());
+ } else {
+ code.append(object.getCreationMethodName()).append("();");
+ code.append(JAXXCompiler.getLineSeparator());
+ lastWasMethodCall = true;
+ }
+ }
+ }
+ return lastWasMethodCall;
+ }
+}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -222,6 +222,8 @@
/** Maps objects to their ID strings. These are created during the second compilation pass. */
protected Map<CompiledObject, String> ids = new LinkedHashMap<CompiledObject, String>();
+ protected CompiledObjectDecorator defaultDecorator;
+
/*---------------------------------------------------------------------------------*/
/*-- Constructor methods ----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
@@ -268,6 +270,11 @@
addImport(extraImport);
}
}
+ defaultDecorator = CompiledObjectDecorator.getDecorator(options.getDefaultDecoratorClass());
+ if (defaultDecorator == null) {
+ log.error("could not find default decorator : "+options.getDefaultDecoratorClass());
+ throw new IllegalArgumentException("could not find default decorator : " + options.getDefaultDecoratorClass());
+ }
}
/*---------------------------------------------------------------------------------*/
@@ -484,6 +491,10 @@
}
objects.put(id, object);
ids.put(object, id);
+ if (object.getDecorator() == null) {
+ // use compiler decorator
+ object.setDecorator(defaultDecorator);
+ }
}
public CompiledObject getCompiledObject(String id) {
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -23,7 +23,7 @@
/** log */
protected static final Log log = LogFactory.getLog(JAXXCompilerLaunchor.class);
- enum LifeCycle {
+ protected enum LifeCycle {
init,// state before compilation
compile_first_pass, // state when first pass of compilation
compile_second_pass, // state when second pass of compilation
@@ -174,6 +174,7 @@
jaxxFileClassNames.clear();
symbolTables.clear();
compilers.clear();
+ //CompiledObjectDecorator.reset();
}
public String getVersion() {
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -147,7 +147,10 @@
javaFile.setSuperGenericType(compiler.getSuperGenericType());
for (CompiledObject object : compiler.getObjects().values()) {
- if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
+ CompiledObjectDecorator decorator = object.getDecorator();
+ decorator.finalizeCompiler(compiler, root, object,javaFile, packageName, className,fullClassName);
+
+ /*if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
String id = object.getId();
int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
if (object == root) {
@@ -160,7 +163,7 @@
if (!compiler.inlineCreation(object) && object != root) {
javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
- }
+ }*/
}
// DataBinding
@@ -283,15 +286,6 @@
addEventHandlers(compiler, javaFile);
- /*//TODO : move this to jaxx-compiler-swing generator
- if (ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.Application").isAssignableFrom(root.getObjectClass()) && !compiler.isMainDeclared()) {
- // TODO: check for existing main method first
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC | Modifier.STATIC, "void", "main",
- "SwingUtilities.invokeLater(new Runnable() { public void run() { new " + className + "().setVisible(true); } });",
- new JavaArgument("String[]", "arg"))
- );
- }*/
-
}
@@ -451,7 +445,12 @@
boolean lastWasMethodCall = false;
while (i.hasNext()) {
CompiledObject object = i.next();
- if (object != root && !object.isOverride()) {
+ if (object == root) {
+ continue;
+ }
+ CompiledObjectDecorator decorator = object.getDecorator();
+ lastWasMethodCall = decorator.createInitializer(compiler, root, object, code, lastWasMethodCall);
+ /*if (object != root && !object.isOverride()) {
if (compiler.inlineCreation(object)) {
if (lastWasMethodCall) {
lastWasMethodCall = false;
@@ -464,13 +463,14 @@
code.append(JAXXCompiler.getLineSeparator());
lastWasMethodCall = true;
}
- }
+ }*/
}
- String rootCode = root.getInitializationCode(compiler);
+ root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall);
+ /*String rootCode = root.getInitializationCode(compiler);
if (rootCode != null && rootCode.length() > 0) {
code.append(rootCode);
code.append(JAXXCompiler.getLineSeparator());
- }
+ }*/
code.append(JAXXCompiler.getLineSeparator());
if (compiler.getInitializer().length() > 0) {
code.append(compiler.getInitializer());
@@ -487,7 +487,10 @@
code.append("allComponentsCreated = true;");
code.append(JAXXCompiler.getLineSeparator());
for (CompiledObject object : compiler.getObjects().values()) {
- //TC - 20081017 only generate the method if not empty ?
+ CompiledObjectDecorator decorator = object.getDecorator();
+ code.append(decorator.createCompleteSetupMethod(compiler, object, javaFile, initDataBindings));
+
+ /*//TC - 20081017 only generate the method if not empty ?
if (object.getId().startsWith("$")) {
code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
} else {
@@ -497,7 +500,7 @@
additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
}
- }
+ }*/
//code.append(getLineSeparator());
}
@@ -559,11 +562,14 @@
/*-- Create methods code ----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
- protected String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
+/* protected String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
if (object instanceof ScriptInitializer) {
return object.getInitializationCode(compiler);
}
- StringBuffer result = new StringBuffer();
+ CompiledObjectDecorator decorator = object.getDecorator();
+ String result = decorator.getCreationCode(compiler, object);
+ return result;*/
+ /*StringBuffer result = new StringBuffer();
result.append(object.getId());
result.append(" = ");
if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
@@ -586,7 +592,7 @@
}
result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
- return result.toString();
- }
+ return result.toString();*/
+// }
}
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JavaFile.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JavaFile.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/compiler/JavaFile.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -226,16 +226,6 @@
result.append(lineSeparator).append(lineSeparator);
}
- /*
- java.util.Collections.sort(methods); // sort methods
-
- for (JavaMethod method : methods) {
- result.append(addIndentation(method.toString(), 4));
- result.append(lineSeparator);
- result.append(lineSeparator);
- }
- */
-
EnumMap<MethodOrder, List<JavaMethod>> map = JavaMethod.getSortedMethods(methods);
for (Entry<MethodOrder, List<JavaMethod>> entry : map.entrySet()) {
List<JavaMethod> list = entry.getValue();
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultObjectHandler.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/DefaultObjectHandler.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -43,6 +43,7 @@
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
+import jaxx.compiler.CompiledObjectDecorator;
/**
* Default handler for class tags. Class tags are tags which represent instances of Java classes,
@@ -512,12 +513,14 @@
}
+ @Override
public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
scanAttributesForDependencies(tag, compiler);
compileChildrenFirstPass(tag, compiler);
}
+ @Override
public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
try {
init();
@@ -654,7 +657,7 @@
attributes.add((Attr) children.item(i));
}
Collections.sort(attributes, getAttributeComparator());
-
+
for (Attr attribute : attributes) {
String name = attribute.getName();
String value = attribute.getValue().trim();
@@ -711,6 +714,14 @@
continue;
}
+ if (name.equals("decorator")) {
+ if (!value.isEmpty()) {
+ CompiledObjectDecorator decorator = CompiledObjectDecorator.getDecorator(value);
+ object.setDecorator(decorator);
+ }
+ continue;
+ }
+
if (isEventHandlerName(name)) {
// event handler
if (!value.endsWith(";")) {
@@ -733,6 +744,7 @@
*/
protected Comparator<Attr> getAttributeComparator() {
return new Comparator<Attr>() {
+ @Override
public int compare(Attr a, Attr b) {
int aOrder = getAttributeOrdering(a);
int bOrder = getAttributeOrdering(b);
Modified: jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/TagManager.java
===================================================================
--- jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/TagManager.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-api/src/main/java/jaxx/tags/TagManager.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -91,6 +91,7 @@
registeredBeans.clear();
registeredTags.clear();
defaultNamespaces.clear();
+ CompiledObjectDecorator.reset();
JAXXCompilerLaunchor.loadLibraries(verbose);
}
Copied: jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/SwingInitializer.java (from rev 1237, jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/tags/swing/SwingInitializer.java)
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/SwingInitializer.java (rev 0)
+++ jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/SwingInitializer.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx;
+
+import jaxx.tags.swing.*;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Application;
+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.spi.Initializer;
+import jaxx.tags.DefaultObjectHandler;
+import jaxx.tags.TagManager;
+import jaxx.types.ColorConverter;
+import jaxx.types.GridBagConstraintsConverter;
+import jaxx.types.InsetsConverter;
+import jaxx.types.KeyStrokeConverter;
+import jaxx.types.TypeManager;
+import jaxx.beaninfos.BeanInfoUtil;
+
+import javax.swing.*;
+import javax.swing.text.JTextComponent;
+import java.awt.Color;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import jaxx.compiler.BoxedCompiledObjectDecorator;
+import jaxx.compiler.CompiledObjectDecorator;
+
+public class SwingInitializer implements Initializer {
+
+ public void initialize() {
+
+ BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos");
+
+ TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class);
+ TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class)));
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXList.class), JListHandler.class);
+ TagManager.registerTag("javax.swing.*", "JList", new JListHandler(ClassDescriptorLoader.getClassDescriptor(JAXXList.class)));
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JMenu.class), JMenuHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPasswordField.class), JPasswordFieldHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPopupMenu.class), JPopupMenuHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JProgressBar.class), JProgressBarHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButton.class), JRadioButtonHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButtonMenuItem.class), JRadioButtonHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JScrollPane.class), JScrollPaneHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSlider.class), JSliderHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSpinner.class), JSpinnerHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSplitPane.class), JSplitPaneHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), JTabbedPaneHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTextComponent.class), JTextComponentHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToggleButton.class), JRadioButtonHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToolBar.class), JToolBarHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class), JTreeHandler.class);
+ TagManager.registerTag("javax.swing.*", "JTree", new JTreeHandler(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class)));
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JWindow.class), JWindowHandler.class);
+
+ TagManager.registerDefaultNamespace("JEditorPane", "javax.swing.*");
+ TagManager.registerDefaultNamespace("JFormattedTextField", "javax.swing.*");
+ TagManager.registerDefaultNamespace("JPasswordField", "javax.swing.*");
+ TagManager.registerDefaultNamespace("JTextArea", "javax.swing.*");
+ TagManager.registerDefaultNamespace("JTextField", "javax.swing.*");
+ TagManager.registerDefaultNamespace("JTextPane", "javax.swing.*");
+
+ TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "tab", new TabHandler());
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Table.class), TableHandler.class);
+ TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "row", new RowHandler());
+ TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "cell", new CellHandler());
+ TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler());
+
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTab.class), JAXXTabHandler.class);
+
+ TypeManager.registerTypeConverter(Color.class, new ColorConverter());
+ TypeManager.registerTypeConverter(GridBagConstraints.class, new GridBagConstraintsConverter());
+ TypeManager.registerTypeConverter(Insets.class, new InsetsConverter());
+ TypeManager.registerTypeConverter(KeyStroke.class, new KeyStrokeConverter());
+
+ CompiledObjectDecorator.registerDecorator("boxed", BoxedCompiledObjectDecorator.class);
+ }
+}
\ No newline at end of file
Property changes on: jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/SwingInitializer.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java (rev 0)
+++ jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,26 @@
+package jaxx.compiler;
+
+import jaxx.compiler.CompiledObject.ChildRef;
+
+/**
+ * A decorator to surround a compiled object (should be a component at least)
+ * with a JXLayer.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class BoxedCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
+
+ @Override
+ public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
+ CompiledObject parent = object.getParent();
+ for (ChildRef child : parent.getChilds()) {
+ if (child.getChild() == object) {
+ String javaCode = child.getChildJavaCode();
+ child.setChildJavaCode("jaxx.runtime.SwingUtil.boxComponentWithJxLayer(" + javaCode + ")");
+ break;
+ }
+ }
+ super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
+ }
+}
Deleted: jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/tags/swing/SwingInitializer.java
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/tags/swing/SwingInitializer.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-swing/src/main/java/jaxx/tags/swing/SwingInitializer.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -1,88 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.tags.swing;
-
-import jaxx.compiler.JAXXCompiler;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.swing.Application;
-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.spi.Initializer;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.TagManager;
-import jaxx.types.ColorConverter;
-import jaxx.types.GridBagConstraintsConverter;
-import jaxx.types.InsetsConverter;
-import jaxx.types.KeyStrokeConverter;
-import jaxx.types.TypeManager;
-import jaxx.beaninfos.BeanInfoUtil;
-
-import javax.swing.*;
-import javax.swing.text.JTextComponent;
-import java.awt.Color;
-import java.awt.GridBagConstraints;
-import java.awt.Insets;
-
-public class SwingInitializer implements Initializer {
-
- public void initialize() {
-
- BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos");
-
- TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
-
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class);
- TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class)));
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXList.class), JListHandler.class);
- TagManager.registerTag("javax.swing.*", "JList", new JListHandler(ClassDescriptorLoader.getClassDescriptor(JAXXList.class)));
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JMenu.class), JMenuHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPasswordField.class), JPasswordFieldHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPopupMenu.class), JPopupMenuHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JProgressBar.class), JProgressBarHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButton.class), JRadioButtonHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButtonMenuItem.class), JRadioButtonHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JScrollPane.class), JScrollPaneHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSlider.class), JSliderHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSpinner.class), JSpinnerHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSplitPane.class), JSplitPaneHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), JTabbedPaneHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTextComponent.class), JTextComponentHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToggleButton.class), JRadioButtonHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToolBar.class), JToolBarHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class), JTreeHandler.class);
- TagManager.registerTag("javax.swing.*", "JTree", new JTreeHandler(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class)));
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JWindow.class), JWindowHandler.class);
-
- TagManager.registerDefaultNamespace("JEditorPane", "javax.swing.*");
- TagManager.registerDefaultNamespace("JFormattedTextField", "javax.swing.*");
- TagManager.registerDefaultNamespace("JPasswordField", "javax.swing.*");
- TagManager.registerDefaultNamespace("JTextArea", "javax.swing.*");
- TagManager.registerDefaultNamespace("JTextField", "javax.swing.*");
- TagManager.registerDefaultNamespace("JTextPane", "javax.swing.*");
-
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "tab", new TabHandler());
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Table.class), TableHandler.class);
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "row", new RowHandler());
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "cell", new CellHandler());
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler());
-
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTab.class), JAXXTabHandler.class);
-
- TypeManager.registerTypeConverter(Color.class, new ColorConverter());
- TypeManager.registerTypeConverter(GridBagConstraints.class, new GridBagConstraintsConverter());
- TypeManager.registerTypeConverter(Insets.class, new InsetsConverter());
- TypeManager.registerTypeConverter(KeyStroke.class, new KeyStrokeConverter());
- }
-}
\ No newline at end of file
Modified: jaxx/trunk/jaxx-compiler-swing/src/main/resources/META-INF/services/jaxx.spi.Initializer
===================================================================
--- jaxx/trunk/jaxx-compiler-swing/src/main/resources/META-INF/services/jaxx.spi.Initializer 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-swing/src/main/resources/META-INF/services/jaxx.spi.Initializer 2009-02-23 02:06:29 UTC (rev 1239)
@@ -1 +1 @@
-jaxx.tags.swing.SwingInitializer
\ No newline at end of file
+jaxx.SwingInitializer
\ No newline at end of file
Modified: jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/compiler/ValidatorGenerator.java
===================================================================
--- jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-compiler-validator/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -34,7 +34,7 @@
boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId());
if (found) {
// box the child component in a JxLayer
- child.setChildJavaCode("jaxx.runtime.Util.boxComponentWithJxLayer(" + javaCode + ")");
+ child.setChildJavaCode("jaxx.runtime.SwingUtil.boxComponentWithJxLayer(" + javaCode + ")");
}
}
}
Property changes on: jaxx/trunk/jaxx-example
___________________________________________________________________
Name: svn:ignore
- target
velocity.log
+ velocity.log
target
nbactions.xml
Added: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx (rev 0)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/BoxedDecoratorDemo.jaxx 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,56 @@
+
+<DemoPanel>
+ <jaxx.runtime.swing.BlockingLayerUI id='layerUI'
+ blockIcon='{SwingUtil.createImageIcon("action-block.png")}'
+ acceptIcon='{SwingUtil.createImageIcon("action-accept.png")}'
+ acceptAction='{new AbstractAction() { private static final long serialVersionUID = 1L;
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ accept(e, "from icon of layer");
+ }
+ }}' />
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+public void setLayer(boolean active) {
+ for (JComponent boxed : SwingUtil.getLayeredComponents(this)) {
+ jaxx.runtime.swing.BlockingLayerUI ui = active ? layerUI.clone() : null;
+ SwingUtil.getLayer(boxed).setUI(ui);
+ }
+}
+
+protected void accept(ActionEvent e, String suffix) {
+ JButton source = (JButton) e.getSource();
+ String msg = "'" + source.getText() + "' clicked - " + suffix;
+ ((DefaultListModel)messages.getModel()).addElement(msg);
+}]]>
+ </script>
+ <Table id='demoPanel' fill='both' weightx='1'>
+ <row>
+ <cell>
+ <JCheckBox id='toggle' selected='true'
+ text='{toggle.isSelected() ? "Active layer" : "No layer"}'
+ onActionPerformed='setLayer(toggle.isSelected());'/>
+ </cell>
+ </row>
+ <row>
+ <cell weighty='0.5'>
+ <JPanel layout='{new GridLayout(1,3,3,3)}'>
+ <JButton text='button A' decorator='boxed'
+ onActionPerformed='accept(event, "from button (no layer)")'/>
+ <JButton text='button B' decorator='boxed'
+ onActionPerformed='accept(event, "from button (no layer)")'/>
+ <JButton text='button C' decorator='boxed'
+ onActionPerformed='accept(event, "from button (no layer)");'/>
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell weighty='0.5'>
+ <JScrollPane>
+ <JList id='messages' model='{new DefaultListModel()}'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
+</DemoPanel>
\ No newline at end of file
Modified: jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx
===================================================================
--- jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-example/src/main/java/jaxx/demo/JAXXDemo.jaxx 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,7 +9,7 @@
// init i18n
org.codelutin.i18n.I18n.init();
-
+boxedDecoratorDemo.setLayer(true);
]]></script>
<JSplitPane>
<!--JSplitPane dividerLocation='200'-->
@@ -73,6 +73,7 @@
<item value='{validationDemo2}'/>
</item>
<item value='{dataBindingDemo}'/>
+ <item value='{boxedDecoratorDemo}'/>
</item>
</JTree>
</JScrollPane>
@@ -103,6 +104,7 @@
<LabelStyleDemo id='labelStyleDemo' constraints='labelStyleDemo.getLabel()'/>
<CounterDemo id='counterDemo' constraints='counterDemo.getLabel()'/>
<CalculatorDemo id='calculatorDemo' constraints='calculatorDemo.getLabel()'/>
+ <BoxedDecoratorDemo id='boxedDecoratorDemo' constraints='boxedDecoratorDemo.getLabel()'/>
</JPanel>
</JSplitPane>
</Application>
\ No newline at end of file
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-en_GB.properties 2009-02-23 02:06:29 UTC (rev 1239)
@@ -24,6 +24,7 @@
C=
CE=
Cancel=
+Change\ layer\ state=
Comments\:=
Config\ file\ \:=
Config\ file\:=
@@ -84,6 +85,10 @@
\\u00f7=
adjust\ the\ spacing=
between\ these\ lines=
+button\ A=
+button\ B=
+button\ C=
+button\ with\ layer=
cancel=
close=
close2=
@@ -91,6 +96,7 @@
edit=
edit2=
edit3=
+no\ layer=
valid=
validator.field=Champ
validator.field.tip=
@@ -98,4 +104,5 @@
validator.message.tip=
validator.scope=...
validator.scope.tip=
+with\ layer=
x=
Modified: jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties
===================================================================
--- jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-example/src/main/resources/i18n/jaxx-example-fr_FR.properties 2009-02-23 02:06:29 UTC (rev 1239)
@@ -24,6 +24,7 @@
C=
CE=
Cancel=
+Change\ layer\ state=
Comments\:=
Config\ file\ \:=
Config\ file\:=
@@ -84,6 +85,10 @@
\\u00f7=
adjust\ the\ spacing=
between\ these\ lines=
+button\ A=
+button\ B=
+button\ C=
+button\ with\ layer=
cancel=
close=
close2=
@@ -91,6 +96,7 @@
edit=
edit2=
edit3=
+no\ layer=
valid=
validator.field=Champ
validator.field.tip=
@@ -98,4 +104,5 @@
validator.message.tip=
validator.scope=...
validator.scope.tip=
+with\ layer=
x=
Added: jaxx/trunk/jaxx-example/src/main/resources/icons/action-accept.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-example/src/main/resources/icons/action-accept.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jaxx/trunk/jaxx-example/src/main/resources/icons/action-block.png
===================================================================
(Binary files differ)
Property changes on: jaxx/trunk/jaxx-example/src/main/resources/icons/action-block.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java
===================================================================
--- jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/Util.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -3,7 +3,6 @@
import jaxx.Base64Coder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jdesktop.jxlayer.JXLayer;
import javax.swing.DefaultListCellRenderer;
import javax.swing.Icon;
@@ -12,12 +11,7 @@
import javax.swing.JList;
import javax.swing.UIManager;
import java.awt.Component;
-import java.awt.Container;
import java.awt.Dimension;
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.lang.reflect.InvocationHandler;
@@ -27,10 +21,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EventListener;
-import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import java.util.WeakHashMap;
@@ -282,78 +273,6 @@
}
/**
- * recherche les composants portant le meme nom que les champs de la classe
- * clazz. Cette methode est statique pour pouvoir eventuellement l'utiliser
- * dans un autre context (je pense par exemple a la generation jaxx).
- * <p/>
- * <p/>
- * Si la recherche echoue pour quelque raison que se soit, aucune exception
- * n'est leve, et la map retournee est tout simplement vide ou incomplete
- *
- * @param clazz la classe ou recherche les champs
- * @param container le container ou rechercher les composants d'edition
- * @return le dictionnaire des composants recherches.
- */
- public static Map<String, JComponent> lookingForEditor(Class clazz, Container container) {
- Map<String, JComponent> result = new HashMap<String, JComponent>();
- try {
- // looking for all component with name set
- Map<String, JComponent> allNamedComponent = new HashMap<String, JComponent>();
- List<Container> todo = new LinkedList<Container>();
- todo.add(container);
- while (todo.size() > 0) {
- for (ListIterator<Container> i = todo.listIterator(); i.hasNext();) {
- Container parent = i.next();
- i.remove();
- for (Component c : parent.getComponents()) {
- if (c instanceof Container) {
- i.add((Container) c);
- String name = c.getName();
- if (c instanceof JComponent &&
- name != null && !"".equals(name)) {
- allNamedComponent.put(name, (JComponent) c);
- }
- }
- }
- }
- }
-
- // looking for all properties on class
- BeanInfo info = Introspector.getBeanInfo(clazz);
- PropertyDescriptor[] props = info.getPropertyDescriptors();
-
- // find if one properties have same name that component
- for (PropertyDescriptor prop : props) {
- String name = prop.getName();
- if (allNamedComponent.containsKey(name)) {
- result.put(name, allNamedComponent.get(name));
- }
- }
-
- } catch (IntrospectionException eee) {
- log.warn("Can't introspect bean", eee);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("Result: " + result);
- }
-
- return result;
- }
-
- /**
- * Box a component in a {@link org.jdesktop.jxlayer.JXLayer}.
- *
- * @param component the component to box
- * @return the {@link org.jdesktop.jxlayer.JXLayer} boxing the component
- */
- public static JXLayer boxComponentWithJxLayer(JComponent component) {
- JXLayer layer = new org.jdesktop.jxlayer.JXLayer();
- layer.add(component);
- return layer;
- }
-
- /**
* Compute the string representation of an object.
* <p/>
* Return empty string if given object is null
@@ -372,6 +291,7 @@
* <p/>
* If entry is found, return his value in context.
*
+ * @param <T> the type of required data
* @param context the context to test
* @param def the definition of the entry to seek in context
* @return the value from the context
@@ -426,6 +346,9 @@
public static <O> DefaultListCellRenderer newDecoratedListCellRenderer(final Decorator<O> decorator) {
return new DefaultListCellRenderer() {
+
+ private static final long serialVersionUID = 1L;
+
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
String decorated;
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/SwingUtil.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,260 @@
+package jaxx.runtime;
+
+import java.awt.Component;
+import java.awt.Container;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.util.List;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.SwingUtilities;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import javax.swing.text.AbstractDocument;
+import javax.swing.text.JTextComponent;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import javax.swing.JComponent;
+import jaxx.runtime.swing.I18nTableCellRenderer;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXComboBox;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.jxlayer.JXLayer;
+
+/**
+ * The runtime swing util class with some nice stuff.
+ *
+ * Note : Replace previous class jaxx.runtime.swing.Utils in previous versions.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class SwingUtil extends Util {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(SwingUtil.class);
+ private static Field numReaders;
+ private static Field notifyingListeners;
+
+ public static void setText(final JTextComponent c, final String text) {
+ try {
+ // AbstractDocument deadlocks if we try to acquire a write lock while a read lock is held by the current thread
+ // If there are any readers, dispatch an invokeLater. This should only happen in the event of circular bindings.
+ // Similarly, circular bindings can result in an "Attempt to mutate in notification" error, which we deal with
+ // by checking for the 'notifyingListeners' property.
+ AbstractDocument document = (AbstractDocument) c.getDocument();
+ if (numReaders == null) {
+ numReaders = AbstractDocument.class.getDeclaredField("numReaders");
+ numReaders.setAccessible(true);
+ }
+ if (notifyingListeners == null) {
+ notifyingListeners = AbstractDocument.class.getDeclaredField("notifyingListeners");
+ notifyingListeners.setAccessible(true);
+ }
+
+ if (notifyingListeners.get(document).equals(Boolean.TRUE)) {
+ return;
+ }
+
+ if ((Integer) numReaders.get(document) > 0) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ if (!c.getText().equals(text)) {
+ c.setText(text);
+ }
+ }
+ });
+ return;
+ }
+
+ String oldText = c.getText();
+ if (oldText == null || !oldText.equals(text)) {
+ c.setText(text);
+ }
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (SecurityException e) {
+ c.setText(text);
+ }
+ }
+
+ /**
+ * Fill a combo box model with some datas, and select after all the given object
+ *
+ * @param combo the combo to fill
+ * @param data data ot inject in combo
+ * @param select the object to select in combo after reflling his model
+ */
+ public static void fillComboBox(JComboBox combo, Collection<?> data, Object select) {
+ if (!(combo.getModel() instanceof DefaultComboBoxModel)) {
+ throw new IllegalArgumentException("this method need a DefaultComboBoxModel for this model but was " + combo.getModel().getClass());
+ }
+ DefaultComboBoxModel model = (DefaultComboBoxModel) combo.getModel();
+ // evince the model
+ model.removeListDataListener(combo);
+ model.removeAllElements();
+ for (Object o : data) {
+ model.addElement(o);
+ }
+ // attach the model
+ model.addListDataListener(combo);
+ model.setSelectedItem(select);
+ }
+
+ /**
+ * Fill a combo box model with some datas, and select after all the given object
+ *
+ * @param combo the combo to fill
+ * @param data data ot inject in combo
+ * @param select the object to select in combo after reflling his model
+ * @param firstNull add a first null element
+ */
+ public static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull) {
+ List<Item> items = new ArrayList<Item>();
+ if (firstNull) {
+ items.add(new Item("null", " ", null, false));
+ }
+ for (Object d : data) {
+ items.add(new Item(d.toString(), d.toString(), d, d.equals(select)));
+ }
+ combo.setItems(items);
+ }
+
+ public static void fixTableColumnWidth(JTable table, int columnIndex, int width) {
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ column.setMaxWidth(width);
+ column.setMinWidth(width);
+ column.setWidth(width);
+ column.setPreferredWidth(width);
+ }
+
+ public static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor) {
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ column.setCellEditor(editor);
+ }
+
+ public static void setTableColumnRenderer(JTable table, int columnIndex, TableCellRenderer editor) {
+ TableColumn column = table.getColumnModel().getColumn(columnIndex);
+ column.setCellRenderer(editor);
+ }
+
+ public static void setI18nTableHeaderRenderer(JTable table, String... libelles) {
+ table.getTableHeader().setDefaultRenderer(new I18nTableCellRenderer(table.getTableHeader().getDefaultRenderer(), libelles));
+ }
+
+ /**
+ * Box a component in a {@link org.jdesktop.jxlayer.JXLayer}.
+ *
+ * @param component the component to box
+ * @return the {@link org.jdesktop.jxlayer.JXLayer} boxing the component
+ */
+ public static JXLayer boxComponentWithJxLayer(JComponent component) {
+ JXLayer layer = getLayer(component);
+ if (layer != null) {
+ return layer;
+ }
+ layer = new org.jdesktop.jxlayer.JXLayer();
+ layer.add(component);
+ return layer;
+ }
+
+ public static List<JComponent> getLayeredComponents(JAXXObject object) {
+ List<JComponent> result = new ArrayList<JComponent>();
+ for (Entry<String, Object> child : object.get$objectMap().entrySet()) {
+ if (JComponent.class.isAssignableFrom(child.getValue().getClass())) {
+ JComponent comp = (JComponent) child.getValue();
+ if (isLayered(comp)) {
+ result.add(comp);
+ }
+ }
+ }
+ return result;
+ }
+
+ public static JXLayer<JComponent> getLayer(JComponent comp) {
+ if (!isLayered(comp)) {
+ return null;
+ }
+ return (JXLayer<JComponent>) comp.getParent();
+ }
+
+ public static boolean isLayered(JComponent comp) {
+ Container parent = comp.getParent();
+ return parent != null && parent instanceof JXLayer;
+ }
+
+ /**
+ * recherche les composants portant le meme nom que les champs de la classe
+ * clazz. Cette methode est statique pour pouvoir eventuellement l'utiliser
+ * dans un autre context (je pense par exemple a la generation jaxx).
+ * <p/>
+ * <p/>
+ * Si la recherche echoue pour quelque raison que se soit, aucune exception
+ * n'est leve, et la map retournee est tout simplement vide ou incomplete
+ *
+ * @param clazz la classe ou recherche les champs
+ * @param container le container ou rechercher les composants d'edition
+ * @return le dictionnaire des composants recherches.
+ */
+ public static Map<String, JComponent> lookingForEditor(Class clazz, Container container) {
+ Map<String, JComponent> result = new HashMap<String, JComponent>();
+ try {
+ // looking for all component with name set
+ Map<String, JComponent> allNamedComponent = new HashMap<String, JComponent>();
+ List<Container> todo = new LinkedList<Container>();
+ todo.add(container);
+ while (todo.size() > 0) {
+ for (ListIterator<Container> i = todo.listIterator(); i.hasNext();) {
+ Container parent = i.next();
+ i.remove();
+ for (Component c : parent.getComponents()) {
+ if (c instanceof Container) {
+ i.add((Container) c);
+ String name = c.getName();
+ if (c instanceof JComponent &&
+ name != null && !"".equals(name)) {
+ allNamedComponent.put(name, (JComponent) c);
+ }
+ }
+ }
+ }
+ }
+
+ // looking for all properties on class
+ BeanInfo info = Introspector.getBeanInfo(clazz);
+ PropertyDescriptor[] props = info.getPropertyDescriptors();
+
+ // find if one properties have same name that component
+ for (PropertyDescriptor prop : props) {
+ String name = prop.getName();
+ if (allNamedComponent.containsKey(name)) {
+ result.put(name, allNamedComponent.get(name));
+ }
+ }
+
+ } catch (IntrospectionException eee) {
+ log.warn("Can't introspect bean", eee);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Result: " + result);
+ }
+
+ return result;
+ }
+}
Added: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLayerUI.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,179 @@
+package jaxx.runtime.swing;
+
+import java.awt.Component;
+import java.awt.Graphics2D;
+import java.awt.Point;
+import java.awt.RenderingHints;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.awt.image.BufferedImage;
+import javax.swing.Action;
+import javax.swing.ImageIcon;
+import javax.swing.JComponent;
+import org.jdesktop.jxlayer.JXLayer;
+
+/**
+ *
+ * A JXLayer ui implementation that permits to block a component but still
+ * allow an action when clicking on the right-top icon painted on the layer.
+ *
+ * You can change the blocking and accepting icon.
+ *
+ * To hook an click on the layer's icon, you can :
+ *
+ * <ul><li>pass an Action via method {@link #setAcceptAction(Action)}</li>
+ * <li>override the method {@link #acceptEvent(java.awt.event.MouseEvent, org.jdesktop.jxlayer.JXLayer)}</li>
+ * </ul>
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class BlockingLayerUI extends org.jdesktop.jxlayer.plaf.AbstractLayerUI<JComponent> {
+
+ public static final String CAN_CLICK_PROPERTY = "canClick";
+ public static final String ACCEPT_ICON_PROPERTY = "acceptIcon";
+ public static final String BLOCK_ICON_PROPERTY = "blockIcon";
+ private static final long serialVersionUID = 1L;
+ /**
+ * Action to be treated when click on icon
+ */
+ protected Action acceptAction;
+ /**
+ * Icon when you can not click
+ */
+ protected BufferedImage blockIcon;
+ /**
+ * Icon when you can click
+ */
+ protected BufferedImage acceptIcon;
+ /**
+ * Internal state to known when we can accept click
+ */
+ protected boolean canClick;
+
+ public void setAcceptAction(Action acceptAction) {
+ this.acceptAction = acceptAction;
+ }
+
+ public void setAcceptIcon(ImageIcon acceptIcon) {
+ this.acceptIcon = prepareIcon(acceptIcon);
+ firePropertyChange(ACCEPT_ICON_PROPERTY, null, acceptIcon);
+ setDirty(true);
+ }
+
+ public void setBlockIcon(ImageIcon blockIcon) {
+ this.blockIcon = prepareIcon(blockIcon);
+ firePropertyChange(BLOCK_ICON_PROPERTY, null, blockIcon);
+ setDirty(true);
+ }
+
+ public void setCanClick(boolean canClick) {
+ boolean oldvalue = this.canClick;
+ this.canClick = canClick;
+ firePropertyChange(CAN_CLICK_PROPERTY, oldvalue, canClick);
+ if (oldvalue != canClick) {
+ setDirty(true);
+ }
+ }
+
+ public BufferedImage getBlockIcon() {
+ return blockIcon;
+ }
+
+ protected BufferedImage getAcceptIcon() {
+ return acceptIcon;
+ }
+
+ public boolean isCanClick() {
+ return canClick;
+ }
+
+ @Override
+ public BlockingLayerUI clone() {
+ BlockingLayerUI clone = new BlockingLayerUI();
+ clone.acceptAction = acceptAction;
+ clone.acceptIcon = acceptIcon;
+ clone.blockIcon = blockIcon;
+ clone.setCanClick(false);
+ return clone;
+ }
+
+ @Override
+ protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) {
+ e.consume();
+ }
+
+ @Override
+ protected void processMouseMotionEvent(MouseEvent e, JXLayer<JComponent> l) {
+ updateCanClickState(l, e);
+ e.consume();
+ }
+
+ @Override
+ protected void processMouseEvent(MouseEvent e, JXLayer<JComponent> l) {
+
+ switch (e.getID()) {
+ case MouseEvent.MOUSE_ENTERED:
+ updateCanClickState(l, e);
+ break;
+ case MouseEvent.MOUSE_EXITED:
+ setCanClick(false);
+ break;
+ case MouseEvent.MOUSE_CLICKED:
+ if (canClick) {
+ acceptEvent(e, l);
+ }
+ break;
+ }
+ e.consume();
+ }
+
+ @Override
+ protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
+ super.paintLayer(g2, l);
+ if (getCurrentIcon() != null) {
+ g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().getWidth() - 1, 0, null);
+ }
+ }
+
+ protected void acceptEvent(MouseEvent e, JXLayer<JComponent> l) {
+ if (acceptAction != null) {
+ acceptAction.putValue("layer", l);
+ Component source = l.getView();
+ acceptAction.actionPerformed(new ActionEvent(source, 0, "accept"));
+ }
+ }
+
+ protected BufferedImage getCurrentIcon() {
+ return canClick ? acceptIcon : blockIcon;
+ }
+
+ protected BufferedImage prepareIcon(ImageIcon image) {
+ BufferedImage icon = new BufferedImage(image.getIconWidth(), image.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
+ Graphics2D g2 = (Graphics2D) icon.getGraphics();
+ g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+ g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
+ g2.drawImage(image.getImage(), 0, 0, null);
+ g2.dispose();
+ return icon;
+ }
+
+ protected void updateCanClickState(JXLayer<JComponent> l, MouseEvent e) {
+ // udpate toolTipText
+ Point layerLocation = l.getView().getLocation();
+ Point mousePoint = e.getPoint();
+ BufferedImage currentIcon = getCurrentIcon();
+ if (currentIcon == null) {
+ setCanClick(false);
+ return;
+ }
+ int minX = (int) layerLocation.getX() + l.getWidth() - currentIcon.getWidth();
+ int maxX = (int) layerLocation.getX() + l.getWidth();
+ int minY = 0;
+ int maxY = currentIcon.getHeight();
+ boolean accept = minX <= mousePoint.getX() && mousePoint.getX() <= maxX;
+ accept &= minY <= mousePoint.getLocation().getY() && mousePoint.getLocation().getY() <= maxY;
+ setCanClick(accept);
+ }
+}
Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Utils.java
===================================================================
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Utils.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Utils.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -6,7 +6,6 @@
import java.util.List;
import javax.swing.DefaultComboBoxModel;
-import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
@@ -18,13 +17,18 @@
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
-import jaxx.runtime.swing.Item;
-
+/**
+ *
+ * @author tony
+ * @deprecatedwill remove in release 1.2, prefer use the {@link jaxx.runtime.SwingUtil} class.
+ *
+ */
public class Utils {
private static Field numReaders;
private static Field notifyingListeners;
+ @Deprecated
public static void setText(final JTextComponent c, final String text) {
try {
// AbstractDocument deadlocks if we try to acquire a write lock while a read lock is held by the current thread
@@ -73,47 +77,13 @@
}
/**
- * @param path icones from path /icons
- * @return the icone
- * @deprecated prefer use {@link jaxx.runtime.Util#createImageIcon(String)}
- */
- @Deprecated
- public static ImageIcon createImageIcon(String path) {
- java.net.URL imgURL = Utils.class.getResource("/icons/" + path);
- if (imgURL != null) {
- return new ImageIcon(imgURL);
- } else {
- throw new IllegalArgumentException("could not find icon " + path);
- }
- }
-
- /**
- * @param name icones from path /icons/action-xx.png
- * @return the icone
- * @deprecated prefer use {@link jaxx.runtime.Util#createActionIcon(String)}
- */
- @Deprecated
- public static ImageIcon createActionIcon(String name) {
- return createImageIcon("action-" + name + ".png");
- }
-
- /**
- * @param name icones from path /icons/i18n/xx-.png icones
- * @return the icone
- * @deprecated prefer use {@link jaxx.runtime.Util#createI18nIcon(String)}
- */
- @Deprecated
- public static ImageIcon createI18nIcon(String name) {
- return createImageIcon("i18n/" + name + ".png");
- }
-
- /**
* Fill a combo box model with some datas, and select after all the given object
*
* @param combo the combo to fill
* @param data data ot inject in combo
* @param select the object to select in combo after reflling his model
*/
+ @Deprecated
public static void fillComboBox(JComboBox combo, Collection<?> data, Object select) {
if (!(combo.getModel() instanceof DefaultComboBoxModel)) {
throw new IllegalArgumentException("this method need a DefaultComboBoxModel for this model but was " + combo.getModel().getClass());
@@ -138,6 +108,7 @@
* @param select the object to select in combo after reflling his model
* @param firstNull add a first null element
*/
+ @Deprecated
public static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull) {
List<Item> items = new ArrayList<Item>();
if (firstNull)
@@ -147,7 +118,7 @@
}
combo.setItems(items);
}
-
+ @Deprecated
public static void fixTableColumnWidth(JTable table, int columnIndex, int width) {
TableColumn column = table.getColumnModel().getColumn(columnIndex);
column.setMaxWidth(width);
@@ -155,17 +126,17 @@
column.setWidth(width);
column.setPreferredWidth(width);
}
-
+ @Deprecated
public static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor) {
TableColumn column = table.getColumnModel().getColumn(columnIndex);
column.setCellEditor(editor);
}
-
+ @Deprecated
public static void setTableColumnRenderer(JTable table, int columnIndex, TableCellRenderer editor) {
TableColumn column = table.getColumnModel().getColumn(columnIndex);
column.setCellRenderer(editor);
}
-
+ @Deprecated
public static void setI18nTableHeaderRenderer(JTable table, String... libelles) {
table.getTableHeader().setDefaultRenderer(new I18nTableCellRenderer(table.getTableHeader().getDefaultRenderer(), libelles));
}
Modified: jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/AbstractValidatorTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/AbstractValidatorTest.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-runtime-validator/src/test/java/jaxx/runtime/validator/AbstractValidatorTest.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -1,7 +1,5 @@
package jaxx.runtime.validator;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -14,9 +12,6 @@
*/
public abstract class AbstractValidatorTest extends Assert {
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(AbstractValidatorTest.class);
-
static protected BeanValidator<ValidatorBean> validator;
static protected File basedir;
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/SwingValidator.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -217,6 +217,7 @@
/** install ui on required components */
public void installUIs() {
SwingUtilities.invokeLater(new Runnable() {
+ @Override
public void run() {
if (uiClass == null) {
// use the default one
Modified: jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java
===================================================================
--- jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/jaxx-runtime-validator-swing/src/main/java/jaxx/runtime/validator/swing/ui/AbstractBeanValidatorUI.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -22,8 +22,8 @@
public AbstractBeanValidatorUI(ValidatorField field) {
this.field = field;
- if (log.isInfoEnabled()) {
- log.info("install " + this + "<field:" + field + ">");
+ if (log.isDebugEnabled()) {
+ log.debug("install " + this + "<field:" + field + ">");
}
}
Modified: jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -45,6 +45,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Set;
+import jaxx.compiler.CompiledObjectDecorator;
/**
* Classe permettant de transformer des sources jaxx vers du source java.
@@ -237,6 +238,18 @@
* @see jaxx.runtime.validator.swing.SwingValidator#DEFAULT_UI_CLASS
*/
protected String defaultErrorUIFQN;
+
+ /**
+ * the FQN of the ui to use for error notification.
+ * <p/>
+ * If not given, will use the one defined in validator
+ *
+ * @parameter expression="${jaxx.defaultDecorator}" default-value="jaxx.compiler.DefaultCompiledObjectDecorator"
+ *
+ * @see jaxx.compiler.CompiledObjectDecorator
+ */
+ protected String defaultDecoratorFQN;
+
/**
* a flag to use UIManager to retreave icons.
*
@@ -255,6 +268,7 @@
protected boolean skip = true;
private Class<?> defaultErrorUIClass;
+ private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
protected ClassLoader cl;
private Class<? extends JAXXCompiler> compilerClass;
@@ -269,10 +283,11 @@
}
compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN);
-
+ defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN);
+
// check the validator class is correct
Class.forName(validatorFQN);
-
+
if (defaultErrorUIFQN != null && !defaultErrorUIFQN.trim().isEmpty()) {
defaultErrorUIClass = Class.forName(defaultErrorUIFQN);
}
@@ -309,21 +324,21 @@
}
ds.scan();
- String[] files = ds.getIncludedFiles();
+ String[] filesFind = ds.getIncludedFiles();
if (verbose) {
- getLog().info("jaxx - discover " + files.length + " jaxx file(s). ");
+ getLog().info("jaxx - discover " + filesFind.length + " jaxx file(s). ");
}
updater = (MirroredFileUpdater) FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
if (force) {
// we will regenerate all files
- this.files = files;
+ this.files = filesFind;
} else {
// filter files
List<String> listFiles = new ArrayList<String>();
- for (String file : files) {
+ for (String file : filesFind) {
if (updater.isFileUpToDate(new File(src, file))) {
if (verbose) {
getLog().info("jaxx - skip file [" + file + "].");
@@ -367,12 +382,14 @@
result.setExtraImports(extraImports);
result.setDefaultErrorUI(defaultErrorUIClass);
result.setUseUIManagerForIcon(useUIManagerForIcon);
+ result.setDefaultDecoratorClass(defaultDecoratorClass);
if (cl != null) {
result.setClassLoader(cl);
}
return result;
}
+ @Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
@@ -492,13 +509,13 @@
getLog().info("will generate " + file);
}
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- getLog().info(cl.toString());
- if (cl.getClass().getSimpleName().equals("RealmClassLoader")) {
+ ClassLoader threadLoader = Thread.currentThread().getContextClassLoader();
+ getLog().info(threadLoader.toString());
+ if (threadLoader.getClass().getSimpleName().equals("RealmClassLoader")) {
try {
- java.lang.reflect.Method m = cl.getClass().getDeclaredMethod("getURLs");
+ java.lang.reflect.Method m = threadLoader.getClass().getDeclaredMethod("getURLs");
m.setAccessible(true);
- URL[] urls = (URL[]) m.invoke(cl);
+ URL[] urls = (URL[]) m.invoke(threadLoader);
for (URL url : urls) {
getLog().info("url in class loader " + url);
Added: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/DecoratorTest.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/DecoratorTest.java (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/DecoratorTest.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,11 @@
+package org.codelutin.jaxx;
+
+public class DecoratorTest extends JaxxBaseTest {
+
+ public void testDecorator() throws Exception {
+ mojo.execute();
+ assertNumberJaxxFiles(1);
+ checkPattern(mojo, "root.add(jaxx.runtime.SwingUtil.boxComponentWithJxLayer(boxedButton))", true);
+ }
+
+}
\ No newline at end of file
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/JaxxBaseTest.java
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/JaxxBaseTest.java 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/JaxxBaseTest.java 2009-02-23 02:06:29 UTC (rev 1239)
@@ -34,6 +34,7 @@
mojo.jaxxContextImplementorClass = DefaultJAXXContext.class.getName();
mojo.compilerFQN = jaxx.compiler.SwingCompiler.class.getName();
mojo.validatorFQN = jaxx.runtime.validator.swing.SwingValidator.class.getName();
+ mojo.defaultDecoratorFQN = jaxx.compiler.DefaultCompiledObjectDecorator.class.getName();
assertNotNull(mojo);
}
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1722.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<verbose>true</verbose>
<includes>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1750.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1750.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1750.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<verbose>true</verbose>
<resetAfterCompile>false</resetAfterCompile>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1751.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1751.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Bug_1751.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/it-1751/java</outJava>
- <outResource>${basedir}/target/it-generated-source/it-1751/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<i18nable>true</i18nable>
<force>true</force>
<verbose>true</verbose>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/CSSTests.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/CSSTests.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/CSSTests.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<i18nable>false</i18nable>
<includes>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/ClassReferences/*.jaxx</value>
Added: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Decorator.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Decorator.xml (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Decorator.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,23 @@
+<?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">
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codelutin</groupId>
+ <artifactId>maven-jaxx-plugin</artifactId>
+ <configuration>
+ <src>${basedir}/src/test/resources</src>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <force>true</force>
+ <addLogger>false</addLogger>
+ <includes>
+ <value>**/decorator/*.jaxx</value>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ErrorJaxxContextImplementorClass.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ErrorJaxxContextImplementorClass.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ErrorJaxxContextImplementorClass.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<jaxxContextImplementorClass>java.lang.String</jaxxContextImplementorClass>
<force>true</force>
</configuration>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Errors.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Errors.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Errors.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/errors/*.jaxx</value>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Force.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Force.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Force.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/force/*.jaxx</value>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nText.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nText.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nText.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<i18nable>true</i18nable>
<includes>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nTitle.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nTitle.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nTitle.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<i18nable>true</i18nable>
<includes>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nToolTipText.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nToolTipText.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/I18nToolTipText.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<i18nable>true</i18nable>
<includes>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Initializers.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Initializers.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Initializers.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/Initializers/*.jaxx</value>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/InnerClasses.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/InnerClasses.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/InnerClasses.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/InnerClasses/*.jaxx</value>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/NoLog.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/NoLog.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/NoLog.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<addLogger>false</addLogger>
<includes>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/OverridingDataBindings.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/OverridingDataBindings.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/OverridingDataBindings.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/OverridingDataBindings/*.jaxx</value>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Script.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Script.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/Script.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/Script/*.jaxx</value>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/SpecialSubclassing.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/SpecialSubclassing.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/SpecialSubclassing.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/SpecialSubclassing/*.jaxx</value>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ValidatorErrors.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ValidatorErrors.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ValidatorErrors.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/validator/errors/*.jaxx</value>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ValidatorOk.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ValidatorOk.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ValidatorOk.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
<value>**/validator/ok/*.jaxx</value>
Modified: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/WithLog.xml
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/WithLog.xml 2009-02-21 18:17:21 UTC (rev 1238)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/WithLog.xml 2009-02-23 02:06:29 UTC (rev 1239)
@@ -9,8 +9,8 @@
<artifactId>maven-jaxx-plugin</artifactId>
<configuration>
<src>${basedir}/src/test/resources</src>
- <outJava>${basedir}/target/it-generated-source/java</outJava>
- <outResource>${basedir}/target/it-generated-source/resources</outResource>
+ <outJava>${basedir}/target/it-generated-sources/java</outJava>
+ <outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<addLogger>true</addLogger>
<includes>
Added: jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/decorator/BoxedDecorator.jaxx
===================================================================
--- jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/decorator/BoxedDecorator.jaxx (rev 0)
+++ jaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/decorator/BoxedDecorator.jaxx 2009-02-23 02:06:29 UTC (rev 1239)
@@ -0,0 +1,3 @@
+<JPanel id='root'>
+ <JButton id='boxedButton' decorator='boxed'/>
+</JPanel>
1
0
r1238 - in jaxx/trunk/jaxx-runtime-api: . src/main/java/jaxx/runtime src/test/java/jaxx/runtime
by tchemit@users.labs.libre-entreprise.org Feb. 21, 2009
by tchemit@users.labs.libre-entreprise.org Feb. 21, 2009
Feb. 21, 2009
Author: tchemit
Date: 2009-02-21 18:17:21 +0000 (Sat, 21 Feb 2009)
New Revision: 1238
Added:
jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java
jaxx/trunk/jaxx-runtime-api/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java
Modified:
jaxx/trunk/jaxx-runtime-api/changelog.txt
Log:
introduce DefaultApplicationContext iwth annotation system.
Modified: jaxx/trunk/jaxx-runtime-api/changelog.txt
===================================================================
--- jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-02-20 14:33:52 UTC (rev 1237)
+++ jaxx/trunk/jaxx-runtime-api/changelog.txt 2009-02-21 18:17:21 UTC (rev 1238)
@@ -1,3 +1,6 @@
+1.2 ??? 2009????
+ * 2009021 [chemit] - introduce DefaultApplicationContext iwth annotation system.
+
1.1 chemit 20090220
* 20090124 [chemit] - add methods to retreave icons from UIManager in Util class
* 20090123 [chemit] - add a simple createIcon method in Util classe (to create an icon with no path prefix)
Added: jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java
===================================================================
--- jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-api/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-02-21 18:17:21 UTC (rev 1238)
@@ -0,0 +1,222 @@
+package jaxx.runtime;
+
+import java.lang.annotation.*;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The default context to be used for an application.
+ *
+ * This extends the {@link DefaultJAXXContext} and add a possibility to auto-instanciate
+ * some classes asked via {@link #getContextValue(java.lang.Class)} and
+ * {@link #getContextValue(java.lang.Class, java.lang.String)} methods.
+ *
+ * To registred a such class, just annotate your class with {@link AutoLoad}.
+ *
+ * @author chemit
+ * @since 1.2
+ * @see DefaultJAXXContext
+ */
+public class DefaultApplicationContext extends DefaultJAXXContext {
+
+ /**
+ * A class annotated @AutoLoad is used by context to auto
+ * instanciate the class when required.
+ *
+ * Note : A such class always have a public default constructor.
+ *
+ * @author chemit
+ * @version 1.0, 21/02/09
+ * @since 1.2
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE)
+ public static @interface AutoLoad {
+ //TODO use this to add a method to init
+
+ String initMethod() default "";
+ }
+
+ /**
+ * A class annotated @MethodAccess is used by context to obtain the value
+ * of an entry via a declared method.
+ *
+ * Note : A such class must have a method called {@link #methodName()} with
+ * a single String parameter.
+ *
+ * @author chemit
+ * @version 1.0, 21/02/09
+ * @since 1.2
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE)
+ public static @interface MethodAccess {
+
+ /**
+ * Define a forward to a target class. When the target class
+ * will be asked with method {@link #getContextValue(java.lang.Class, java.lang.String)}
+ * it will be delegating to this class.
+ *
+ * @return the forwarded class
+ */
+ Class<?> target() default Object.class;
+
+ /**
+ * @return the name of the method to access data
+ */
+ String methodName();
+ }
+ /**
+ * Map of forwarded classes (key) to classes (values).
+ */
+ protected Map<Class, Class> forwards;
+
+ public DefaultApplicationContext() {
+ super();
+ forwards = new HashMap<Class, Class>();
+ }
+
+ public DefaultApplicationContext(JAXXObject ui) {
+ super(ui);
+ }
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(DefaultApplicationContext.class);
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public <T> T getContextValue(Class<T> clazz, String name) {
+ Object value = null;
+ MethodAccess access;
+
+ Class<?> realClass;
+
+ if (forwards.containsKey(clazz)) {
+ // this is a forward class
+ realClass = forwards.get(clazz);
+ // always call the forwarder with no name
+ value = getContextValue(realClass, null);
+ if (log.isDebugEnabled()) {
+ log.debug("detect forward from " + clazz + " to " + realClass + " (" + value + ")");
+ }
+
+ } else {
+ realClass = clazz;
+ value = super.getContextValue(realClass, name);
+ }
+
+ if (value == null) {
+ AutoLoad anno = clazz.getAnnotation(AutoLoad.class);
+
+ if (anno == null) {
+ // no annotation, so do nothing
+ return null;
+ }
+
+ if (name != null) {
+ throw new IllegalArgumentException("an " + AutoLoad.class.getName() + " can not have a named context but was call with this one : " + name);
+ }
+ value = newInstance(clazz);
+ if (log.isDebugEnabled()) {
+ log.debug("new instance " + clazz + " : " + value);
+ }
+ // save new instance
+ setContextValue(value, null);
+ }
+
+ access = realClass.getAnnotation(MethodAccess.class);
+
+ if (access != null) {
+ if (name == null) {
+ if (access.target() != Object.class) {
+ // register forward
+ Class<?> targetClass = access.target();
+ if (!forwards.containsKey(targetClass)) {
+ // register forward
+ forwards.put(targetClass, clazz);
+ if (log.isDebugEnabled()) {
+ log.debug("register forward from " + targetClass + " to " + clazz);
+ }
+ }
+ }
+ } else {
+ // specialized access
+ value = newAccess(realClass, value, access.methodName(), name);
+ }
+ }
+ return (T) value;
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz, String name) {
+ Entry<Class, Class> entry;
+ if (name == null && forwards.containsValue(klazz)) {
+ // remove forward
+ Iterator<Entry<Class, Class>> itr = forwards.entrySet().iterator();
+ while (itr.hasNext()) {
+ entry = itr.next();
+ if (entry.getValue().equals(klazz)) {
+ itr.remove();
+ if (log.isDebugEnabled()) {
+ log.debug("removed forward from " + entry.getKey() + " to " + klazz);
+ }
+ break;
+ }
+ }
+ }
+ //FIXME should update forwards state
+ super.removeContextValue(klazz, name);
+ }
+
+ protected Object newInstance(Class<?> clazz) throws IllegalArgumentException {
+
+ Object value = null;
+
+ Constructor<?> constructor = null;
+ try {
+ constructor = clazz.getConstructor();
+ // auto instanciate the class
+ if (constructor == null) {
+ throw new IllegalArgumentException(clazz + " has no public constructor");
+ }
+ } catch (NoSuchMethodException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (SecurityException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ try {
+ value = constructor.newInstance();
+
+ } catch (InstantiationException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ return value;
+ }
+
+ protected Object newAccess(Class<?> clazz, Object parent, String methodName, String name) throws IllegalArgumentException {
+ Object value;
+ try {
+ Method m = clazz.getMethod(methodName, String.class);
+ value = m.invoke(parent, name);
+ return value;
+ } catch (NoSuchMethodException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (SecurityException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ }
+}
Added: jaxx/trunk/jaxx-runtime-api/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java
===================================================================
--- jaxx/trunk/jaxx-runtime-api/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java (rev 0)
+++ jaxx/trunk/jaxx-runtime-api/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java 2009-02-21 18:17:21 UTC (rev 1238)
@@ -0,0 +1,117 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package jaxx.runtime;
+
+import jaxx.runtime.DefaultApplicationContext.AutoLoad;
+import jaxx.runtime.DefaultApplicationContext.MethodAccess;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author tony
+ */
+public class DefaultApplicationContextTest {
+
+ static int helloCount;
+ static int helloGetCount;
+
+ @AutoLoad
+ @MethodAccess(methodName = "hello", target = String.class)
+ public static class Hello {
+
+ public Hello() {
+ helloCount++;
+ }
+
+ public String hello(String name) {
+ helloGetCount++;
+ return "hello " + name;
+ }
+ }
+ DefaultApplicationContext context;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ helloCount = 0;
+ helloGetCount = 0;
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() {
+ context = new DefaultApplicationContext();
+ assertEquals(0, helloCount);
+ assertEquals(0, helloGetCount);
+ }
+
+ @After
+ public void tearDown() {
+ context = null;
+ helloCount = helloGetCount = 0;
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testAutoLoadNamed() {
+ context.getContextValue(Hello.class, "fakeName");
+ }
+
+ @Test
+ public void testAutoLoad() {
+ Hello hello = context.getContextValue(Hello.class);
+ assertNotNull(hello);
+ assertEquals(1, helloCount);
+
+ Hello hello2 = context.getContextValue(Hello.class);
+ assertNotNull(hello2);
+ assertEquals(1, helloCount);
+ assertEquals(hello, hello2);
+ }
+
+ @Test
+ public void testForward() {
+ context.getContextValue(Hello.class);
+ assertEquals(1, helloCount);
+ String response = context.getContextValue(String.class, "John");
+ assertNotNull(response);
+ assertEquals(1, helloGetCount);
+ assertEquals(new Hello().hello("John"), response);
+ }
+
+ @Test
+ public void testRemove() {
+ String response;
+
+ context.getContextValue(Hello.class);
+ assertEquals(1, helloCount);
+ assertEquals(1, context.forwards.size());
+ response = context.getContextValue(String.class, "John");
+ assertNotNull(response);
+
+ context.removeContextValue(Hello.class);
+ assertEquals(0, context.forwards.size());
+ response = context.getContextValue(String.class, "John");
+ assertEquals(1, helloCount);
+ assertNull(response);
+
+ // reinstanciate the service
+ context.getContextValue(Hello.class);
+ assertEquals(2, helloCount);
+ assertEquals(1, context.forwards.size());
+
+ // no effect with a name
+ context.removeContextValue(Hello.class, "fake");
+ assertEquals(1, context.forwards.size());
+ context.getContextValue(Hello.class);
+ assertEquals(2, helloCount);
+ }
+}
\ No newline at end of file
1
0
Feb. 20, 2009
Author: tchemit
Date: 2009-02-20 14:33:52 +0000 (Fri, 20 Feb 2009)
New Revision: 1237
Modified:
jaxx/tags/1.1/jaxx-example/pom.xml
Log:
fix bug on jnlp site (wrong phase)
Modified: jaxx/tags/1.1/jaxx-example/pom.xml
===================================================================
--- jaxx/tags/1.1/jaxx-example/pom.xml 2009-02-20 14:29:45 UTC (rev 1236)
+++ jaxx/tags/1.1/jaxx-example/pom.xml 2009-02-20 14:33:52 UTC (rev 1237)
@@ -171,7 +171,7 @@
<!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
<execution>
<id>JnlpSun</id>
- <phase>compile</phase>
+ <phase>verify</phase>
<configuration>
<tasks>
<mkdir dir="${jnlp.build.directory}" />
1
0
Feb. 20, 2009
Author: tchemit
Date: 2009-02-20 14:29:45 +0000 (Fri, 20 Feb 2009)
New Revision: 1236
Modified:
jaxx/trunk/jaxx-example/pom.xml
Log:
fix jnlp site bug (wrong phase)
Modified: jaxx/trunk/jaxx-example/pom.xml
===================================================================
--- jaxx/trunk/jaxx-example/pom.xml 2009-02-20 14:03:57 UTC (rev 1235)
+++ jaxx/trunk/jaxx-example/pom.xml 2009-02-20 14:29:45 UTC (rev 1236)
@@ -172,7 +172,7 @@
<!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
<execution>
<id>JnlpSun</id>
- <phase>compile</phase>
+ <phase>verify</phase>
<configuration>
<tasks>
<mkdir dir="${jnlp.build.directory}"/>
1
0