Buix-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 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 02 Apr '09
by kmorin@users.labs.libre-entreprise.org 02 Apr '09
02 Apr '09
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 30 Mar '09
by sletellier@users.labs.libre-entreprise.org 30 Mar '09
30 Mar '09
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 29 Mar '09
by tchemit@users.labs.libre-entreprise.org 29 Mar '09
29 Mar '09
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 29 Mar '09
by tchemit@users.labs.libre-entreprise.org 29 Mar '09
29 Mar '09
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 24 Mar '09
by tchemit@users.labs.libre-entreprise.org 24 Mar '09
24 Mar '09
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 24 Mar '09
by tchemit@users.labs.libre-entreprise.org 24 Mar '09
24 Mar '09
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 23 Mar '09
by tchemit@users.labs.libre-entreprise.org 23 Mar '09
23 Mar '09
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 23 Mar '09
by tchemit@users.labs.libre-entreprise.org 23 Mar '09
23 Mar '09
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