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
- 3898 discussions
r1573 - branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin
by tchemit@users.nuiton.org 11 Oct '09
by tchemit@users.nuiton.org 11 Oct '09
11 Oct '09
Author: tchemit
Date: 2009-10-11 15:10:37 +0200 (Sun, 11 Oct 2009)
New Revision: 1573
Removed:
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/TemplateGenerator.java
Modified:
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
Log:
use VelocityTemplateGenerator from maven-helper-plugin
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-10 16:48:11 UTC (rev 1572)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-11 13:10:37 UTC (rev 1573)
@@ -39,6 +39,7 @@
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.StringUtils;
import org.nuiton.i18n.I18n;
+import org.nuiton.plugin.VelocityTemplateGenerator;
import org.nuiton.util.FileUtil;
import org.nuiton.util.SortedProperties;
@@ -347,7 +348,7 @@
protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception {
int touchedFiles = 0;
- TemplateGenerator gen = prepareGenerator(contentTemplate);
+ VelocityTemplateGenerator gen = prepareGenerator(contentTemplate);
Enumeration<?> keys = helpIds.keys();
while (keys.hasMoreElements()) {
String key = (String) keys.nextElement();
@@ -572,17 +573,17 @@
}
protected void doGen(File template, File f, Properties env) throws Exception {
- TemplateGenerator gen = prepareGenerator(template);
+ VelocityTemplateGenerator gen = prepareGenerator(template);
gen.generate(env, f);
}
- protected TemplateGenerator prepareGenerator(File template) throws Exception {
+ protected VelocityTemplateGenerator prepareGenerator(File template) throws Exception {
URL templateURL = getTemplate(template);
if (verbose) {
getLog().info("using template " + templateURL);
}
- TemplateGenerator gen = new TemplateGenerator(project, templateURL);
+ VelocityTemplateGenerator gen = new VelocityTemplateGenerator(project, templateURL);
return gen;
}
}
Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/TemplateGenerator.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/TemplateGenerator.java 2009-10-10 16:48:11 UTC (rev 1572)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/TemplateGenerator.java 2009-10-11 13:10:37 UTC (rev 1573)
@@ -1,142 +0,0 @@
-/*
- * Copyright 2001-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License" );
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.nuiton.jaxx.plugin;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-
-/**
- * Generator of template base on velocity.
- *
- * @author chemit
- * @since 1.3
- *
- */
-public class TemplateGenerator {
-
- protected VelocityEngine engine;
- protected final MavenProject mavenProject;
- protected Template velocityTemplate;
-
- protected TemplateGenerator(MavenProject mavenProject, URL template) throws URISyntaxException {
-
- if (mavenProject == null) {
- throw new IllegalArgumentException("mavenProject must not be null");
- }
-
- if (template == null) {
- throw new IllegalArgumentException("template must not be null");
- }
-
- this.mavenProject = mavenProject;
-
- Properties props = new Properties();
-
- String templateName;
-
- if (template.toURI().isOpaque()) {
-
- // template is in a jar
-
- props = new Properties();
- props.setProperty("resource.loader", "jar");
- props.setProperty("jar.resource.loader.description", "Jar resource loader for default webstart templates");
- props.setProperty("jar.resource.loader.class", "org.apache.velocity.runtime.resource.loader.JarResourceLoader");
-
- // obtain the jar url
-
- String url = template.toString();
- int i = url.indexOf("!");
- templateName = url.substring(i + 2);
-
- props.setProperty("jar.resource.loader.path", url.substring(0, i + 2));
-
- } else {
-
-
- templateName = new File(template.getFile()).getName();
-
- //props.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, "org.apache.velocity.runtime.log.NullLogSystem");
- props.setProperty("file.resource.loader.path", template.getFile());
-
- }
-
- try {
- engine = new VelocityEngine();
- //engine.setProperty("runtime.log.logsystem", new NullLogSystem());
- engine.init(props);
- } catch (Exception e) {
- IllegalArgumentException iae = new IllegalArgumentException("Could not initialise Velocity");
- iae.initCause(e);
- throw iae;
- }
-
- try {
- this.velocityTemplate = engine.getTemplate(templateName);
- } catch (Exception e) {
- IllegalArgumentException iae =
- new IllegalArgumentException("Could not load the template file from '" + template + "'");
- iae.initCause(e);
- throw iae;
- }
- }
-
- public void generate(Properties context, File outputFile) throws Exception {
-
-
- VelocityContext vcontext = new VelocityContext();
-
- // Note: properties that contain dots will not be properly parsed by Velocity. Should we replace dots with underscores ?
- addPropertiesToContext(System.getProperties(), vcontext);
-
- addPropertiesToContext(mavenProject.getProperties(), vcontext);
- addPropertiesToContext(context, vcontext);
-
- vcontext.put("project", mavenProject.getModel());
-
- vcontext.put("outputFile", outputFile.getName());
-
- FileWriter writer = new FileWriter(outputFile);
-
- try {
- velocityTemplate.merge(vcontext, writer);
- writer.flush();
- } catch (Exception e) {
- throw new Exception("Could not generate the template " + velocityTemplate.getName() + ": " + e.getMessage(), e);
- } finally {
- writer.close();
- }
- }
-
- protected void addPropertiesToContext(Properties properties, VelocityContext context) {
-
- for (Iterator<?> iter = properties.keySet().iterator(); iter.hasNext();) {
- String key = (String) iter.next();
- Object value = properties.get(key);
- context.put(key, value);
- }
-
- }
-}
1
0
Author: tchemit
Date: 2009-10-10 18:48:11 +0200 (Sat, 10 Oct 2009)
New Revision: 1572
Modified:
branches/jaxx-2.X/jaxx-demo/pom.xml
branches/jaxx-2.X/pom.xml
Log:
utilisation de mavenpom 1.1.0, maven-license-plugin
Modified: branches/jaxx-2.X/jaxx-demo/pom.xml
===================================================================
--- branches/jaxx-2.X/jaxx-demo/pom.xml 2009-10-09 07:23:00 UTC (rev 1571)
+++ branches/jaxx-2.X/jaxx-demo/pom.xml 2009-10-10 16:48:11 UTC (rev 1572)
@@ -135,19 +135,10 @@
<plugin>
<groupId>org.nuiton</groupId>
- <artifactId>maven-helper-plugin</artifactId>
+ <artifactId>maven-license-plugin</artifactId>
<configuration>
<copyToMETA_INF>true</copyToMETA_INF>
</configuration>
- <executions>
- <execution>
- <id>attach-licenses</id>
- <goals>
- <goal>add-license</goal>
- <goal>add-third-party</goal>
- </goals>
- </execution>
- </executions>
</plugin>
</plugins>
@@ -210,10 +201,14 @@
<plugin>
<groupId>org.nuiton</groupId>
- <artifactId>maven-helper-plugin</artifactId>
+ <artifactId>maven-license-plugin</artifactId>
<executions>
<execution>
<id>attach-licenses</id>
+ <goals>
+ <goal>add-license</goal>
+ <goal>add-third-party</goal>
+ </goals>
</execution>
</executions>
</plugin>
Modified: branches/jaxx-2.X/pom.xml
===================================================================
--- branches/jaxx-2.X/pom.xml 2009-10-09 07:23:00 UTC (rev 1571)
+++ branches/jaxx-2.X/pom.xml 2009-10-10 16:48:11 UTC (rev 1572)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.0.3-SNAPSHOT</version>
+ <version>1.1.0-SNAPSHOT</version>
</parent>
<artifactId>jaxx</artifactId>
1
0
r1571 - in branches/jaxx-2.X: jaxx-compiler/src/main/java/jaxx/compiler maven-jaxx-plugin maven-jaxx-plugin/src/site maven-jaxx-plugin/src/site/rst
by tchemit@users.nuiton.org 09 Oct '09
by tchemit@users.nuiton.org 09 Oct '09
09 Oct '09
Author: tchemit
Date: 2009-10-09 09:23:00 +0200 (Fri, 09 Oct 2009)
New Revision: 1571
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java
branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/site/rst/index.rst
branches/jaxx-2.X/maven-jaxx-plugin/src/site/site.xml
Log:
fix javadoc + documentation
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-08 21:10:15 UTC (rev 1570)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-09 07:23:00 UTC (rev 1571)
@@ -93,11 +93,11 @@
*/
public static final int INLINE_THRESHOLD = 300;
/**
- *
+ * The unique object handler used in first pass
*/
protected final DefaultObjectHandler firstPassClassTagHandler;
/**
- *
+ * list of static imports
*/
protected List<String> staticImports = new ArrayList<String>();
@@ -133,7 +133,7 @@
*/
protected List<DataBinding> dataBindings = new ArrayList<DataBinding>();
/**
- *
+ * table of symbols for this compiler
*/
protected SymbolTable symbolTable = new SymbolTable();
/**
@@ -250,7 +250,7 @@
*/
protected JavaFile javaFile;
/**
- *
+ * configuration of the compiler
*/
protected CompilerConfiguration configuration;
/**
@@ -270,7 +270,7 @@
*/
protected Map<CompiledObject, String> ids = new LinkedHashMap<CompiledObject, String>();
/**
- *
+ * default decodator to use if none specified
*/
protected CompiledObjectDecorator defaultDecorator;
Modified: branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-08 21:10:15 UTC (rev 1570)
+++ branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-09 07:23:00 UTC (rev 1571)
@@ -77,12 +77,6 @@
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
</dependency>
-
- <!-- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <version>1.5</version>
- </dependency>-->
<dependency>
<groupId>commons-lang</groupId>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/site/rst/index.rst
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/site/rst/index.rst 2009-10-08 21:10:15 UTC (rev 1570)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/site/rst/index.rst 2009-10-09 07:23:00 UTC (rev 1571)
@@ -4,10 +4,23 @@
.. contents::
-Présentation
+Introduction
------------
-Le plugin maven pour lancer le compilateur jaxx dans un projet maven TODO
+The plugin permits to generate java files from jaxx files via the `generate`_ goal.
-**Veuillez consulter la JavaDoc pour de plus ample détails sur les différentes
-librairies.**
+You can also generate the java help system via the `generate-help`_ goal.
+
+Default layout
+--------------
+
+The plugin defines some directory layout convention, using them is a great
+benefit.
+
+ * the jaxx files should be under *src/main/java*
+ * the generated java files should be under *target/generated-sources/java*
+ * the java help files should be under *src/main/help*
+
+.. _generate: generate-mojo.html
+
+.. _generate-help: generate-help-mojo.html
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/site/site.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/site/site.xml 2009-10-08 21:10:15 UTC (rev 1570)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/site/site.xml 2009-10-09 07:23:00 UTC (rev 1571)
@@ -19,17 +19,11 @@
<item name="Accueil" href="index.html"/>
<item name="Détail goals" href="plugin-info.html">
<item name="generate" href="generate-mojo.html"/>
+ <item name="generate-help" href="generate-help-mojo.html"/>
<item name="help" href="help-mojo.html"/>
</item>
</menu>
- <menu name="Téléchargement" inherit="top">
- <item href="${labs.builder.url}/org/codelutin/jaxx/${project.artifactId}/${project.version}"
- name="Télécharger la dernière version"/>
- <item href="${labs.builder.url}/org/codelutin/jaxx/${project.artifactId}"
- name="Voir toutes les versions"/>
- </menu>
-
<menu name="Développeur" inherit="top">
<item name="A faire" href="Todo.html"/>
</menu>
1
0
r1570 - in branches/jaxx-2.X/maven-jaxx-plugin/src/main: java/org/nuiton/jaxx/plugin resources
by tchemit@users.nuiton.org 08 Oct '09
by tchemit@users.nuiton.org 08 Oct '09
08 Oct '09
Author: tchemit
Date: 2009-10-08 23:10:15 +0200 (Thu, 08 Oct 2009)
New Revision: 1570
Modified:
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
Log:
generate help search index (still does not works everywhere, a shame the code is from com.sun we do not have the source...)
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 21:10:15 UTC (rev 1570)
@@ -18,18 +18,26 @@
*##%*/
package org.nuiton.jaxx.plugin;
+import com.sun.java.help.search.Indexer;
import java.io.BufferedReader;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import org.apache.maven.plugin.MojoFailureException;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
import org.nuiton.i18n.I18n;
import org.nuiton.util.FileUtil;
import org.nuiton.util.SortedProperties;
@@ -82,7 +90,7 @@
/**
* The template used to generate helpset file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.helpsetTemplate}" default-value="/defaultHelpSet.hs.vm"
* @required
@@ -93,7 +101,7 @@
/**
* The template used to generate helpset map file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
* @required
@@ -104,7 +112,7 @@
/**
* The template used to generate helpset index file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
* @required
@@ -115,7 +123,7 @@
/**
* The template used to generate helpset toc file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
* @required
@@ -126,7 +134,7 @@
/**
* The template used to generate helpset content file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
* @required
@@ -135,6 +143,15 @@
*/
protected File contentTemplate;
/**
+ * Flag to generate the search index.
+ *
+ * @parameter expression="${jaxx.generateSearch}" default-value="true"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected boolean generateSearch;
+ /**
* The help ids discovered in {@link #helpIdsStore} files.
*/
private Properties helpIds;
@@ -192,7 +209,7 @@
}
// load ids from idsStore file
-
+
helpIds = new SortedProperties();
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(idsStore), getEncoding()));
@@ -255,7 +272,7 @@
env.put("mapFileName", mapFileName);
env.put("indexFileName", indexFileName);
env.put("tocFileName", tocFileName);
-// env.put("searchData", localePath + "/index");
+ env.put("generateSearch", generateSearch);
// ---------------------------------------------------------------
// --- main helpset file -----------------------------------------
@@ -275,7 +292,7 @@
file = new File(localizedTarget, mapFileName);
- Properties mergedHelpIds = generateMapFile(file, env);
+ generateMapFile(file, env);
touchedFiles++;
// ---------------------------------------------------------------
@@ -284,7 +301,7 @@
file = new File(localizedTarget, indexFileName);
- NodeItem indexRootItem = generateIndexFile(file, env);
+ generateIndexFile(file, env);
touchedFiles++;
// ---------------------------------------------------------------
@@ -293,7 +310,7 @@
file = new File(localizedTarget, tocFileName);
- NodeItem tocRootItem = generateTocFile(file, env);
+ generateTocFile(file, env);
touchedFiles++;
// ---------------------------------------------------------------
@@ -302,6 +319,16 @@
touchedFiles += generateContentFiles(localizedTarget, env, localePath);
+ // ---------------------------------------------------------------
+ // --- generate search index -------------------------------------
+ // ---------------------------------------------------------------
+
+ if (generateSearch) {
+
+ generateSearchIndex(localizedTarget, locale);
+ }
+
+
}
getLog().info(touchedFiles + " file(s) treated.");
@@ -475,6 +502,35 @@
return rootItem;
}
+ protected void generateSearchIndex(File localizedTarget, Locale locale) throws IllegalArgumentException, IOException, InvocationTargetException, SecurityException, IllegalAccessException, NoSuchMethodException {
+
+ Method m = Indexer.class.getDeclaredMethod("main", String[].class);
+ File indexDir = new File(localizedTarget, "JavaHelpSearch");
+ // remove old index
+ FileUtils.deleteDirectory(indexDir);
+ //copy resources to a tmp dir (without any VCS infos)
+ File tmpDir = new File(project.getBasedir(), "target" + File.separator + "jaxx-tmp" + File.separator + "indexer-" + locale + "-" + System.nanoTime());
+ getLog().info("copy files to " + tmpDir + " for indexing them");
+ FileUtils.copyDirectory(localizedTarget, tmpDir, "**/*", StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ","));
+ List<String> params = new ArrayList<String>();
+ params.add("-verbose");
+ params.add("-db");
+ params.add(indexDir.getAbsolutePath());
+ params.add("-logfile");
+ File logFile = new File(project.getBasedir(), "target" + File.separator + "generated-sources" + File.separator + "jaxx" + File.separator + "indexer-" + locale + ".log");
+ params.add(logFile.getAbsolutePath());
+ params.add(tmpDir.getAbsolutePath());
+ PrintStream out = System.out;
+ PrintStream err = System.err;
+ try {
+ m.invoke(null, (Object) params.toArray(new String[params.size()]));
+ } finally {
+ System.setOut(out);
+ System.setErr(err);
+ }
+ getLog().info("Search Index generated");
+ }
+
protected NodeItem generateTocFile(File file, Properties env) throws Exception {
NodeItem rootItem = null;
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 21:10:15 UTC (rev 1570)
@@ -386,7 +386,7 @@
return;
}
- getLog().info("Detects " + files.length + " modify jaxx file(s). ");
+ getLog().info("Detects " + files.length + " modified jaxx file(s). ");
try {
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-10-08 19:10:44 UTC (rev 1569)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-10-08 21:10:15 UTC (rev 1570)
@@ -31,13 +31,13 @@
<data>$localePath/$indexFileName</data>
</view>
-#if ( $searchData )
+#if ( $generateSearch )
<view>
<name>Search</name>
<label>Search</label>
<type>javax.help.SearchView</type>
<data engine="com.sun.java.help.search.DefaultSearchEngine">
- $searchData
+ $localePath/JavaHelpSearch
</data>
</view>
#end
1
0
r1569 - in branches/jaxx-2.X: jaxx-compiler/src/main/java/jaxx/compiler maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin
by tchemit@users.nuiton.org 08 Oct '09
by tchemit@users.nuiton.org 08 Oct '09
08 Oct '09
Author: tchemit
Date: 2009-10-08 21:10:44 +0200 (Thu, 08 Oct 2009)
New Revision: 1569
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
Log:
- add encoding on goals (should be in JAXXCompiler)
- simplify helpIdsStore (only store ids, path will be computed if needed)
- maven-helper-plugin common code
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -122,4 +122,10 @@
* @return {@code true} if compiler is verbose
*/
boolean isVerbose();
+
+ /**
+ *
+ * @return the encoding to use to write files
+ */
+ String getEncoding();
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -86,6 +86,10 @@
* since this class should be in sources (so not yet compiled)
*/
private String helpBrokerFQN;
+ /**
+ * Encoding to use to write files
+ */
+ private String encoding;
@Override
public File getTargetDirectory() {
@@ -182,6 +186,11 @@
}
@Override
+ public String getEncoding() {
+ return encoding;
+ }
+
+ @Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -32,6 +32,9 @@
*/
public abstract class AbstractJaxxMojo extends AbstractPlugin {
+ public abstract File getTargetDirectory();
+
+ public abstract void setTargetDirectory(File targetDirectory);
/**
* Dépendance du projet.
*
@@ -41,6 +44,13 @@
*/
protected MavenProject project;
/**
+ * Encoding pour la generation des fichiers
+ *
+ * @parameter expression="${jaxx.encoding}" default-value="${project.build.sourceEncoding}"
+ * @since 2.0.0
+ */
+ protected String encoding;
+ /**
* verbose flag
*
* @parameter expression="${jaxx.verbose}" default-value="false"
@@ -52,7 +62,7 @@
* The store of helpIds generated by the goal {@link GenerateMojo} and then
* used by the goal {@link GenerateHelpMojo}.
*
- * @parameter expression="${jaxx.helpIdsStore}" default-value="target/helpIds.properties"
+ * @parameter expression="${jaxx.helpIdsStore}" default-value="target/generated-sources/jaxx/helpIds.properties"
* @required
*
* @since 1.3
@@ -91,4 +101,12 @@
public void setHelpIdsStore(File helpIdsStore) {
this.helpIdsStore = helpIdsStore;
}
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
}
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -18,11 +18,12 @@
*##%*/
package org.nuiton.jaxx.plugin;
+import java.io.BufferedReader;
import org.apache.maven.plugin.MojoFailureException;
import java.io.File;
import java.io.FileInputStream;
-import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -185,21 +186,21 @@
checkResource(tocTemplate);
checkResource(contentTemplate);
- if (!outHelp.exists()) {
- getLog().info("mkdir " + outHelp);
- outHelp.mkdirs();
+ if (!getTargetDirectory().exists()) {
+ getLog().info("mkdir " + getTargetDirectory());
+ getTargetDirectory().mkdirs();
}
+ // load ids from idsStore file
+
helpIds = new SortedProperties();
- InputStream stream = new FileInputStream(idsStore);
-
- try {
- helpIds.load(stream);
- } finally {
- if (stream != null) {
- stream.close();
- }
+ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(idsStore), getEncoding()));
+ String id = null;
+ while ((id = reader.readLine()) != null) {
+ id = id.trim();
+ String path = id.replaceAll("\\.", File.separator) + ".html";
+ helpIds.put(id, path);
}
if (helpIds.isEmpty()) {
@@ -208,7 +209,6 @@
getLog().warn("No helpIds detected, will skip.");
return false;
}
-
return true;
}
@@ -235,7 +235,9 @@
localizedTarget.mkdirs();
}
getLog().info("Generate help for language " + language);
- getLog().info(" Localized target : " + localizedTarget);
+ if (isVerbose()) {
+ getLog().info(" Localized target : " + localizedTarget);
+ }
Properties env = new Properties();
@@ -305,6 +307,16 @@
getLog().info(touchedFiles + " file(s) treated.");
}
+ @Override
+ public File getTargetDirectory() {
+ return outHelp;
+ }
+
+ @Override
+ public void setTargetDirectory(File targetDirectory) {
+ this.outHelp = targetDirectory;
+ }
+
protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception {
int touchedFiles = 0;
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -27,27 +27,18 @@
import jaxx.compiler.tags.TagManager;
import jaxx.runtime.JAXXContext;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
import org.nuiton.io.FileUpdaterHelper;
import org.nuiton.io.MirroredFileUpdater;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.util.Map;
import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.Set;
import jaxx.runtime.swing.help.JAXXHelpBroker;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -336,7 +327,6 @@
return true;
}
-// if (addSourcesToClassPath || addProjectClassPath) {
cl = initClassLoader(project,
src,
addSourcesToClassPath,
@@ -346,10 +336,6 @@
addProjectClassPath);
Thread.currentThread().setContextClassLoader(cl);
-// } else {
-// cl = getClass().getClassLoader();
- //cl = Thread.currentThread().getContextClassLoader();
-// }
compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
@@ -368,8 +354,8 @@
BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
}
- if (!outJava.exists()) {
- outJava.mkdirs();
+ if (!getTargetDirectory().exists()) {
+ getTargetDirectory().mkdirs();
}
// compute extra imports (can not use java classes since some of
@@ -442,6 +428,11 @@
}
@Override
+ public void setTargetDirectory(File targetDirectory) {
+ this.outJava = targetDirectory;
+ }
+
+ @Override
public boolean getOptimize() {
return optimize;
}
@@ -534,16 +525,9 @@
}
if (testPhase) {
- if (!project.getTestCompileSourceRoots().contains(
- outJava.getPath())) {
- getLog().info("Add test compile source root : " + outJava);
- project.addTestCompileSourceRoot(outJava.getPath());
- }
+ addTestCompileSourceRoots(getTargetDirectory());
} else {
- if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
- getLog().info("Add compile source root : " + outJava);
- project.addCompileSourceRoot(outJava.getPath());
- }
+ addCompileSourceRoots(getTargetDirectory());
}
}
@@ -586,91 +570,18 @@
idsStore.getParentFile().mkdirs();
}
- Properties p = new Properties();
+ StringBuilder buffer = new StringBuilder();
for (String helpId : helpIds) {
- String path = helpId.replaceAll("\\.", File.separator);
- path = removeQuote(path) + ".html";
- p.put(removeQuote(helpId), path);
+ buffer.append(removeQuote(helpId)).append('\n');
}
+ writeFile(idsStore, buffer.toString(), encoding);
- FileOutputStream w = new FileOutputStream(idsStore);
-
- try {
- p.store(w, null);
- } finally {
- w.close();
- }
-
getLog().info("helpIdStore generated in " + idsStore);
helpIds.clear();
}
- //TODO use the AbstractPublig method
- @SuppressWarnings({"unchecked"})
- protected URLClassLoader initClasLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
- URLClassLoader loader = null;
- if (project != null) {
-
- URLClassLoader result;
- try {
-
- List<URL> lUrls = new ArrayList<URL>();
- List<String> sources = project.getCompileSourceRoots();
-
- if (addSourcesToClassPath) {
- for (String source : sources) {
- lUrls.add(new File(source).toURI().toURL());
- }
- if (testPhase) {
- for (Object source : project.getTestCompileSourceRoots()) {
- lUrls.add(new File(source.toString()).toURI().toURL());
- }
- }
- }
- if (addResourcesToClassPath) {
- for (Object source : project.getResources()) {
- Resource r = (Resource) source;
- lUrls.add(new File(r.getDirectory()).toURI().toURL());
- }
- }
- if (testPhase && addCompileClassPath) {
- if (project != null) {
- lUrls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
- }
- }
- if (addProjectClassPath) {
- getLog().info("use project compile scope class-path");
- // add also all dependencies of the project in compile scope
- Set<?> artifacts = project.getArtifacts();
- for (Object o : artifacts) {
- Artifact a = (Artifact) o;
- lUrls.add(a.getFile().toURI().toURL());
- }
- }
-
- result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
-
- } catch (IOException e) {
- throw new RuntimeException("Can't create ClassLoader for reason " + e.getMessage(), e);
- }
- loader = result;
- } else {
- List<URL> lUrls = new ArrayList<URL>();
- if (addSourcesToClassPath) {
- lUrls.add(src.toURI().toURL());
- }
- loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
- }
- if (verbose) {
- for (URL entry : loader.getURLs()) {
- log.info("classpath : " + entry);
- }
- }
- return loader;
- }
-
protected String removeQuote(String txt) {
if (txt.startsWith("\"")) {
txt = txt.substring(1);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -35,6 +35,10 @@
return childs;
}
+ public void setText(String text) {
+ this.text = text;
+ }
+
public NodeItem findChild(String path) {
NodeItem result = null;
String[] paths = path.split("\\.");
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -106,7 +106,7 @@
// premier item
if (rootItem.getTarget().equals(target)) {
// le premier item est bien top
- //rootItem.setText(text);
+ rootItem.setText(text);
currentItem = rootItem;
} else {
// le premier noeud n'est pas top
1
0
Author: tchemit
Date: 2009-10-08 18:48:27 +0200 (Thu, 08 Oct 2009)
New Revision: 1568
Added:
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
Removed:
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm
branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java
Log:
evolution #78 : rendre le syst?\195?\168me d'aide multi-langue + JAXXContext is returned to jaxx.runtime package
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -14,7 +14,7 @@
/**
*
- * @return the class loader to use by compilers
+ * @return the class loader used by compilers
*/
ClassLoader getClassLoader();
@@ -51,36 +51,6 @@
/**
*
- * @return the name of the help set to generate
- */
- String getHelpSetName();
-
- /**
- *
- * @return the prefix of i18n keys to use in help system
- */
- String getHelpsetI18nPrefix();
-
- /**
- *
- * @return the suffix of i18n keys to use in index of help system
- */
- String getHelpsetIndexI18nSuffix();
-
- /**
- *
- * @return the suffix of i18n keys to use in title of the help system
- */
- String getHelpsetTitleI18nSuffix();
-
- /**
- *
- * @return the suffix of i18n keys to use in toc of the help system
- */
- String getHelpsetTocI18nSuffix();
-
- /**
- *
* @return the type of context to use in each generated jaxx object
*/
Class<? extends JAXXContext> getJaxxContextClass();
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -13,24 +13,20 @@
*/
public class DefaultCompilerConfiguration implements CompilerConfiguration {
-// private File javacTargetDirectory;
-// private String classPath;
-// private String javacOpts;
-// private boolean keepJavaFiles;
/**
- *
+ * where to generate
*/
private File targetDirectory;
/**
- *
+ * flag to optimize generated code
*/
private boolean optimize;
/**
- *
+ * verbose flag
*/
private boolean verbose;
/**
- *
+ * to do a profile pass after generation
*/
private boolean profile;
/**
@@ -59,11 +55,11 @@
*/
private Class<?> defaultErrorUI;
/**
- *
+ * class loader to use in compiler
*/
private ClassLoader classLoader;
/**
- *
+ * the compiler class to use
*/
private Class<? extends JAXXCompiler> compilerClass;
/**
@@ -90,36 +86,6 @@
* since this class should be in sources (so not yet compiled)
*/
private String helpBrokerFQN;
- /**
- * The prefix to add to i18n key for any help i18n key.
- *
- * @since 1.3
- */
- protected String helpsetI18nPrefix;
- /**
- * The suffix to add to i18n key for an help Id.
- *
- * @since 1.3
- */
- protected String helpsetTitleI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @since 1.3
- */
- protected String helpsetTocI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @since 1.3
- */
- protected String helpsetIndexI18nSuffix;
- /**
- * The helpset name
- *
- * @since 1.3
- */
- protected String helpSetName;
@Override
public File getTargetDirectory() {
@@ -211,31 +177,6 @@
}
@Override
- public String getHelpsetIndexI18nSuffix() {
- return helpsetIndexI18nSuffix;
- }
-
- @Override
- public String getHelpsetTitleI18nSuffix() {
- return helpsetTitleI18nSuffix;
- }
-
- @Override
- public String getHelpsetTocI18nSuffix() {
- return helpsetTocI18nSuffix;
- }
-
- @Override
- public String getHelpSetName() {
- return helpSetName;
- }
-
- @Override
- public String getHelpsetI18nPrefix() {
- return helpsetI18nPrefix;
- }
-
- @Override
public Class<?> getValidatorClass() {
return validatorClass;
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -44,8 +44,8 @@
if (options.isGenerateHelp()) {
- // add JaxxHelpUI interface
- Class<?> validatorInterface = jaxx.runtime.swing.JaxxHelpUI.class;
+ // add JAXXHelpUI interface
+ Class<?> validatorInterface = jaxx.runtime.swing.help.JAXXHelpUI.class;
String helpBrokerFQN = getBrokerFQN(compiler);
javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">");
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -91,7 +91,9 @@
* @param <O> type of container to obtain from context
* @param clazz clazz desired
* @return parent's container
+ * @deprecated since 2.0.0 : breaks neutral since Swing
*/
+ @Deprecated
public <O extends Container> O getParentContainer(Class<O> clazz);
/**
@@ -101,6 +103,8 @@
* @param top the top container
* @param clazz desired
* @return parent's container
+ * @deprecated since 2.0.0 : breaks neutral since Swing
*/
+ @Deprecated
public <O extends Container> O getParentContainer(Object top, Class<O> clazz);
}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,6 +1,5 @@
package jaxx.runtime.context;
-import jaxx.runtime.JAXXContext;
import jaxx.runtime.*;
import static jaxx.runtime.context.JAXXContextEntryDef.newDef;
import org.apache.commons.logging.Log;
@@ -25,14 +24,25 @@
*/
public class DefaultJAXXContext implements JAXXContext {
+ /**
+ * entry of the parent context
+ */
protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = newDef(JAXXContext.class);
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * Logger
+ */
static private final Log log = LogFactory.getLog(DefaultJAXXContext.class);
- /** l'ui auquel est rattache le context */
+ /**
+ * l'ui auquel est rattache le context
+ */
protected JAXXObject ui;
- /** le context parent */
+ /**
+ * le context parent
+ */
protected JAXXContext parentContext;
- /** les données contenues dans le context */
+ /**
+ * les données contenues dans le context
+ */
protected final Map<JAXXContextEntryDef<?>, Object> data;
public DefaultJAXXContext() {
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,556 +0,0 @@
-package jaxx.runtime.swing;
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Vector;
-import javax.help.CSH;
-import javax.help.HelpBroker;
-import javax.help.HelpSet;
-import javax.swing.AbstractButton;
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * La classe pour encapsuler l'aide de l'application.
- *
- * @param <B> le type de broker
- * @author tony
- * @since 1.4
- */
-public abstract class JaxxHelpBroker<B extends JaxxHelpBroker<?>> {
-
- public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext";
- /**
- * Logger
- */
- static private Log log = LogFactory.getLog(JaxxHelpBroker.class);
- /**
- * name of helpset
- */
- protected final String helpsetName;
- /**
- * default id to use if none given
- */
- protected final String defaultID;
- /**
- * help key
- */
- protected final String helpKey;
- /**
- * helpset to use
- */
- protected HelpSet helpset;
- /**
- * help broker
- */
- protected HelpBroker helpBroker;
- /**
- * current locale used
- */
- protected Locale locale;
- /**
- * cache of cursors modified when in context-sensitive mode
- */
- protected Hashtable<Component, Cursor> cursors;
- /**
- * cursor to use in context-sensitive mode
- */
- protected Cursor onItemCursor;
- /**
- * cache of component which cursor have been modified
- */
- protected final Map<Component, String> cache;
-
- protected JaxxHelpBroker(String helpsetName, String helpKey, String defaultID) {
- this(null, helpsetName, helpKey, defaultID);
- }
-
- protected JaxxHelpBroker(Locale locale, String helpsetName, String helpKey, String defaultID) {
- if (helpsetName == null) {
- throw new NullPointerException("parameter helpsetName can not be null!");
- }
- this.locale = locale;
- this.helpsetName = helpsetName;
- this.helpKey = helpKey;
- this.defaultID = defaultID;
- cache = new HashMap<Component, String>();
-// try {
-// ClassLoader cl = getClass().getClassLoader();
-// URL url = HelpSet.findHelpSet(cl, helpsetName, this.locale);
-// helpset = new HelpSet(cl, url);
-// helpBroker = helpset.createHelpBroker();
-// } catch (Exception ee) {
-// throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
-// }
- }
-
- public void prepareUI(JAXXObject c) {
- if (c == null) {
- throw new NullPointerException("parameter c can not be null!");
- }
-
- // l'ui doit avoir un boutton showHelp
- AbstractButton help = getShowHelpButton(c);
-
- if (help == null) {
- if (log.isDebugEnabled()) {
- log.debug("no showButton detected for " + c.getClass());
- }
- } else {
-
- // attach context to button
- help.putClientProperty(JAXX_CONTEXT_ENTRY, c.getDelegateContext());
-
- // add tracking action
- ActionListener listener = getShowHelpAction();
- if (log.isDebugEnabled()) {
- log.debug("adding tracking action " + listener);
- }
- help.addActionListener(listener);
-
- }
- if (log.isDebugEnabled()) {
- log.debug("done for " + c);
- }
- }
-
- public HelpBroker getHelpBroker() {
- if (helpBroker == null) {
- helpBroker = getHelpset().createHelpBroker();
- }
- return helpBroker;
- }
-
- public String getHelpKey() {
- return helpKey;
- }
-
- public HelpSet getHelpset() {
- if (helpset == null) {
- try {
- ClassLoader cl = getClass().getClassLoader();
- URL url = HelpSet.findHelpSet(cl, helpsetName, this.locale);
- helpset = new HelpSet(cl, url);
- } catch (Exception ee) {
- throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
- }
- }
- return helpset;
- }
-
- public String getHelpsetName() {
- return helpsetName;
- }
-
- public String getDefaultID() {
- return defaultID;
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- // need to reload helpset and helpbroker
- helpset = null;
- helpBroker = null;
- getHelpset();
- getHelpBroker();
- }
-
- public void showHelpSet() {
- if (log.isDebugEnabled()) {
- log.debug(this);
- }
- new CSH.DisplayHelpFromSource(helpBroker);
- }
-
- public void showHelp(JAXXContext context, String helpId) {
- }
-
- public void installUI(Component comp, String helpId) {
- CSH.setHelpIDString(comp, helpId);
- if (log.isDebugEnabled()) {
- log.debug(helpId + " : " + comp.getName());
- }
- cache.put(comp, helpId);
- }
-
- public class ShowHelpForTrackedComponentAction implements ActionListener {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- AbstractButton source = (AbstractButton) e.getSource();
-
- JAXXContext context = (JAXXContext) source.getClientProperty(JAXX_CONTEXT_ENTRY);
-
- // prepare cursor
- onItemCursor = (Cursor) UIManager.get("HelpOnItemCursor");
- Vector<?> topComponents = null;
- cursors = null;
-
- if (onItemCursor != null) {
- cursors = new Hashtable<Component, Cursor>();
- topComponents = getTopContainers(source);
- Enumeration<?> enums = topComponents.elements();
- while (enums.hasMoreElements()) {
- setAndStoreCursors((Container) enums.nextElement(), onItemCursor);
- }
- }
-
- // get the tracked component
- Component comp = null;
- try {
- MouseEvent event = getMouseEvent();
- if (event == null) {
- // tracking canceled
- return;
- }
- comp = (Component) event.getSource();
- if (log.isDebugEnabled()) {
- log.debug("component traking " + comp.getName() + " : " + comp.getClass().getName());
- }
- comp = SwingUtil.getDeepestObjectAt(comp, event.getX(), event.getY());
- if (log.isDebugEnabled()) {
- log.debug("deepest component " + comp.getName() + " : " + comp.getClass().getName());
- }
- } finally {
- // restore the old cursors
- if (topComponents != null) {
- Enumeration<?> containers = topComponents.elements();
- while (containers.hasMoreElements()) {
- resetAndRestoreCursors((Container) containers.nextElement());
- }
- }
- cursors = null;
- }
-
- String helpID = findHelpId(comp);
- showHelp(context, helpID);
- }
-
- public String findHelpId(Component comp) {
- String helpID = CSH.getHelpIDString(comp);
- if (defaultID.equals(helpID)) {
- String id = cache.get(comp);
- // on verifie qu'on est bien sur sur le bon id
- if (helpID.equals(id)) {
- // ok
- return helpID;
- }
- if (log.isDebugEnabled()) {
- log.debug("will try to find better id for comp : " + comp.getName());
- }
- // on est pas sur le bon id
- // on recherche parmis les parents
- helpID = findExtactHelpId(comp);
- }
- if (log.isInfoEnabled()) {
- log.info("helpID " + helpID + " for comp " + comp.getName() + " : " + comp.getClass().getName());
- }
- return helpID;
- }
-
- protected String findExtactHelpId(Component comp) {
- Container parent = comp.getParent();
- while (parent != null) {
- String id = cache.get(parent);
- if (id == null) {
- // ce container n'a pas d'id
- // on va directement sur le parent
- parent = parent.getParent();
- continue;
- }
- // le parent possède un id
- // on utilise cet id
- return id;
- }
- // on a pas trouve d'id
- // on retourne l'id par defaut
- return defaultID;
- }
- }
-
- protected AbstractButton getShowHelpButton(JAXXObject c) {
- return (AbstractButton) c.getObjectById("showHelp");
- }
-
- protected ActionListener getShowHelpAction() {
- return new ShowHelpForTrackedComponentAction();
- }
-
- //-------------------------------------------------------------------------
- //--- Copy CSH code but with accessible modifiers and little improvments
- //-------------------------------------------------------------------------
- /*
- * Get all top level containers to change it's cursors
- */
- protected Vector<?> getTopContainers(Object source) {
- // This method is used to obtain all top level components of application
- // for which the changing of cursor to question mark is wanted.
- // Method Frame.getFrames() is used to get list of Frames and
- // Frame.getOwnedWindows() method on elements of the list
- // returns all Windows, Dialogs etc. It works correctly in application.
- // Problem is in applets. There is no way how to get reference to applets
- // from elsewhere than applet itself. So, if request for CSH (this means
- // pressing help button or select help menu item) does't come from component
- // in a Applet, cursor for applets is not changed to question mark. Only for
- // Frames, Windows and Dialogs is cursor changed properly.
-
- Vector<Component> containers = new Vector<Component>();
- Component topComponent = null;
- topComponent = getRoot(source);
- if (topComponent instanceof Applet) {
- try {
- Enumeration<Applet> applets = ((Applet) topComponent).getAppletContext().getApplets();
- while (applets.hasMoreElements()) {
- containers.add(applets.nextElement());
- }
- } catch (NullPointerException npe) {
- containers.add(topComponent);
- }
- }
- Frame frames[] = Frame.getFrames();
- for (int i = 0; i < frames.length; i++) {
- Window[] windows = frames[i].getOwnedWindows();
- for (int j = 0; j < windows.length; j++) {
- containers.add(windows[j]);
- }
- if (!containers.contains(frames[i])) {
- containers.add(frames[i]);
- }
- }
- return containers;
- }
-
- protected Component getRoot(Object comp) {
- Object parent = comp;
- while (parent != null) {
- comp = parent;
- if (comp instanceof MenuComponent) {
- parent = ((MenuComponent) comp).getParent();
- } else if (comp instanceof Component) {
- if (comp instanceof Window) {
- break;
- }
- if (comp instanceof Applet) {
- break;
- }
- parent = ((Component) comp).getParent();
- } else {
- break;
- }
- }
- if (comp instanceof Component) {
- return ((Component) comp);
- }
- return null;
- }
-
- /*
- * Set the cursor for a component and its children.
- * Store the old cursors for future resetting
- */
- protected void setAndStoreCursors(Component comp, Cursor cursor) {
- if (comp == null) {
- return;
- }
- Cursor compCursor = comp.getCursor();
- if (compCursor != cursor) {
- cursors.put(comp, compCursor);
- log.debug("set cursor on " + comp);
- comp.setCursor(cursor);
- }
- if (comp instanceof Container) {
- Component component[] = ((Container) comp).getComponents();
- for (int i = 0; i < component.length; i++) {
- setAndStoreCursors(component[i], cursor);
- }
- }
- }
-
- /*
- * Actually restore the cursor for a component and its children
- */
- protected void resetAndRestoreCursors(Component comp) {
- if (comp == null) {
- return;
- }
- Cursor oldCursor = cursors.get(comp);
- if (oldCursor != null) {
- log.debug("restored cursor " + oldCursor + " on " + comp);
- comp.setCursor(oldCursor);
- }
- if (comp instanceof Container) {
- Component component[] = ((Container) comp).getComponents();
- for (int i = 0; i < component.length; i++) {
- resetAndRestoreCursors(component[i]);
- }
- }
- }
-
- /**
- * Context Sensitive Event Tracking
- *
- * Creates a new EventDispatchThread from which to dispatch events. This
- * method returns when stopModal is invoked.
- *
- * @return MouseEvent The mouse event occurred. Null if
- * cancelled on an undetermined object.
- */
- public static MouseEvent getMouseEvent() {
- // Should the cursor change to a quesiton mark here or
- // require the user to change the cursor externally to this method?
- // The problem is that each component can have it's own cursor.
- // For that reason it might be better to have the user change the
- // cusor rather than us.
-
- // To track context-sensitive events get the event queue and process
- // the events the same way EventDispatchThread does. Filter out
- // ContextSensitiveEvents SelectObject & Cancel (MouseDown & ???).
- // Note: This code only handles mouse events. Accessiblity might
- // require additional functionality or event trapping
-
- // If the eventQueue can't be retrieved, the thread gets interrupted,
- // or the thread isn't a instanceof EventDispatchThread then return
- // a null as we won't be able to trap events.
- try {
- if (EventQueue.isDispatchThread()) {
- EventQueue eq = null;
-
- // Find the eventQueue. If we can't get to it then just return
- // null since we won't be able to trap any events.
-
- try {
- eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
- } catch (Exception ee) {
- log.debug(ee);
- }
-
- // Safe guard
- if (eq == null) {
- return null;
- }
-
- int eventNumber = -1;
-
- // Process the events until an object has been selected or
- // the context-sensitive search has been canceled.
- while (true) {
- // This is essentially the body of EventDispatchThread
- // modified to trap context-senstive events and act
- // appropriately
- eventNumber++;
- AWTEvent event = eq.getNextEvent();
- Object src = event.getSource();
- // can't call eq.dispatchEvent
- // so I pasted it's body here
-
- if (log.isDebugEnabled()) {
- log.debug(event);
- }
-
- // Not sure if I should suppress ActiveEvents or not
- // Modal dialogs do. For now we will not suppress the
- // ActiveEvent events
-
- if (event instanceof ActiveEvent) {
- ((ActiveEvent) event).dispatch();
- continue;
- }
-
- if (src instanceof Component) {
- // Trap the context-sensitive events here
- if (event instanceof KeyEvent) {
- KeyEvent e = (KeyEvent) event;
- // if this is the cancel key then exit
- // otherwise pass all other keys up
- if (e.getKeyCode() == KeyEvent.VK_CANCEL ||
- e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- e.consume();
- return null;
- } else {
- e.consume();
- // dispatchEvent(event);
- }
- } else if (event instanceof MouseEvent) {
- MouseEvent e = (MouseEvent) event;
- int eID = e.getID();
-
- if ((eID == MouseEvent.MOUSE_CLICKED ||
- eID == MouseEvent.MOUSE_PRESSED ||
- eID == MouseEvent.MOUSE_RELEASED) &&
- SwingUtilities.isRightMouseButton(e)) {
- // cancel tracking
- e.consume();
- if (log.isDebugEnabled()) {
- log.debug("tracking canceled!!!");
- }
- return null;
- }
-
- if ((eID == MouseEvent.MOUSE_CLICKED ||
- eID == MouseEvent.MOUSE_PRESSED ||
- eID == MouseEvent.MOUSE_RELEASED) &&
- SwingUtilities.isLeftMouseButton(e)) {
- if (eID == MouseEvent.MOUSE_CLICKED) {
- if (eventNumber == 0) {
- dispatchEvent(event);
- continue;
- }
- }
- e.consume();
- return e;
- } else {
- e.consume();
- }
- } else {
- dispatchEvent(event);
- }
- } else if (src instanceof MenuComponent) {
- if (event instanceof InputEvent) {
- ((InputEvent) event).consume();
- }
- } else {
- log.error("unable to dispatch event: " + event);
- }
- }
- }
- } catch (InterruptedException e) {
- if (log.isDebugEnabled()) {
- log.debug(e);
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("Fall Through code");
- }
- return null;
- }
-
- private static void dispatchEvent(AWTEvent event) {
- Object src = event.getSource();
- if (event instanceof ActiveEvent) {
- // This could become the sole method of dispatching in time.
- ((ActiveEvent) event).dispatch();
- } else if (src instanceof Component) {
- ((Component) src).dispatchEvent(event);
- } else if (src instanceof MenuComponent) {
- ((MenuComponent) src).dispatchEvent(event);
- } else {
- log.error("unable to dispatch event: " + event);
- }
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,22 +0,0 @@
-package jaxx.runtime.swing;
-
-import java.awt.Component;
-
-/**
- *
- * Contract to be added on JAXXObject wihch wants to use javax help.
- *
- * @param <B> type of broker.
- *
- * @author tony
- * @since 1.3
- * @see JaxxHelpBroker
- */
-public interface JaxxHelpUI<B extends JaxxHelpBroker<?>> {
-
- B getBroker();
-
- void registerHelpId(B broker, Component component, String helpId);
-
- void showHelp(String helpId);
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java (from rev 1567, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,564 @@
+package jaxx.runtime.swing.help;
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Vector;
+import javax.help.CSH;
+import javax.help.HelpBroker;
+import javax.help.HelpSet;
+import javax.swing.AbstractButton;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * La classe pour encapsuler l'aide de l'application.
+ *
+ * @author tony
+ * @since 1.4
+ */
+public class JAXXHelpBroker {
+
+ public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext";
+ /**
+ * Logger
+ */
+ static private Log log = LogFactory.getLog(JAXXHelpBroker.class);
+ /**
+ * name of helpset
+ */
+ protected final String helpsetName;
+ /**
+ * default id to use if none given
+ */
+ protected final String defaultID;
+ /**
+ * help key
+ */
+ protected final String helpKey;
+ /**
+ * helpset to use
+ */
+ protected HelpSet helpset;
+ /**
+ * help broker
+ */
+ protected HelpBroker helpBroker;
+ /**
+ * current locale used
+ */
+ protected Locale locale;
+ /**
+ * cache of cursors modified when in context-sensitive mode
+ */
+ protected Hashtable<Component, Cursor> cursors;
+ /**
+ * cursor to use in context-sensitive mode
+ */
+ protected Cursor onItemCursor;
+ /**
+ * cache of component which cursor have been modified
+ */
+ protected final Map<Component, String> cache;
+ /**
+ * help ui handler
+ */
+ protected JAXXHelpUIHandler handler;
+
+ public JAXXHelpBroker(String helpsetName, String helpKey, String defaultID, JAXXHelpUIHandler handler) {
+ this(null, helpsetName, helpKey, defaultID, handler);
+ }
+
+ public JAXXHelpBroker(Locale locale, String helpsetName, String helpKey, String defaultID, JAXXHelpUIHandler handler) {
+ if (helpsetName == null) {
+ throw new NullPointerException("parameter helpsetName can not be null!");
+ }
+ if (handler == null) {
+ throw new NullPointerException("handler can not be null");
+ }
+ this.locale = locale;
+ this.helpsetName = helpsetName;
+ this.helpKey = helpKey;
+ this.defaultID = defaultID;
+ this.handler = handler;
+ this.cache = new HashMap<Component, String>();
+ }
+
+ public void prepareUI(JAXXObject c) {
+ if (c == null) {
+ throw new NullPointerException("parameter c can not be null!");
+ }
+
+ // l'ui doit avoir un boutton showHelp
+ AbstractButton help = getShowHelpButton(c);
+
+ if (help == null) {
+ // no showHelp button
+ return;
+ }
+
+ // attach context to button
+ if (log.isDebugEnabled()) {
+ log.debug("attach context to showhelp button " + c);
+ }
+ help.putClientProperty(JAXX_CONTEXT_ENTRY, c);
+
+ // add tracking action
+ ActionListener listener = getShowHelpAction();
+ if (log.isDebugEnabled()) {
+ log.debug("adding tracking action " + listener);
+ }
+ help.addActionListener(listener);
+
+ if (log.isDebugEnabled()) {
+ log.debug("done for " + c);
+ }
+
+
+ getHelpBroker().enableHelpKey(((Component) c), getDefaultID(), getHelpset());
+ }
+
+ public void showHelp(JAXXContext context, String helpId) {
+ getHandler().showHelp(context, this, helpId);
+ }
+
+ public JAXXHelpUIHandler getHandler() {
+ return handler;
+ }
+
+ public HelpBroker getHelpBroker() {
+ if (helpBroker == null) {
+ helpBroker = getHelpset().createHelpBroker();
+ }
+ return helpBroker;
+ }
+
+ public String getHelpKey() {
+ return helpKey;
+ }
+
+ public HelpSet getHelpset() {
+ if (helpset == null) {
+ try {
+ ClassLoader cl = getClass().getClassLoader();
+ URL url = HelpSet.findHelpSet(cl, helpsetName, locale);
+ helpset = new HelpSet(cl, url);
+ } catch (Exception ee) {
+ throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
+ }
+ }
+ return helpset;
+ }
+
+ public String getHelpsetName() {
+ return helpsetName;
+ }
+
+ public String getDefaultID() {
+ return defaultID;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ // need to reload helpset and helpbroker
+ helpset = null;
+ helpBroker = null;
+ getHelpset();
+ getHelpBroker();
+ }
+
+ public void showHelpSet() {
+ if (log.isDebugEnabled()) {
+ log.debug(this);
+ }
+ new CSH.DisplayHelpFromSource(getHelpBroker());
+ }
+
+ public void installUI(Component comp, String helpId) {
+ CSH.setHelpIDString(comp, helpId);
+ if (log.isDebugEnabled()) {
+ log.debug(helpId + " : " + comp.getName());
+ }
+ cache.put(comp, helpId);
+ }
+
+ public class ShowHelpForTrackedComponentAction implements ActionListener {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ AbstractButton source = (AbstractButton) e.getSource();
+
+ JAXXContext context = (JAXXContext) source.getClientProperty(JAXX_CONTEXT_ENTRY);
+
+ // prepare cursor
+ onItemCursor = (Cursor) UIManager.get("HelpOnItemCursor");
+ Vector<?> topComponents = null;
+ cursors = null;
+
+ if (onItemCursor != null) {
+ cursors = new Hashtable<Component, Cursor>();
+ topComponents = getTopContainers(source);
+ Enumeration<?> enums = topComponents.elements();
+ while (enums.hasMoreElements()) {
+ setAndStoreCursors((Container) enums.nextElement(), onItemCursor);
+ }
+ }
+
+ // get the tracked component
+ Component comp = null;
+ try {
+ MouseEvent event = getMouseEvent();
+ if (event == null) {
+ // tracking canceled
+ return;
+ }
+ comp = (Component) event.getSource();
+ if (log.isDebugEnabled()) {
+ log.debug("component traking " + comp.getName() + " : " + comp.getClass().getName());
+ }
+ comp = SwingUtil.getDeepestObjectAt(comp, event.getX(), event.getY());
+ if (log.isDebugEnabled()) {
+ log.debug("deepest component " + comp.getName() + " : " + comp.getClass().getName());
+ }
+ } finally {
+ // restore the old cursors
+ if (topComponents != null) {
+ Enumeration<?> containers = topComponents.elements();
+ while (containers.hasMoreElements()) {
+ resetAndRestoreCursors((Container) containers.nextElement());
+ }
+ }
+ cursors = null;
+ }
+
+ String helpID = findHelpId(comp);
+ showHelp(context, helpID);
+ }
+
+ public String findHelpId(Component comp) {
+ String helpID = CSH.getHelpIDString(comp);
+ if (defaultID.equals(helpID)) {
+ String id = cache.get(comp);
+ // on verifie qu'on est bien sur sur le bon id
+ if (helpID.equals(id)) {
+ // ok
+ return helpID;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will try to find better id for comp : " + comp.getName());
+ }
+ // on est pas sur le bon id
+ // on recherche parmis les parents
+ helpID = findExtactHelpId(comp);
+ }
+ if (log.isInfoEnabled()) {
+ log.info("helpID " + helpID + " for comp " + comp.getName() + " : " + comp.getClass().getName());
+ }
+ return helpID;
+ }
+
+ protected String findExtactHelpId(Component comp) {
+ Container parent = comp.getParent();
+ while (parent != null) {
+ String id = cache.get(parent);
+ if (id == null) {
+ // ce container n'a pas d'id
+ // on va directement sur le parent
+ parent = parent.getParent();
+ continue;
+ }
+ // le parent possède un id
+ // on utilise cet id
+ return id;
+ }
+ // on a pas trouve d'id
+ // on retourne l'id par defaut
+ return defaultID;
+ }
+ }
+
+ protected AbstractButton getShowHelpButton(JAXXObject c) {
+ return (AbstractButton) c.getObjectById("showHelp");
+ }
+
+ protected ActionListener getShowHelpAction() {
+ return new ShowHelpForTrackedComponentAction();
+ }
+
+ //-------------------------------------------------------------------------
+ //--- Copy CSH code but with accessible modifiers and little improvments
+ //-------------------------------------------------------------------------
+ /*
+ * Get all top level containers to change it's cursors
+ */
+ protected Vector<?> getTopContainers(Object source) {
+ // This method is used to obtain all top level components of application
+ // for which the changing of cursor to question mark is wanted.
+ // Method Frame.getFrames() is used to get list of Frames and
+ // Frame.getOwnedWindows() method on elements of the list
+ // returns all Windows, Dialogs etc. It works correctly in application.
+ // Problem is in applets. There is no way how to get reference to applets
+ // from elsewhere than applet itself. So, if request for CSH (this means
+ // pressing help button or select help menu item) does't come from component
+ // in a Applet, cursor for applets is not changed to question mark. Only for
+ // Frames, Windows and Dialogs is cursor changed properly.
+
+ Vector<Component> containers = new Vector<Component>();
+ Component topComponent = null;
+ topComponent = getRoot(source);
+ if (topComponent instanceof Applet) {
+ try {
+ Enumeration<Applet> applets = ((Applet) topComponent).getAppletContext().getApplets();
+ while (applets.hasMoreElements()) {
+ containers.add(applets.nextElement());
+ }
+ } catch (NullPointerException npe) {
+ containers.add(topComponent);
+ }
+ }
+ Frame frames[] = Frame.getFrames();
+ for (int i = 0; i < frames.length; i++) {
+ Window[] windows = frames[i].getOwnedWindows();
+ for (int j = 0; j < windows.length; j++) {
+ containers.add(windows[j]);
+ }
+ if (!containers.contains(frames[i])) {
+ containers.add(frames[i]);
+ }
+ }
+ return containers;
+ }
+
+ protected Component getRoot(Object comp) {
+ Object parent = comp;
+ while (parent != null) {
+ comp = parent;
+ if (comp instanceof MenuComponent) {
+ parent = ((MenuComponent) comp).getParent();
+ } else if (comp instanceof Component) {
+ if (comp instanceof Window) {
+ break;
+ }
+ if (comp instanceof Applet) {
+ break;
+ }
+ parent = ((Component) comp).getParent();
+ } else {
+ break;
+ }
+ }
+ if (comp instanceof Component) {
+ return ((Component) comp);
+ }
+ return null;
+ }
+
+ /*
+ * Set the cursor for a component and its children.
+ * Store the old cursors for future resetting
+ */
+ protected void setAndStoreCursors(Component comp, Cursor cursor) {
+ if (comp == null) {
+ return;
+ }
+ Cursor compCursor = comp.getCursor();
+ if (compCursor != cursor) {
+ cursors.put(comp, compCursor);
+ log.debug("set cursor on " + comp);
+ comp.setCursor(cursor);
+ }
+ if (comp instanceof Container) {
+ Component component[] = ((Container) comp).getComponents();
+ for (int i = 0; i < component.length; i++) {
+ setAndStoreCursors(component[i], cursor);
+ }
+ }
+ }
+
+ /*
+ * Actually restore the cursor for a component and its children
+ */
+ protected void resetAndRestoreCursors(Component comp) {
+ if (comp == null) {
+ return;
+ }
+ Cursor oldCursor = cursors.get(comp);
+ if (oldCursor != null) {
+ log.debug("restored cursor " + oldCursor + " on " + comp);
+ comp.setCursor(oldCursor);
+ }
+ if (comp instanceof Container) {
+ Component component[] = ((Container) comp).getComponents();
+ for (int i = 0; i < component.length; i++) {
+ resetAndRestoreCursors(component[i]);
+ }
+ }
+ }
+
+ /**
+ * Context Sensitive Event Tracking
+ *
+ * Creates a new EventDispatchThread from which to dispatch events. This
+ * method returns when stopModal is invoked.
+ *
+ * @return MouseEvent The mouse event occurred. Null if
+ * cancelled on an undetermined object.
+ */
+ public static MouseEvent getMouseEvent() {
+ // Should the cursor change to a quesiton mark here or
+ // require the user to change the cursor externally to this method?
+ // The problem is that each component can have it's own cursor.
+ // For that reason it might be better to have the user change the
+ // cusor rather than us.
+
+ // To track context-sensitive events get the event queue and process
+ // the events the same way EventDispatchThread does. Filter out
+ // ContextSensitiveEvents SelectObject & Cancel (MouseDown & ???).
+ // Note: This code only handles mouse events. Accessiblity might
+ // require additional functionality or event trapping
+
+ // If the eventQueue can't be retrieved, the thread gets interrupted,
+ // or the thread isn't a instanceof EventDispatchThread then return
+ // a null as we won't be able to trap events.
+ try {
+ if (EventQueue.isDispatchThread()) {
+ EventQueue eq = null;
+
+ // Find the eventQueue. If we can't get to it then just return
+ // null since we won't be able to trap any events.
+
+ try {
+ eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ } catch (Exception ee) {
+ log.debug(ee);
+ }
+
+ // Safe guard
+ if (eq == null) {
+ return null;
+ }
+
+ int eventNumber = -1;
+
+ // Process the events until an object has been selected or
+ // the context-sensitive search has been canceled.
+ while (true) {
+ // This is essentially the body of EventDispatchThread
+ // modified to trap context-senstive events and act
+ // appropriately
+ eventNumber++;
+ AWTEvent event = eq.getNextEvent();
+ Object src = event.getSource();
+ // can't call eq.dispatchEvent
+ // so I pasted it's body here
+
+ if (log.isDebugEnabled()) {
+ log.debug(event);
+ }
+
+ // Not sure if I should suppress ActiveEvents or not
+ // Modal dialogs do. For now we will not suppress the
+ // ActiveEvent events
+
+ if (event instanceof ActiveEvent) {
+ ((ActiveEvent) event).dispatch();
+ continue;
+ }
+
+ if (src instanceof Component) {
+ // Trap the context-sensitive events here
+ if (event instanceof KeyEvent) {
+ KeyEvent e = (KeyEvent) event;
+ // if this is the cancel key then exit
+ // otherwise pass all other keys up
+ if (e.getKeyCode() == KeyEvent.VK_CANCEL ||
+ e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ e.consume();
+ return null;
+ } else {
+ e.consume();
+ // dispatchEvent(event);
+ }
+ } else if (event instanceof MouseEvent) {
+ MouseEvent e = (MouseEvent) event;
+ int eID = e.getID();
+
+ if ((eID == MouseEvent.MOUSE_CLICKED ||
+ eID == MouseEvent.MOUSE_PRESSED ||
+ eID == MouseEvent.MOUSE_RELEASED) &&
+ SwingUtilities.isRightMouseButton(e)) {
+ // cancel tracking
+ e.consume();
+ if (log.isDebugEnabled()) {
+ log.debug("tracking canceled!!!");
+ }
+ return null;
+ }
+
+ if ((eID == MouseEvent.MOUSE_CLICKED ||
+ eID == MouseEvent.MOUSE_PRESSED ||
+ eID == MouseEvent.MOUSE_RELEASED) &&
+ SwingUtilities.isLeftMouseButton(e)) {
+ if (eID == MouseEvent.MOUSE_CLICKED) {
+ if (eventNumber == 0) {
+ dispatchEvent(event);
+ continue;
+ }
+ }
+ e.consume();
+ return e;
+ } else {
+ e.consume();
+ }
+ } else {
+ dispatchEvent(event);
+ }
+ } else if (src instanceof MenuComponent) {
+ if (event instanceof InputEvent) {
+ ((InputEvent) event).consume();
+ }
+ } else {
+ log.error("unable to dispatch event: " + event);
+ }
+ }
+ }
+ } catch (InterruptedException e) {
+ if (log.isDebugEnabled()) {
+ log.debug(e);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Fall Through code");
+ }
+ return null;
+ }
+
+ private static void dispatchEvent(AWTEvent event) {
+ Object src = event.getSource();
+ if (event instanceof ActiveEvent) {
+ // This could become the sole method of dispatching in time.
+ ((ActiveEvent) event).dispatch();
+ } else if (src instanceof Component) {
+ ((Component) src).dispatchEvent(event);
+ } else if (src instanceof MenuComponent) {
+ ((MenuComponent) src).dispatchEvent(event);
+ } else {
+ log.error("unable to dispatch event: " + event);
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java (from rev 1567, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,22 @@
+package jaxx.runtime.swing.help;
+
+import java.awt.Component;
+
+/**
+ *
+ * Contract to be added on JAXXObject which wants to use javax help.
+ *
+ * @param <B> type of broker.
+ *
+ * @author tony
+ * @since 1.3
+ * @see JAXXHelpBroker
+ */
+public interface JAXXHelpUI<B extends JAXXHelpBroker> {
+
+ B getBroker();
+
+ void registerHelpId(B broker, Component component, String helpId);
+
+ void showHelp(String helpId);
+}
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,12 @@
+package jaxx.runtime.swing.help;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ *
+ * @author chemit
+ */
+public interface JAXXHelpUIHandler {
+
+ void showHelp(JAXXContext context, JAXXHelpBroker broker, String helpID);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -41,12 +41,6 @@
*/
protected MavenProject project;
/**
- * Repertoire de destination des fichiers java a generer.
- *
- * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
- */
- protected File outJava;
- /**
* verbose flag
*
* @parameter expression="${jaxx.verbose}" default-value="false"
@@ -55,72 +49,15 @@
*/
protected boolean verbose;
/**
- * to make compiler i18nable, says add the {@link org.nuiton.i18n.I18n#_(String, Object[])} method
- * invocation on {@link jaxx.compiler.I18nHelper#I18N_ATTRIBUTES} attributes.
- *
- * @parameter expression="${jaxx.i18nable}" default-value="true"
- * @see jaxx.compiler.I18nHelper
- */
- protected boolean i18nable;
- /**
- * The store of helpIds generated by {@link JaxxGeneratorMojo}.
- * <p/>
- *
- * @parameter expression="${jaxx.helpIdStore}" default-value="target/helpIds.properties"
+ * The store of helpIds generated by the goal {@link GenerateMojo} and then
+ * used by the goal {@link GenerateHelpMojo}.
+ *
+ * @parameter expression="${jaxx.helpIdsStore}" default-value="target/helpIds.properties"
* @required
*
* @since 1.3
*/
- protected File helpIdStore;
- /**
- * The name of the helpset to generate.
- *
- * @parameter expression="${jaxx.helpSetName}" default-value="${project.artifactId}"
- * @required
- *
- * @since 1.3
- */
- protected String helpSetName;
- /**
- * The prefix to add to i18n key for any help i18n key.
- *
- * @parameter expression="${jaxx.helpsetI18nPrefix}" default-value="${jaxx.helpSetName}.help."
- * @required
- *
- * @since 1.3
- */
- protected String helpsetI18nPrefix;
- /**
- * The suffix to add to i18n key for an help Id.
- *
- * @parameter expression="${jaxx.helpsetTitleI18nSuffix}" default-value=".title"
- * @required
- *
- * @since 1.3
- */
- protected String helpsetTitleI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @parameter expression="${jaxx.helpsetTocI18nSuffix}" default-value=".toc"
- * @required
- *
- * @since 1.3
- */
- protected String helpsetTocI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @parameter expression="${jaxx.helpsetIndexI18nSuffix}" default-value=".index"
- * @required
- *
- * @since 1.3
- */
- protected String helpsetIndexI18nSuffix;
- /**
- *
- */
- protected ClassLoader cl;
+ protected File helpIdsStore;
@Override
protected boolean checkPackaging() {
@@ -146,4 +83,12 @@
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
+
+ public File getHelpIdsStore() {
+ return helpIdsStore;
+ }
+
+ public void setHelpIdsStore(File helpIdsStore) {
+ this.helpIdsStore = helpIdsStore;
+ }
}
Copied: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java (from rev 1566, branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java)
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,520 @@
+/* *##%
+ * Copyright (C) 2007
+ * JaxxPlugin, Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+package org.nuiton.jaxx.plugin;
+
+import org.apache.maven.plugin.MojoFailureException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+import org.nuiton.i18n.I18n;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.SortedProperties;
+
+/**
+ * Mojo to generate javax help stuff for your project.
+ *
+ * HelpIds should have been discovered by the JaxxMojo.
+ *
+ * @author chemit
+ * @goal generate-help
+ * @phase process-sources
+ *
+ * @requiresProject
+ * @requiresDependencyResolution compile
+ * @since 1.3
+ */
+public class GenerateHelpMojo extends AbstractJaxxMojo {
+
+ private static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
+ /**
+ * The directory where to generate help files.
+ *
+ * @parameter expression="${jaxx.outHelp}" default-value="${project.basedir}/src/main/help"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File outHelp;
+ /**
+ * The locales to generate for help, seprated by comma.
+ *
+ * The first locale given is the default locale.
+ *
+ * @parameter expression="${jaxx.locales}"
+ * @required
+ *
+ * @since 2.0.0
+ */
+ protected String locales;
+ /**
+ * The name of the helpset to generate.
+ *
+ * @parameter expression="${jaxx.helpsetName}" default-value="${project.artifactId}"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String helpsetName;
+ /**
+ * The template used to generate helpset file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.helpsetTemplate}" default-value="/defaultHelpSet.hs.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File helpsetTemplate;
+ /**
+ * The template used to generate helpset map file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File mapTemplate;
+ /**
+ * The template used to generate helpset index file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File indexTemplate;
+ /**
+ * The template used to generate helpset toc file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File tocTemplate;
+ /**
+ * The template used to generate helpset content file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File contentTemplate;
+ /**
+ * The help ids discovered in {@link #helpIdsStore} files.
+ */
+ private Properties helpIds;
+ /**
+ * Default locale (the first locale in {@link #localesToTreate}.
+ */
+ private Locale defaultLocale;
+ /**
+ * Locales to treate
+ */
+ private Locale[] localesToTreate;
+
+ @Override
+ public boolean init() throws Exception {
+
+ File idsStore = getHelpIdsStore();
+
+ if (!idsStore.exists()) {
+ getLog().info("no helpIdStore to react at " + idsStore);
+ return false;
+ }
+
+ if (locales == null || locales.trim().isEmpty()) {
+ throw new MojoFailureException("You must set the 'locales' property properly (was " + locales + ").");
+ }
+
+ // check there is a outHelp
+ if (outHelp == null) {
+ throw new MojoFailureException("You must set the 'target' property.");
+ }
+
+ List<Locale> tmp = new ArrayList<Locale>();
+ for (String loc : locales.split(",")) {
+ Locale l = I18n.newLocale(loc);
+ tmp.add(l);
+ }
+
+ if (tmp.isEmpty()) {
+ throw new MojoFailureException("you must set the 'locales' property.");
+ }
+
+ localesToTreate = tmp.toArray(new Locale[tmp.size()]);
+ defaultLocale = localesToTreate[0];
+
+ // check ressources
+ checkResource(helpsetTemplate);
+ checkResource(mapTemplate);
+ checkResource(indexTemplate);
+ checkResource(tocTemplate);
+ checkResource(contentTemplate);
+
+ if (!outHelp.exists()) {
+ getLog().info("mkdir " + outHelp);
+ outHelp.mkdirs();
+ }
+
+ helpIds = new SortedProperties();
+
+ InputStream stream = new FileInputStream(idsStore);
+
+ try {
+ helpIds.load(stream);
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ }
+
+ if (helpIds.isEmpty()) {
+
+ // no ids detected
+ getLog().warn("No helpIds detected, will skip.");
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ int touchedFiles = 0;
+
+ String mapFileName = helpsetName + "Map.jhm";
+ String indexFileName = helpsetName + "Index.xml";
+ String tocFileName = helpsetName + "TOC.xml";
+
+ for (Locale locale : localesToTreate) {
+
+ boolean isDefaultLocale = locale == defaultLocale;
+
+ String language = locale.getLanguage();
+
+ String localePath = (isDefaultLocale ? "default" : language);
+
+ File localizedTarget = new File(outHelp, localePath);
+
+ if (!localizedTarget.exists()) {
+ localizedTarget.mkdirs();
+ }
+ getLog().info("Generate help for language " + language);
+ getLog().info(" Localized target : " + localizedTarget);
+
+ Properties env = new Properties();
+
+ env.put("helpSetName", helpsetName);
+ env.put("locale", language);
+ env.put("localePath", localePath);
+ env.put("separator", " ");
+ env.put("autoremoveLine", AUTOREMOVE_LINE);
+
+ String localeSuffix = isDefaultLocale ? "" : "_" + language;
+ String helpsetFileName = helpsetName + localeSuffix + ".hs";
+
+ env.put("helpSetFileName", helpsetFileName);
+
+ env.put("mapFileName", mapFileName);
+ env.put("indexFileName", indexFileName);
+ env.put("tocFileName", tocFileName);
+// env.put("searchData", localePath + "/index");
+
+ // ---------------------------------------------------------------
+ // --- main helpset file -----------------------------------------
+ // ---------------------------------------------------------------
+
+ File file = new File(outHelp, helpsetFileName);
+
+ boolean doCreate = generateHelpsetFile(file, env);
+
+ if (doCreate) {
+ touchedFiles++;
+ }
+
+ // ---------------------------------------------------------------
+ // --- helpset map file ------------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(localizedTarget, mapFileName);
+
+ Properties mergedHelpIds = generateMapFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset index file ----------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(localizedTarget, indexFileName);
+
+ NodeItem indexRootItem = generateIndexFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset toc file ------------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(localizedTarget, tocFileName);
+
+ NodeItem tocRootItem = generateTocFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset content files -------------------------------------
+ // ---------------------------------------------------------------
+
+ touchedFiles += generateContentFiles(localizedTarget, env, localePath);
+
+ }
+
+ getLog().info(touchedFiles + " file(s) treated.");
+ }
+
+ protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception {
+
+ int touchedFiles = 0;
+ TemplateGenerator gen = prepareGenerator(contentTemplate);
+ Enumeration<?> keys = helpIds.keys();
+ while (keys.hasMoreElements()) {
+ String key = (String) keys.nextElement();
+ String url = (String) helpIds.get(key);
+ url = helpsetName + File.separator + url;
+ File f = new File(localizedTarget, url);
+ boolean exist = f.exists();
+ if (exist) {
+ // check if there is a autoremoveLine in content
+ String content = FileUtil.readAsString(f);
+ if (!content.contains(AUTOREMOVE_LINE)) {
+ // no regenerate marker detected, so skip this file
+ if (verbose) {
+ getLog().debug("skip existing file " + f);
+ }
+ continue;
+ }
+ }
+ f.getParentFile().mkdirs();
+ if (verbose) {
+ if (exist) {
+ getLog().info("regenerate content file " + f);
+ } else {
+ getLog().info("generate content file " + f);
+ }
+ }
+ env.put("helpId", key);
+ env.put("helpIdUrl", localePath + "/" + url);
+ gen.generate(env, f);
+ touchedFiles++;
+ }
+ return touchedFiles;
+ }
+
+ protected boolean generateHelpsetFile(File file, Properties env) throws Exception {
+
+ if (file.exists()) {
+ // check the autoremove line presence
+ String content = FileUtil.readAsString(file);
+ if (!content.contains(AUTOREMOVE_LINE)) {
+ // no regenerate marker detected, so skip this file
+ if (verbose) {
+ getLog().info("skip existing helpset main file " + file);
+ }
+ return false;
+ }
+ }
+
+ if (verbose) {
+ if (file.exists()) {
+ getLog().info("regenerate helpset main file " + file);
+ } else {
+ getLog().info("generate helpset main file " + file);
+ }
+ }
+ doGen(helpsetTemplate, file, env);
+ return true;
+ }
+
+ protected Properties generateMapFile(File file, Properties env) throws Exception {
+
+ boolean create;
+
+ Properties mergedHelpIds = null;
+ if (file.exists()) {
+
+ // get back the exisiting data and merge it with incoming ones
+
+ if (verbose) {
+ getLog().info("loading existing helpset map file " + file);
+ }
+
+ mergedHelpIds = XmlHelper.getExistingHelpIds(file, verbose, getLog());
+ create = false;
+
+ } else {
+
+ mergedHelpIds = new SortedProperties();
+ create = true;
+ }
+
+ // inject new helpIds
+
+ for (Object k : helpIds.keySet()) {
+ mergedHelpIds.put(k, helpsetName + "/" + helpIds.get(k));
+ }
+
+ if (!mergedHelpIds.contains("top")) {
+
+ // on ajoute une entree vers le root du helpset
+
+ String topUrl = helpsetName + ".html";
+ helpIds.put("top", topUrl);
+ mergedHelpIds.put("top", helpsetName + "/" + topUrl);
+ if (verbose) {
+ getLog().debug("add top entry with url " + topUrl);
+ }
+ }
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate helpset map file " + file);
+ } else {
+ getLog().info("udpate helpset map file " + file);
+ }
+ }
+
+ env.put("helpIds", mergedHelpIds);
+ doGen(mapTemplate, file, env);
+ env.remove("helpIds");
+ return mergedHelpIds;
+ }
+
+ protected NodeItem generateIndexFile(File file, Properties env) throws Exception {
+ NodeItem rootItem = null;
+
+ boolean create;
+
+ if (file.exists()) {
+
+ create = false;
+
+ rootItem = XmlHelper.getExistingItems("indexitem", file);
+ } else {
+ create = true;
+ }
+
+ if (rootItem == null) {
+ rootItem = new NodeItem("top", helpsetName);
+ }
+
+ // inject new index entries
+
+ for (Object k : helpIds.keySet()) {
+ NodeItem toc = rootItem.findChild(k + "");
+ if (verbose) {
+ getLog().debug("index " + k + " : " + toc);
+ }
+ }
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate helpset index file " + file);
+ } else {
+ getLog().info("udpate helpset index file " + file);
+ }
+ }
+
+ env.put("rootItem", rootItem);
+ doGen(indexTemplate, file, env);
+ env.remove("rootItem");
+ return rootItem;
+ }
+
+ protected NodeItem generateTocFile(File file, Properties env) throws Exception {
+ NodeItem rootItem = null;
+
+ boolean create;
+
+ if (file.exists()) {
+
+ create = false;
+
+ rootItem = XmlHelper.getExistingItems("tocitem", file);
+ } else {
+ create = true;
+ }
+
+ if (rootItem == null) {
+ rootItem = new NodeItem("top", helpsetName);
+ }
+ // inject new toc entries
+
+ for (Object k : helpIds.keySet()) {
+ NodeItem toc = rootItem.findChild(k + "");
+ if (verbose) {
+ getLog().debug("toc " + k + " : " + toc);
+ }
+ }
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate helpset toc file " + file);
+ } else {
+ getLog().info("udpate helpset toc file " + file);
+ }
+ }
+
+ env.put("rootItem", rootItem);
+ doGen(tocTemplate, file, env);
+ env.remove("rootItem");
+ return rootItem;
+ }
+
+ protected void doGen(File template, File f, Properties env) throws Exception {
+ TemplateGenerator gen = prepareGenerator(template);
+ gen.generate(env, f);
+ }
+
+ protected TemplateGenerator prepareGenerator(File template) throws Exception {
+ URL templateURL = getTemplate(template);
+
+ if (verbose) {
+ getLog().info("using template " + templateURL);
+ }
+ TemplateGenerator gen = new TemplateGenerator(project, templateURL);
+ return gen;
+ }
+}
Copied: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java (from rev 1567, branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java)
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,683 @@
+/* *##%
+ * Copyright (C) 2007
+ * JaxxPlugin, Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+package org.nuiton.jaxx.plugin;
+
+import jaxx.compiler.CompilerConfiguration;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.beans.BeanInfoUtil;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
+import jaxx.compiler.tags.TagManager;
+import jaxx.runtime.JAXXContext;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+import org.nuiton.io.FileUpdaterHelper;
+import org.nuiton.io.MirroredFileUpdater;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Map;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import jaxx.runtime.swing.help.JAXXHelpBroker;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ * Generates some java code from jaxx files.
+ *
+ * @author chemit
+ * @goal generate
+ * @phase process-sources
+ * @requiresDependencyResolution compile
+ * @requiresProject
+ */
+public class GenerateMojo extends AbstractJaxxMojo implements CompilerConfiguration {
+
+ /**
+ * Default includes to use, if none provided
+ */
+ private static final String[] INCLUDES = {"**\\/*.jaxx"};
+ /**
+ * Repertoire sources des fichiers jaxx a generer.
+ *
+ * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java"
+ */
+ protected File src;
+ /**
+ * Repertoire de destination des fichiers java a generer.
+ *
+ * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
+ */
+ protected File outJava;
+ /**
+ * pour filter les fichiers a traiter
+ *
+ * @parameter expression="${jaxx.includes}"
+ */
+ protected String[] includes;
+ /**
+ * pour filter les fichiers a ne pas traiter
+ *
+ * @parameter expression="${jaxx.excludes}"
+ */
+ protected String[] excludes;
+ /**
+ * Le compilateur à utiliser (par défaut celui de Swing)
+ *
+ * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.JAXXCompiler"
+ */
+ protected String compilerFQN;
+ /**
+ * Le compilateur à utiliser (par défaut celui de Swing)
+ *
+ * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
+ */
+ protected String validatorFQN;
+ /**
+ * the name of implementation of {@link jaxx.runtime.JAXXContext}
+ * to be used on {@link jaxx.runtime.JAXXObject}.
+ * <p/>
+ * Must not be abstract.
+ *
+ * @parameter expression="${jaxx.jaxxContextFQN}" default-value="jaxx.runtime.context.DefaultJAXXContext"
+ * @required
+ */
+ protected String jaxxContextFQN;
+ /**
+ * the FQN of the ui to use for error notification.
+ * <p/>
+ * If not given, will use the one defined in validator
+ *
+ * @parameter expression="${jaxx.defaultErrorUIFQN}"
+ */
+ protected String defaultErrorUIFQN;
+ /**
+ * the FQN of the ui to use for error notification.
+ * <p/>
+ * If not given, will use the one defined in validator
+ *
+ * @parameter expression="${jaxx.defaultDecoratorFQN}" default-value="jaxx.compiler.decorators.DefaultCompiledObjectDecorator"
+ *
+ * @see jaxx.compiler.decorators.CompiledObjectDecorator
+ */
+ protected String defaultDecoratorFQN;
+ /**
+ * flag to include in compiler classpath the java sources directories (src and outJava).
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addSourcesToClassPath}" default-value="false"
+ */
+ protected boolean addSourcesToClassPath;
+ /**
+ * flag to include in compiler classpath the java resources directories (src and outJava).
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addResourcesToClassPath}" default-value="false"
+ * @since 1.6.0
+ */
+ protected boolean addResourcesToClassPath;
+ /**
+ * flag to include in compiler classpath the compile class-path (can only be used in a test phase).
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addCompileClassPath}" default-value="false"
+ * @since 1.6.0
+ */
+ protected boolean addCompileClassPath;
+ /**
+ * flag to include in compiler classpath the project compile classpath.
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addProjectClassPath}" default-value="false"
+ */
+ protected boolean addProjectClassPath;
+ /**
+ * to force generation of java source for any jaxx files with no timestamp checking.
+ * <p/>
+ * By default, never force generation.
+ *
+ * @parameter expression="${jaxx.force}" default-value="false"
+ */
+ protected boolean force;
+ /**
+ * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots.
+ *
+ * @parameter expression="${jaxx.testPhase}" default-value="false"
+ * @since 1.6.0
+ */
+ protected boolean testPhase;
+ /**
+ * to make compiler i18nable, says add the {@link org.nuiton.i18n.I18n#_(String, Object[])} method
+ * invocation on {@link jaxx.compiler.I18nHelper#I18N_ATTRIBUTES} attributes.
+ *
+ * @parameter expression="${jaxx.i18nable}" default-value="true"
+ * @see jaxx.compiler.I18nHelper
+ */
+ protected boolean i18nable;
+ /**
+ * pour optimizer le code compile ou genere ?
+ *
+ * @parameter expression="${jaxx.optimize}" default-value="false"
+ */
+ protected boolean optimize;
+ /**
+ * flag to add logger to each generated jaxx file.
+ * <p/>
+ * By default, always add it.
+ *
+ * @parameter expression="${jaxx.addLogger}" default-value="true"
+ */
+ protected boolean addLogger;
+ /**
+ * flag to keep compilers after the generate operation (usefull for tests.
+ * <p/>
+ * By default, always reset.
+ *
+ * @parameter expression="${jaxx.resetAfterCompile}" default-value="true"
+ */
+ protected boolean resetAfterCompile;
+ /**
+ * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(java.lang.String[])}.
+ * <p/>
+ * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String[])}
+ * <p/>
+ * and then will be use by {@link jaxx.compiler.spi.DefaultInitializer#initialize()}.
+ * <p/>
+ * <p/>
+ * This permit to use real beanInfo of imported graphic libraries.
+ *
+ * @parameter expression="${jaxx.beanInfoSearchPath}"
+ */
+ protected String[] beanInfoSearchPath;
+ /**
+ * list of fqn of class toimport for all generated jaxx files
+ *
+ * @parameter expression="${jaxx.extraImportList}"
+ */
+ protected String extraImportList;
+ /**
+ * a flag to use UIManager to retreave icons.
+ *
+ * @parameter expression="${jaxx.useUIManagerForIcon}" default-value="false"
+ */
+ protected boolean useUIManagerForIcon;
+ /**
+ * flag to activate profile mode.
+ * <p/>
+ * By default, not active.
+ *
+ * @parameter expression="${jaxx.profile}" default-value="false"
+ */
+ protected boolean profile;
+ /**
+ * flag to activate help generation process.
+ * <p/>
+ * By default, not active.
+ *
+ * @parameter expression="${jaxx.generateHelp}" default-value="false"
+ *
+ * @since 1.3
+ */
+ protected boolean generateHelp;
+ /**
+ * the FQN of help broker
+ * <p/>
+ * By default, use the JAXX implementation {@link JAXXHelpBroker}.
+ *
+ * @parameter expression="${jaxx.helpBrokerFQN}" default-value="jaxx.runtime.swing.help.JAXXHelpBroker"
+ *
+ * @since 1.3
+ */
+ protected String helpBrokerFQN;
+ /**
+ * detected jaxx files in {@link #init()} method
+ */
+ protected String[] files;
+ /**
+ * file updater used to detect jaxx files.
+ *
+ * <b>Note:</b> if {@link #verbose} flag is on, will ne be used
+ */
+ protected MirroredFileUpdater updater;
+ /**
+ *
+ */
+ private Class<?> defaultErrorUIClass;
+ /**
+ *
+ */
+ private Class<?> validatorClass;
+ /**
+ *
+ */
+ private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
+ /**
+ *
+ */
+ private Class<? extends JAXXContext> jaxxContextClass;
+ /**
+ *
+ */
+ private Class<? extends JAXXCompiler> compilerClass;
+ /**
+ *
+ */
+ private String[] extraImports;
+ /**
+ *
+ */
+ private boolean nofiles;
+ /**
+ *
+ */
+ protected ClassLoader cl;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init() throws Exception {
+
+ if (generateHelp) {
+ // check there is some bundle
+ if (getHelpIdsStore() == null) {
+ throw new MojoFailureException("you must set the 'helpIdStore' property.");
+ }
+ }
+
+ fixCompileSourceRoots();
+
+ if (includes == null || includes.length == 0) {
+ // use default includes
+ includes = INCLUDES;
+ }
+ updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
+
+ Map<File, String[]> result = new HashMap<File, String[]>();
+ getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
+
+ this.files = result.get(src);
+
+ nofiles = files == null || files.length == 0;
+ if (nofiles) {
+ return true;
+ }
+
+// if (addSourcesToClassPath || addProjectClassPath) {
+ cl = initClassLoader(project,
+ src,
+ addSourcesToClassPath,
+ testPhase,
+ addResourcesToClassPath,
+ addCompileClassPath,
+ addProjectClassPath);
+
+ Thread.currentThread().setContextClassLoader(cl);
+// } else {
+// cl = getClass().getClassLoader();
+ //cl = Thread.currentThread().getContextClassLoader();
+// }
+
+ compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
+ defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
+ jaxxContextClass = (Class<? extends JAXXContext>) Class.forName(jaxxContextFQN, false, cl);
+ if (!JAXXContext.class.isAssignableFrom(jaxxContextClass)) {
+ throw new MojoExecutionException("jaxxContextFQN must be an implementation of " + JAXXContext.class + " but was : " + jaxxContextClass);
+ }
+ validatorClass = Class.forName(validatorFQN, false, cl);
+
+ if (defaultErrorUIFQN != null && !defaultErrorUIFQN.trim().isEmpty()) {
+ defaultErrorUIClass = Class.forName(defaultErrorUIFQN, false, cl);
+ }
+
+ if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) {
+ // register extra path
+ BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
+ }
+
+ if (!outJava.exists()) {
+ outJava.mkdirs();
+ }
+
+ // compute extra imports (can not use java classes since some of
+ // imports can not be still compiled)
+ if (extraImportList != null && !extraImportList.isEmpty()) {
+ String[] imports = extraImportList.split(",");
+ int i = 0;
+ for (String importS : imports) {
+ imports[i++] = importS.trim();
+ }
+ if (verbose) {
+ getLog().info("extra imports " + java.util.Arrays.toString(imports));
+ }
+ extraImports = imports;
+ }
+
+ if (verbose) {
+ printInit();
+ }
+ return true;
+ }
+
+ @Override
+ public void doAction() throws MojoExecutionException {
+
+ if (nofiles) {
+ getLog().info("No files to treate.");
+ return;
+ }
+
+ getLog().info("Detects " + files.length + " modify jaxx file(s). ");
+
+ try {
+
+ // force compiler init from here, not in a static block
+ TagManager.reset(verbose);
+
+ JAXXCompilerLaunchor launchor;
+ launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
+ boolean success = launchor.compile();
+ getLog().info("Generated " + launchor.getCompilerCount() + " file(s). ");
+
+ if (!success) {
+ throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
+ }
+
+ if (generateHelp) {
+ // generate help
+ generateHelp();
+ }
+
+ } catch (MojoExecutionException e) {
+ getLog().error(e);
+ throw e;
+ } catch (Exception e) {
+ //getLog().error(e);
+ Throwable e2 = e;
+ while (e2.getCause() != null) {
+ e2 = e.getCause();
+ }
+ getLog().error(e2);
+
+ throw new MojoExecutionException(e2.getMessage(), e2);
+ }
+ }
+
+ @Override
+ public File getTargetDirectory() {
+ return outJava;
+ }
+
+ @Override
+ public boolean getOptimize() {
+ return optimize;
+ }
+
+ @Override
+ public boolean isI18nable() {
+ return i18nable;
+ }
+
+ @Override
+ public boolean isUseUIManagerForIcon() {
+ return useUIManagerForIcon;
+ }
+
+ @Override
+ public boolean isAddLogger() {
+ return addLogger;
+ }
+
+ @Override
+ public Class<? extends JAXXContext> getJaxxContextClass() {
+ return jaxxContextClass;
+ }
+
+ @Override
+ public String[] getExtraImports() {
+ return extraImports;
+ }
+
+ @Override
+ public boolean isResetAfterCompile() {
+ return resetAfterCompile;
+ }
+
+ @Override
+ public boolean isOptimize() {
+ return optimize;
+ }
+
+ @Override
+ public Class<?> getDefaultErrorUI() {
+ return defaultErrorUIClass;
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ return cl;
+ }
+
+ @Override
+ public Class<? extends JAXXCompiler> getCompilerClass() {
+ return compilerClass;
+ }
+
+ @Override
+ public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() {
+ return defaultDecoratorClass;
+ }
+
+ @Override
+ public boolean isProfile() {
+ return profile;
+ }
+
+ @Override
+ public boolean isGenerateHelp() {
+ return generateHelp;
+ }
+
+ @Override
+ public String getHelpBrokerFQN() {
+ return helpBrokerFQN;
+ }
+
+ @Override
+ public Class<?> getValidatorClass() {
+ return validatorClass;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+
+ protected void fixCompileSourceRoots() {
+ if (project == null) {
+ // no project defined, can not fix anything
+ // this case could appears if we wanted to do some tests of the plugin
+ return;
+ }
+
+ if (testPhase) {
+ if (!project.getTestCompileSourceRoots().contains(
+ outJava.getPath())) {
+ getLog().info("Add test compile source root : " + outJava);
+ project.addTestCompileSourceRoot(outJava.getPath());
+ }
+ } else {
+ if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
+ getLog().info("Add compile source root : " + outJava);
+ project.addCompileSourceRoot(outJava.getPath());
+ }
+ }
+ }
+
+ protected void printInit() {
+ getLog().info(toString());
+ getLog().info("includes : " + Arrays.toString(includes));
+ for (String file : files) {
+ getLog().info("will generate " + file);
+ }
+
+ ClassLoader threadLoader = Thread.currentThread().getContextClassLoader();
+ getLog().info(threadLoader.toString());
+ if (threadLoader.getClass().getSimpleName().equals("RealmClassLoader")) {
+ try {
+ java.lang.reflect.Method m = threadLoader.getClass().getDeclaredMethod("getURLs");
+ m.setAccessible(true);
+ URL[] urls = (URL[]) m.invoke(threadLoader);
+
+ for (URL url : urls) {
+ getLog().info("url in class loader " + url);
+ }
+ } catch (Exception e) {
+ getLog().warn("??? : " + e.getMessage(), e);
+ }
+ }
+ }
+
+ protected void generateHelp() throws IOException {
+ Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
+ if (helpIds.isEmpty()) {
+ if (verbose) {
+ // no ids detected in this compilation round
+ getLog().info("no helpIds detected.");
+ }
+ return;
+ }
+ File idsStore = getHelpIdsStore();
+
+ if (!idsStore.getParentFile().exists()) {
+ idsStore.getParentFile().mkdirs();
+ }
+
+ Properties p = new Properties();
+
+ for (String helpId : helpIds) {
+ String path = helpId.replaceAll("\\.", File.separator);
+ path = removeQuote(path) + ".html";
+ p.put(removeQuote(helpId), path);
+ }
+
+ FileOutputStream w = new FileOutputStream(idsStore);
+
+ try {
+ p.store(w, null);
+ } finally {
+ w.close();
+ }
+
+ getLog().info("helpIdStore generated in " + idsStore);
+
+ helpIds.clear();
+ }
+
+ //TODO use the AbstractPublig method
+ @SuppressWarnings({"unchecked"})
+ protected URLClassLoader initClasLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
+ URLClassLoader loader = null;
+ if (project != null) {
+
+ URLClassLoader result;
+ try {
+
+ List<URL> lUrls = new ArrayList<URL>();
+ List<String> sources = project.getCompileSourceRoots();
+
+ if (addSourcesToClassPath) {
+ for (String source : sources) {
+ lUrls.add(new File(source).toURI().toURL());
+ }
+ if (testPhase) {
+ for (Object source : project.getTestCompileSourceRoots()) {
+ lUrls.add(new File(source.toString()).toURI().toURL());
+ }
+ }
+ }
+ if (addResourcesToClassPath) {
+ for (Object source : project.getResources()) {
+ Resource r = (Resource) source;
+ lUrls.add(new File(r.getDirectory()).toURI().toURL());
+ }
+ }
+ if (testPhase && addCompileClassPath) {
+ if (project != null) {
+ lUrls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
+ }
+ }
+ if (addProjectClassPath) {
+ getLog().info("use project compile scope class-path");
+ // add also all dependencies of the project in compile scope
+ Set<?> artifacts = project.getArtifacts();
+ for (Object o : artifacts) {
+ Artifact a = (Artifact) o;
+ lUrls.add(a.getFile().toURI().toURL());
+ }
+ }
+
+ result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
+
+ } catch (IOException e) {
+ throw new RuntimeException("Can't create ClassLoader for reason " + e.getMessage(), e);
+ }
+ loader = result;
+ } else {
+ List<URL> lUrls = new ArrayList<URL>();
+ if (addSourcesToClassPath) {
+ lUrls.add(src.toURI().toURL());
+ }
+ loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
+ }
+ if (verbose) {
+ for (URL entry : loader.getURLs()) {
+ log.info("classpath : " + entry);
+ }
+ }
+ return loader;
+ }
+
+ protected String removeQuote(String txt) {
+ if (txt.startsWith("\"")) {
+ txt = txt.substring(1);
+ }
+ if (txt.endsWith("\"")) {
+ txt = txt.substring(0, txt.length() - 1);
+ }
+ return txt;
+ }
+}
Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,688 +0,0 @@
-/* *##%
- * Copyright (C) 2007
- * JaxxPlugin, Code Lutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-package org.nuiton.jaxx.plugin;
-
-import jaxx.compiler.CompilerConfiguration;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.JAXXCompilerLaunchor;
-import jaxx.compiler.beans.BeanInfoUtil;
-import jaxx.compiler.decorators.CompiledObjectDecorator;
-import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
-import jaxx.compiler.tags.TagManager;
-import jaxx.runtime.JAXXContext;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-
-import org.nuiton.io.FileUpdaterHelper;
-import org.nuiton.io.MirroredFileUpdater;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.Map;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-/**
- * Generates some java code from jaxx files.
- *
- * @author chemit
- * @goal generate
- * @phase process-sources
- * @requiresDependencyResolution compile
- * @requiresProject
- */
-public class JaxxGeneratorMojo extends AbstractJaxxMojo implements CompilerConfiguration {
-
- /**
- * Default includes to use, if none provided
- */
- private static final String[] INCLUDES = {"**\\/*.jaxx"};
- /**
- * Repertoire sources des fichiers jaxx a generer.
- *
- * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java"
- */
- protected File src;
- /**
- * pour filter les fichiers a traiter
- *
- * @parameter expression="${jaxx.includes}"
- */
- protected String[] includes;
- /**
- * pour filter les fichiers a ne pas traiter
- *
- * @parameter expression="${jaxx.excludes}"
- */
- protected String[] excludes;
- /**
- * Le compilateur à utiliser (par défaut celui de Swing)
- *
- * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.JAXXCompiler"
- */
- protected String compilerFQN;
- /**
- * Le compilateur à utiliser (par défaut celui de Swing)
- *
- * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
- */
- protected String validatorFQN;
- /**
- * the name of implementation of {@link jaxx.runtime.JAXXContext}
- * to be used on {@link jaxx.runtime.JAXXObject}.
- * <p/>
- * Must not be abstract.
- *
- * @parameter expression="${jaxx.jaxxContextFQN}" default-value="jaxx.runtime.context.DefaultJAXXContext"
- * @required
- */
- protected String jaxxContextFQN;
- /**
- * the FQN of the ui to use for error notification.
- * <p/>
- * If not given, will use the one defined in validator
- *
- * @parameter expression="${jaxx.defaultErrorUIFQN}"
- */
- protected String defaultErrorUIFQN;
- /**
- * the FQN of the ui to use for error notification.
- * <p/>
- * If not given, will use the one defined in validator
- *
- * @parameter expression="${jaxx.defaultDecoratorFQN}" default-value="jaxx.compiler.decorators.DefaultCompiledObjectDecorator"
- *
- * @see jaxx.compiler.decorators.CompiledObjectDecorator
- */
- protected String defaultDecoratorFQN;
- /**
- * flag to include in compiler classpath the java sources directories (src and outJava).
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addSourcesToClassPath}" default-value="false"
- */
- protected boolean addSourcesToClassPath;
- /**
- * flag to include in compiler classpath the java resources directories (src and outJava).
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addResourcesToClassPath}" default-value="false"
- * @since 1.6.0
- */
- protected boolean addResourcesToClassPath;
- /**
- * flag to include in compiler classpath the compile class-path (can only be used in a test phase).
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addCompileClassPath}" default-value="false"
- * @since 1.6.0
- */
- protected boolean addCompileClassPath;
- /**
- * flag to include in compiler classpath the project compile classpath.
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addProjectClassPath}" default-value="false"
- */
- protected boolean addProjectClassPath;
- /**
- * to force generation of java source for any jaxx files with no timestamp checking.
- * <p/>
- * By default, never force generation.
- *
- * @parameter expression="${jaxx.force}" default-value="false"
- */
- protected boolean force;
- /**
- * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots.
- *
- * @parameter expression="${jaxx.testPhase}" default-value="false"
- * @since 1.6.0
- */
- protected boolean testPhase;
- /**
- * pour optimizer le code compile ou genere ?
- *
- * @parameter expression="${jaxx.optimize}" default-value="false"
- */
- protected boolean optimize;
- /**
- * flag to add logger to each generated jaxx file.
- * <p/>
- * By default, always add it.
- *
- * @parameter expression="${jaxx.addLogger}" default-value="true"
- */
- protected boolean addLogger;
- /**
- * flag to keep compilers after the generate operation (usefull for tests.
- * <p/>
- * By default, always reset.
- *
- * @parameter expression="${jaxx.resetAfterCompile}" default-value="true"
- */
- protected boolean resetAfterCompile;
- /**
- * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(java.lang.String[])}.
- * <p/>
- * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String[])}
- * <p/>
- * and then will be use by {@link jaxx.compiler.spi.DefaultInitializer#initialize()}.
- * <p/>
- * <p/>
- * This permit to use real beanInfo of imported graphic libraries.
- *
- * @parameter expression="${jaxx.beanInfoSearchPath}"
- */
- protected String[] beanInfoSearchPath;
- /**
- * list of fqn of class toimport for all generated jaxx files
- *
- * @parameter expression="${jaxx.extraImportList}"
- */
- protected String extraImportList;
- /**
- * a flag to use UIManager to retreave icons.
- *
- * @parameter expression="${jaxx.useUIManagerForIcon}" default-value="false"
- */
- protected boolean useUIManagerForIcon;
- /**
- * flag to activate profile mode.
- * <p/>
- * By default, not active.
- *
- * @parameter expression="${jaxx.profile}" default-value="false"
- */
- protected boolean profile;
- /**
- * flag to activate help generation process.
- * <p/>
- * By default, not active.
- *
- * @parameter expression="${jaxx.generateHelp}" default-value="false"
- *
- * @since 1.3
- */
- protected boolean generateHelp;
- /**
- * the FQN of help broker
- * <p/>
- * By default, none.
- *
- * @parameter expression="${jaxx.helpBrokerFQN}"
- *
- * @since 1.3
- */
- protected String helpBrokerFQN;
- /**
- * detected jaxx files in {@link #init()} method
- */
- protected String[] files;
- /**
- * file updater used to detect jaxx files.
- *
- * <b>Note:</b> if {@link #verbose} flag is on, will ne be used
- */
- protected MirroredFileUpdater updater;
- /**
- *
- */
- private Class<?> defaultErrorUIClass;
- /**
- *
- */
- private Class<?> validatorClass;
- /**
- *
- */
- private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
- /**
- *
- */
- private Class<? extends JAXXContext> jaxxContextClass;
- /**
- *
- */
- private Class<? extends JAXXCompiler> compilerClass;
- /**
- *
- */
- private String[] extraImports;
- /**
- *
- */
- private boolean nofiles;
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean init() throws Exception {
-
- if (generateHelp) {
- // check there is some bundle
- if (helpIdStore == null) {
- throw new MojoFailureException("you must set the helpIdStore property.");
- }
- }
-
- fixCompileSourceRoots();
-
- if (includes == null || includes.length == 0) {
- // use default includes
- includes = INCLUDES;
- }
- updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
-
- Map<File, String[]> result = new HashMap<File, String[]>();
- getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
-
- this.files = result.get(src);
-
- nofiles = files == null || files.length == 0;
- if (nofiles) {
- return true;
- }
-
-// if (addSourcesToClassPath || addProjectClassPath) {
- cl = initClassLoader(project,
- src,
- addSourcesToClassPath,
- testPhase,
- addResourcesToClassPath,
- addCompileClassPath,
- addProjectClassPath);
-
- Thread.currentThread().setContextClassLoader(cl);
-// } else {
-// cl = getClass().getClassLoader();
- //cl = Thread.currentThread().getContextClassLoader();
-// }
-
- compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
- defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
- jaxxContextClass = (Class<? extends JAXXContext>) Class.forName(jaxxContextFQN, false, cl);
- if (!JAXXContext.class.isAssignableFrom(jaxxContextClass)) {
- throw new MojoExecutionException("jaxxContextFQN must be an implementation of " + JAXXContext.class + " but was : " + jaxxContextClass);
- }
- validatorClass = Class.forName(validatorFQN, false, cl);
-
- if (defaultErrorUIFQN != null && !defaultErrorUIFQN.trim().isEmpty()) {
- defaultErrorUIClass = Class.forName(defaultErrorUIFQN, false, cl);
- }
-
- if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) {
- // register extra path
- BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
- }
-
- if (!outJava.exists()) {
- outJava.mkdirs();
- }
-
- // compute extra imports (can not use java classes since some of
- // imports can not be still compiled)
- if (extraImportList != null && !extraImportList.isEmpty()) {
- String[] imports = extraImportList.split(",");
- int i = 0;
- for (String importS : imports) {
- imports[i++] = importS.trim();
- }
- if (verbose) {
- getLog().info("extra imports " + java.util.Arrays.toString(imports));
- }
- extraImports = imports;
- }
-
- if (verbose) {
- printInit();
- }
- return true;
- }
-
- @Override
- public void doAction() throws MojoExecutionException {
-
- if (nofiles) {
- getLog().info("No files to treate.");
- return;
- }
-
- getLog().info("Detects " + files.length + " modify jaxx file(s). ");
-
- try {
-
- // force compiler init from here, not in a static block
- TagManager.reset(verbose);
-
- JAXXCompilerLaunchor launchor;
- launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
- boolean success = launchor.compile();
- getLog().info("Generated " + launchor.getCompilerCount() + " file(s). ");
-
- if (!success) {
- throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
- }
-
- if (generateHelp) {
- // generate help
- generateHelp();
- }
-
- } catch (MojoExecutionException e) {
- getLog().error(e);
- throw e;
- } catch (Exception e) {
- //getLog().error(e);
- Throwable e2 = e;
- while (e2.getCause() != null) {
- e2 = e.getCause();
- }
- getLog().error(e2);
-
- throw new MojoExecutionException(e2.getMessage(), e2);
- }
- }
-
- @Override
- public File getTargetDirectory() {
- return outJava;
- }
-
- @Override
- public boolean getOptimize() {
- return optimize;
- }
-
- @Override
- public boolean isI18nable() {
- return i18nable;
- }
-
- @Override
- public boolean isUseUIManagerForIcon() {
- return useUIManagerForIcon;
- }
-
- @Override
- public boolean isAddLogger() {
- return addLogger;
- }
-
- @Override
- public Class<? extends JAXXContext> getJaxxContextClass() {
- return jaxxContextClass;
- }
-
- @Override
- public String[] getExtraImports() {
- return extraImports;
- }
-
- @Override
- public boolean isResetAfterCompile() {
- return resetAfterCompile;
- }
-
- @Override
- public boolean isOptimize() {
- return optimize;
- }
-
- @Override
- public Class<?> getDefaultErrorUI() {
- return defaultErrorUIClass;
- }
-
- @Override
- public ClassLoader getClassLoader() {
- return cl;
- }
-
- @Override
- public Class<? extends JAXXCompiler> getCompilerClass() {
- return compilerClass;
- }
-
- @Override
- public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() {
- return defaultDecoratorClass;
- }
-
- @Override
- public boolean isProfile() {
- return profile;
- }
-
- @Override
- public boolean isGenerateHelp() {
- return generateHelp;
- }
-
- @Override
- public String getHelpBrokerFQN() {
- return helpBrokerFQN;
- }
-
- @Override
- public String getHelpsetIndexI18nSuffix() {
- return helpsetIndexI18nSuffix;
- }
-
- @Override
- public String getHelpsetTitleI18nSuffix() {
- return helpsetTitleI18nSuffix;
- }
-
- @Override
- public String getHelpsetTocI18nSuffix() {
- return helpsetTocI18nSuffix;
- }
-
- @Override
- public String getHelpSetName() {
- return helpSetName;
- }
-
- @Override
- public String getHelpsetI18nPrefix() {
- return helpsetI18nPrefix;
- }
-
- @Override
- public Class<?> getValidatorClass() {
- return validatorClass;
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
- }
-
- protected void fixCompileSourceRoots() {
- if (project == null) {
- // no project defined, can not fix anything
- // this case could appears if we wanted to do some tests of the plugin
- return;
- }
-
- if (testPhase) {
- if (!project.getTestCompileSourceRoots().contains(
- outJava.getPath())) {
- getLog().info("Add test compile source root : " + outJava);
- project.addTestCompileSourceRoot(outJava.getPath());
- }
- } else {
- if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
- getLog().info("Add compile source root : " + outJava);
- project.addCompileSourceRoot(outJava.getPath());
- }
- }
- }
-
- protected void printInit() {
- getLog().info(toString());
- getLog().info("includes : " + Arrays.toString(includes));
- for (String file : files) {
- getLog().info("will generate " + file);
- }
-
- ClassLoader threadLoader = Thread.currentThread().getContextClassLoader();
- getLog().info(threadLoader.toString());
- if (threadLoader.getClass().getSimpleName().equals("RealmClassLoader")) {
- try {
- java.lang.reflect.Method m = threadLoader.getClass().getDeclaredMethod("getURLs");
- m.setAccessible(true);
- URL[] urls = (URL[]) m.invoke(threadLoader);
-
- for (URL url : urls) {
- getLog().info("url in class loader " + url);
- }
- } catch (Exception e) {
- getLog().warn("??? : " + e.getMessage(), e);
- }
- }
- }
-
- protected void generateHelp() throws IOException {
- Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
- if (helpIds.isEmpty()) {
- if (verbose) {
- // no ids detected in this compilation round
- getLog().info("no helpIds detected.");
- }
- return;
- }
-
- if (!helpIdStore.getParentFile().exists()) {
- helpIdStore.getParentFile().mkdirs();
- }
-
- Properties p = new Properties();
-
- for (String helpId : helpIds) {
- String path = helpId.replaceAll("\\.", File.separator);
- path = removeQuote(path) + ".html";
- p.put(removeQuote(helpId), path);
- }
-
- FileOutputStream w = new FileOutputStream(helpIdStore);
-
- try {
- p.store(w, null);
- } finally {
- w.close();
- }
-
- getLog().info("helpIdStore generated in " + helpIdStore);
-
- helpIds.clear();
- }
-
- //TODO use the AbstractPublig method
- @SuppressWarnings({"unchecked"})
- protected URLClassLoader initClasLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
- URLClassLoader loader = null;
- if (project != null) {
-
- URLClassLoader result;
- try {
-
- List<URL> lUrls = new ArrayList<URL>();
- List<String> sources = project.getCompileSourceRoots();
-
- if (addSourcesToClassPath) {
- for (String source : sources) {
- lUrls.add(new File(source).toURI().toURL());
- }
- if (testPhase) {
- for (Object source : project.getTestCompileSourceRoots()) {
- lUrls.add(new File(source.toString()).toURI().toURL());
- }
- }
- }
- if (addResourcesToClassPath) {
- for (Object source : project.getResources()) {
- Resource r = (Resource) source;
- lUrls.add(new File(r.getDirectory()).toURI().toURL());
- }
- }
- if (testPhase && addCompileClassPath) {
- if (project != null) {
- lUrls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
- }
- }
- if (addProjectClassPath) {
- getLog().info("use project compile scope class-path");
- // add also all dependencies of the project in compile scope
- Set<?> artifacts = project.getArtifacts();
- for (Object o : artifacts) {
- Artifact a = (Artifact) o;
- lUrls.add(a.getFile().toURI().toURL());
- }
- }
-
- result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
-
- } catch (IOException e) {
- throw new RuntimeException("Can't create ClassLoader for reason " + e.getMessage(), e);
- }
- loader = result;
- } else {
- List<URL> lUrls = new ArrayList<URL>();
- if (addSourcesToClassPath) {
- lUrls.add(src.toURI().toURL());
- }
- loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
- }
- if (verbose) {
- for (URL entry : loader.getURLs()) {
- log.info("classpath : " + entry);
- }
- }
- return loader;
- }
-
- protected String removeQuote(String txt) {
- if (txt.startsWith("\"")) {
- txt = txt.substring(1);
- }
- if (txt.endsWith("\"")) {
- txt = txt.substring(0, txt.length() - 1);
- }
- return txt;
- }
-}
Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,780 +0,0 @@
-/* *##%
- * Copyright (C) 2007
- * JaxxPlugin, Code Lutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-package org.nuiton.jaxx.plugin;
-
-import org.apache.maven.plugin.MojoFailureException;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Stack;
-import org.apache.maven.model.Resource;
-import org.nuiton.i18n.I18n;
-import org.nuiton.util.FileUtil;
-import org.nuiton.util.SortedProperties;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Mojo to generate javax help stuff for your project.
- *
- * HelpIds should have been discovered by the JaxxMojo.
- *
- * @author chemit
- * @goal generate-help
- * @phase process-sources
- *
- * @requiresProject
- * @requiresDependencyResolution compile
- * @since 1.3
- */
-public class JaxxHelpGeneratorMojo extends AbstractJaxxMojo {
-
- /**
- * The directory where to generate javaHelp skeleton files.
- * <p/>
- * Is required if generateHelp is on.
- *
- * @parameter expression="${jaxx.helpTarget}" alias="target" default-value="${maven.src.dir}/main/help"
- * @required
- *
- * @since 1.3
- */
- protected File target;
- /**
- * The locale to generate for help.
- *
- * By default, stay in France.
- *
- * @parameter expression="${jaxx.locale}" default-value="fr"
- * @required
- *
- * @since 1.3
- */
- protected String locale;
- /**
- * The package where to generate i18n java file.
- *
- * @parameter expression="${jaxx.packageName}" default-value="${project.groupId}"
- * @required
- *
- * @since 1.3
- */
- protected String packageName;
- /**
- * The file name of the helpset to generate.
- *
- * @parameter expression="${jaxx.helpSetFileName}" default-value="${jaxx.helpSetName}.hs"
- * @required
- *
- * @since 1.3
- */
- protected String helpsetFileName;
- /**
- * The file name of the helpset map to generate.
- *
- * @parameter expression="${jaxx.mapFileName}" default-value="${jaxx.helpSetName}Map.jhm"
- * @required
- *
- * @since 1.3
- */
- protected String mapFileName;
- /**
- * The file name of the helpset index to generate.
- *
- * @parameter expression="${jaxx.indexFileName}" default-value="${jaxx.helpSetName}Index.xml"
- * @required
- *
- * @since 1.3
- */
- protected String indexFileName;
- /**
- * The file name of the helpset toc to generate.
- *
- * @parameter expression="${jaxx.tocFileName}" default-value="${jaxx.helpSetName}TOC.xml"
- * @required
- *
- * @since 1.3
- */
- protected String tocFileName;
- /**
- * The file name of the i18n java file to generate.
- *
- * @parameter expression="${jaxx.i8nFileName}" default-value="${jaxx.helpSetName}I18n.java"
- * @required
- *
- * @since 1.3
- */
- protected String i8nFileName;
- /**
- * The template used to generate helpset file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.helpSetTemplate}" default-value="/defaultHelpSet.hs.vm"
- * @required
- *
- * @since 1.3
- */
- protected File helpSetTemplate;
- /**
- * The template used to generate helpset map file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
- * @required
- *
- * @since 1.3
- */
- protected File mapTemplate;
- /**
- * The template used to generate helpset index file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
- * @required
- *
- * @since 1.3
- */
- protected File indexTemplate;
- /**
- * The template used to generate helpset toc file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
- * @required
- *
- * @since 1.3
- */
- protected File tocTemplate;
- /**
- * The template used to generate helpset content file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
- * @required
- *
- * @since 1.3
- */
- protected File contentTemplate;
- /**
- * The template used to generate helpset content file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.i18nTemplate}" default-value="/defaultI18n.java.vm"
- * @required
- *
- * @since 1.3
- */
- protected File i18nTemplate;
- /**
- * The help ids discovered by Jaxx compilation
- */
- protected Properties helpIds;
- private static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
-
- @Override
- public boolean init() throws Exception {
-
- if (!helpIdStore.exists()) {
- getLog().info("no helpIdStore to react at " + helpIdStore);
- return false;
- }
-
- // check there is some bundle
- if (locale == null) {
- throw new MojoFailureException("you must set the bundles property.");
- }
- // check there is some bundle
- if (target == null) {
- throw new MojoFailureException("you must set the target property.");
- }
- // check ressources
- checkResource(helpSetTemplate);
- checkResource(mapTemplate);
- checkResource(indexTemplate);
- checkResource(tocTemplate);
- checkResource(contentTemplate);
-
- if (!target.exists()) {
- getLog().info("mkdir " + target);
- target.mkdirs();
- }
-
- helpIds = new SortedProperties();
-
- InputStream stream = new FileInputStream(helpIdStore);
-
- helpIds.load(stream);
-
- stream.close();
-
- if (helpIds.isEmpty()) {
-
- // no ids detected
- getLog().warn("no helpIds detected, will skip.");
- return false;
- }
-
- return true;
- }
-
- @Override
- public void doAction() throws Exception {
-
- if (i18nable) {
-
- List<URL> lUrls = new java.util.ArrayList<URL>();
- List<?> resources = project.getResources();
- for (Object o : resources) {
- Resource resource = (Resource) o;
- lUrls.add(new File(resource.getDirectory()).toURI().toURL());
- }
- I18n.setExtraURL(lUrls.toArray(new URL[lUrls.size()]));
- I18n.init(locale, null);
- }
-
- File file;
-
- Properties env = new Properties();
-
- env.put("helpSetName", helpSetName);
- env.put("helpSetFileName", helpsetFileName);
- env.put("mapFileName", mapFileName);
- env.put("indexFileName", indexFileName);
- env.put("tocFileName", tocFileName);
- env.put("separator", " ");
- env.put("autoremoveLine", AUTOREMOVE_LINE);
-
-
- int touchedFiles = 0;
-
- // ---------------------------------------------------------------
- // --- main helpset file -----------------------------------------
- // ---------------------------------------------------------------
-
-
- file = new File(target, helpsetFileName);
-
- boolean doCreate = generateHelSetFile(file, env);
-
- if (doCreate) {
- touchedFiles++;
- }
-
- // ---------------------------------------------------------------
- // --- helpset map file ------------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(target, mapFileName);
-
- Properties mergedHelpIds = generateMapFile(file, env);
- touchedFiles++;
-
- // ---------------------------------------------------------------
- // --- helpset index file ----------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(target, indexFileName);
-
- NodeItem indexRootItem = generateIndexFile(file, env);
- touchedFiles++;
-
- // ---------------------------------------------------------------
- // --- helpset toc file ------------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(target, tocFileName);
-
- NodeItem tocRootItem = generateTocFile(file, env);
- touchedFiles++;
-
- // ---------------------------------------------------------------
- // --- helpset content files -------------------------------------
- // ---------------------------------------------------------------
-
- TemplateGenerator gen = prepareGenerator(contentTemplate);
-
- Enumeration<?> keys = helpIds.keys();
-
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- String url = (String) helpIds.get(key);
- url = helpSetName + File.separator + url;
-
- File f = new File(target, url);
-
- boolean exist = f.exists();
-
- if (exist) {
- // check if there is a autoremoveLine in content
- String content = FileUtil.readAsString(f);
- if (!content.contains(AUTOREMOVE_LINE)) {
- // no regenerate marker detected, so skip this file
- if (verbose) {
- getLog().debug("skip existing file " + f);
- }
- continue;
- }
- }
-
- f.getParentFile().mkdirs();
-
- if (verbose) {
- if (exist) {
- getLog().info("regenerate content file " + f);
- } else {
- getLog().info("generate content file " + f);
- }
- }
-
- env.put("helpId", key);
- String i18n = helpsetI18nPrefix + key + helpsetTitleI18nSuffix;
- env.put("helpIdTitle", _(i18n));
- env.put("helpIdUrl", url);
-
- gen.generate(env, f);
- touchedFiles++;
- }
-
- // ---------------------------------------------------------------
- // --- i18n file -------------------------------------------------
- // ---------------------------------------------------------------
-
- String path = packageName.replaceAll("\\.", File.separator);
- path += File.separator + i8nFileName;
- file = new File(outJava, path);
- generateI18nFile(file, env, mergedHelpIds, indexRootItem, tocRootItem);
- touchedFiles++;
-
- getLog().info(touchedFiles + " file(s) treated.");
- }
-
- protected void generateI18nFile(File file, Properties env, Properties mergedHelpIds, NodeItem indexRootItem, NodeItem tocRootItem) throws Exception {
-
- boolean create = !file.exists();
-
- if (!file.getParentFile().exists()) {
- file.getParentFile().mkdirs();
- }
-
- Set<String> keys = new java.util.HashSet<String>();
-
- for (Object k : mergedHelpIds.keySet()) {
- String key = helpsetI18nPrefix + k + helpsetTitleI18nSuffix;
- keys.add(key);
- }
- indexRootItem.extractI18n(keys, helpsetI18nPrefix, helpsetIndexI18nSuffix);
- tocRootItem.extractI18n(keys, helpsetI18nPrefix, helpsetTocI18nSuffix);
-
- env.put("keys", keys);
- env.put("packageName", packageName);
- String className = file.getName();
- int index = className.lastIndexOf(".");
- className = className.substring(0, index);
- env.put("className", className);
-
- if (verbose) {
- if (create) {
- getLog().info("generate i18n java file " + file);
- } else {
- getLog().info("udpate i18n java file " + file);
- }
- }
-
- doGen(i18nTemplate, file, env);
-
- }
-
- protected boolean generateHelSetFile(File file, Properties env) throws Exception {
-
- if (file.exists()) {
- // check the auto removeline presence
- String content = FileUtil.readAsString(file);
- if (!content.contains(AUTOREMOVE_LINE)) {
- // no regenerate marker detected, so skip this file
- if (verbose) {
- getLog().info("skip existing helpset main file " + file);
- }
- return false;
- }
- }
-
- if (verbose) {
- if (file.exists()) {
- getLog().info("regenerate helpset main file " + file);
- } else {
- getLog().info("generate helpset main file " + file);
- }
- }
- doGen(helpSetTemplate, file, env);
- return true;
- }
-
- protected Properties generateMapFile(File file, Properties env) throws Exception {
-
- boolean create;
-
- Properties mergedHelpIds = null;
- if (file.exists()) {
-
- // get back the exisiting data and merge it with incoming ones
-
- if (verbose) {
- getLog().info("loading existing helpset map file " + file);
- }
-
- mergedHelpIds = getExistingHelpIds(file);
- create = false;
-
- } else {
-
- mergedHelpIds = new SortedProperties();
- create = true;
- }
-
- // inject new helpIds
-
- for (Object k : helpIds.keySet()) {
- mergedHelpIds.put(k, helpSetName + "/" + helpIds.get(k));
- }
-
- if (!mergedHelpIds.contains("top")) {
- // on ajoute une entree vers le root du helpset
-
- String topUrl = helpSetName + ".html";
- helpIds.put("top", topUrl);
- mergedHelpIds.put("top", helpSetName + "/" + topUrl);
- if (verbose) {
- getLog().debug("add top entry with url " + topUrl);
- }
- }
-
- if (verbose) {
- if (create) {
- getLog().info("generate helpset map file " + file);
- } else {
- getLog().info("udpate helpset map file " + file);
- }
- }
-
- env.put("helpIds", mergedHelpIds);
- doGen(mapTemplate, file, env);
- env.remove("helpIds");
- return mergedHelpIds;
- }
-
- protected NodeItem generateIndexFile(File file, Properties env) throws Exception {
- NodeItem rootItem = null;
-
- boolean create;
-
- if (file.exists()) {
-
- create = false;
-
- rootItem = getExistingItems("indexitem", file);
- } else {
- create = true;
- }
-
- if (rootItem == null) {
- rootItem = new NodeItem("top", helpSetName);
- }
-
- // inject new index entries
-
- for (Object k : helpIds.keySet()) {
- NodeItem toc = rootItem.findChild(k + "");
- if (verbose) {
- getLog().debug("index " + k + " : " + toc);
- }
- }
-
- //String prefix = helpsetI18nPrefix;
- //String prefix = helpsetI18nPrefix + helpSetName + ".";
- rootItem.applyI18n(helpsetI18nPrefix, helpsetIndexI18nSuffix);
-
- if (verbose) {
- if (create) {
- getLog().info("generate helpset index file " + file);
- } else {
- getLog().info("udpate helpset index file " + file);
- }
- }
-
- env.put("rootItem", rootItem);
- doGen(indexTemplate, file, env);
- env.remove("rootItem");
- return rootItem;
- }
-
- protected NodeItem generateTocFile(File file, Properties env) throws Exception {
- NodeItem rootItem = null;
-
- boolean create;
-
- if (file.exists()) {
-
- create = false;
-
- rootItem = getExistingItems("tocitem", file);
- } else {
- create = true;
- }
-
- if (rootItem == null) {
- rootItem = new NodeItem("top", helpSetName);
- }
- // inject new toc entries
-
- for (Object k : helpIds.keySet()) {
- NodeItem toc = rootItem.findChild(k + "");
- if (verbose) {
- getLog().debug("toc " + k + " : " + toc);
- }
- }
-
- //String prefix = helpsetI18nPrefix + helpSetName + ".";
- rootItem.applyI18n(helpsetI18nPrefix, helpsetTocI18nSuffix);
-
- if (verbose) {
- if (create) {
- getLog().info("generate helpset toc file " + file);
- } else {
- getLog().info("udpate helpset toc file " + file);
- }
- }
-
- env.put("rootItem", rootItem);
- doGen(tocTemplate, file, env);
- env.remove("rootItem");
- return rootItem;
- }
-
- protected void doGen(File template, File f, Properties env) throws Exception {
- TemplateGenerator gen = prepareGenerator(template);
- gen.generate(env, f);
- }
-
- protected TemplateGenerator prepareGenerator(File template) throws Exception {
- URL templateURL = getTemplate(template);
-
- if (verbose) {
- getLog().info("using template " + templateURL);
- }
- TemplateGenerator gen = new TemplateGenerator(project, templateURL);
- return gen;
- }
-
-// protected URL getTemplate(File f) throws IOException {
-// URL r = null;
-// if (f.exists()) {
-// r = f.toURI().toURL();
-// } else {
-// r = getClass().getResource(f.toString());
-// }
-// return r;
-// }
-//
-// protected void checkResource(File f) throws MojoFailureException {
-// if (!f.exists()) {
-// // test in classPath
-// InputStream r = getClass().getResourceAsStream(f.toString());
-// if (r == null) {
-// throw new MojoFailureException("could not find ressource " + f);
-// }
-// }
-// }
- protected Properties getExistingHelpIds(File file) throws SAXException, IOException {
-
- final Properties result = new SortedProperties();
-
- XMLReader parser = XMLReaderFactory.createXMLReader();
-
- parser.setContentHandler(new ContentHandlerAdapter() {
-
- String target;
- String url;
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
- if ("mapID".equals(localName)) {
- target = atts.getValue("target");
- url = atts.getValue("url");
- if (verbose) {
- getLog().debug("detect map entry : " + target + " : " + url);
- }
- result.put(target, url);
- }
- }
- });
-
- InputStream s = new FileInputStream(file);
- try {
- parser.parse(new InputSource(s));
- } finally {
- s.close();
- }
- return result;
- }
-
- protected NodeItem getExistingItems(String tagName, File file) throws SAXException, IOException {
-
- XMLReader parser = XMLReaderFactory.createXMLReader();
- NodeItemHandler handler = new NodeItemHandler(tagName);
-
- parser.setContentHandler(handler);
-
- NodeItem rootItem = null;
- InputStream s = new FileInputStream(file);
- try {
- parser.parse(new InputSource(s));
- rootItem = handler.rootItem;
- } finally {
- s.close();
- }
- return rootItem;
- }
-
- static class NodeItemHandler extends ContentHandlerAdapter {
-
- NodeItem rootItem;
- NodeItem currentItem;
- final Stack<NodeItem> stack;
- final String tagName;
-
- public NodeItemHandler(String tagName) {
- this.tagName = tagName;
- this.stack = new Stack<NodeItem>();
- }
-
- @Override
- public void startDocument() throws SAXException {
- rootItem = new NodeItem("top", null);
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
- if (tagName.equals(localName)) {
-
- String target = atts.getValue("target");
- String text = atts.getValue("text");
-
- // debut d'un item
- if (currentItem == null) {
- // premier item
- if (rootItem.getTarget().equals(target)) {
- // le premier item est bien top
- //rootItem.setText(text);
- currentItem = rootItem;
- } else {
- // le premier noeud n'est pas top
- // en l'encapsule
- stack.push(rootItem);
- currentItem = new NodeItem(target, text);
- rootItem.addChild(currentItem);
- }
- } else {
- NodeItem newItem = new NodeItem(target, text);
- currentItem.addChild(newItem);
- currentItem = newItem;
- }
- currentItem.adjustTarget();
- stack.push(currentItem);
-
- }
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (tagName.equals(localName)) {
- // fin d'un item
- stack.pop();
- if (!stack.isEmpty()) {
- currentItem = stack.peek();
- }
- }
- }
- }
-
- static class ContentHandlerAdapter implements ContentHandler {
-
- @Override
- public void setDocumentLocator(Locator locator) {
- }
-
- @Override
- public void startDocument() throws SAXException {
- }
-
- @Override
- public void endDocument() throws SAXException {
- }
-
- @Override
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- }
-
- @Override
- public void endPrefixMapping(String prefix) throws SAXException {
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- }
-
- @Override
- public void characters(char[] ch, int start, int length) throws SAXException {
- }
-
- @Override
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- }
-
- @Override
- public void processingInstruction(String target, String data) throws SAXException {
- }
-
- @Override
- public void skippedEntity(String name) throws SAXException {
- }
- }
-}
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,187 @@
+package org.nuiton.jaxx.plugin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.Stack;
+import org.apache.maven.plugin.logging.Log;
+import org.nuiton.util.SortedProperties;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * To load {@link NodeItem} from xml.
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+public class XmlHelper {
+
+ public static Properties getExistingHelpIds(File file, final boolean verbose, final Log log) throws SAXException, IOException {
+
+ final Properties result = new SortedProperties();
+
+ XMLReader parser = XMLReaderFactory.createXMLReader();
+
+ parser.setContentHandler(new ContentHandlerAdapter() {
+
+ String target;
+ String url;
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ if ("mapID".equals(localName)) {
+ target = atts.getValue("target");
+ url = atts.getValue("url");
+ if (verbose) {
+ log.debug("detect map entry : " + target + " : " + url);
+ }
+ result.put(target, url);
+ }
+ }
+ });
+
+ InputStream s = new FileInputStream(file);
+ try {
+ parser.parse(new InputSource(s));
+ } finally {
+ if (s != null) {
+ s.close();
+ }
+ }
+ return result;
+ }
+
+ public static NodeItem getExistingItems(String tagName, File file) throws SAXException, IOException {
+
+ XMLReader parser = XMLReaderFactory.createXMLReader();
+ NodeItemHandler handler = new NodeItemHandler(tagName);
+
+ parser.setContentHandler(handler);
+
+ NodeItem rootItem = null;
+ InputStream s = new FileInputStream(file);
+ try {
+ parser.parse(new InputSource(s));
+ rootItem = handler.rootItem;
+ } finally {
+ s.close();
+ }
+ return rootItem;
+ }
+
+ static class NodeItemHandler extends ContentHandlerAdapter {
+
+ NodeItem rootItem;
+ NodeItem currentItem;
+ final Stack<NodeItem> stack;
+ final String tagName;
+
+ public NodeItemHandler(String tagName) {
+ this.tagName = tagName;
+ this.stack = new Stack<NodeItem>();
+ }
+
+ @Override
+ public void startDocument() throws SAXException {
+ rootItem = new NodeItem("top", null);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ if (tagName.equals(localName)) {
+
+ String target = atts.getValue("target");
+ String text = atts.getValue("text");
+
+ // debut d'un item
+ if (currentItem == null) {
+ // premier item
+ if (rootItem.getTarget().equals(target)) {
+ // le premier item est bien top
+ //rootItem.setText(text);
+ currentItem = rootItem;
+ } else {
+ // le premier noeud n'est pas top
+ // en l'encapsule
+ stack.push(rootItem);
+ currentItem = new NodeItem(target, text);
+ rootItem.addChild(currentItem);
+ }
+ } else {
+ NodeItem newItem = new NodeItem(target, text);
+ currentItem.addChild(newItem);
+ currentItem = newItem;
+ }
+ currentItem.adjustTarget();
+ stack.push(currentItem);
+
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ if (tagName.equals(localName)) {
+ // fin d'un item
+ stack.pop();
+ if (!stack.isEmpty()) {
+ currentItem = stack.peek();
+ }
+ }
+ }
+ }
+
+ static class ContentHandlerAdapter implements ContentHandler {
+
+ @Override
+ public void setDocumentLocator(Locator locator) {
+ }
+
+ @Override
+ public void startDocument() throws SAXException {
+ }
+
+ @Override
+ public void endDocument() throws SAXException {
+ }
+
+ @Override
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ }
+
+ @Override
+ public void endPrefixMapping(String prefix) throws SAXException {
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ }
+
+ @Override
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+ }
+
+ @Override
+ public void processingInstruction(String target, String data) throws SAXException {
+ }
+
+ @Override
+ public void skippedEntity(String name) throws SAXException {
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm 2009-10-08 16:48:27 UTC (rev 1568)
@@ -2,11 +2,11 @@
<HTML>
<HEAD>
<TITLE>
-$helpIdTitle
+$helpId
</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
-<H1>$helpIdTitle</H1>
+<H1>$helpId</H1>
<!-- $autoremoveLine -->
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-10-08 16:48:27 UTC (rev 1568)
@@ -3,7 +3,7 @@
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN"
"http://java.sun.com/products/javahelp/helpset_1_0.dtd">
-<helpset version="1.0">
+<helpset version="1.0" xml:lang="$locale">
<!-- $autoremoveLine -->
@@ -13,7 +13,7 @@
<!-- maps -->
<maps>
<homeID>top</homeID>
- <mapref location="$mapFileName"/>
+ <mapref location="$localePath/$mapFileName"/>
</maps>
<!-- views -->
@@ -21,17 +21,17 @@
<name>TOC</name>
<label>Table Of Contents</label>
<type>javax.help.TOCView</type>
- <data>$tocFileName</data>
+ <data>$localePath/$tocFileName</data>
</view>
<view>
<name>Index</name>
<label>Index</label>
<type>javax.help.IndexView</type>
- <data>$indexFileName</data>
+ <data>$localePath/$indexFileName</data>
</view>
-#if ( $!searchData != "" )
+#if ( $searchData )
<view>
<name>Search</name>
<label>Search</label>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -7,7 +7,7 @@
@Test
public void Bug_1751() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
assertNumberJaxxFiles(3);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -23,7 +23,7 @@
@Test
public void Icon() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
checkPattern(mojo, ".createImageIcon(\"myIcon.png\")", true);
checkPattern(mojo, ".createActionIcon(\"myActionIcon.png\")", true);
@@ -40,7 +40,7 @@
@Test
public void ClientProperty() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
checkPattern(mojo, ".putClientProperty(\"testOne\", \"oneTest\")", true);
checkPattern(mojo, ".putClientProperty(\"testTwo\", \"anotherTest\")", true);
@@ -60,7 +60,7 @@
@Test
public void WithLog() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
String[] files = mojo.files;
assertNumberJaxxFiles(2);
@@ -85,7 +85,7 @@
@Test
public void NoLog() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
assertNumberJaxxFiles(2);
checkPattern(mojo, "Log log = LogFactory.getLog(", false);
@@ -96,7 +96,7 @@
@SuppressWarnings({"unchecked"})
@Test
public void Errors() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
// init mojo to get alls files to treate
mojo.init();
@@ -160,7 +160,7 @@
@Test
public void ErrorJaxxContextImplementorClass() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.jaxxContextFQN = null;
try {
mojo.init();
@@ -213,7 +213,7 @@
public void Force() throws Exception {
// first round, with force option so will generate theonly JButton.jaxx file
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
String[] files = mojo.files;
assertNumberJaxxFiles(1);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -24,7 +24,7 @@
@SuppressWarnings({"unchecked"})
public void ValidatorErrors() throws Exception {
// init mojo to get alls files to treate
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.init();
String[] files = mojo.files;
assertNumberJaxxFiles(19);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -6,7 +6,7 @@
@Test
public void Decorator() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
assertNumberJaxxFiles(1);
checkPattern(mojo, "root.add(jaxx.runtime.SwingUtil.boxComponentWithJxLayer(boxedButton))", true);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -15,7 +15,7 @@
@Test
public void ok() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
assertNumberJaxxFiles(6);
@@ -38,7 +38,7 @@
@SuppressWarnings({"unchecked"})
@Test
public void error() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
// init mojo to get alls files to treate
mojo.init();
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -6,7 +6,7 @@
@Test
public void I18nText() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.i18nable = false;
mojo.execute();
checkPattern(mojo, "testId.setText(_(\"test.text\"));", false);
@@ -19,7 +19,7 @@
@Test
public void I18nTitle() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.i18nable = false;
mojo.execute();
checkPattern(mojo, "testId.setTitle(_(\"test.title\"));", false);
@@ -32,7 +32,7 @@
@Test
public void I18nToolTipText() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.i18nable = false;
mojo.execute();
checkPattern(mojo, "testId.setToolTipText(_(\"test.toolTipText\"));", false);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -15,9 +15,9 @@
*
* @author chemit
* @see AbstractMojoTest
- * @see JaxxGeneratorMojo
+ * @see GenerateMojo
*/
-public abstract class JaxxBaseTest extends AbstractMojoTest<JaxxGeneratorMojo> {
+public abstract class JaxxBaseTest extends AbstractMojoTest<GenerateMojo> {
@Override
protected String getGoalName(String methodName) {
@@ -25,7 +25,7 @@
}
@Override
- protected void setUpMojo(JaxxGeneratorMojo mojo, File pomFile) throws Exception {
+ protected void setUpMojo(GenerateMojo mojo, File pomFile) throws Exception {
super.setUpMojo(mojo, pomFile);
mojo.jaxxContextFQN = DefaultJAXXContext.class.getName();
mojo.compilerFQN = jaxx.compiler.JAXXCompiler.class.getName();
@@ -33,7 +33,7 @@
mojo.defaultDecoratorFQN = jaxx.compiler.decorators.DefaultCompiledObjectDecorator.class.getName();
}
- protected void checkPattern(JaxxGeneratorMojo mojo, String pattern, boolean required, String... files) throws IOException {
+ protected void checkPattern(GenerateMojo mojo, String pattern, boolean required, String... files) throws IOException {
if (files.length == 0) {
files = mojo.files;
}
1
0
Author: tchemit
Date: 2009-10-07 23:03:42 +0200 (Wed, 07 Oct 2009)
New Revision: 1567
Added:
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java
Removed:
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
branches/jaxx-2.X/pom.xml
branches/jaxx-2.X/src/site/rst/JAXXContext.rst
branches/jaxx-2.X/src/site/rst/migration.rst
Log:
ending migration
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -2,7 +2,7 @@
import java.io.File;
import jaxx.compiler.decorators.CompiledObjectDecorator;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
/**
* TODO javadoc.
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -5,7 +5,7 @@
import org.apache.commons.lang.builder.ToStringStyle;
import java.io.File;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
/**
* Options of the {@link JAXXCompiler} and {@link JAXXCompilerLaunchor}.
@@ -46,7 +46,7 @@
*/
private boolean resetAfterCompile;
/**
- * the name of implementation of {@link jaxx.runtime.context.JAXXContext}
+ * the name of implementation of {@link jaxx.runtime.JAXXContext}
* to be used on {@link jaxx.runtime.JAXXObject}.
*/
protected Class<? extends JAXXContext> jaxxContextClass;
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -45,7 +45,7 @@
if (options.isGenerateHelp()) {
// add JaxxHelpUI interface
- Class<?> validatorInterface = jaxx.runtime.JaxxHelpUI.class;
+ Class<?> validatorInterface = jaxx.runtime.swing.JaxxHelpUI.class;
String helpBrokerFQN = getBrokerFQN(compiler);
javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">");
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -11,7 +11,7 @@
import jaxx.compiler.types.TypeManager;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.JAXXObjectDescriptor;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.Util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,7 +49,7 @@
protected static final JavaField PREVIOUS_VALUES_FIELD = JavaField.newField(0,
"java.util.Map", "$previousValues", "new java.util.HashMap()");
protected static final JavaField DELEGATE_CONTEXT_FIELD = JavaField.newField(PROTECTED,
- "jaxx.runtime.context.JAXXContext", "delegateContext");
+ JAXXContext.class.getName(), "delegateContext");
protected static final JavaField PROPERTY_CHANGE_SUPPORT_FIELD = JavaField.newField(0,
"java.beans.PropertyChangeSupport", "$propertyChangeSupport");
protected static final JavaMethod GET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue",
@@ -431,7 +431,7 @@
}
code.append("$initialize();");
code.append(JAXXCompiler.getLineSeparator());
- return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString(), new JavaArgument("jaxx.runtime.context.JAXXContext", "parentContext"));
+ return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString(), new JavaArgument(JAXXContext.class.getName(), "parentContext"));
}
public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException {
Modified: branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst 2009-10-07 21:03:42 UTC (rev 1567)
@@ -13,7 +13,7 @@
Le besoin initial de ce développement est de pouvoir facilement intégrer un context applicatif dans JAXX et de pouvoir
l'utiliser dans les fichiers JAXX pour injecter par exemple des données dans les widgets.
-jaxx.runtime.context.JAXXContext
+jaxx.runtime.JAXXContext
========================
Il s'agit du contrat de base du context applicatif.
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -20,7 +20,7 @@
*/
package jaxx.demo;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.CardLayout2;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -21,7 +21,7 @@
package jaxx.demo;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.swing.navigation.NavigationTreeNode;
import org.apache.commons.logging.Log;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -21,7 +21,7 @@
package jaxx.demo.component.jaxx.navigation;
import jaxx.runtime.JAXXObject;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import static jaxx.runtime.context.JAXXContextEntryDef.newListDef;
import jaxx.runtime.decorator.Decorator;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,7 +1,6 @@
package jaxx.runtime;
import jaxx.runtime.context.JAXXInitialContext;
-import jaxx.runtime.context.JAXXContext;
/**
* This is the contract to be realized by any class to be used as Action class for an ui.
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,106 @@
+package jaxx.runtime;
+
+import java.awt.Container;
+
+/**
+ * The {@link jaxx.runtime.JAXXContext} contract defines a generic context.
+ * <p/>
+ * A context contains two king of entries :
+ * <p/>
+ * <h2>Unamed entry</h2>
+ * a such entry maps filter only on the clas of the object of the entry.
+ * <p/>
+ * To add a <b>unamed</b> entry, use {@link #setContextValue(Object)} and {@link #getContextValue(Class)} to reteave a
+ * such entry.
+ * <p/>
+ * <h2>named entry</h2>
+ * a such entry filter on class of the object and on the name of the entry.
+ * <p/>
+ * To add a <b>named</b> entry, use {@link #setContextValue(Object,String)} and {@link #getContextValue(Class,String)}
+ * to reteave a such entry.
+ *
+ * @author letellier
+ * @author chemit
+ */
+public interface JAXXContext {
+
+ /**
+ * Push in the context a new unamed entry.
+ * <p/>
+ * If a previous entry exists in context (unamed and same class), it will be removed.
+ *
+ * @param <T> type of data to set in context
+ * @param o the value to push in context
+ */
+ public <T> void setContextValue(T o);
+
+ /**
+ * * Push in the context a new amed entry.
+ * <p/>
+ * If a previous entry exists in context (same name and class), it will be removed.
+ *
+ * @param <T> type of data to set in context
+ * @param o the value to push in context
+ * @param name the name of the new entry
+ */
+ public <T> void setContextValue(T o, String name);
+
+ /**
+ * Remove from context the value with the given klazz as an unamed entry
+ *
+ * @param <T> type of data to remove from context
+ * @param klazz the klazz entry
+ */
+ public <T> void removeContextValue(Class<T> klazz);
+
+ /**
+ * Remove from context the value with the given klazz as an unamed (if name is null) or named entry
+ *
+ * @param <T> type of data to remove from context
+ * @param klazz the klazz entry
+ * @param name extra name of the entry
+ */
+ public <T> void removeContextValue(Class<T> klazz, String name);
+
+ /**
+ * Seek for a unamed entry in the context
+ * <p/>
+ * This is an exemple to call a method in JAXX :
+ * <p/>
+ * <code><JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/></code>
+ *
+ * @param <T> type of data to obtain from context
+ * @param clazz the class of unamed entry to seek in context
+ * @return the value of the unamed entry for the given class, or <code>null</code> if no such entry.
+ */
+ public <T> T getContextValue(Class<T> clazz);
+
+ /**
+ * Seek for a named entry in the context
+ *
+ * @param <T> type of data to obtain from context
+ * @param clazz the class of named entry to seek in context
+ * @param name the name of the entry to seek in context
+ * @return the value of the named entry for the given class, or <code>null</code> if no such entry.
+ */
+ public <T> T getContextValue(Class<T> clazz, String name);
+
+ /**
+ * Return parent's container corresponding to the Class clazz
+ *
+ * @param <O> type of container to obtain from context
+ * @param clazz clazz desired
+ * @return parent's container
+ */
+ public <O extends Container> O getParentContainer(Class<O> clazz);
+
+ /**
+ * Return parent's container corresponding to the Class clazz
+ *
+ * @param <O> type of container to obtain from context
+ * @param top the top container
+ * @param clazz desired
+ * @return parent's container
+ */
+ public <O extends Container> O getParentContainer(Object top, Class<O> clazz);
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -5,7 +5,6 @@
package jaxx.runtime;
import java.util.Map;
-import jaxx.runtime.context.JAXXContext;
/**
* The <code>JAXXObject</code> interface is implemented by all classes
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,23 +0,0 @@
-package jaxx.runtime;
-
-import java.awt.Component;
-import jaxx.runtime.swing.JaxxHelpBroker;
-
-/**
- *
- * Contract to be added on JAXXObject wihch wants to use javax help.
- *
- * @param <B> type of broker.
- *
- * @author tony
- * @since 1.3
- * @see JaxxHelpBroker
- */
-public interface JaxxHelpUI<B extends JaxxHelpBroker<?>> {
-
- B getBroker();
-
- void registerHelpId(B broker, Component component, String helpId);
-
- void showHelp(String helpId);
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -53,10 +53,10 @@
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
-import jaxx.runtime.swing.BooleanCellRenderer;
-import jaxx.runtime.swing.EmptyNumberTableCellRenderer;
-import jaxx.runtime.swing.EnumTableCellRenderer;
-import jaxx.runtime.swing.I18nTableCellRenderer;
+import jaxx.runtime.swing.renderer.BooleanCellRenderer;
+import jaxx.runtime.swing.renderer.EmptyNumberTableCellRenderer;
+import jaxx.runtime.swing.renderer.EnumTableCellRenderer;
+import jaxx.runtime.swing.renderer.I18nTableCellRenderer;
import jaxx.runtime.swing.Item;
import jaxx.runtime.swing.JAXXComboBox;
import org.apache.commons.logging.Log;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,6 +1,5 @@
package jaxx.runtime;
-import jaxx.runtime.context.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.*;
import java.awt.Container;
import java.beans.PropertyChangeListener;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -118,6 +118,8 @@
value = super.getContextValue(realClass, name);
}
+ //TC-20091007 TODO Make possible use of named autoload entries
+ //(add a parameter on AutoLoad annotation)
if (value == null) {
AutoLoad anno = clazz.getAnnotation(AutoLoad.class);
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.*;
import static jaxx.runtime.context.JAXXContextEntryDef.newDef;
import org.apache.commons.logging.Log;
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,107 +0,0 @@
-package jaxx.runtime.context;
-
-import java.awt.Container;
-
-/**
- * The {@link jaxx.runtime.context.JAXXContext} contract defines a generic context.
- * <p/>
- * A context contains two king of entries :
- * <p/>
- * <h2>Unamed entry</h2>
- * a such entry maps filter only on the clas of the object of the entry.
- * <p/>
- * To add a <b>unamed</b> entry, use {@link #setContextValue(Object)} and {@link #getContextValue(Class)} to reteave a
- * such entry.
- * <p/>
- * <h2>named entry</h2>
- * a such entry filter on class of the object and on the name of the entry.
- * <p/>
- * To add a <b>named</b> entry, use {@link #setContextValue(Object,String)} and {@link #getContextValue(Class,String)}
- * to reteave a such entry.
- *
- * @author letellier
- * @author chemit
- */
-public interface JAXXContext {
-
- /**
- * Push in the context a new unamed entry.
- * <p/>
- * If a previous entry exists in context (unamed and same class), it will be removed.
- *
- * @param <T> type of data to set in context
- * @param o the value to push in context
- */
- public <T> void setContextValue(T o);
-
- /**
- * * Push in the context a new amed entry.
- * <p/>
- * If a previous entry exists in context (same name and class), it will be removed.
- *
- * @param <T> type of data to set in context
- * @param o the value to push in context
- * @param name the name of the new entry
- */
- public <T> void setContextValue(T o, String name);
-
- /**
- * Remove from context the value with the given klazz as an unamed entry
- *
- * @param <T> type of data to remove from context
- * @param klazz the klazz entry
- */
- public <T> void removeContextValue(Class<T> klazz);
-
- /**
- * Remove from context the value with the given klazz as an unamed (if name is null) or named entry
- *
- * @param <T> type of data to remove from context
- * @param klazz the klazz entry
- * @param name extra name of the entry
- */
-
- public <T> void removeContextValue(Class<T> klazz, String name);
-
- /**
- * Seek for a unamed entry in the context
- * <p/>
- * This is an exemple to call a method in JAXX :
- * <p/>
- * <code><JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/></code>
- *
- * @param <T> type of data to obtain from context
- * @param clazz the class of unamed entry to seek in context
- * @return the value of the unamed entry for the given class, or <code>null</code> if no such entry.
- */
- public <T> T getContextValue(Class<T> clazz);
-
- /**
- * Seek for a named entry in the context
- *
- * @param <T> type of data to obtain from context
- * @param clazz the class of named entry to seek in context
- * @param name the name of the entry to seek in context
- * @return the value of the named entry for the given class, or <code>null</code> if no such entry.
- */
- public <T> T getContextValue(Class<T> clazz, String name);
-
- /**
- * Return parent's container corresponding to the Class clazz
- *
- * @param <O> type of container to obtain from context
- * @param clazz clazz desired
- * @return parent's container
- */
- public <O extends Container> O getParentContainer(Class<O> clazz);
-
- /**
- * Return parent's container corresponding to the Class clazz
- *
- * @param <O> type of container to obtain from context
- * @param top the top container
- * @param clazz desired
- * @return parent's container
- */
- public <O extends Container> O getParentContainer(Object top, Class<O> clazz);
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import java.util.Collections;
import java.util.List;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import java.awt.Container;
import java.util.Map.Entry;
import jaxx.runtime.JAXXObject;
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,61 +0,0 @@
-package jaxx.runtime.swing;
-
-import javax.swing.Icon;
-import javax.swing.JCheckBox;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-
-/** @author chemit
- * @since 1.5
- */
-public class BooleanCellRenderer extends JPanel implements TableCellRenderer {
-
- private static final long serialVersionUID = 1L;
- protected TableCellRenderer defaultDelegate;
- protected JCheckBox checkBox;
-
- public BooleanCellRenderer(TableCellRenderer delegate) {
- //super(new BorderLayout());
- this.checkBox = new JCheckBox();
- add(checkBox, BorderLayout.CENTER);
- checkBox.setHorizontalAlignment(JLabel.CENTER);
- checkBox.setBorderPainted(true);
- this.defaultDelegate = delegate;
- }
-
- public BooleanCellRenderer(TableCellRenderer delegate, Icon icon) {
- //super(new BorderLayout());
- this.checkBox = new JCheckBox(icon);
- add(checkBox, BorderLayout.NORTH);
- checkBox.setHorizontalAlignment(JLabel.CENTER);
- checkBox.setVerticalTextPosition(JLabel.TOP);
- checkBox.setBorderPainted(true);
- this.defaultDelegate = delegate;
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- ((JComponent) defaultDelegate).setBackground(null);
- JComponent render = (JComponent) defaultDelegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- if (isSelected) {
- setForeground(table.getSelectionForeground());
- setBackground(table.getSelectionBackground());
- } else {
- setForeground(render.getForeground());
- setBackground(render.getBackground());
- //fixme make this works... and remove the test
- if (row % 2 == 1) {
- setBackground(Color.WHITE);
- }
- }
- checkBox.setSelected((value != null && (Boolean) value));
- setBorder(render.getBorder());
- return this;
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,37 +0,0 @@
-package jaxx.runtime.swing;
-
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Component;
-import javax.swing.table.DefaultTableCellRenderer;
-
-/**
- * A {@link TableCellRenderer} which does not display numbers when they are
- * equals to 0.
- *
- * @author chemit
- * @since 1.5
- */
-public class EmptyNumberTableCellRenderer implements TableCellRenderer {
-
- protected final Integer ZERO = 0;
- protected final Float ZEROF = 0F;
- protected final Double ZEROD = 0D;
- private TableCellRenderer delegate;
-
- public EmptyNumberTableCellRenderer() {
- this(new DefaultTableCellRenderer());
- }
-
- public EmptyNumberTableCellRenderer(TableCellRenderer delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- if (value == null || ZERO.equals(value) || ZEROF.equals(value) || ZEROD.equals(value)) {
- value = null;
- }
- return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,47 +0,0 @@
-package jaxx.runtime.swing;
-
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Component;
-import java.util.EnumSet;
-
-/**
- *
- *
- * A {@link TableCellRenderer} which displays enum values from their ordinal value.
- *
- * @param <E> le type de l'énumération.
- *
- * @author chemit
- * @since 1.5
- */
-public class EnumTableCellRenderer<E extends Enum<E>> implements TableCellRenderer {
-
- private TableCellRenderer delegate;
- private EnumSet<E> enumValues;
-
- public EnumTableCellRenderer(TableCellRenderer delegate, Class<E> enumClass) {
- this.delegate = delegate;
- this.enumValues = EnumSet.allOf(enumClass);
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
-
- if (value != null) {
- //FIXME : should be also able to read it by name ?
- Integer ordinal = Integer.valueOf(value + "");
- if (ordinal == -1) {
- value = null;
- } else {
- for (E enumValue : enumValues) {
- if (ordinal == enumValue.ordinal()) {
- value = enumValue;
- break;
- }
- }
- }
- }
- return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,66 +0,0 @@
-package jaxx.runtime.swing;
-
-import static org.nuiton.i18n.I18n._;
-
-import javax.swing.JComponent;
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import java.awt.Component;
-
-/**
- * A simple TableCellRenderer using a delegate TableCellRenderer to render everything elese thant the text :
- * the text is I18nalize.
- *
- * @author chemit
- */
-public class I18nTableCellRenderer implements TableCellRenderer {
-
- /** i18n keys of libelles to display */
- protected final String[] keys;
-
- /** i18n keys of toolTipTexts to display */
- protected final String[] tips;
-
- /** the delegate cell renderer */
- protected TableCellRenderer delegate;
-
- public I18nTableCellRenderer(TableCellRenderer delegate, String... keysAndTips) {
- this.delegate = delegate;
- if (keysAndTips.length == 0) {
- throw new IllegalArgumentException("can not have empty keysAndTips parameters (means no column ?)");
- }
- if (keysAndTips.length % 2 == 1) {
- throw new IllegalArgumentException("must have some couple (text,tooltTipText), but had a even number of data in keysAndTips parameter");
- }
- int size = keysAndTips.length / 2;
- this.keys = new String[size];
- this.tips = new String[size];
- for (int i = 0; i < size; i++) {
- this.keys[i] = keysAndTips[2 * i];
- this.tips[i] = keysAndTips[2 * i + 1];
- }
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
- if (column > keys.length) {
- throw new IndexOutOfBoundsException("colum can not be greater than " + keys.length);
- }
- TableColumn col = table.getColumn(table.getColumnName(column));
- int index = col.getModelIndex();
- value = _(keys[index]);
- JComponent rendererComponent = (JComponent) delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
- rendererComponent.setToolTipText(_(tips[index]));
- return rendererComponent;
- }
-
- public String[] getKeys() {
- return keys;
- }
-
- public String[] getTips() {
- return tips;
- }
-
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -11,6 +11,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Locale;
import java.util.Map;
import java.util.Vector;
import javax.help.CSH;
@@ -19,7 +20,7 @@
import javax.swing.AbstractButton;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
@@ -35,34 +36,68 @@
public abstract class JaxxHelpBroker<B extends JaxxHelpBroker<?>> {
public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext";
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * Logger
+ */
static private Log log = LogFactory.getLog(JaxxHelpBroker.class);
+ /**
+ * name of helpset
+ */
protected final String helpsetName;
+ /**
+ * default id to use if none given
+ */
protected final String defaultID;
+ /**
+ * help key
+ */
protected final String helpKey;
- // Main HelpSet & Broker
- protected final HelpSet helpset;
- protected final HelpBroker helpBroker;
+ /**
+ * helpset to use
+ */
+ protected HelpSet helpset;
+ /**
+ * help broker
+ */
+ protected HelpBroker helpBroker;
+ /**
+ * current locale used
+ */
+ protected Locale locale;
+ /**
+ * cache of cursors modified when in context-sensitive mode
+ */
protected Hashtable<Component, Cursor> cursors;
+ /**
+ * cursor to use in context-sensitive mode
+ */
protected Cursor onItemCursor;
+ /**
+ * cache of component which cursor have been modified
+ */
protected final Map<Component, String> cache;
protected JaxxHelpBroker(String helpsetName, String helpKey, String defaultID) {
+ this(null, helpsetName, helpKey, defaultID);
+ }
+
+ protected JaxxHelpBroker(Locale locale, String helpsetName, String helpKey, String defaultID) {
if (helpsetName == null) {
throw new NullPointerException("parameter helpsetName can not be null!");
}
+ this.locale = locale;
this.helpsetName = helpsetName;
this.helpKey = helpKey;
this.defaultID = defaultID;
cache = new HashMap<Component, String>();
- try {
- ClassLoader cl = getClass().getClassLoader();
- URL url = HelpSet.findHelpSet(cl, helpsetName);
- helpset = new HelpSet(cl, url);
- helpBroker = helpset.createHelpBroker();
- } catch (Exception ee) {
- throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
- }
+// try {
+// ClassLoader cl = getClass().getClassLoader();
+// URL url = HelpSet.findHelpSet(cl, helpsetName, this.locale);
+// helpset = new HelpSet(cl, url);
+// helpBroker = helpset.createHelpBroker();
+// } catch (Exception ee) {
+// throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
+// }
}
public void prepareUI(JAXXObject c) {
@@ -96,6 +131,9 @@
}
public HelpBroker getHelpBroker() {
+ if (helpBroker == null) {
+ helpBroker = getHelpset().createHelpBroker();
+ }
return helpBroker;
}
@@ -104,6 +142,15 @@
}
public HelpSet getHelpset() {
+ if (helpset == null) {
+ try {
+ ClassLoader cl = getClass().getClassLoader();
+ URL url = HelpSet.findHelpSet(cl, helpsetName, this.locale);
+ helpset = new HelpSet(cl, url);
+ } catch (Exception ee) {
+ throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
+ }
+ }
return helpset;
}
@@ -115,6 +162,15 @@
return defaultID;
}
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ // need to reload helpset and helpbroker
+ helpset = null;
+ helpBroker = null;
+ getHelpset();
+ getHelpBroker();
+ }
+
public void showHelpSet() {
if (log.isDebugEnabled()) {
log.debug(this);
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,22 @@
+package jaxx.runtime.swing;
+
+import java.awt.Component;
+
+/**
+ *
+ * Contract to be added on JAXXObject wihch wants to use javax help.
+ *
+ * @param <B> type of broker.
+ *
+ * @author tony
+ * @since 1.3
+ * @see JaxxHelpBroker
+ */
+public interface JaxxHelpUI<B extends JaxxHelpBroker<?>> {
+
+ B getBroker();
+
+ void registerHelpId(B broker, Component component, String helpId);
+
+ void showHelp(String helpId);
+}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,126 +0,0 @@
-package jaxx.runtime.swing;
-
-import java.awt.Component;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.Icon;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- *
- * @author chemit
- */
-public class LocaleListCellRenderer extends DefaultListCellRenderer {
-
- public static final Log log = LogFactory.getLog(LocaleListCellRenderer.class);
- private static final long serialVersionUID = 1L;
- protected final Map<Locale, Icon> cache = new HashMap<Locale, Icon>();
- protected boolean showIcon;
- protected boolean showText;
-
- public LocaleListCellRenderer() {
- this(true, true);
- }
-
- public LocaleListCellRenderer(boolean showIcon, boolean showText) {
- this.showIcon = showIcon;
- this.showText = showText;
- }
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- Locale locale = (Locale) value;
- if (locale != null) {
- Icon icon = getIcon(locale);
- comp.setIcon(icon);
- }
- String text = getText(locale);
- String tip = getToolTipText(locale);
- comp.setText(text);
- comp.setToolTipText(tip);
- return comp;
- }
-
- public String getText(Locale locale) {
- String text = null;
- if (showText) {
- text = getSafeText(locale);
- }
- return text;
- }
-
- public Icon getIcon(Locale locale) {
- if (!showIcon) {
- return null;
- }
- synchronized (cache) {
- Icon icon = getSafeIcon(locale);
- return icon;
- }
- }
-
- public String getToolTipText(Locale locale) {
- String tip = locale.getDisplayName(Locale.getDefault());
- return tip;
- }
-
- public boolean isShowText() {
- return showText;
- }
-
- public boolean isShowIcon() {
- return showIcon;
- }
-
- public void setShowIcon(boolean showIcon) {
- boolean old = this.showIcon;
- this.showIcon = showIcon;
- firePropertyChange("showIcon", old, showIcon);
- }
-
- public void setShowText(boolean showText) {
- boolean old = this.showText;
- this.showText = showText;
- firePropertyChange("showText", old, showText);
- }
-
- public String getSafeText(Locale locale) {
- String text = locale.getDisplayName(Locale.getDefault());
- return text;
- }
-
- public synchronized Icon getSafeIcon(Locale locale) {
- Icon icon = cache.get(locale);
- if (icon != null) {
- return icon;
- }
-
- icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.toString());
-
- if (icon == null) {
- log.warn("could not find icon action.i18n-" + locale.toString());
- if (locale.getCountry() != null) {
- icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.getCountry().toLowerCase());
- if (icon == null) {
- log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
-
- icon = SwingUtil.createActionIcon("i18n-" + locale.getCountry().toLowerCase());
- if (icon == null) {
- log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
- }
- }
-
- }
- }
-
- cache.put(locale, icon);
- return icon;
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,104 +0,0 @@
-package jaxx.runtime.swing;
-
-import org.nuiton.util.EnumEditor;
-
-import javax.swing.DefaultCellEditor;
-import javax.swing.Icon;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.table.TableCellEditor;
-import java.awt.Component;
-
-/**
- * @author chemit
- * @since 1.5
- */
-public class MyDefaultCellEditor extends DefaultCellEditor {
-
- private static final long serialVersionUID = 1L;
-
- public static TableCellEditor newTextEditor() {
- return new MyDefaultCellEditor(new JTextField());
- }
-
- public static TableCellEditor newBooleanEditor() {
- return new MyDefaultCellEditor(new JCheckBox());
- }
-
- public static TableCellEditor newListEditor() {
- return newListEditor(new JComboBox());
- }
-
- public static TableCellEditor newListEditor(JComboBox editor) {
- return new MyDefaultCellEditor(editor);
- }
-
- public static TableCellEditor newEnumEditor(EnumEditor editor) {
- return new MyDefaultCellEditor(editor) {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public Object getCellEditorValue() {
- Object value = super.getCellEditorValue();
- if (value != null) {
- value = ((Enum) value).ordinal();
- } else {
- value = -1;
- }
- return value;
- }
- };
- }
-
- public static TableCellEditor newBooleanEditor(Icon icon) {
- return new MyDefaultCellEditor(new JCheckBox(icon));
- }
-
- public static TableCellEditor newBooleanEditor(Icon icon, boolean requireSelect) {
- TableCellEditor cellEditor = newBooleanEditor(icon);
- ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
- return cellEditor;
- }
-
- public static TableCellEditor newBooleanEditor(boolean requireSelect) {
- TableCellEditor cellEditor = newBooleanEditor();
- ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
- return cellEditor;
- }
- protected boolean requireSelect = true;
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (!isSelected && requireSelect) {
- // force to have select the cell before editing, a way to not modify edition for nothing...
- return null;
- }
- return super.getTableCellEditorComponent(table, value, isSelected, row, column);
- }
-
- public boolean isRequireSelect() {
- return requireSelect;
- }
-
- public void setRequireSelect(boolean requireSelect) {
- this.requireSelect = requireSelect;
- }
-
- protected MyDefaultCellEditor(JTextField textField) {
- super(textField);
- setClickCountToStart(1);
- }
-
- protected MyDefaultCellEditor(JCheckBox checkBox) {
- super(checkBox);
- setClickCountToStart(1);
- }
-
- protected MyDefaultCellEditor(JComboBox comboBox) {
- super(comboBox);
- setClickCountToStart(1);
- }
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,103 @@
+package jaxx.runtime.swing.editor;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+import jaxx.runtime.swing.editor.EnumEditor;
+
+/**
+ * @author chemit
+ * @since 1.5
+ */
+public class MyDefaultCellEditor extends DefaultCellEditor {
+
+ private static final long serialVersionUID = 1L;
+
+ public static TableCellEditor newTextEditor() {
+ return new MyDefaultCellEditor(new JTextField());
+ }
+
+ public static TableCellEditor newBooleanEditor() {
+ return new MyDefaultCellEditor(new JCheckBox());
+ }
+
+ public static TableCellEditor newListEditor() {
+ return newListEditor(new JComboBox());
+ }
+
+ public static TableCellEditor newListEditor(JComboBox editor) {
+ return new MyDefaultCellEditor(editor);
+ }
+
+ public static TableCellEditor newEnumEditor(EnumEditor<?> editor) {
+ return new MyDefaultCellEditor(editor) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object getCellEditorValue() {
+ Object value = super.getCellEditorValue();
+ if (value != null) {
+ value = ((Enum) value).ordinal();
+ } else {
+ value = -1;
+ }
+ return value;
+ }
+ };
+ }
+
+ public static TableCellEditor newBooleanEditor(Icon icon) {
+ return new MyDefaultCellEditor(new JCheckBox(icon));
+ }
+
+ public static TableCellEditor newBooleanEditor(Icon icon, boolean requireSelect) {
+ TableCellEditor cellEditor = newBooleanEditor(icon);
+ ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
+ return cellEditor;
+ }
+
+ public static TableCellEditor newBooleanEditor(boolean requireSelect) {
+ TableCellEditor cellEditor = newBooleanEditor();
+ ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
+ return cellEditor;
+ }
+ protected boolean requireSelect = true;
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (!isSelected && requireSelect) {
+ // force to have select the cell before editing, a way to not modify edition for nothing...
+ return null;
+ }
+ return super.getTableCellEditorComponent(table, value, isSelected, row, column);
+ }
+
+ public boolean isRequireSelect() {
+ return requireSelect;
+ }
+
+ public void setRequireSelect(boolean requireSelect) {
+ this.requireSelect = requireSelect;
+ }
+
+ protected MyDefaultCellEditor(JTextField textField) {
+ super(textField);
+ setClickCountToStart(1);
+ }
+
+ protected MyDefaultCellEditor(JCheckBox checkBox) {
+ super(checkBox);
+ setClickCountToStart(1);
+ }
+
+ protected MyDefaultCellEditor(JComboBox comboBox) {
+ super(comboBox);
+ setClickCountToStart(1);
+ }
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,7 +1,7 @@
package jaxx.runtime.swing.navigation;
import javax.swing.JTree;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
/**
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -6,7 +6,7 @@
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.TreePath;
import jaxx.runtime.JAXXAction;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.JAXXObject;
import org.apache.commons.logging.Log;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,6 +1,6 @@
package jaxx.runtime.swing.navigation;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.CardLayout2;
import org.apache.commons.logging.Log;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -4,7 +4,7 @@
import java.util.regex.Pattern;
import javax.swing.JTree;
import javax.swing.tree.TreePath;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,6 +1,6 @@
package jaxx.runtime.swing.navigation;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -2,7 +2,7 @@
import java.util.Enumeration;
import jaxx.runtime.JAXXAction;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.decorator.Decorator;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -4,7 +4,7 @@
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import jaxx.runtime.JAXXAction;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
import org.apache.commons.jxpath.JXPathContext;
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,61 @@
+package jaxx.runtime.swing.renderer;
+
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+
+/** @author chemit
+ * @since 1.5
+ */
+public class BooleanCellRenderer extends JPanel implements TableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+ protected TableCellRenderer defaultDelegate;
+ protected JCheckBox checkBox;
+
+ public BooleanCellRenderer(TableCellRenderer delegate) {
+ //super(new BorderLayout());
+ this.checkBox = new JCheckBox();
+ add(checkBox, BorderLayout.CENTER);
+ checkBox.setHorizontalAlignment(JLabel.CENTER);
+ checkBox.setBorderPainted(true);
+ this.defaultDelegate = delegate;
+ }
+
+ public BooleanCellRenderer(TableCellRenderer delegate, Icon icon) {
+ //super(new BorderLayout());
+ this.checkBox = new JCheckBox(icon);
+ add(checkBox, BorderLayout.NORTH);
+ checkBox.setHorizontalAlignment(JLabel.CENTER);
+ checkBox.setVerticalTextPosition(JLabel.TOP);
+ checkBox.setBorderPainted(true);
+ this.defaultDelegate = delegate;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ ((JComponent) defaultDelegate).setBackground(null);
+ JComponent render = (JComponent) defaultDelegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ if (isSelected) {
+ setForeground(table.getSelectionForeground());
+ setBackground(table.getSelectionBackground());
+ } else {
+ setForeground(render.getForeground());
+ setBackground(render.getBackground());
+ //fixme make this works... and remove the test
+ if (row % 2 == 1) {
+ setBackground(Color.WHITE);
+ }
+ }
+ checkBox.setSelected((value != null && (Boolean) value));
+ setBorder(render.getBorder());
+ return this;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,37 @@
+package jaxx.runtime.swing.renderer;
+
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ * A {@link TableCellRenderer} which does not display numbers when they are
+ * equals to 0.
+ *
+ * @author chemit
+ * @since 1.5
+ */
+public class EmptyNumberTableCellRenderer implements TableCellRenderer {
+
+ protected final Integer ZERO = 0;
+ protected final Float ZEROF = 0F;
+ protected final Double ZEROD = 0D;
+ private TableCellRenderer delegate;
+
+ public EmptyNumberTableCellRenderer() {
+ this(new DefaultTableCellRenderer());
+ }
+
+ public EmptyNumberTableCellRenderer(TableCellRenderer delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ if (value == null || ZERO.equals(value) || ZEROF.equals(value) || ZEROD.equals(value)) {
+ value = null;
+ }
+ return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,47 @@
+package jaxx.runtime.swing.renderer;
+
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import java.util.EnumSet;
+
+/**
+ *
+ *
+ * A {@link TableCellRenderer} which displays enum values from their ordinal value.
+ *
+ * @param <E> le type de l'énumération.
+ *
+ * @author chemit
+ * @since 1.5
+ */
+public class EnumTableCellRenderer<E extends Enum<E>> implements TableCellRenderer {
+
+ private TableCellRenderer delegate;
+ private EnumSet<E> enumValues;
+
+ public EnumTableCellRenderer(TableCellRenderer delegate, Class<E> enumClass) {
+ this.delegate = delegate;
+ this.enumValues = EnumSet.allOf(enumClass);
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+
+ if (value != null) {
+ //FIXME : should be also able to read it by name ?
+ Integer ordinal = Integer.valueOf(value + "");
+ if (ordinal == -1) {
+ value = null;
+ } else {
+ for (E enumValue : enumValues) {
+ if (ordinal == enumValue.ordinal()) {
+ value = enumValue;
+ break;
+ }
+ }
+ }
+ }
+ return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,66 @@
+package jaxx.runtime.swing.renderer;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import java.awt.Component;
+
+/**
+ * A simple TableCellRenderer using a delegate TableCellRenderer to render everything elese thant the text :
+ * the text is I18nalize.
+ *
+ * @author chemit
+ */
+public class I18nTableCellRenderer implements TableCellRenderer {
+
+ /** i18n keys of libelles to display */
+ protected final String[] keys;
+
+ /** i18n keys of toolTipTexts to display */
+ protected final String[] tips;
+
+ /** the delegate cell renderer */
+ protected TableCellRenderer delegate;
+
+ public I18nTableCellRenderer(TableCellRenderer delegate, String... keysAndTips) {
+ this.delegate = delegate;
+ if (keysAndTips.length == 0) {
+ throw new IllegalArgumentException("can not have empty keysAndTips parameters (means no column ?)");
+ }
+ if (keysAndTips.length % 2 == 1) {
+ throw new IllegalArgumentException("must have some couple (text,tooltTipText), but had a even number of data in keysAndTips parameter");
+ }
+ int size = keysAndTips.length / 2;
+ this.keys = new String[size];
+ this.tips = new String[size];
+ for (int i = 0; i < size; i++) {
+ this.keys[i] = keysAndTips[2 * i];
+ this.tips[i] = keysAndTips[2 * i + 1];
+ }
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
+ if (column > keys.length) {
+ throw new IndexOutOfBoundsException("colum can not be greater than " + keys.length);
+ }
+ TableColumn col = table.getColumn(table.getColumnName(column));
+ int index = col.getModelIndex();
+ value = _(keys[index]);
+ JComponent rendererComponent = (JComponent) delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
+ rendererComponent.setToolTipText(_(tips[index]));
+ return rendererComponent;
+ }
+
+ public String[] getKeys() {
+ return keys;
+ }
+
+ public String[] getTips() {
+ return tips;
+ }
+
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,126 @@
+package jaxx.runtime.swing.renderer;
+
+import java.awt.Component;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author chemit
+ */
+public class LocaleListCellRenderer extends DefaultListCellRenderer {
+
+ public static final Log log = LogFactory.getLog(LocaleListCellRenderer.class);
+ private static final long serialVersionUID = 1L;
+ protected final Map<Locale, Icon> cache = new HashMap<Locale, Icon>();
+ protected boolean showIcon;
+ protected boolean showText;
+
+ public LocaleListCellRenderer() {
+ this(true, true);
+ }
+
+ public LocaleListCellRenderer(boolean showIcon, boolean showText) {
+ this.showIcon = showIcon;
+ this.showText = showText;
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ Locale locale = (Locale) value;
+ if (locale != null) {
+ Icon icon = getIcon(locale);
+ comp.setIcon(icon);
+ }
+ String text = getText(locale);
+ String tip = getToolTipText(locale);
+ comp.setText(text);
+ comp.setToolTipText(tip);
+ return comp;
+ }
+
+ public String getText(Locale locale) {
+ String text = null;
+ if (showText) {
+ text = getSafeText(locale);
+ }
+ return text;
+ }
+
+ public Icon getIcon(Locale locale) {
+ if (!showIcon) {
+ return null;
+ }
+ synchronized (cache) {
+ Icon icon = getSafeIcon(locale);
+ return icon;
+ }
+ }
+
+ public String getToolTipText(Locale locale) {
+ String tip = locale.getDisplayName(Locale.getDefault());
+ return tip;
+ }
+
+ public boolean isShowText() {
+ return showText;
+ }
+
+ public boolean isShowIcon() {
+ return showIcon;
+ }
+
+ public void setShowIcon(boolean showIcon) {
+ boolean old = this.showIcon;
+ this.showIcon = showIcon;
+ firePropertyChange("showIcon", old, showIcon);
+ }
+
+ public void setShowText(boolean showText) {
+ boolean old = this.showText;
+ this.showText = showText;
+ firePropertyChange("showText", old, showText);
+ }
+
+ public String getSafeText(Locale locale) {
+ String text = locale.getDisplayName(Locale.getDefault());
+ return text;
+ }
+
+ public synchronized Icon getSafeIcon(Locale locale) {
+ Icon icon = cache.get(locale);
+ if (icon != null) {
+ return icon;
+ }
+
+ icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.toString());
+
+ if (icon == null) {
+ log.warn("could not find icon action.i18n-" + locale.toString());
+ if (locale.getCountry() != null) {
+ icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.getCountry().toLowerCase());
+ if (icon == null) {
+ log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
+
+ icon = SwingUtil.createActionIcon("i18n-" + locale.getCountry().toLowerCase());
+ if (icon == null) {
+ log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
+ }
+ }
+
+ }
+ }
+
+ cache.put(locale, icon);
+ return icon;
+ }
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,7 +1,7 @@
package jaxx.runtime.swing.wizard;
import javax.swing.SwingWorker;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -4,7 +4,7 @@
import java.beans.PropertyChangeListener;
import java.util.Date;
import javax.swing.SwingWorker.StateValue;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -2,7 +2,7 @@
import java.awt.Window;
import javax.swing.ImageIcon;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.JAXXObject;
import org.apache.commons.beanutils.ConstructorUtils;
Modified: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.*;
import org.junit.Assert;
import org.junit.Before;
Modified: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -4,7 +4,7 @@
import jaxx.runtime.swing.navigation.NavigationTreeModel;
import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
import jaxx.runtime.context.DefaultJAXXContext;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import org.junit.Assert;
import org.junit.Test;
@@ -85,7 +85,7 @@
}
/**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.context.JAXXContext, String)} with an entry point
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
* as a bean.
* <p/>
* Tree is like this
@@ -205,7 +205,7 @@
}
/**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.context.JAXXContext, String)} with an entry point
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
* as a list.
* <p/>
* Tree is like this
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx 2009-10-07 21:03:42 UTC (rev 1567)
@@ -44,7 +44,7 @@
<script><![CDATA[
import javax.swing.table.TableColumn;
import javax.swing.table.TableCellRenderer;
-import jaxx.runtime.swing.I18nTableCellRenderer;
+import jaxx.runtime.swing.renderer.I18nTableCellRenderer;
public static final String TABLE_PROPERTY = "myTable";
public static final String POPUP_VISIBLE_PROPERTY = "popupVisible";
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-10-07 21:03:42 UTC (rev 1567)
@@ -42,7 +42,7 @@
<Locale id='selectedLocale' javaBean='Locale.getDefault()'/>
- <jaxx.runtime.swing.LocaleListCellRenderer id='renderer'
+ <jaxx.runtime.swing.renderer.LocaleListCellRenderer id='renderer'
showIcon='{isShowIcon()}'
showText='{isShowText()}'
javaBean='new LocaleListCellRenderer(showIcon , showText)'/>
@@ -71,7 +71,7 @@
<script><![CDATA[
import java.util.Locale;
import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.LocaleListCellRenderer;
+import jaxx.runtime.swing.renderer.LocaleListCellRenderer;
import static org.nuiton.i18n.I18n.n_;
public static final String DEFAULT_SELECTED_TOOLTIP = n_("i18neditor.selected");
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -32,7 +32,7 @@
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.SwingUtil;
@@ -59,7 +59,7 @@
* @param defaultCategory la categorie a selectionner
* @return l'ui instanciate
*/
- public static ConfigUI newConfigUI(jaxx.runtime.context.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
+ public static ConfigUI newConfigUI(jaxx.runtime.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model);
final ConfigUI ui = new ConfigUI(tx);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-07 21:03:42 UTC (rev 1567)
@@ -57,6 +57,11 @@
<artifactId>maven-helper-plugin</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-velocity</artifactId>
+ </dependency>
+
<!-- pour acceder aux BeansInfos swing via Introspector -->
<dependency>
<groupId>com.sun</groupId>
@@ -67,26 +72,18 @@
</dependency>
<!-- tests dependencies -->
-<!--
+
<dependency>
<groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-plugin-testing-harness</artifactId>
- <version>1.1</version>
- <scope>test</scope>
- </dependency>
--->
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
- <version>1.0</version>
- <scope>test</scope>
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.5</version>
- </dependency>
+ </dependency>-->
+
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -25,7 +25,7 @@
import jaxx.compiler.decorators.CompiledObjectDecorator;
import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
import jaxx.compiler.tags.TagManager;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Resource;
@@ -98,7 +98,7 @@
*/
protected String validatorFQN;
/**
- * the name of implementation of {@link jaxx.runtime.context.JAXXContext}
+ * the name of implementation of {@link jaxx.runtime.JAXXContext}
* to be used on {@link jaxx.runtime.JAXXObject}.
* <p/>
* Must not be abstract.
Modified: branches/jaxx-2.X/pom.xml
===================================================================
--- branches/jaxx-2.X/pom.xml 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/pom.xml 2009-10-07 21:03:42 UTC (rev 1567)
@@ -26,8 +26,6 @@
<module>jaxx-widgets</module>
- <!-- deprecated since 1.7.2, will be removed before 2.0.0
- <module>jaxx-example</module-->
<module>jaxx-demo</module>
</modules>
@@ -257,6 +255,26 @@
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-velocity</artifactId>
+ <version>1.1.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>velocity</groupId>
+ <artifactId>velocity</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>junit</groupId>
@@ -266,6 +284,13 @@
</dependency>
<dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-verifier</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>1.2</version>
Modified: branches/jaxx-2.X/src/site/rst/JAXXContext.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/JAXXContext.rst 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/src/site/rst/JAXXContext.rst 2009-10-07 21:03:42 UTC (rev 1567)
@@ -13,7 +13,7 @@
Le besoin initial de ce développement est de pouvoir facilement intégrer un context applicatif dans JAXX et de pouvoir
l'utiliser dans les fichiers JAXX pour injecter par exemple des données dans les widgets.
-jaxx.runtime.context.JAXXContext
+jaxx.runtime.JAXXContext
========================
Il s'agit du contrat de base du context applicatif.
Modified: branches/jaxx-2.X/src/site/rst/migration.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/migration.rst 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/src/site/rst/migration.rst 2009-10-07 21:03:42 UTC (rev 1567)
@@ -15,7 +15,7 @@
* JList, JComboBox et JTree n'acceptent plus de fils Item (utiliser JAXXList,
JAXXComboBox, JAXXTree).
- * changement de paquetage de jaxx.runtime.JAXXContext vers jaxx.runtime.context.JAXXContext
+ * changement de paquetage de jaxx.runtime.JAXXContext vers jaxx.runtime.JAXXContext
* changement de paquetage de jaxx.runtime.\*Decorator vers jaxx.runtime.decorator.\*Decorator
1
0
r1566 - branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources
by tchemit@users.nuiton.org 07 Oct '09
by tchemit@users.nuiton.org 07 Oct '09
07 Oct '09
Author: tchemit
Date: 2009-10-07 20:15:26 +0200 (Wed, 07 Oct 2009)
New Revision: 1566
Modified:
branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/log4j.properties
Log:
changement logs (on veut pas voir nuiton-util en console :))
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/log4j.properties
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/log4j.properties 2009-10-07 17:57:38 UTC (rev 1565)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/log4j.properties 2009-10-07 18:15:26 UTC (rev 1566)
@@ -1,5 +1,5 @@
# Global logging configuration
-log4j.rootLogger=INFO, stdout
+log4j.rootLogger=WARN, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
1
0
Author: tchemit
Date: 2009-10-07 19:57:38 +0200 (Wed, 07 Oct 2009)
New Revision: 1565
Added:
branches/jaxx-2.X/src/site/rst/migration.rst
Modified:
branches/jaxx-2.X/src/site/rst/index.rst
branches/jaxx-2.X/src/site/site.xml
Log:
debut doc de migration 2.0
Modified: branches/jaxx-2.X/src/site/rst/index.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/index.rst 2009-10-07 17:37:55 UTC (rev 1564)
+++ branches/jaxx-2.X/src/site/rst/index.rst 2009-10-07 17:57:38 UTC (rev 1565)
@@ -1,5 +1,5 @@
-jaxx-core
-=========
+JAXX
+====
.. contents::
@@ -7,8 +7,11 @@
Présentation
------------
-Le projet Jaxx.
+TODO A faire car plus a jour...
+Le projet JAXX ...
+
+
Depuis la version 1.0, et en prévision de nouveaux générateurs s'appuyant sur Jaxx,on a revu l'architecture du projet.
Désormais, une séparation a été effectuée entre le code de compilation et le code d'exécution.
@@ -22,6 +25,13 @@
**Veuillez consulter la JavaDoc pour de plus ample détails sur les différentes
librairies.**
+Migration vers JAXX 2.0
+-----------------------
+
+La version 2.0 de JAXX n'est pas compatible avec les versions antérieures.
+
+Pour plus de détail consulter la page `Migration`_.
+
Nouvelles fonctionnalités
-------------------------
@@ -35,6 +45,8 @@
* NavigationTreeModel_
+.. _Migration: migration.html
+
.. _Core: Core.html
.. _I18n: I18n.html
Added: branches/jaxx-2.X/src/site/rst/migration.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/migration.rst (rev 0)
+++ branches/jaxx-2.X/src/site/rst/migration.rst 2009-10-07 17:57:38 UTC (rev 1565)
@@ -0,0 +1,25 @@
+Migration vers JAXX 2.0
+=======================
+
+.. contents::
+
+
+Présentation
+------------
+
+Ce document énumère les choses à migrer pour passer sur la version 2.0 de JAXX.
+
+Nouvelles fonctionnalités
+-------------------------
+
+ * JList, JComboBox et JTree n'acceptent plus de fils Item (utiliser JAXXList,
+ JAXXComboBox, JAXXTree).
+
+ * changement de paquetage de jaxx.runtime.JAXXContext vers jaxx.runtime.context.JAXXContext
+
+ * changement de paquetage de jaxx.runtime.\*Decorator vers jaxx.runtime.decorator.\*Decorator
+
+ * le framwork NavigationTree n'est plus compatible avec l'ancien... TODO
+
+TODO finish it
+
Modified: branches/jaxx-2.X/src/site/site.xml
===================================================================
--- branches/jaxx-2.X/src/site/site.xml 2009-10-07 17:37:55 UTC (rev 1564)
+++ branches/jaxx-2.X/src/site/site.xml 2009-10-07 17:57:38 UTC (rev 1565)
@@ -24,6 +24,7 @@
<menu name="Utilisateur">
<item name="Accueil" href="index.html"/>
+ <item name="Migration JAXX 2.0" href="migration.html"/>
</menu>
<menu name="Développeur">
1
0
Author: tchemit
Date: 2009-10-07 19:37:55 +0200 (Wed, 07 Oct 2009)
New Revision: 1564
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml
Log:
fix javadocs + improve messages in goal
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -14,73 +14,74 @@
/**
*
- * @return
+ * @return the class loader to use by compilers
*/
ClassLoader getClassLoader();
/**
*
- * @return
+ * @return the type of compiler to use
*/
Class<? extends JAXXCompiler> getCompilerClass();
/**
*
- * @return
+ * @return the type of default decorator to use if none specified
*/
Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass();
/**
*
- * @return
+ * @return the type of the default error UI to use for validation
*/
Class<?> getDefaultErrorUI();
/**
*
- * @return
+ * @return extra imports to add on all generated jaxx object
*/
String[] getExtraImports();
/**
*
- * @return
+ * @return the FQN of the help broker (can not directly a type since
+ * the help broker should (may?) be inside the sources.
*/
String getHelpBrokerFQN();
/**
*
- * @return
+ * @return the name of the help set to generate
*/
String getHelpSetName();
/**
*
- * @return
+ * @return the prefix of i18n keys to use in help system
*/
String getHelpsetI18nPrefix();
/**
*
- * @return
+ * @return the suffix of i18n keys to use in index of help system
*/
String getHelpsetIndexI18nSuffix();
/**
*
- * @return
+ * @return the suffix of i18n keys to use in title of the help system
*/
String getHelpsetTitleI18nSuffix();
/**
*
- * @return
+ * @return the suffix of i18n keys to use in toc of the help system
*/
String getHelpsetTocI18nSuffix();
/**
*
- * @return
+ * @return the type of context to use in each generated jaxx object
*/
Class<? extends JAXXContext> getJaxxContextClass();
@@ -92,64 +93,63 @@
boolean getOptimize();
/**
- * Returns the target directory, generally specified with the "-d" option on the command line.
+ * Returns the target directory.
*
* @return the target directory
- * @see #setTargetDirectory
*/
File getTargetDirectory();
/**
*
- * @return
+ * @return the type of validator to use
*/
Class<?> getValidatorClass();
/**
*
- * @return
+ * @return {@code true} if a logger must add on each generated jaxx object
*/
boolean isAddLogger();
/**
*
- * @return
+ * @return {@code true} if we are generating help
*/
boolean isGenerateHelp();
/**
*
- * @return
+ * @return {@code true} if we use the i18n system
*/
boolean isI18nable();
/**
*
- * @return
+ * @return {@code true} to generate optimized code
*/
boolean isOptimize();
/**
*
- * @return
+ * @return {@code true} if a profile pass must be done
*/
boolean isProfile();
/**
*
- * @return
+ * @return {@code true} if states must be reset after the compilation
*/
boolean isResetAfterCompile();
/**
*
- * @return
+ * @return {@code true} if UIManager is used to retrieve icons
*/
boolean isUseUIManagerForIcon();
/**
*
- * @return
+ * @return {@code true} if compiler is verbose
*/
boolean isVerbose();
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -7,9 +7,9 @@
import java.util.List;
/**
- * I18n methods to add {@link org.nuiton.i18n.I18n#_(String, Object[])} method on some attributes.
+ * I18n methods to add {@link org.nuiton.i18n.I18n#_(java.lang.String, java.lang.Object[])} method on some attributes.
* <p/>
- * Make sure to set an i18nable compiler to have his {@link CompilerOptions#isI18nable()} returning true.
+ * Make sure to set an i18nable compiler to have his {@link CompilerConfiguration#isI18nable()} returning true.
*
* @author chemit
*/
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -105,7 +105,7 @@
}
/**
- * Load the {@link jaxx.spi.Initializer} services found via the{@link ServiceLoader} mecanism.
+ * Load the {@link Initializer} services found via the{@link ServiceLoader} mecanism.
*
* @param verbose <ocde>true</code> to print initializers
*/
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -7,7 +7,7 @@
/**
* Thrown by <code>TagHandler</code> when an unsupported attribute is encountered.
*
- * @see jaxx.tags.TagHandler
+ * @see jaxx.compiler.tags.TagHandler
*/
public class UnsupportedAttributeException extends CompilerException {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -4,7 +4,7 @@
/**
* Mirrors the class <code>java.beans.BeanDescriptor</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXBeanDescriptor extends JAXXFeatureDescriptor {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -1,8 +1,10 @@
package jaxx.compiler.beans;
+import jaxx.compiler.reflect.ClassDescriptor;
+
/**
* Mirrors the class <code>java.beans.BeanInfo</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXBeanInfo {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -5,7 +5,7 @@
/**
* Mirrors the class <code>java.beans.EventSetDescriptor</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXEventSetDescriptor extends JAXXFeatureDescriptor {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -7,7 +7,7 @@
/**
* Mirrors the class <code>java.beans.FeatureDescriptor</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXFeatureDescriptor {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -24,7 +24,7 @@
* don't believe it results in any meaningful incompatibilities.
* <p/>
* JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXIntrospector {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -6,7 +6,7 @@
/**
* Mirrors the class <code>java.beans.PropertyDescriptor</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXPropertyDescriptor extends JAXXFeatureDescriptor {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -52,7 +52,7 @@
public static void main(String[] args) {
startingTime = System.nanoTime();
- log.info("Observe start at " + new java.util.Date() + " args: " + java.util.Arrays.toString(args));
+ log.info("JAXX Demo start at " + new java.util.Date() + " args: " + java.util.Arrays.toString(args));
try {
@@ -177,7 +177,6 @@
try {
super.run();
- //JAXXContext.get().close();
// force to kill main thread
log.info(_("jaxxdemo.init.closed", new java.util.Date()));
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -454,7 +454,7 @@
*
* Says using method {@link JTabbedPane#getComponent(int)}
* @param tabs the
- * @return
+ * @return the iterator
* @since 1.4
*/
public static TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs) {
@@ -572,7 +572,7 @@
* @param parent
* @param x
* @param y
- * @return
+ * @return the deppest component
*/
public static Component getDeepestObjectAt(Component parent, int x, int y) {
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -2,6 +2,7 @@
import java.awt.Container;
import java.util.Map.Entry;
+import jaxx.runtime.JAXXObject;
/**
* An initial context to be inject in a {@link JAXXObject}.
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -24,11 +24,11 @@
* To register a new decorator, use the method {@link #register(String, Decorator)}.
* <p/>
* To obtain a registred decorator, use the method {@link #get(String)}
- * (get the decorator based on his registred name). or the method {@link #get(Class, tring)}
+ * (get the decorator based on his registred name). or the method {@link #get(Class, String)}
* (get the decorator based on the type of decorator and the registred name).
* <p/>
* To sort a list of data, using a {@link JXPathDecorator}, use the method
- * {@link #sort(JXPathDecorator, java.util.List, int)}.
+ * {@link #sort(JXPathDecorator, List, int)}.
* <p/>
*
* @author tony
@@ -43,7 +43,7 @@
/**
* Factory method to instanciate a new {@link PropertyDecorator} for the
- * given class {@link O} and a readable property name.
+ * given class {@code internlaClass} and a readable property name.
*
* @param internalClass the class of the objects decorated by the new decorator
* @param property the property
@@ -63,7 +63,7 @@
/**
* Factory method to instanciate a new {@link JXPathDecorator} for the
- * given class {@link O} and expression.
+ * given class {@code internalClass} and expression.
*
* @param internalClass the class of the objects decorated by the new decorator
* @param expression the expression to use to decorated objects
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -148,7 +148,7 @@
/**
* Remove all childs nodes
*
- * @param list of items to remove
+ * @param items list of items to remove
*/
public void removeChilds(List<Item> items) {
if (children != null) {
@@ -181,7 +181,7 @@
/**
* Set the parent of this item
*
- * @return the item parent (or null)
+ * @param parent the item parent (or null)
*/
public void setParent(Item parent) {
this.parent = parent;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -27,7 +27,7 @@
*/
static private final Log log = LogFactory.getLog(NavigationTreeModel.class);
/**
- * The path separator used to build the {@link #fullPath}.
+ * The path separator used to build the {@link NavigationTreeNode#fullPath}.
*
* @see NavigationTreeNode#getNodePath()
* @see NavigationTreeNode#getFullPath()
@@ -51,7 +51,7 @@
/**
* Search from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#navigationPath} valued separated by dot.
+ * {@link NavigationTreeNode#path} valued separated by dot.
* <p/>
* Example :
* <p/>
@@ -68,7 +68,7 @@
* 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 #pathSeparator}.
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
* <p/>
* <p/>
* Example :
@@ -87,7 +87,7 @@
* 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 #pathSeparator}.
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
* <p/>
* Example :
* <p/>
@@ -103,7 +103,7 @@
/**
* Search from a given root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
*
* @param root root node to be used
* @param path the fully path of the searched node.
@@ -117,7 +117,7 @@
* 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 #pathSeparator}.
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
*
* @param root root node to be used
* @param path the fully path of the searched node.
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -255,8 +255,8 @@
}
/**
- * @param path the name of the {@link #path} to be matched in the cild of this node.
- * @return the child of this node with given {@link # path} value.
+ * @param path the name of the {@link #path} to be matched in the child of this node.
+ * @return the child of this node with given {@link #path} value.
*/
public NavigationTreeNode getChild(String path) {
Enumeration<?> childs = children();
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -12,7 +12,7 @@
* Thread qui réalise les opérations.
*
* Pour exécuter une nouvelle opération, on utilise la méthode
- * {@link #launchOperation(SynchroActionWorker)}.
+ * {@link #launchOperation(WizardOperationStep)}.
*
* Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setWaiting(boolean)}
*
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -328,9 +328,9 @@
* programmation, ce qui est utile par exemple si le bean ne supporte
* pas les {@link PropertyChangeListener}
*
- * TODO la methode devra repasser en protected et on preperar utiliser la
- * methode {@link #doRevalidate()} car {@link #validate()} ne modifie pas
- * les etats internes et cela en rends son utilisation delicate (le
+ * TODO la methode devra repasser en protected et on utilise la
+ * methode {@link #doValidate()} car {@link #validate()} ne modifie pas
+ * les etats internes et cela en rend son utilisation delicate (le
* validateur entre dans un etat incoherent par rapport aux messages envoyés).
*/
public void validate() {
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -1,7 +1,7 @@
package jaxx.runtime.validator;
/**
- * The listener contract to be used on {@link BeanValidator]
+ * The listener contract to be used on {@link BeanValidator}
*
* @author chemit
* @since 1.3
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -3,7 +3,7 @@
/**
* The object to box a validation message.
*
- * @param <E> type of message (use for override {@link #compareTo(E)} method.
+ * @param <E> type of message (use for override {@link #compareTo(Object)} method.
*
* @author chemit
* @since 1.3
@@ -15,7 +15,7 @@
*/
protected BeanValidator<?> validator;
/**
- * the field thatproduce the message
+ * the field that produce the message
*/
protected BeanValidatorField<?> field;
/**
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -53,7 +53,7 @@
import org.apache.commons.lang.builder.ToStringStyle;
/**
- * Classe permettant de transformer des sources jaxx vers du source java.
+ * Generates some java code from jaxx files.
*
* @author chemit
* @goal generate
@@ -113,8 +113,6 @@
* If not given, will use the one defined in validator
*
* @parameter expression="${jaxx.defaultErrorUIFQN}"
- *
- * @see jaxx.runtime.validator.swing.SwingValidator
*/
protected String defaultErrorUIFQN;
/**
@@ -124,7 +122,7 @@
*
* @parameter expression="${jaxx.defaultDecoratorFQN}" default-value="jaxx.compiler.decorators.DefaultCompiledObjectDecorator"
*
- * @see jaxx.compiler.CompiledObjectDecorator
+ * @see jaxx.compiler.decorators.CompiledObjectDecorator
*/
protected String defaultDecoratorFQN;
/**
@@ -203,7 +201,7 @@
* <p/>
* add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String[])}
* <p/>
- * and then will be use by {@link jaxx.tags.swing.SwingInitializer#initialize()}.
+ * and then will be use by {@link jaxx.compiler.spi.DefaultInitializer#initialize()}.
* <p/>
* <p/>
* This permit to use real beanInfo of imported graphic libraries.
@@ -252,15 +250,17 @@
*/
protected String helpBrokerFQN;
/**
- *
+ * detected jaxx files in {@link #init()} method
*/
protected String[] files;
/**
+ * file updater used to detect jaxx files.
*
+ * <b>Note:</b> if {@link #verbose} flag is on, will ne be used
*/
protected MirroredFileUpdater updater;
/**
- *
+ *
*/
private Class<?> defaultErrorUIClass;
/**
@@ -283,6 +283,10 @@
*
*/
private String[] extraImports;
+ /**
+ *
+ */
+ private boolean nofiles;
@SuppressWarnings("unchecked")
@Override
@@ -295,14 +299,39 @@
}
}
- if (addSourcesToClassPath || addProjectClassPath) {
- cl = initClassLoader(project, getLog());
- Thread.currentThread().setContextClassLoader(cl);
- } else {
- cl = getClass().getClassLoader();
- //cl = Thread.currentThread().getContextClassLoader();
+ fixCompileSourceRoots();
+
+ if (includes == null || includes.length == 0) {
+ // use default includes
+ includes = INCLUDES;
}
+ updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
+ Map<File, String[]> result = new HashMap<File, String[]>();
+ getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
+
+ this.files = result.get(src);
+
+ nofiles = files == null || files.length == 0;
+ if (nofiles) {
+ return true;
+ }
+
+// if (addSourcesToClassPath || addProjectClassPath) {
+ cl = initClassLoader(project,
+ src,
+ addSourcesToClassPath,
+ testPhase,
+ addResourcesToClassPath,
+ addCompileClassPath,
+ addProjectClassPath);
+
+ Thread.currentThread().setContextClassLoader(cl);
+// } else {
+// cl = getClass().getClassLoader();
+ //cl = Thread.currentThread().getContextClassLoader();
+// }
+
compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
jaxxContextClass = (Class<? extends JAXXContext>) Class.forName(jaxxContextFQN, false, cl);
@@ -324,25 +353,8 @@
outJava.mkdirs();
}
- fixCompileSourceRoots();
-
- boolean noIncludes = includes == null || includes.length == 0;
-
- if (noIncludes) {
- includes = INCLUDES;
- }
- updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
-
- Map<File, String[]> result = new HashMap<File, String[]>();
- getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
-
- this.files = result.get(src);
-
- if (files == null || files.length == 0) {
- getLog().warn("No files to treate.");
- return false;
- }
-
+ // compute extra imports (can not use java classes since some of
+ // imports can not be still compiled)
if (extraImportList != null && !extraImportList.isEmpty()) {
String[] imports = extraImportList.split(",");
int i = 0;
@@ -364,16 +376,22 @@
@Override
public void doAction() throws MojoExecutionException {
- getLog().info("jaxx - detects " + this.files.length + " modify jaxx file(s). ");
+ if (nofiles) {
+ getLog().info("No files to treate.");
+ return;
+ }
+ getLog().info("Detects " + files.length + " modify jaxx file(s). ");
+
try {
// force compiler init from here, not in a static block
TagManager.reset(verbose);
- JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
+ JAXXCompilerLaunchor launchor;
+ launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
boolean success = launchor.compile();
- getLog().info("jaxx - generate " + launchor.getCompilerCount() + " file(s). ");
+ getLog().info("Generated " + launchor.getCompilerCount() + " file(s). ");
if (!success) {
throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
@@ -596,7 +614,7 @@
//TODO use the AbstractPublig method
@SuppressWarnings({"unchecked"})
- protected URLClassLoader initClassLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
+ protected URLClassLoader initClasLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
URLClassLoader loader = null;
if (project != null) {
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml 2009-10-07 17:37:55 UTC (rev 1564)
@@ -17,6 +17,9 @@
<!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<jaxxContextFQN>java.lang.String</jaxxContextFQN>
<force>true</force>
+ <includes>
+ <value>**/Evolution74Test/ok/*.jaxx</value>
+ </includes>
</configuration>
</plugin>
</plugins>
1
0