Jaxx-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
November 2008
- 2 participants
- 31 discussions
[Buix-commits] r1041 - in lutinjaxx/trunk: jaxx-core jaxx-core/src/site/fr/rst jaxx-example jaxx-swing-action jaxx-util maven-jaxx-plugin
by chemit@users.labs.libre-entreprise.org 30 Nov '08
by chemit@users.labs.libre-entreprise.org 30 Nov '08
30 Nov '08
Author: chemit
Date: 2008-11-30 22:23:22 +0000 (Sun, 30 Nov 2008)
New Revision: 1041
Modified:
lutinjaxx/trunk/jaxx-core/pom.xml
lutinjaxx/trunk/jaxx-core/src/site/fr/rst/NavigationTreeModel.rst
lutinjaxx/trunk/jaxx-example/pom.xml
lutinjaxx/trunk/jaxx-swing-action/pom.xml
lutinjaxx/trunk/jaxx-util/pom.xml
lutinjaxx/trunk/maven-jaxx-plugin/pom.xml
Log:
fix scm values + debut mise a jour doc
Modified: lutinjaxx/trunk/jaxx-core/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-core/pom.xml 2008-11-30 21:12:00 UTC (rev 1040)
+++ lutinjaxx/trunk/jaxx-core/pom.xml 2008-11-30 22:23:22 UTC (rev 1041)
@@ -18,18 +18,6 @@
<dependencies>
- <!--dependency>
- <groupId>org.codelutin</groupId>
- <artifactId>jaxx-util</artifactId>
- </dependency-->
-
- <!-- pour acceder aux BeansInfos swing via Introspector -->
- <!--dependency>
- <groupId>com.sun</groupId>
- <artifactId>dt</artifactId>
- <scope>system</scope>
- </dependency-->
-
<!-- pour utiliser javaHelp -->
<dependency>
<groupId>javax.help</groupId>
@@ -68,8 +56,8 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
+ <connection>${maven.scm.connection.son}</connection>
+ <developerConnection>${maven.scm.developerConnection.son}</developerConnection>
+ <url>${maven.scm.url.son}</url>
</scm>
</project>
Modified: lutinjaxx/trunk/jaxx-core/src/site/fr/rst/NavigationTreeModel.rst
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/site/fr/rst/NavigationTreeModel.rst 2008-11-30 21:12:00 UTC (rev 1040)
+++ lutinjaxx/trunk/jaxx-core/src/site/fr/rst/NavigationTreeModel.rst 2008-11-30 22:23:22 UTC (rev 1041)
@@ -16,7 +16,7 @@
Le développement est effectué dans le paquetage *jaxx.runtime.swing.navigation*.
jaxx.runtime.swing.navigation.NavigationTreeModel
-======================================
+=================================================
Il s'agit du modèle de l'arbre utilisé, c'est une extension d'un *javax.swing.tree.DefaultTreeModel*.
@@ -24,7 +24,8 @@
L'idée principale est de pouvoir associé à un noeud précis un chemin depuis la racine, ce que l'on appele *chemin de navigation*.
-Pour obtenir le chemin de navigation d'un noeud donné, on récupère l'enmseble des neoud depuis la racine vers ce noeud et les concatène en suffixant par un *.*.
+Pour obtenir le chemin de navigation d'un noeud donné, on récupère l'enmseble des neoud depuis la racine vers ce noeud
+et les concatène en suffixant par le caractère séparateur défini.
Définition d'un noeud
=====================
@@ -33,7 +34,7 @@
Il apporte les nouvelles propriétés suivantes :
- * *context* : nom de chemin de navigation de ce noeud.
+ * *navigationPAth* : nom de chemin de navigation de ce noeud.
* *jaxxClass* : nom qualifié de la classe d'ui associé à ce noeud (doit être obligatoirement un *JAXXObject*)
@@ -41,7 +42,9 @@
* *jaxxContextEntryDef* : définition de l'entrée dans le context JAXX associé à ce noeud.
+ * *jaxxContextEntryJXPath* : définition d'une expression JXPath à appliquer sur le bean associé au noeud.
+
Retrouver un noeud à partir du chemin de navigation
***************************************************
@@ -68,10 +71,8 @@
* redescendre à partir de ce noeud vers le noeud d'origine (si ce noeud était différent) et en descendant conjointement dans l'objet du context JAXX :
- - le chemin de navigation de chaque noeud rencontré est le nom de la propriété à extraire de l'objet du context JAXX
+ - on utilise l'expression JXPath pour obtenir l'objet associé au noeud
- - si l'objet courant extrait du context JAXX est une liste, on utilise alors la position dans la liste de l'objet recherché
-
Exemple :
::
@@ -113,6 +114,7 @@
assert model.getJAXXContextValue(context, "$root.locale.country") == myLocale.getCountry();
assert model.getJAXXContextValue(context, "$root.locale.language") == myLocale.getLanguage();
+TODO mettre à jour cet exemple suite à l'utilisation de JXPath pour naviguer dans les objets.
A noter qu'une seconde méthode de récupération de valeur du context JAXX est disponible pour pouvoir récupérer cette
valeur en connaissant le noeud :
@@ -122,7 +124,7 @@
model.getJAXXContextValue(context, myNode);
jaxx.runtime.swing.navigation.NavigationTreeSelectionAdapter
-=================================================
+============================================================
Il s'agit d'un listener sur la sélection d'un noeud dans l'arbre de navigation basé sur notre modèle de navigation. Il
étend *javax.swing.event.TreeSelectionListener*.
@@ -147,7 +149,7 @@
Si une erreur survient lors de ces opérations, on entre dans la méthode *goBackToPreviousNode* qui est abstraite et permet de notifier les erreur de retourner au noeud précdent.
jaxx.runtime.swing.navigation.NavigationtreeSelectionAdapterWithCardLayout
-***************************************************************
+**************************************************************************
Il s'agit d'une implantation du listener précédent qui suppose que les uis associées aux noeuds sont affichées dans un
unique container en utilisant le layout *jaxx.runtime.swing.CardLayout2*.
Modified: lutinjaxx/trunk/jaxx-example/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-example/pom.xml 2008-11-30 21:12:00 UTC (rev 1040)
+++ lutinjaxx/trunk/jaxx-example/pom.xml 2008-11-30 22:23:22 UTC (rev 1041)
@@ -140,11 +140,6 @@
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
- <!--plugin>
- <groupId>org.codehaus.mojo.webstart</groupId>
- <artifactId>webstart-maven-plugin</artifactId>
- </plugin-->
-
</plugins>
</build>
Modified: lutinjaxx/trunk/jaxx-swing-action/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-swing-action/pom.xml 2008-11-30 21:12:00 UTC (rev 1040)
+++ lutinjaxx/trunk/jaxx-swing-action/pom.xml 2008-11-30 22:23:22 UTC (rev 1041)
@@ -72,9 +72,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
+ <connection>${maven.scm.connection.son}</connection>
+ <developerConnection>${maven.scm.developerConnection.son}</developerConnection>
+ <url>${maven.scm.url.son}</url>
</scm>
</project>
Modified: lutinjaxx/trunk/jaxx-util/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-util/pom.xml 2008-11-30 21:12:00 UTC (rev 1040)
+++ lutinjaxx/trunk/jaxx-util/pom.xml 2008-11-30 22:23:22 UTC (rev 1041)
@@ -39,9 +39,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
+ <connection>${maven.scm.connection.son}</connection>
+ <developerConnection>${maven.scm.developerConnection.son}</developerConnection>
+ <url>${maven.scm.url.son}</url>
</scm>
</project>
Modified: lutinjaxx/trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/pom.xml 2008-11-30 21:12:00 UTC (rev 1040)
+++ lutinjaxx/trunk/maven-jaxx-plugin/pom.xml 2008-11-30 22:23:22 UTC (rev 1041)
@@ -127,9 +127,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>${maven.scm.connection}</connection>
- <developerConnection>${maven.scm.developerConnection}</developerConnection>
- <url>${maven.scm.url}</url>
+ <connection>${maven.scm.connection.son}</connection>
+ <developerConnection>${maven.scm.developerConnection.son}</developerConnection>
+ <url>${maven.scm.url.son}</url>
</scm>
</project>
\ No newline at end of file
1
0
[Buix-commits] r1040 - lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx
by chemit@users.labs.libre-entreprise.org 30 Nov '08
by chemit@users.labs.libre-entreprise.org 30 Nov '08
30 Nov '08
Author: chemit
Date: 2008-11-30 21:12:00 +0000 (Sun, 30 Nov 2008)
New Revision: 1040
Removed:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/BuildExamples.java
Log:
no more used
Deleted: lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/BuildExamples.java
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/BuildExamples.java 2008-11-30 21:10:13 UTC (rev 1039)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/java/org/codelutin/jaxx/BuildExamples.java 2008-11-30 21:12:00 UTC (rev 1040)
@@ -1,106 +0,0 @@
-package org.codelutin.jaxx;
-
-import junit.framework.TestCase;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.maven.it.VerificationException;
-import org.apache.maven.it.Verifier;
-import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author chemit
- * @deprecated This goal is not ny longer used : we have specific maven modules to build examples...
- */
-public abstract class BuildExamples extends TestCase {
-
- protected static final Log log = LogFactory.getLog(BuildExamples.class);
-
- protected File srcDir;
-
- protected File destDir;
-
- protected File siteDir;
- protected File siteDestDir;
-
- protected Verifier verifier;
-
- protected File getBasedir() {
- String b = System.getenv("basedir");
- if (b == null) {
- b = new File("").getAbsolutePath();
- }
- return new File(b);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- log.info("start " + getName());
- String dirname = getName().substring(4);
-
- srcDir = new File(getBasedir(), "src" + File.separator + "examples" + File.separator + dirname);
- destDir = new File(getBasedir(), "target" + File.separator + "examples" + File.separator + dirname);
- siteDestDir = new File(getBasedir(), "target" + File.separator + "generated-site" + File.separator + "resources" + File.separator + "examples");
- siteDir = new File(destDir, "target" + File.separator + "jnlp");
-
- destDir.mkdirs();
-
- FileUtils.copyDirectoryStructure(srcDir, destDir);
-
- verifier = new Verifier(destDir.getAbsolutePath(), true);
-
- List<String> cliOptions = new ArrayList<String>();
- cliOptions.add("-Dmaven.verbose=true");
- verifier.setCliOptions(cliOptions);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- srcDir = destDir = null;
- if (verifier != null) {
- verifier.resetStreams();
- verifier = null;
- }
- }
-
- /**
- * fixme : make this test works again.
- *
- * @throws Exception if any
- */
- public void estComponents() throws Exception {
- buildExample();
- }
-
- public void testCalculator() throws Exception {
- buildExample();
- }
-
- public void testCounter() throws Exception {
- buildExample();
- }
-
- public void testLabelStyle() throws Exception {
- buildExample();
- }
-
- public void testValidation() throws Exception {
- buildExample();
- }
-
- protected void buildExample() throws VerificationException, IOException {
- verifier.executeGoals(Arrays.asList("jaxx:generate", "package"));
- verifier.verifyErrorFreeLog();
- FileUtils.copyDirectory(new File(siteDir, "lib"), new File(siteDestDir, "lib"));
- FileUtils.copyDirectory(siteDir, siteDestDir, "*.jnlp", "");
- }
-
-
-}
1
0
[Buix-commits] r1039 - in lutinjaxx/trunk: jaxx-example maven-jaxx-plugin/src/test/resources/testcases/ClassReferences
by chemit@users.labs.libre-entreprise.org 30 Nov '08
by chemit@users.labs.libre-entreprise.org 30 Nov '08
30 Nov '08
Author: chemit
Date: 2008-11-30 21:10:13 +0000 (Sun, 30 Nov 2008)
New Revision: 1039
Added:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/JavaTaist.java
Removed:
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/JavaTest.java
Modified:
lutinjaxx/trunk/jaxx-example/pom.xml
lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/ClassReferences.jaxx
Log:
rename non test class
make possible to not do jnlp on example (for hudson...)
Modified: lutinjaxx/trunk/jaxx-example/pom.xml
===================================================================
--- lutinjaxx/trunk/jaxx-example/pom.xml 2008-11-30 20:44:13 UTC (rev 1038)
+++ lutinjaxx/trunk/jaxx-example/pom.xml 2008-11-30 21:10:13 UTC (rev 1039)
@@ -1,4 +1,5 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -87,61 +88,9 @@
<plugins>
<plugin>
-
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <!-- Ajout des libs signe par Sun dans un fichier jnlp separe -->
- <execution>
- <id>JnlpSun</id>
- <phase>compile</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.codelutin</groupId>
<artifactId>maven-jaxx-plugin</artifactId>
- <version>0.7-SNAPSHOT</version>
+ <version>${project.version}</version>
<configuration>
<src>${basedir}/src/main/java</src>
<force>true</force>
@@ -170,75 +119,14 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
- <mainClass>${maven.jar.main.class}</mainClass>
- <classpathPrefix>lib/</classpathPrefix>
+ <classpathPrefix>./lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
+ </plugins>
- <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-${project.artifactId}.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>
-
</pluginManagement>
<plugins>
@@ -252,12 +140,147 @@
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
- <plugin>
+ <!--plugin>
<groupId>org.codehaus.mojo.webstart</groupId>
<artifactId>webstart-maven-plugin</artifactId>
- </plugin>
+ </plugin-->
</plugins>
</build>
+ <profiles>
+ <!-- by default example are included, use -Ddoexample=false to disable examples -->
+ <profile>
+ <id>dojnlp</id>
+ <activation>
+ <property>
+ <name>dojnlp</name>
+ <value>!false</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>compile</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-${project.artifactId}.jnlp</outputFile>
+ <mainClass>${maven.jar.main.class}</mainClass>
+ <allPermissions>true</allPermissions>
+ <offlineAllowed>true</offlineAllowed>
+ </jnlp>
+
+ <sign>
+ <keystore>${keystorepath}</keystore>
+ <keypass/>
+ <storepass>${keystorepass}</storepass>
+ <storetype/>
+ <alias>${keystorealias}</alias>
+ <validity/>
+ <dnameCn/>
+ <dnameOu/>
+ <dnameO/>
+ <dnameL/>
+ <dnameSt/>
+ <dnameC/>
+ <verify>true</verify>
+ <keystoreConfig>
+ <delete>false</delete>
+ <gen>false</gen>
+ </keystoreConfig>
+ </sign>
+
+
+ <pack200>false</pack200>
+ <gzip>true</gzip>
+ <verbose>false</verbose>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
\ No newline at end of file
Modified: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/ClassReferences.jaxx
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/ClassReferences.jaxx 2008-11-30 20:44:13 UTC (rev 1038)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/ClassReferences.jaxx 2008-11-30 21:10:13 UTC (rev 1039)
@@ -13,6 +13,6 @@
<!-- TODO Ce cas ne fonctionne plus (il faut posséder cette classe compilée ? -->
<!--ClassTest customProperty='Compiled class file worked'/-->
<JAXXTest customProperty='Uncompiled JAXX file worked'/>
- <JavaTest customProperty='Uncompiled Java file worked'/>
+ <JavaTaist customProperty='Uncompiled Java file worked'/>
</VBox>
</Application>
\ No newline at end of file
Copied: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/JavaTaist.java (from rev 1003, lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/JavaTest.java)
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/JavaTaist.java (rev 0)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/JavaTaist.java 2008-11-30 21:10:13 UTC (rev 1039)
@@ -0,0 +1,9 @@
+package testcases.ClassReferences;
+
+import javax.swing.*;
+
+public class JavaTaist extends JLabel {
+ public void setCustomProperty(String label) {
+ setText(label);
+ }
+}
\ No newline at end of file
Deleted: lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/JavaTest.java
===================================================================
--- lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/JavaTest.java 2008-11-30 20:44:13 UTC (rev 1038)
+++ lutinjaxx/trunk/maven-jaxx-plugin/src/test/resources/testcases/ClassReferences/JavaTest.java 2008-11-30 21:10:13 UTC (rev 1039)
@@ -1,9 +0,0 @@
-package testcases.ClassReferences;
-
-import javax.swing.*;
-
-public class JavaTest extends JLabel {
- public void setCustomProperty(String label) {
- setText(label);
- }
-}
\ No newline at end of file
1
0
[Buix-commits] r1038 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler
by chemit@users.labs.libre-entreprise.org 30 Nov '08
by chemit@users.labs.libre-entreprise.org 30 Nov '08
30 Nov '08
Author: chemit
Date: 2008-11-30 20:44:13 +0000 (Sun, 30 Nov 2008)
New Revision: 1038
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
Log:
only pass in $initialize method once.
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2008-11-30 18:31:15 UTC (rev 1037)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2008-11-30 20:44:13 UTC (rev 1038)
@@ -410,6 +410,12 @@
protected JavaMethod createInitializer() throws CompilerException {
StringBuffer code = new StringBuffer();
CompiledObject root = compiler.getRootObject();
+ code.append("if (allComponentsCreated) {");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" return;");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("}");
+ code.append(JAXXCompiler.getLineSeparator());
code.append("$objectMap.put(").append(TypeManager.getJavaCode(root.getId())).append(", this);");
code.append(JAXXCompiler.getLineSeparator());
1
0
[Buix-commits] r1037 - lutinjaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action
by chemit@users.labs.libre-entreprise.org 30 Nov '08
by chemit@users.labs.libre-entreprise.org 30 Nov '08
30 Nov '08
Author: chemit
Date: 2008-11-30 18:31:15 +0000 (Sun, 30 Nov 2008)
New Revision: 1037
Modified:
lutinjaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java
Log:
fix ServiceLoader failure when application is launched from a java -jar
Modified: lutinjaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java
===================================================================
--- lutinjaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java 2008-11-30 14:05:52 UTC (rev 1036)
+++ lutinjaxx/trunk/jaxx-swing-action/src/main/java/org/codelutin/jaxx/action/ActionFactoryFromProvider.java 2008-11-30 18:31:15 UTC (rev 1037)
@@ -21,6 +21,7 @@
import jaxx.runtime.swing.JAXXToggleButton;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.Resource;
import javax.swing.AbstractButton;
import javax.swing.Action;
@@ -29,6 +30,8 @@
import javax.swing.JComponent;
import java.awt.event.ActionEvent;
import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -389,6 +392,12 @@
if (log.isDebugEnabled()) {
log.debug("start loading " + this);
}
+ URLClassLoader newCL = fixClassLoader(getClass());
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ if (newCL != null) {
+ // replace current cl by our fiexed cl
+ Thread.currentThread().setContextClassLoader(newCL);
+ }
// obtain a ServiceLoader on ActionProvider
ServiceLoader<ActionProvider> loader = ServiceLoader.load(ActionProvider.class);
Map<String, Class<? extends MyAbstractAction>> cache = new TreeMap<String, Class<? extends MyAbstractAction>>();
@@ -399,7 +408,50 @@
}
cache.putAll(actionProvider.getClasses());
}
+ if (newCL != null) {
+ // to avoid side effects, push back old cl
+ Thread.currentThread().setContextClassLoader(cl);
+ }
return cache;
}
+ /**
+ * Fix the class loader when application is launched from a java -jar
+ * The ServiceLoader seems not to find services from jar manifest...
+ * <p/>
+ * Our solution is to get all jar from the jar manifest and create a URLClassLoader, this is not perfect but works.
+ * <p/>
+ * TODO Put this nice code in a ServiceLoaderUtil in lutinutil...
+ *
+ * @param klass class to use to obtain classloader
+ * @return the fixed classloader
+ */
+ public static URLClassLoader fixClassLoader(Class klass) {
+ ClassLoader l = klass.getClassLoader();
+ URLClassLoader cl;
+ if (!(l instanceof URLClassLoader)) {
+ log.warn("using cl is not a URL classloader " + l);
+ cl = new URLClassLoader(new URL[0], l);
+ } else {
+ cl = (URLClassLoader) l;
+ }
+ if (cl.getURLs().length == 1) {
+ // come from a java -jar, must expand all jar to make possible ServiceLoader to work
+ try {
+ //todo put this in lutinutil ServiceLoaderUtil
+ URL[] urls = Resource.getClassPathURLsFromJarManifest(cl.getURLs()[0]);
+ URLClassLoader newCL = new URLClassLoader(urls);
+ if (log.isTraceEnabled()) {
+ for (URL url : newCL.getURLs()) {
+ log.trace(url);
+ }
+ }
+ return newCL;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return null;
+ }
+
}
\ No newline at end of file
1
0
[Buix-commits] r1036 - in lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime: . swing/navigation
by chemit@users.labs.libre-entreprise.org 30 Nov '08
by chemit@users.labs.libre-entreprise.org 30 Nov '08
30 Nov '08
Author: chemit
Date: 2008-11-30 14:05:52 +0000 (Sun, 30 Nov 2008)
New Revision: 1036
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeCellRenderer.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
Log:
improve NodeRenderer and Decorator : keep the internalClass to be render (will be used for example by some renderer...)
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java 2008-11-26 01:06:42 UTC (rev 1035)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/Decorator.java 2008-11-30 14:05:52 UTC (rev 1036)
@@ -5,12 +5,24 @@
*
* @author chemit
*/
-public interface Decorator<O> extends java.io.Serializable {
+public abstract class Decorator<O> implements java.io.Serializable {
+ protected final Class<O> internalClass;
+ private static final long serialVersionUID = -1L;
+
+ public Decorator(Class<O> internalClass) {
+ this.internalClass = internalClass;
+ }
+
/**
* @param bean the bean to decorate
* @return the string value of the given bean
*/
- String toString(O bean);
+ public abstract String toString(Object bean);
+
+ public final Class<O> getInternalClass() {
+ return internalClass;
+ }
+
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java 2008-11-26 01:06:42 UTC (rev 1035)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JXPathDecorator.java 2008-11-30 14:05:52 UTC (rev 1036)
@@ -5,7 +5,7 @@
import org.apache.commons.logging.LogFactory;
/** @author chemit */
-public class JXPathDecorator<O> implements Decorator<O> {
+public class JXPathDecorator<O> extends Decorator<O> {
/** to use log facility, just put in your code: log.info(\"...\"); */
private static final Log log = LogFactory.getLog(JXPathDecorator.class);
@@ -14,11 +14,13 @@
protected String expression;
- public JXPathDecorator(String expression) {
+ public JXPathDecorator(Class<O> internalClass, String expression) {
+ super(internalClass);
this.expression = expression;
}
- public String toString(O bean) {
+ public String toString(Object bean) {
+ //todo check bean class
JXPathContext jxcontext = JXPathContext.newContext(bean);
String result = (String) jxcontext.getValue(expression);
if (log.isDebugEnabled()) {
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeCellRenderer.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeCellRenderer.java 2008-11-26 01:06:42 UTC (rev 1035)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeCellRenderer.java 2008-11-30 14:05:52 UTC (rev 1036)
@@ -8,7 +8,11 @@
import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.Component;
-/** @author chemit */
+/**
+ * A simple cell renderer which use the {@link NavigationTreeNode#renderer} to display node.
+ *
+ * @author chemit
+ */
public class NavigationTreeCellRenderer extends DefaultTreeCellRenderer {
protected JAXXContext context;
@@ -19,16 +23,29 @@
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
+
+ if (value != null) {
+
+ NodeRenderer renderer = getNodeRenderer(value);
+ if (renderer != null) {
+ value = renderer.toString(context);
+ }
+ }
+
+ return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
+ }
+
+ protected NodeRenderer getNodeRenderer(Object value) {
+ NodeRenderer render = null;
+
if (value != null && value instanceof NavigationTreeNode && ((NavigationTreeNode) value).getUserObject() instanceof NodeRenderer) {
// NodeRenderer used as userObject
NavigationTreeNode navigationTreeNode = (NavigationTreeNode) value;
// could have a cached value (
- NodeRenderer render = (NodeRenderer) navigationTreeNode.getUserObject();
-
- value = render.toString(context);
+ render = (NodeRenderer) navigationTreeNode.getUserObject();
}
+ return render;
+ }
- return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
- }
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-26 01:06:42 UTC (rev 1035)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-30 14:05:52 UTC (rev 1036)
@@ -143,7 +143,9 @@
return null;
}
path = matcher.group(1);
- log.info("matching regex " + regex + " : " + path);
+ if (log.isDebugEnabled()) {
+ log.debug("matching regex " + regex + " : " + path);
+ }
}
StringTokenizer stk = new StringTokenizer(path, navigationPathSeparator);
NavigationTreeNode result = root;
@@ -310,6 +312,10 @@
this.jaxxContextEntryPath = jaxxContextEntryPath;
}
+ public Class<?> getInternalClass() {
+ return renderer.getInternalClass();
+ }
+
/** @return the fully context pathof the node from the root node to this. */
public String getContextPath() {
TreeNode[] path = getPath();
@@ -406,7 +412,9 @@
// special case when we want to access a collection
jxpathExpression = '.' + jxpathExpression;
}
- log.info("jxpath : " + jxpathExpression);
+ if (log.isDebugEnabled()) {
+ log.debug("jxpath : " + jxpathExpression);
+ }
JXPathContext jxcontext = JXPathContext.newContext(parentBean);
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-26 01:06:42 UTC (rev 1035)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-30 14:05:52 UTC (rev 1036)
@@ -25,7 +25,7 @@
return context.getContextValue(NavigationTreeNode.class, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_NODE);
}
- public static <O> O getSelectedBean(JAXXContext context,Class<O> clazz) {
+ public static <O> O getSelectedBean(JAXXContext context, Class<O> clazz) {
return context.getContextValue(clazz, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_BEAN);
}
@@ -88,14 +88,18 @@
protected NavigationTreeNode node;
+ protected Class<?> internalClass;
+
private static final long serialVersionUID = -1238962588426200861L;
public NodeRenderer(String libelle) {
this.libelle = libelle;
+ this.internalClass = String.class;
}
- public NodeRenderer(Decorator<?> decorator) {
+ public NodeRenderer(Decorator decorator) {
this.decorator = decorator;
+ this.internalClass = decorator.getInternalClass();
}
public String toString(JAXXContext context) {
@@ -121,6 +125,10 @@
public void setNode(NavigationTreeNode node) {
this.node = node;
}
+
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
}
}
1
0
[Buix-commits] r1035 - in lutinjaxx/trunk/jaxx-core/src: main/java/jaxx/runtime/swing/navigation test/java/jaxx/runtime/swing/navigation
by chemit@users.labs.libre-entreprise.org 26 Nov '08
by chemit@users.labs.libre-entreprise.org 26 Nov '08
26 Nov '08
Author: chemit
Date: 2008-11-26 01:06:42 +0000 (Wed, 26 Nov 2008)
New Revision: 1035
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
Log:
improve and refactor navigation model to make findNode more efficent + can now defined the navigation path separator.
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 09:42:25 UTC (rev 1034)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-26 01:06:42 UTC (rev 1035)
@@ -13,8 +13,7 @@
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Stack;
+import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -30,17 +29,181 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private final Log log = LogFactory.getLog(NavigationTreeModel.class);
- private static final long serialVersionUID = 1L;
+ static private final long serialVersionUID = 1L;
- /** la représentation d'un noeud dans le model {@link NavigationTreeModel} */
- public static class NavigationTreeNode extends DefaultMutableTreeNode {
+ /** the separator char used to produce the navigation path of a node. */
+ protected final String navigationPathSeparator;
+ public NavigationTreeModel(TreeNode root, String navigationPathSeparator) {
+ super(root);
+ this.navigationPathSeparator = navigationPathSeparator;
+ }
+
+ @Override
+ public NavigationTreeNode getRoot() {
+ return (NavigationTreeNode) super.getRoot();
+ }
+
+ /**
+ * Search from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by dot.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the root node, or <code>null</code> if not find.
+ */
+ public NavigationTreeNode findNode(String path) {
+ return findNode(getRoot(), path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ * <p/>
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, String regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, Pattern regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+
+ /**
+ * Search from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path) {
+ return findNode(root, path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes)
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) {
+ return findNode(root, path, regex == null ? null : Pattern.compile(regex));
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #navigationPathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) {
+ if (regex != null) {
+ Matcher matcher = regex.matcher(path);
+ if (!matcher.matches() || matcher.groupCount() < 1) {
+ log.warn("no matching regex " + regex + " to " + path);
+ return null;
+ }
+ path = matcher.group(1);
+ log.info("matching regex " + regex + " : " + path);
+ }
+ StringTokenizer stk = new StringTokenizer(path, navigationPathSeparator);
+ NavigationTreeNode result = root;
+ // pas the first token (matches the root node)
+ if (root.isRoot() && stk.hasMoreTokens()) {
+ String rootPath = stk.nextToken();
+ if (!rootPath.equals(root.getNavigationPath())) {
+ return null;
+ }
+ }
+ while (stk.hasMoreTokens()) {
+ result = result.getChild(stk.nextToken());
+ }
+ return result;
+ }
+
+
+ /**
+ * Obtain the associated bean value from context corresponding to node from given navigation path.
+ *
+ * @param context the context where to seek value
+ * @param navigationPath the current context path of the node
+ * @return the value associated in context with the given navigation path
+ */
+ public Object getJAXXContextValue(JAXXContext context, String navigationPath) {
+ Object result;
+ NavigationTreeNode node = findNode(navigationPath, (Pattern) null);
+ result = getJAXXContextValue(context, node);
+ return result;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param context the context where to seek value
+ * @param node the current node
+ * @return the value associated in context with the given node.
+ */
+ public Object getJAXXContextValue(JAXXContext context, NavigationTreeNode node) {
+ if (node == null) {
+ return null;
+ //fixme should throw a NPE exception
+ //throw new NullPointerException("node can not be null");
+ }
+ return node.getJAXXContextValue(context);
+ }
+
+ /**
+ * la représentation d'un noeud dans le modele {@link NavigationTreeModel}
+ *
+ * @author chemit
+ */
+ public class NavigationTreeNode extends DefaultMutableTreeNode {
+
private static final long serialVersionUID = 1L;
/** pour representer le context du noeud. */
- protected String context;
+ protected String navigationPath;
- /** the JAXXObject class associated with this node */
+ /** the JAXXObject class associated with this node (can be null) */
protected Class<? extends JAXXObject> jaxxClass;
/** the JAXXAction class associated with this node and will be put in ui context */
@@ -49,13 +212,15 @@
/** the definition of the JAXXContext entry associated to this node, if null will seek in parent */
protected JAXXContextEntryDef jaxxContextEntryDef;
+ /** jxPath to process to obtain real value associated from context with the node (can be null) */
protected String jaxxContextEntryPath;
+ /** renderer of the node */
protected NodeRenderer renderer;
public NavigationTreeNode(Object renderer,
Object jaxxContextEntryDef,
- String context,
+ String navigationPath,
Class<? extends JAXXObject> jaxxClass,
Class<? extends JAXXAction> jaxxActionClass) {
super(renderer);
@@ -64,13 +229,11 @@
((NodeRenderer) renderer).setNode(this);
} else if (renderer instanceof String) {
// nothing special to be done
- } else {
- if (renderer != null) {
- // wrong renderer type
- throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
- }
+ } else if (renderer != null) {
+ // wrong renderer type
+ throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
}
- this.context = context;
+ this.navigationPath = navigationPath;
this.jaxxClass = jaxxClass;
this.jaxxActionClass = jaxxActionClass;
@@ -78,18 +241,16 @@
this.jaxxContextEntryDef = ((JAXXContextEntryDef) jaxxContextEntryDef);
} else if (jaxxContextEntryDef instanceof String) {
this.jaxxContextEntryPath = (String) jaxxContextEntryDef;
- } else {
- if (jaxxContextEntryDef != null) {
- // wront context definition type
- throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef);
- }
+ } else if (jaxxContextEntryDef != null) {
+ // wrong context definition type
+ throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef);
}
}
public NavigationTreeNode(Object renderer,
JAXXContextEntryDef jaxxContextEntryDef,
String jaxxContextEntryPath,
- String context,
+ String navigationPath,
Class<? extends JAXXObject> jaxxClass,
Class<? extends JAXXAction> jaxxActionClass) {
super(renderer);
@@ -98,25 +259,23 @@
((NodeRenderer) renderer).setNode(this);
} else if (renderer instanceof String) {
// nothing special to be done
- } else {
- if (renderer != null) {
- // wrong renderer type
- throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
- }
+ } else if (renderer != null) {
+ // wrong renderer type
+ throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
}
- this.context = context;
+ this.navigationPath = navigationPath;
this.jaxxClass = jaxxClass;
this.jaxxActionClass = jaxxActionClass;
this.jaxxContextEntryDef = jaxxContextEntryDef;
this.jaxxContextEntryPath = jaxxContextEntryPath;
}
- public String getContext() {
- return context;
+ public String getNavigationPath() {
+ return navigationPath;
}
- public void setContext(String context) {
- this.context = context;
+ public void setNavigationPath(String navigationPath) {
+ this.navigationPath = navigationPath;
}
public Class<? extends JAXXObject> getJaxxClass() {
@@ -143,13 +302,21 @@
this.jaxxContextEntryDef = jaxxContextEntryDef;
}
+ public String getJaxxContextEntryPath() {
+ return jaxxContextEntryPath;
+ }
+
+ public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
/** @return the fully context pathof the node from the root node to this. */
public String getContextPath() {
TreeNode[] path = getPath();
StringBuilder sb = new StringBuilder();
for (TreeNode treeNode : path) {
NavigationTreeNode myNode = (NavigationTreeNode) treeNode;
- sb.append('.').append(myNode.getContext());
+ sb.append(navigationPathSeparator).append(myNode.getNavigationPath());
}
return sb.substring(1);
}
@@ -165,13 +332,13 @@
}
/**
- * @param context the name of the {@link #context} to be matched in the cild of this node.
- * @return the child of this node with given {@link #context} value.
+ * @param navigationPath the name of the {@link #navigationPath} to be matched in the cild of this node.
+ * @return the child of this node with given {@link # navigationPath} value.
*/
- public NavigationTreeNode getChild(String context) {
+ public NavigationTreeNode getChild(String navigationPath) {
for (int i = 0, max = getChildCount(); i < max; i++) {
NavigationTreeNode son = getChildAt(i);
- if (context.equals(son.getContext())) {
+ if (navigationPath.equals(son.getNavigationPath())) {
return son;
}
}
@@ -179,48 +346,16 @@
}
/**
- * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
- * or <code>null</code> if none find..
- */
- protected NavigationTreeNode getFirstAncestorWithDef() {
- if (jaxxContextEntryDef != null) {
- return this;
- }
- return getParent() == null ? null : getParent().getFirstAncestorWithDef();
- }
-
- protected NavigationTreeNode findNode(Stack<String> stack) {
- if (log.isDebugEnabled()) {
- log.debug(context + " : enter with " + stack);
- }
- if (stack.isEmpty()) {
- return this;
- }
- // next context to search
- String currentPath = stack.pop();
- if (getContext().equals(currentPath) && currentPath.startsWith("$")) {
- // this node matchs (only do this for root node)
- return findNode(stack);
- }
- // find the next matching son
- NavigationTreeNode son = getChild(currentPath);
- return son == null ? null : son.findNode(stack);
- }
-
- /**
* Obtain the associated bean value from context corresponding to node
*
* @param context the context to seek
* @return the value associated in context with the given context path
- * @throws InvocationTargetException todo
- * @throws NoSuchMethodException todo
- * @throws IllegalAccessException todo
*/
- public Object getJAXXContextValue(JAXXContext context) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ public Object getJAXXContextValue(JAXXContext context) {
Object result;
if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
- // the node maps directly a value in context, with no jxpath resolving
+ // the node maps directly a value in context, with no jxpath resolving
result = getJaxxContextEntryDef().getContextValue(context);
return result;
}
@@ -234,7 +369,6 @@
}
Object parentBean = parentNode.getJaxxContextEntryDef().getContextValue(context);
- //Object parentBean = parentNode.getJAXXContextValue(context);
if (parentBean == null) {
// must be an error no bean found
@@ -281,6 +415,17 @@
return result;
}
+ /**
+ * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
+ * or <code>null</code> if none find..
+ */
+ protected NavigationTreeNode getFirstAncestorWithDef() {
+ if (jaxxContextEntryDef != null) {
+ return this;
+ }
+ return getParent() == null ? null : getParent().getFirstAncestorWithDef();
+ }
+
protected String computeJXPath(String expr, NavigationTreeNode parentNode) {
if (parentNode == this) {
// reach the parent limit node, return the expr computed
@@ -337,162 +482,4 @@
}
}
- @Override
- public NavigationTreeNode getRoot() {
- return (NavigationTreeNode) super.getRoot();
- }
-
-
- public NavigationTreeModel(TreeNode root) {
- super(root);
- }
-
- public NavigationTreeModel(TreeNode root, boolean asksAllowsChildren) {
- super(root, asksAllowsChildren);
- }
-
- /**
- * Search from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- * <p/>
- * Example :
- * <p/>
- * <pre>$root.child1.leaf1</pre>
- *
- * @param path the fully path of the searched node.
- * @return the node matching the fully context from the root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(String path) {
- return findNode(getRoot(), path, (Pattern) null);
- }
-
- /**
- * Apply first the regex pattern to obtain the searched node.
- * <p/>
- * Search then from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- * <p/>
- * <p/>
- * Example :
- * <p/>
- * <pre>$root.child1.leaf1</pre>
- *
- * @param path the fully path of the searched node.
- * @param regex a optional regex to apply to path before searching
- * @return the node matching the fully context from the root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(String path, String regex) {
- return findNode(getRoot(), path, regex);
- }
-
- /**
- * Apply first the regex pattern to obtain the searched node.
- * <p/>
- * Search then from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- * <p/>
- * Example :
- * <p/>
- * <pre>$root.child1.leaf1</pre>
- *
- * @param path the fully path of the searched node.
- * @param regex a optional regex to apply to path before searching
- * @return the node matching the fully context from the root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(String path, Pattern regex) {
- return findNode(getRoot(), path, regex);
- }
-
-
- /**
- * Search from a given root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- *
- * @param root root node to be used
- * @param path the fully path of the searched node.
- * @return the node matching the fully context from the given root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(NavigationTreeNode root, String path) {
- return findNode(root, path, (Pattern) null);
- }
-
- /**
- * Apply first the regex pattern to obtain the searched node.
- * <p/>
- * Search then from a given root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- *
- * @param root root node to be used
- * @param path the fully path of the searched node.
- * @param regex a previous regex to apply to path : must have a matches
- * @return the node matching the fully context from the given root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) {
- return findNode(root, path, regex == null ? null : Pattern.compile(regex));
- }
-
- /**
- * Apply first the regex pattern to obtain the searched node.
- * <p/>
- * Search then from a given root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#context} valued separated by dot.
- *
- * @param root root node to be used
- * @param path the fully path of the searched node.
- * @param regex a previous regex to apply to path : must have a matches
- * @return the node matching the fully context from the given root node, or <code>null</code> if not find.
- */
- public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) {
- if (regex != null) {
- Matcher matcher = regex.matcher(path);
- if (!matcher.matches() || matcher.groupCount() < 1) {
- log.warn("no matching regex " + regex + " to " + path);
- return null;
- }
- path = matcher.group(1);
- log.info("matching regex " + regex + " : " + path);
- }
- String[] paths = path.split("\\.");
- Stack<String> stack = new Stack<String>();
- for (int i = paths.length - 1; i > -1; i--) {
- stack.push(paths[i]);
- }
- return root.findNode(stack);
- }
-
-
- /**
- * Obtain the associated bean value from context corresponding to node from given contextPath.
- *
- * @param context the context to seek
- * @param contextPath the current context path of the node
- * @return the value associated in context with the given context path
- * @throws InvocationTargetException todo
- * @throws NoSuchMethodException todo
- * @throws IllegalAccessException todo
- */
- public Object getJAXXContextValue(JAXXContext context, String contextPath) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
- Object result;
- NavigationTreeNode node = findNode(contextPath, (Pattern) null);
- result = getJAXXContextValue(context, node);
- return result;
- }
-
- /**
- * Obtain the associated bean value from context corresponding to node
- *
- * @param context the context to seek
- * @param node the current node
- * @return the value associated in context with the given context path
- * @throws InvocationTargetException todo
- * @throws NoSuchMethodException todo
- * @throws IllegalAccessException todo
- */
- public Object getJAXXContextValue(JAXXContext context, NavigationTreeNode node) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
- //Object result;
- if (node == null) {
- return null;
- }
- return node.getJAXXContextValue(context);
- }
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2008-11-25 09:42:25 UTC (rev 1034)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2008-11-26 01:06:42 UTC (rev 1035)
@@ -12,7 +12,8 @@
protected NavigationTreeModel model;
- public NavigationTreeModelBuilder() {
+ public NavigationTreeModelBuilder(String navigationSeparator) {
+ model = new NavigationTreeModel(null, navigationSeparator);
}
public NavigationTreeModel getModel() {
@@ -25,7 +26,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryDef, entryPath, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(libelle), entryDef, entryPath, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -34,7 +35,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryDef, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(libelle), entryDef, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -43,7 +44,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryPath, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(libelle), entryPath, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -53,7 +54,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryDef, entryPath, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(decorator), entryDef, entryPath, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -62,7 +63,7 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryDef, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(decorator), entryDef, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
@@ -71,72 +72,27 @@
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
- NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryPath, contextName, uiClass, actionClass);
+ NavigationTreeNode node = model.new NavigationTreeNode(new NodeRenderer(decorator), entryPath, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
- public void setRootNode(NavigationTreeNode rootNode) {
- if (model == null) {
- // create model with the root node
- model = new NavigationTreeModel(rootNode);
- } else {
- model.setRoot(rootNode);
- }
- }
-
protected NavigationTreeNode addChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
- if (parentNode != null) {
+ if (parentNode == null) {
+ model.setRoot(node);
+ } else {
parentNode.add(node);
}
+ model.nodeStructureChanged(parentNode);
return node;
}
- public NavigationTreeNode removeChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
- if (parentNode != null) {
+ public NavigationTreeNode removeChildNode(NavigationTreeNode node) {
+ NavigationTreeNode parentNode = node.getParent();
+ /*if (parentNode != null) {
parentNode.remove(node);
- }
- return node;
+ }*/
+ model.removeNodeFromParent(node);
+ return parentNode;
}
- /*
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, JAXXContextEntryDef entryDef,
- String contextName,
- Class<? extends JAXXObject> uiClass) {
- return build(parentNode, libelle, entryDef, contextName, uiClass, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, JAXXContextEntryDef entryDef,
- String contextName) {
- return build(parentNode, libelle, entryDef, contextName, null, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, String contextName,
- Class<? extends JAXXObject> uiClass) {
- return build(parentNode, libelle, (String) null, contextName, uiClass, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, String contextName) {
- return build(parentNode, libelle, (String) null, contextName, null, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator, JAXXContextEntryDef entryDef,
- String contextName, Class<? extends JAXXObject> uiClass) {
- return build(parentNode, decorator, entryDef, contextName, uiClass, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator, JAXXContextEntryDef entryDef,
- String contextName) {
- return build(parentNode, decorator, entryDef, contextName, null, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator,
- String contextName, Class<? extends JAXXObject> uiClass) {
- return build(parentNode, decorator, (String) null, contextName, uiClass, null);
- }
-
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<Object> decorator,
- String contextName) {
- return build(parentNode, decorator, (String) null, contextName, null, null);
- }*/
-
}
Modified: lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2008-11-25 09:42:25 UTC (rev 1034)
+++ lutinjaxx/trunk/jaxx-core/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2008-11-26 01:06:42 UTC (rev 1035)
@@ -7,7 +7,6 @@
import org.junit.Assert;
import org.junit.Test;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -20,29 +19,29 @@
*/
public class NavigationTreeModelTest {
-
private static final String ROOT_CONTEXT = "$root";
private static final String FAKE = "-fake";
- private static final String DOT = ".";
+ private static final String separator = "/";
+
@Test
public void testFindNode() throws Exception {
- NavigationTreeNode rootNode = new NavigationTreeNode(null, null, ROOT_CONTEXT, null, null);
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
for (int i = 0; i < 4; i++) {
- NavigationTreeNode sonNode = new NavigationTreeNode(null, null, getNodeContext(i), null, null);
- rootNode.insert(sonNode, i);
+ NavigationTreeNode sonNode = builder.build(rootNode, (String) null, (String) null, getNodeContext(i), null, null);
for (int j = 0; j < 4; j++) {
- NavigationTreeNode sonSonNode = new NavigationTreeNode(null, null, getNodeContext(i, j), null, null);
- sonNode.insert(sonSonNode, j);
+ NavigationTreeNode sonSonNode = builder.build(sonNode, (String) null, (String) null, getNodeContext(i, j), null, null);
for (int k = 0; k < 4; k++) {
- sonSonNode.insert(new NavigationTreeNode(null, null, getNodeContext(i, j, k), null, null), k);
+ builder.build(sonSonNode, (String) null, (String) null, getNodeContext(i, j, k), null, null);
}
}
}
- NavigationTreeModel model = new NavigationTreeModel(rootNode);
+ NavigationTreeModel model = builder.getModel();
NavigationTreeNode node;
String contextPath;
@@ -57,28 +56,28 @@
for (int i = 0; i < 4; i++) {
currentNode = getNodeContext(i);
- contextPath = ROOT_CONTEXT + DOT + currentNode;
+ contextPath = ROOT_CONTEXT + separator + currentNode;
node = model.findNode(contextPath);
assertNodeEquals(contextPath, currentNode, 1, node, false);
for (int j = 0; j < 4; j++) {
currentNode = getNodeContext(i, j);
- contextPath = ROOT_CONTEXT + DOT + getNodeContext(i) + DOT + currentNode;
+ contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode;
node = model.findNode(contextPath);
assertNodeEquals(contextPath, currentNode, 2, node, false);
for (int k = 0; k < 4; k++) {
currentNode = getNodeContext(i, j, k);
- contextPath = ROOT_CONTEXT + DOT + getNodeContext(i) + DOT + getNodeContext(i, j) + DOT + currentNode;
+ contextPath = ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode;
node = model.findNode(contextPath);
assertNodeEquals(contextPath, currentNode, 3, node, false);
}
- node = model.findNode(ROOT_CONTEXT + DOT + getNodeContext(i) + DOT + getNodeContext(i, j) + DOT + currentNode + FAKE);
+ node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + getNodeContext(i, j) + separator + currentNode + FAKE);
Assert.assertNull(node);
}
- node = model.findNode(ROOT_CONTEXT + DOT + getNodeContext(i) + DOT + currentNode + FAKE);
+ node = model.findNode(ROOT_CONTEXT + separator + getNodeContext(i) + separator + currentNode + FAKE);
Assert.assertNull(node);
}
@@ -128,52 +127,44 @@
@Test
public void testGetJAXXContextValue() throws Exception {
- NavigationTreeNode rootNode = new NavigationTreeNode(null, null, ROOT_CONTEXT, null, null);
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
NavigationTreeNode sonNode;
NavigationTreeNode sonSonNode;
NavigationTreeNode sonSonSonNode;
- sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null);
+ builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name", String.class), "name", null, null);
+ builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null);
- rootNode.insert(sonNode, 0);
+ sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newDef(Model.class), "model", null, null);
- sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newDef("name2", String.class), "name2", null, null);
+ builder.build(sonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonNode, (String) null, "../integerValue", "integerValue", null, null);
- rootNode.insert(sonNode, 1);
+ sonSonNode = builder.build(sonNode, (String) null, "../sons", "sons", null, null);
- sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newDef(Model.class), "model", null, null);
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", 0 + "", null, null);
- rootNode.insert(sonNode, 2);
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
- sonSonNode = new NavigationTreeNode(null, "../name", "name", null, null);
- sonNode.insert(sonSonNode, 0);
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[2]", 1 + "", null, null);
- sonSonNode = new NavigationTreeNode(null, "../integerValue", "integerValue", null, null);
- sonNode.insert(sonSonNode, 1);
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../sons", "sons", null, null);
- sonSonNode = new NavigationTreeNode(null, "../sons", "sons", null, null);
- sonNode.insert(sonSonNode, 2);
-
- sonSonSonNode = new NavigationTreeNode(null, "..[1]", 0 + "", null, null);
- sonSonNode.insert(sonSonSonNode, 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
-
- sonSonSonNode = new NavigationTreeNode(null, "..[2]", 1 + "", null, null);
- sonSonNode.insert(sonSonSonNode, 1);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
-
- sonSonSonNode = new NavigationTreeNode(null, null, 2 + "", null, null);
- //sonSonSonNode = new NavigationTreeNode(null, "..[3]", 2 + "", null, null);
+ sonSonSonNode = builder.build(sonSonNode, (String) null, (String) null, 2 + "", null, null);
+ //sonSonSonNode = model.new NavigationTreeNode(null, "..[3]", 2 + "", null, null);
sonSonNode.insert(sonSonSonNode, 2);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../..[3]/name", "name", null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../..[3]/integerValue", "integerValue", null, null), 1);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../..[3]/sons", "sons", null, null), 2);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/name", "name", null, null);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/integerValue", "integerValue", null, null);
+ builder.build(sonSonSonNode, (String) null, "../..[3]/sons", "sons", null, null);
- NavigationTreeModel model = new NavigationTreeModel(rootNode);
+ NavigationTreeModel model = builder.getModel();
JAXXContext context = new DefaultJAXXContext();
context.setContextValue("the name", "name");
@@ -192,28 +183,28 @@
Assert.assertNull(model.getJAXXContextValue(context, "$root.name" + FAKE));
- testBinding(model, context, "$root.name", context.getContextValue(String.class, "name"));
- testBinding(model, context, "$root.name2", context.getContextValue(String.class, "name2"));
+ testBinding(model, context, "$root/name", context.getContextValue(String.class, "name"));
+ testBinding(model, context, "$root/name2", context.getContextValue(String.class, "name2"));
Model bean = context.getContextValue(Model.class);
- testBinding(model, context, "$root.model", bean);
- testBinding(model, context, "$root.model.name", bean.getName());
- testBinding(model, context, "$root.model.integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root.model.sons", bean.getSons());
+ testBinding(model, context, "$root/model", bean);
+ testBinding(model, context, "$root/model/name", bean.getName());
+ testBinding(model, context, "$root/model/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/model/sons", bean.getSons());
- testBinding(model, context, "$root.model.sons.0.name", bean.getSons().get(0).getName());
- testBinding(model, context, "$root.model.sons.0.integerValue", bean.getSons().get(0).getIntegerValue());
- testBinding(model, context, "$root.model.sons.0.sons", bean.getSons().get(0).getSons());
+ testBinding(model, context, "$root/model/sons/0/name", bean.getSons().get(0).getName());
+ testBinding(model, context, "$root/model/sons/0/integerValue", bean.getSons().get(0).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/0/sons", bean.getSons().get(0).getSons());
- testBinding(model, context, "$root.model.sons.1.name", bean.getSons().get(1).getName());
- testBinding(model, context, "$root.model.sons.1.integerValue", bean.getSons().get(1).getIntegerValue());
- testBinding(model, context, "$root.model.sons.1.sons", bean.getSons().get(1).getSons());
+ testBinding(model, context, "$root/model/sons/1/name", bean.getSons().get(1).getName());
+ testBinding(model, context, "$root/model/sons/1/integerValue", bean.getSons().get(1).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/1/sons", bean.getSons().get(1).getSons());
- testBinding(model, context, "$root.model.sons.2.name", bean.getSons().get(2).getName());
- testBinding(model, context, "$root.model.sons.2.integerValue", bean.getSons().get(2).getIntegerValue());
- testBinding(model, context, "$root.model.sons.2.sons", bean.getSons().get(2).getSons());
+ testBinding(model, context, "$root/model/sons/2/name", bean.getSons().get(2).getName());
+ testBinding(model, context, "$root/model/sons/2/integerValue", bean.getSons().get(2).getIntegerValue());
+ testBinding(model, context, "$root/model/sons/2/sons", bean.getSons().get(2).getSons());
}
/**
@@ -252,90 +243,93 @@
@Test
public void testGetJAXXContextValueFromList() throws Exception {
- NavigationTreeNode rootNode = new NavigationTreeNode(null, null, ROOT_CONTEXT, null, null);
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder(separator);
+
+ NavigationTreeNode rootNode = builder.build(null, (String) null, (String) null, ROOT_CONTEXT, null, null);
+
NavigationTreeNode sonNode;
NavigationTreeNode sonSonNode;
NavigationTreeNode sonSonSonNode;
// first son is a list of models
- sonNode = new NavigationTreeNode(null, JAXXContextEntryDef.newListDef("models"), "models", null, null);
- rootNode.insert(sonNode, 0);
+ sonNode = builder.build(rootNode, (String) null, JAXXContextEntryDef.newListDef("models"), "models", null, null);
// first son son is a model
- sonSonNode = new NavigationTreeNode(null, "..[1]", "0", null, null);
- sonNode.insert(sonSonNode, 0);
+ sonSonNode = builder.build(sonNode, (String) null, "..[1]", "0", null, null);
- sonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonNode.insert(sonSonSonNode = new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ sonSonNode = builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
- sonSonSonNode.insert(sonSonSonNode = new NavigationTreeNode(null, "..[1]", "0", null, null), 0);
- sonSonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
+ sonSonSonNode = builder.build(sonSonNode, (String) null, "..[1]", "0", null, null);
+ builder.build(sonSonSonNode, (String) null, "../name", "name", null, null);
// second son son is a model
- sonSonNode = new NavigationTreeNode(null, "..[2]", "1", null, null);
- sonNode.insert(sonSonNode, 1);
- sonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
+ sonSonNode = builder.build(sonNode, (String) null, "..[2]", "1", null, null);
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
+
// third son son is a model
- sonSonNode = new NavigationTreeNode(null, "..[3]", "2", null, null);
- sonNode.insert(sonSonNode, 2);
- sonSonNode.insert(new NavigationTreeNode(null, "../name", "name", null, null), 0);
- sonSonNode.insert(new NavigationTreeNode(null, "../integerValue", "integerValue", null, null), 1);
- sonSonNode.insert(new NavigationTreeNode(null, "../sons", "sons", null, null), 2);
+ sonSonNode = builder.build(sonNode, (String) null, "..[3]", "2", null, null);
- NavigationTreeModel model = new NavigationTreeModel(rootNode);
+ builder.build(sonSonNode, (String) null, "../name", "name", null, null);
+ builder.build(sonSonNode, (String) null, "../integerValue", "integerValue", null, null);
+ builder.build(sonSonNode, (String) null, "../sons", "sons", null, null);
- JAXXContext context = new DefaultJAXXContext();
- List<Model> list = new ArrayList<Model>();
- list.add(new Model("entryOne", 10,
- Arrays.asList(
- new Model("one", 1, Collections.<Model>emptyList()),
- new Model("two", 2, Collections.<Model>emptyList()),
- new Model("three", 3, Collections.<Model>emptyList())
+ NavigationTreeModel model = builder.getModel();
+
+
+ List<Model> list = Arrays.asList(
+ new Model("entryOne", 10,
+ Arrays.asList(
+ new Model("one", 1, Collections.<Model>emptyList()),
+ new Model("two", 2, Collections.<Model>emptyList()),
+ new Model("three", 3, Collections.<Model>emptyList())
+ )
+ ),
+ new Model("entryTwo", 20,
+ Arrays.asList(
+ new Model("2one", 1, Collections.<Model>emptyList()),
+ new Model("2two", 2, Collections.<Model>emptyList()),
+ new Model("2three", 3, Collections.<Model>emptyList())
+ )
+ ),
+ new Model("entryThree", 30,
+ Arrays.asList(
+ new Model("3one", 1, Collections.<Model>emptyList()),
+ new Model("3two", 2, Collections.<Model>emptyList()),
+ new Model("3three", 3, Collections.<Model>emptyList())
+ )
)
- ));
- list.add(new Model("entryTwo", 20,
- Arrays.asList(
- new Model("2one", 1, Collections.<Model>emptyList()),
- new Model("2two", 2, Collections.<Model>emptyList()),
- new Model("2three", 3, Collections.<Model>emptyList())
- )
- ));
- list.add(new Model("entryThree", 30,
- Arrays.asList(
- new Model("3one", 1, Collections.<Model>emptyList()),
- new Model("3two", 2, Collections.<Model>emptyList()),
- new Model("3three", 3, Collections.<Model>emptyList())
- )
- ));
+ );
+ JAXXContext context = new DefaultJAXXContext();
context.setContextValue(list, "models");
Model bean;
- testBinding(model, context, "$root.models", list);
+ testBinding(model, context, "$root/models", list);
bean = list.get(0);
- testBinding(model, context, "$root.models.0", bean);
- testBinding(model, context, "$root.models.0.name", bean.getName());
- testBinding(model, context, "$root.models.0.integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root.models.0.sons", bean.getSons());
- testBinding(model, context, "$root.models.0.sons.0", bean.getSons().get(0));
- testBinding(model, context, "$root.models.0.sons.0.name", bean.getSons().get(0).getName());
+ testBinding(model, context, "$root/models/0", bean);
+ testBinding(model, context, "$root/models/0/name", bean.getName());
+ testBinding(model, context, "$root/models/0/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/0/sons", bean.getSons());
+ testBinding(model, context, "$root/models/0/sons/0", bean.getSons().get(0));
+ testBinding(model, context, "$root/models/0/sons/0/name", bean.getSons().get(0).getName());
bean = list.get(1);
- testBinding(model, context, "$root.models.1", bean);
- testBinding(model, context, "$root.models.1.name", bean.getName());
- testBinding(model, context, "$root.models.1.integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root.models.1.sons", bean.getSons());
+ testBinding(model, context, "$root/models/1", bean);
+ testBinding(model, context, "$root/models/1/name", bean.getName());
+ testBinding(model, context, "$root/models/1/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/1/sons", bean.getSons());
bean = list.get(2);
- testBinding(model, context, "$root.models.2", bean);
- testBinding(model, context, "$root.models.2.name", bean.getName());
- testBinding(model, context, "$root.models.2.integerValue", bean.getIntegerValue());
- testBinding(model, context, "$root.models.2.sons", bean.getSons());
+ testBinding(model, context, "$root/models/2", bean);
+ testBinding(model, context, "$root/models/2/name", bean.getName());
+ testBinding(model, context, "$root/models/2/integerValue", bean.getIntegerValue());
+ testBinding(model, context, "$root/models/2/sons", bean.getSons());
}
@@ -347,7 +341,7 @@
Assert.assertEquals(expected, value);
}
- protected static String getNodeContext(int... context) {
+ protected String getNodeContext(int... context) {
String result = "";
for (int i : context) {
result += i;
@@ -360,7 +354,7 @@
Assert.assertNotNull(node);
Assert.assertEquals(root, node.isRoot());
Assert.assertEquals(level, node.getLevel());
- Assert.assertEquals(nodeContext, node.getContext());
+ Assert.assertEquals(nodeContext, node.getNavigationPath());
Assert.assertEquals(contextPath, node.getContextPath());
}
1
0
[Buix-commits] r1034 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation
by chemit@users.labs.libre-entreprise.org 25 Nov '08
by chemit@users.labs.libre-entreprise.org 25 Nov '08
25 Nov '08
Author: chemit
Date: 2008-11-25 09:42:25 +0000 (Tue, 25 Nov 2008)
New Revision: 1034
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
Log:
fix bugs on navigation
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 09:00:41 UTC (rev 1033)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 09:42:25 UTC (rev 1034)
@@ -219,7 +219,7 @@
public Object getJAXXContextValue(JAXXContext context) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
Object result;
- if (getJaxxContextEntryDef() != null && jaxxContextEntryPath==null) {
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
// the node maps directly a value in context, with no jxpath resolving
result = getJaxxContextEntryDef().getContextValue(context);
return result;
@@ -242,7 +242,14 @@
return null;
}
- if (this == parentNode && jaxxContextEntryPath == null) {
+ if (parentNode.jaxxContextEntryPath != null) {
+ // apply the jxpath on parentBean
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+
+ parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
+ }
+
+ if (this == parentNode) {
// current node is the node matching the context entry value and no jxpath is found
return parentBean;
}
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-11-25 09:00:41 UTC (rev 1033)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-11-25 09:42:25 UTC (rev 1034)
@@ -144,14 +144,16 @@
Object data = getNavigationTreeModel().getJAXXContextValue(context, path);
if (log.isDebugEnabled()) {
- log.debug("find data for contextPath <" + path + "> : " + data.getClass());
+ log.debug("find data for contextPath <" + path + "> : " + (data == null ? null : data.getClass()));
}
+ context.removeContextValue(Object.class,NAVIGATION_SELECTED_BEAN);
+
if (data != null) {
context.setContextValue(data, NAVIGATION_SELECTED_BEAN);
//todo should we not use this to avoid conflict in context ?
context.setContextValue(data);
- }
+ }
if (newUI == null) {
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-25 09:00:41 UTC (rev 1033)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-25 09:42:25 UTC (rev 1034)
@@ -25,8 +25,8 @@
return context.getContextValue(NavigationTreeNode.class, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_NODE);
}
- public static Object getSelectedBean(JAXXContext context) {
- return context.getContextValue(Object.class, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_BEAN);
+ public static <O> O getSelectedBean(JAXXContext context,Class<O> clazz) {
+ return context.getContextValue(clazz, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_BEAN);
}
public static Object getContextValue(JAXXContext context, String contextKey, String navigationPath) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
1
0
[Buix-commits] r1033 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation
by chemit@users.labs.libre-entreprise.org 25 Nov '08
by chemit@users.labs.libre-entreprise.org 25 Nov '08
25 Nov '08
Author: chemit
Date: 2008-11-25 09:00:41 +0000 (Tue, 25 Nov 2008)
New Revision: 1033
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
Log:
out selected bean in context
improve search of bean algorithm (a node can have a JAXXContextEntryDef ad a jxpath)
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 08:58:41 UTC (rev 1032)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2008-11-25 09:00:41 UTC (rev 1033)
@@ -53,7 +53,11 @@
protected NodeRenderer renderer;
- public NavigationTreeNode(Object renderer, Object jaxxContextEntryDef, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass) {
+ public NavigationTreeNode(Object renderer,
+ Object jaxxContextEntryDef,
+ String context,
+ Class<? extends JAXXObject> jaxxClass,
+ Class<? extends JAXXAction> jaxxActionClass) {
super(renderer);
if (renderer instanceof NodeRenderer) {
// the renderer must keep a reference of the node
@@ -82,29 +86,31 @@
}
}
- /*public NavigationTreeNode(String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
+ public NavigationTreeNode(Object renderer,
+ JAXXContextEntryDef jaxxContextEntryDef,
+ String jaxxContextEntryPath,
+ String context,
+ Class<? extends JAXXObject> jaxxClass,
+ Class<? extends JAXXAction> jaxxActionClass) {
+ super(renderer);
+ if (renderer instanceof NodeRenderer) {
+ // the renderer must keep a reference of the node
+ ((NodeRenderer) renderer).setNode(this);
+ } else if (renderer instanceof String) {
+ // nothing special to be done
+ } else {
+ if (renderer != null) {
+ // wrong renderer type
+ throw new IllegalArgumentException("to define a renderer, must be a String (simple libelle) or a " + NodeRenderer.class + ", but was " + renderer);
+ }
+ }
this.context = context;
this.jaxxClass = jaxxClass;
this.jaxxActionClass = jaxxActionClass;
this.jaxxContextEntryDef = jaxxContextEntryDef;
- }*/
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
- /*public NavigationTreeNode(Object userObject, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
- super(userObject);
- this.context = context;
- this.jaxxClass = jaxxClass;
- this.jaxxActionClass = jaxxActionClass;
- this.jaxxContextEntryDef = jaxxContextEntryDef;
- }*/
-
- /*public NavigationTreeNode(Object userObject, boolean allowsChildren, String context, Class<? extends JAXXObject> jaxxClass, Class<? extends JAXXAction> jaxxActionClass, JAXXContextEntryDef jaxxContextEntryDef) {
- super(userObject, allowsChildren);
- this.context = context;
- this.jaxxClass = jaxxClass;
- this.jaxxActionClass = jaxxActionClass;
- this.jaxxContextEntryDef = jaxxContextEntryDef;
- }*/
-
public String getContext() {
return context;
}
@@ -190,10 +196,10 @@
if (stack.isEmpty()) {
return this;
}
- // nextcontext to search
+ // next context to search
String currentPath = stack.pop();
- if (getContext().equals(currentPath)) {
- // this node matchs
+ if (getContext().equals(currentPath) && currentPath.startsWith("$")) {
+ // this node matchs (only do this for root node)
return findNode(stack);
}
// find the next matching son
@@ -213,8 +219,8 @@
public Object getJAXXContextValue(JAXXContext context) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
Object result;
- if (getJaxxContextEntryDef() != null) {
- // the node maps directly a value in context
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath==null) {
+ // the node maps directly a value in context, with no jxpath resolving
result = getJaxxContextEntryDef().getContextValue(context);
return result;
}
@@ -236,8 +242,8 @@
return null;
}
- if (this == parentNode) {
- // current node is the node matching the context entry value
+ if (this == parentNode && jaxxContextEntryPath == null) {
+ // current node is the node matching the context entry value and no jxpath is found
return parentBean;
}
@@ -257,7 +263,7 @@
}
if (jxpathExpression.startsWith("[")) {
// special case when we want to access a collection
- jxpathExpression = '.'+jxpathExpression;
+ jxpathExpression = '.' + jxpathExpression;
}
log.info("jxpath : " + jxpathExpression);
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2008-11-25 08:58:41 UTC (rev 1032)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2008-11-25 09:00:41 UTC (rev 1033)
@@ -19,15 +19,27 @@
return model;
}
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, JAXXContextEntryDef entryDef,
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef entryDef,
+ String entryPath,
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryDef, entryPath, contextName, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(libelle), entryDef, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
- public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle, String entryPath,
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ String entryPath,
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
@@ -35,15 +47,27 @@
return addChildNode(parentNode, node);
}
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, JAXXContextEntryDef entryDef,
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef entryDef,
+ String entryPath,
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryDef, entryPath, contextName, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
NavigationTreeNode node = new NavigationTreeNode(new NodeRenderer(decorator), entryDef, contextName, uiClass, actionClass);
return addChildNode(parentNode, node);
}
- public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator, String entryPath,
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ String entryPath,
String contextName,
Class<? extends JAXXObject> uiClass,
Class<? extends JAXXAction> actionClass) {
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-11-25 08:58:41 UTC (rev 1032)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeSelectionAdapter.java 2008-11-25 09:00:41 UTC (rev 1033)
@@ -1,7 +1,7 @@
package jaxx.runtime.swing.navigation;
+import jaxx.runtime.JAXXAction;
import jaxx.runtime.JAXXObject;
-import jaxx.runtime.JAXXAction;
import jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -11,7 +11,6 @@
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.TreePath;
import java.awt.Component;
-import java.lang.reflect.InvocationTargetException;
/** A {@link javax.swing.event.TreeSelectionListener} implementation@author chemit */
public abstract class NavigationTreeSelectionAdapter implements TreeSelectionListener {
@@ -23,6 +22,8 @@
static public final String NAVIGATION_SELECTED_NODE = "navigation-selected-node";
+ static public final String NAVIGATION_SELECTED_BEAN = "navigation-selected-bean";
+
/** la classe d'ui par defaut, associé à un noeud de l'arbe */
protected Class<? extends JAXXObject> defaultUIClass;
@@ -86,6 +87,26 @@
*/
protected abstract void goBackToPreviousNode(TreeSelectionEvent event, Exception e);
+ /**
+ * Prepare le nouveau noeud sélectionné.
+ *
+ * @param event l'évènement de selection du noeud
+ * @return le noeud selectionné et preparé
+ */
+ protected NavigationTreeNode prepareNode(TreeSelectionEvent event) {
+ NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent();
+
+ if (node.getJaxxClass() == null) {
+ // no ui is associated with this node, display a empty content
+ node.setJaxxClass(defaultUIClass);
+ }
+
+ if (node.getJaxxActionClass() == null) {
+ node.setJaxxActionClass(defaultUIHandlerClass);
+ }
+ return node;
+ }
+
public void valueChanged(TreeSelectionEvent event) {
if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) {
// do not treate this if no path changed
@@ -94,21 +115,12 @@
try {
- NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent();
+ NavigationTreeNode node = prepareNode(event);
- if (node.getJaxxClass() == null) {
- // no ui is associated with this node, display a empty content
- node.setJaxxClass(defaultUIClass);
- }
-
- if (node.getJaxxActionClass()==null) {
- node.setJaxxActionClass(defaultUIHandlerClass);
- }
-
String path = node.getContextPath();
- if (log.isDebugEnabled()) {
- log.debug(path);
+ if (log.isTraceEnabled()) {
+ log.trace(path);
}
Component newUI = getNewUI(path);
@@ -119,7 +131,6 @@
return;
}
-
if (!closeUI(event, component)) {
// previous ui was not closed, so reselect the previous node in navigation
goBackToPreviousNode(event, null);
@@ -130,9 +141,19 @@
// now, we are free to open the ui associated with the selected node in navigation
// before all, attach bean in context associated with the selected node in naivgation tree
- attachBeanFromNodeToContext(node);
+ Object data = getNavigationTreeModel().getJAXXContextValue(context, path);
+ if (log.isDebugEnabled()) {
+ log.debug("find data for contextPath <" + path + "> : " + data.getClass());
+ }
+ if (data != null) {
+ context.setContextValue(data, NAVIGATION_SELECTED_BEAN);
+ //todo should we not use this to avoid conflict in context ?
+ context.setContextValue(data);
+ }
+
+
if (newUI == null) {
// instanciate a new ui associated with the selected node
newUI = createUI(node);
@@ -149,13 +170,14 @@
openUI(newUI, node);
} catch (Exception e) {
+ // remove data from context
+
// if any error, go back to previvous node
goBackToPreviousNode(event, e);
}
-
}
- protected void attachBeanFromNodeToContext(NavigationTreeNode node) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ /* protected Object attachBeanFromNodeToContext(NavigationTreeNode node) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
String path = node.getContextPath();
@@ -171,7 +193,8 @@
context.setContextValue(data);
}
//}
- }
+ return data;
+ }*/
protected void returnToPreviousNode(JTree tree, TreeSelectionEvent event) {
// go back to previous node
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-25 08:58:41 UTC (rev 1032)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/swing/navigation/NavigationUtil.java 2008-11-25 09:00:41 UTC (rev 1033)
@@ -25,6 +25,10 @@
return context.getContextValue(NavigationTreeNode.class, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_NODE);
}
+ public static Object getSelectedBean(JAXXContext context) {
+ return context.getContextValue(Object.class, NavigationTreeSelectionAdapter.NAVIGATION_SELECTED_BEAN);
+ }
+
public static Object getContextValue(JAXXContext context, String contextKey, String navigationPath) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
NavigationTreeModel navigationModel = context.getContextValue(NavigationTreeModel.class, contextKey);
1
0
[Buix-commits] r1032 - lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime
by chemit@users.labs.libre-entreprise.org 25 Nov '08
by chemit@users.labs.libre-entreprise.org 25 Nov '08
25 Nov '08
Author: chemit
Date: 2008-11-25 08:58:41 +0000 (Tue, 25 Nov 2008)
New Revision: 1032
Modified:
lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java
Log:
can seek from objet in JAXXContext with Object.class
Modified: lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java
===================================================================
--- lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2008-11-24 15:35:11 UTC (rev 1031)
+++ lutinjaxx/trunk/jaxx-core/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2008-11-25 08:58:41 UTC (rev 1032)
@@ -95,8 +95,8 @@
public boolean accept(Class<?> klass, String name) {
if (klass == Object.class && this.klass != Object.class) {
- // block if looking for Object.class
- return false;
+ // try on name only
+ return (this.name != null && name != null && this.name.equals(name));
}
return klass.isAssignableFrom(this.klass) && (this.name == null && name == null
|| (this.name != null && name != null && this.name.equals(name)));
1
0